Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 16378184 | 631 days ago | IN | 0 ETH | 0.13346742 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
UniswapVault
Compiler Version
v0.8.11+commit.d7f03943
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.11; import { SafeERC20Upgradeable, IERC20Upgradeable } from "../../../lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol"; import { IUniswapV2Router02 } from "../../../lib/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; import { IUniswapV2Factory } from "../../../lib/v2-core/contracts/interfaces/IUniswapV2Factory.sol"; import { IUniswapV2Pair } from "../../../lib/v2-core/contracts/interfaces/IUniswapV2Pair.sol"; import { Vault } from "../Vault.sol"; import { UniswapVaultStorage } from "./UniswapVaultStorage.sol"; /// @notice Contains the primary logic for Uniswap Vaults /// @author Recursive Research Inc contract UniswapVault is Vault, UniswapVaultStorage { using SafeERC20Upgradeable for IERC20Upgradeable; function initialize( address coreAddress, uint256 _epochDuration, address _token0, address _token1, uint256 _token0FloorNum, uint256 _token1FloorNum, address _uniswapFactory, address _uniswapRouter ) public virtual initializer { __UniswapVault_init( coreAddress, _epochDuration, _token0, _token1, _token0FloorNum, _token1FloorNum, _uniswapFactory, _uniswapRouter ); } function __UniswapVault_init( address coreAddress, uint256 _epochDuration, address _token0, address _token1, uint256 _token0FloorNum, uint256 _token1FloorNum, address _uniswapFactory, address _uniswapRouter ) internal onlyInitializing { __Vault_init(coreAddress, _epochDuration, _token0, _token1, _token0FloorNum, _token1FloorNum); __UniswapVault_init_unchained(_uniswapFactory, _uniswapRouter); } function __UniswapVault_init_unchained(address _uniswapFactory, address _uniswapRouter) internal onlyInitializing { pair = IUniswapV2Factory(_uniswapFactory).getPair(address(token0), address(token1)); // require that the pair has been created require(pair != address(0), "ZERO_ADDRESS"); factory = _uniswapFactory; router = _uniswapRouter; } // @dev queries the pool reserves and ensure the token ordering is correct function getPoolBalances() internal view virtual override returns (uint256, uint256) { (uint256 reservesA, uint256 reservesB, ) = IUniswapV2Pair(pair).getReserves(); return IUniswapV2Pair(pair).token0() == address(token0) ? (reservesA, reservesB) : (reservesB, reservesA); } // This is provided automatically by the Uniswap router function calcAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) internal view virtual override returns (uint256) { return IUniswapV2Router02(router).getAmountIn(amountOut, reserveIn, reserveOut); } // Withdraws all liquidity // @dev We can ignore the need for frontrunning checks because the `_nextEpoch` function checks // that the pool reserves are as expected beforehand function _withdrawLiquidity() internal virtual override { uint256 lpTokenBalance = IERC20Upgradeable(pair).balanceOf(address(this)); if (lpTokenBalance == 0) return; // use the router to remove liquidity from the uni pool // don't need to decrease allowance afterwards because router guarantees the full amount is burned // safe to ignore return values because we check balances before and after this call IERC20Upgradeable(pair).safeIncreaseAllowance(router, lpTokenBalance); IUniswapV2Router02(router).removeLiquidity( address(token0), address(token1), lpTokenBalance, 0, 0, address(this), block.timestamp ); } // Deposits available liquidity // @dev We can ignore the need for frontrunning checks because the `_nextEpoch` function checks // that the pool reserves are as expected beforehand // `availableToken0` and `availableToken1` are also known to be greater than 0 since they are checked // by `depositLiquidity` in `Vault.sol` function _depositLiquidity(uint256 availableToken0, uint256 availableToken1) internal virtual override returns (uint256 token0Deposited, uint256 token1Deposited) { // use the router to deposit `token0` and `token1` token0.safeIncreaseAllowance(router, availableToken0); token1.safeIncreaseAllowance(router, availableToken1); // can safely ignore `liquidity` return value because when withdrawing we check our full balance (token0Deposited, token1Deposited, ) = IUniswapV2Router02(router).addLiquidity( address(token0), address(token1), availableToken0, availableToken1, 0, 0, address(this), block.timestamp ); // if we didn't deposit the full `availableToken{x}`, reduce allowance for safety if (availableToken0 > token0Deposited) { token0.safeApprove(router, 0); } if (availableToken1 > token1Deposited) { token1.safeApprove(router, 0); } } // For the default Uniswap vault this does nothing function _unstakeLiquidity() internal virtual override {} // For the default Uniswap vault this does nothing function _stakeLiquidity() internal virtual override {} // Swaps tokens // @dev We can ignore the need for frontrunning checks because the `_nextEpoch` function checks // that the pool reserves are as expected beforehand function swap( IERC20Upgradeable tokenIn, IERC20Upgradeable tokenOut, uint256 amountIn ) internal virtual override returns (uint256 amountOut, uint256 amountConsumed) { if (amountIn == 0) return (0, 0); tokenIn.safeIncreaseAllowance(router, amountIn); amountOut = IUniswapV2Router02(router).swapExactTokensForTokens( amountIn, 0, getPath(address(tokenIn), address(tokenOut)), address(this), block.timestamp )[1]; amountConsumed = amountIn; } /// @notice converts two addresses into an address[] type function getPath(address _from, address _to) internal pure returns (address[] memory path) { path = new address[](2); path[0] = _from; path[1] = _to; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = _setInitializedVersion(1); if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original * initialization step. This is essential to configure modules that are added through upgrades and that require * initialization. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. */ modifier reinitializer(uint8 version) { bool isTopLevelCall = _setInitializedVersion(version); if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(version); } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { _setInitializedVersion(type(uint8).max); } function _setInitializedVersion(uint8 version) private returns (bool) { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, and for the lowest level // of initializers, because in other contexts the contract may have been reentered. if (_initializing) { require( version == 1 && !AddressUpgradeable.isContract(address(this)), "Initializable: contract is already initialized" ); return false; } else { require(_initialized < version, "Initializable: contract is already initialized"); _initialized = version; return true; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; }
pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; }
pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); }
pragma solidity >=0.6.2; import './IUniswapV2Router01.sol'; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.11; import { ICorePermissions } from "./ICorePermissions.sol"; /// @notice Interface for Core /// @author Recursive Research Inc interface ICore is ICorePermissions { // ----------- Events --------------------- /// @dev Emitted when the protocol fee (`protocolFee`) is changed /// out of core.MAX_FEE() event ProtocolFeeUpdated(uint256 protocolFee); /// @dev Emitted when the protocol fee destination (`feeTo`) is changed event FeeToUpdated(address indexed feeTo); /// @dev Emitted when the pause is triggered event Paused(); /// @dev Emitted when the pause is lifted event Unpaused(); // @dev Emitted when a vault with address `vault` event VaultRegistered(address indexed vault); // @dev Emitted when a vault with address `vault` event VaultRemoved(address indexed vault); // ----------- Default Getters -------------- /// @dev constant set to 10_000 function MAX_FEE() external view returns (uint256); function feeTo() external view returns (address); /// @dev protocol fee out of core.MAX_FEE() function protocolFee() external view returns (uint256); function wrappedNative() external view returns (address); // ----------- Main Core Utility -------------- function registerVaults(address[] memory vaults) external; function removeVaults(address[] memory vaults) external; /// @dev set core.protocolFee, out of core.MAX_FEE() function setProtocolFee(uint256 _protocolFee) external; function setFeeTo(address _feeTo) external; // ----------- Protocol Pausing ----------- function pause() external; function unpause() external; function paused() external view returns (bool); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.11; import { IAccessControlUpgradeable } from "../../lib/openzeppelin-contracts-upgradeable/contracts/access/IAccessControlUpgradeable.sol"; /// @title Interface for CorePermissions /// @author Recursive Research Inc interface ICorePermissions is IAccessControlUpgradeable { // ----------- Events --------------------- /// @dev Emitted when the whitelist is disabled by `admin`. event WhitelistDisabled(); /// @dev Emitted when the whitelist is disabled by `admin`. event WhitelistEnabled(); // ----------- Governor only state changing api ----------- function createRole(bytes32 role, bytes32 adminRole) external; function whitelistAll(address[] memory addresses) external; // ----------- GRANTING ROLES ----------- function disableWhitelist() external; function enableWhitelist() external; // ----------- Getters ----------- function GUARDIAN_ROLE() external view returns (bytes32); function GOVERN_ROLE() external view returns (bytes32); function PAUSE_ROLE() external view returns (bytes32); function STRATEGIST_ROLE() external view returns (bytes32); function WHITELISTED_ROLE() external view returns (bytes32); function whitelistDisabled() external view returns (bool); // ----------- Read Interface ----------- function isWhitelisted(address _address) external view returns (bool); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.11; interface IWrappy { function deposit() external payable; function transfer(address to, uint256 value) external returns (bool); function withdraw(uint256) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.11; import { Initializable } from "../../lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol"; import { ICore } from "../core/ICore.sol"; /// @notice Stores a reference to the core contract /// @author Recursive Research Inc abstract contract CoreReference is Initializable { ICore public core; bool private _paused; /// initialize logic contract /// This tag here tells OZ to not throw an error on this constructor /// Recommended here: /// https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializing_the_implementation_contract /// @custom:oz-upgrades-unsafe-allow constructor constructor() initializer {} /// @dev Emitted when the pause is triggered event Paused(); /// @dev Emitted when the pause is lifted event Unpaused(); function __CoreReference_init(address coreAddress) internal onlyInitializing { __CoreReference_init_unchained(coreAddress); } function __CoreReference_init_unchained(address coreAddress) internal onlyInitializing { core = ICore(coreAddress); } modifier whenNotPaused() { require(!paused(), "PAUSED"); _; } modifier whenPaused() { require(paused(), "NOT_PAUSED"); _; } modifier onlyPauser() { require(core.hasRole(core.PAUSE_ROLE(), msg.sender), "NOT_PAUSER"); _; } modifier onlyGovernor() { require(core.hasRole(core.GOVERN_ROLE(), msg.sender), "NOT_GOVERNOR"); _; } modifier onlyGuardian() { require(core.hasRole(core.GUARDIAN_ROLE(), msg.sender), "NOT_GUARDIAN"); _; } modifier onlyStrategist() { require(_isStrategist(msg.sender), "NOT_STRATEGIST"); _; } /// @notice view function to see whether or not the contract is paused /// @return true if the contract is paused either by the core or independently function paused() public view returns (bool) { return (core.paused() || _paused); } function pause() external onlyPauser whenNotPaused { _paused = true; emit Paused(); } function unpause() external onlyPauser whenPaused { _paused = false; emit Unpaused(); } function _isStrategist(address _user) internal view returns (bool) { return core.hasRole(core.STRATEGIST_ROLE(), _user); } }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.11; interface IVault { /// @dev Emitted when a new epoch is started /// @param newEpoch number of the new epoch /// @param initiator address of the user who initiated the new epoch /// @param startTime timestamp of the start of this new epoch event NextEpochStarted(uint256 indexed newEpoch, address indexed initiator, uint256 startTime); /// @dev Emitted upon a new deposit request /// @param assetCode code for the type of asset (either `TOKEN0` or `TOKEN1`) /// @param user address of the user who made the deposit request /// @param amount amount of the asset in deposit request /// @param epoch epoch of the deposit request event DepositScheduled(bytes32 indexed assetCode, address indexed user, uint256 amount, uint256 indexed epoch); /// @dev Emitted upon a new withdraw request /// @param assetCode code for the type of asset (either `TOKEN0` or `TOKEN1`) /// @param user address of the user who made the withdraw request /// @param amountDay0 amount of the asset (day 0) in withdraw request /// @param epoch epoch of the withdraw request event WithdrawScheduled(bytes32 indexed assetCode, address indexed user, uint256 amountDay0, uint256 indexed epoch); /// @dev Emitted upon a user claiming their tokens after a withdraw request is processed /// @param assetCode code for the type of asset (either `TOKEN0` or `TOKEN1`) /// @param user address of the user who is claiming their assets /// @param amount amount of the assets (day 0) claimed event AssetsClaimed(bytes32 indexed assetCode, address indexed user, uint256 amount); /// @dev Emitted upon a guardian rescuing funds /// @param guardian address of the guardian who rescued the funds event FundsRescued(address indexed guardian); /// @dev Emitted upon a strategist updating the token0 floor /// @param newFloor the new floor returns on TOKEN0 (out of `RAY`) event Token0FloorUpdated(uint256 newFloor); /// @dev Emitted upon a strategist updating the token1 floor /// @param newFloor the new floor returns on TOKEN1 (out of `RAY`) event Token1FloorUpdated(uint256 newFloor); event EpochDurationUpdated(uint256 newEpochDuration); /// ------------------- Vault Interface ------------------- function depositToken0(uint256 _amount) external payable; function depositToken1(uint256 _amount) external; function withdrawToken0(uint256 _amount) external; function withdrawToken1(uint256 _amount) external; function claimToken0() external; function claimToken1() external; function token0Balance(address user) external view returns ( uint256 deposited, uint256 pendingDeposit, uint256 claimable ); function token1Balance(address user) external view returns ( uint256 deposited, uint256 pendingDeposit, uint256 claimable ); function nextEpoch(uint256 expectedPoolToken0, uint256 expectedPoolToken1) external; function rescueTokens(address[] calldata tokens, uint256[] calldata amounts) external; function collectFees() external; function unstakeLiquidity() external; /// ------------------- Getters ------------------- function token0ValueLocked() external view returns (uint256); function token1ValueLocked() external view returns (uint256); function token0BalanceDay0(address user) external view returns (uint256); function epochToToken0Rate(uint256 _epoch) external view returns (uint256); function token0WithdrawRequests(address user) external view returns (uint256); function token1BalanceDay0(address user) external view returns (uint256); function epochToToken1Rate(uint256 _epoch) external view returns (uint256); function token1WithdrawRequests(address user) external view returns (uint256); function feesAccrued() external view returns (uint256, uint256); /// ------------------- Setters ------------------- function setToken0Floor(uint256 _token0FloorNum) external; function setToken1Floor(uint256 _token1FloorNum) external; function setEpochDuration(uint256 _epochDuration) external; function setDepositsEnabled() external; function setDepositsDisabled() external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.11; /// @notice Storage for uniswap vaults /// @author Recursive Research Inc abstract contract UniswapVaultStorageUnpadded { /// @notice UniswapV2Factory address address public factory; /// @notice UniswapV2Router02 address address public router; // @notice UniswapV2Pair address for token0 and token1 address public pair; } abstract contract UniswapVaultStorage is UniswapVaultStorageUnpadded { // @dev Padding 100 words of storage for upgradeability. Follows OZ's guidance. uint256[100] private __gap; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.11; // Have to use SafeERC20Upgradeable instead of SafeERC20 because SafeERC20 inherits Address.sol, // which uses delegeatecall functions, which are not allowed by OZ's upgrade process // See more: // https://forum.openzeppelin.com/t/error-contract-is-not-upgrade-safe-use-of-delegatecall-is-not-allowed/16859 import { SafeERC20Upgradeable, IERC20Upgradeable } from "../../lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol"; import { ReentrancyGuardUpgradeable } from "../../lib/openzeppelin-contracts-upgradeable/contracts/security/ReentrancyGuardUpgradeable.sol"; import { IWrappy } from "../external/IWrappy.sol"; import { CoreReference } from "../refs/CoreReference.sol"; import { VaultStorage } from "./VaultStorage.sol"; import { IVault } from "./IVault.sol"; /// @notice Contains the primary logic for vaults /// @author Recursive Research Inc abstract contract Vault is IVault, CoreReference, ReentrancyGuardUpgradeable, VaultStorage { using SafeERC20Upgradeable for IERC20Upgradeable; bytes32 public constant TOKEN0 = keccak256("TOKEN0"); bytes32 public constant TOKEN1 = keccak256("TOKEN1"); uint256 public constant RAY = 1e27; uint256 public constant POOL_ERR = 50; // 0.5% error margin allowed uint256 public constant DENOM = 10_000; uint256 public constant MIN_LP = 1000; // minimum amount of tokens to be deposited as LP // ----------- Upgradeable Constructor Pattern ----------- /// Initializes the vault to point to the Core contract and configures it to have /// a given epoch duration, pair of tokens, and floor returns on each Token /// @param coreAddress address of the Core contract /// @param _epochDuration duration of the epoch in seconds /// @param _token0 address of TOKEN0 /// @param _token1 address of TOKEN1 /// @param _token0FloorNum the floor returns of the TOKEN0 side (out of `DENOM`). In practice, /// 10000 to guarantee lossless returns for the TOKEN0 side. /// @param _token1FloorNum the floor returns of the TOKEN1 side (out of `DENOM`). In practice, /// 500 to prevent accounting errors. function __Vault_init( address coreAddress, uint256 _epochDuration, address _token0, address _token1, uint256 _token0FloorNum, uint256 _token1FloorNum ) internal onlyInitializing { __CoreReference_init(coreAddress); __ReentrancyGuard_init(); __Vault_init_unchained(_epochDuration, _token0, _token1, _token0FloorNum, _token1FloorNum); } function __Vault_init_unchained( uint256 _epochDuration, address _token0, address _token1, uint256 _token0FloorNum, uint256 _token1FloorNum ) internal onlyInitializing { require(_token0FloorNum > 0, "INVALID_TOKEN0_FLOOR"); require(_token1FloorNum > 0, "INVALID_TOKEN1_FLOOR"); isNativeVault = _token0 == core.wrappedNative(); token0 = IERC20Upgradeable(_token0); token1 = IERC20Upgradeable(_token1); token0Data.epochToRate[0] = RAY; token1Data.epochToRate[0] = RAY; epoch = 1; epochDuration = _epochDuration; token0FloorNum = _token0FloorNum; token1FloorNum = _token1FloorNum; } modifier onlyParticipantOrStrategist(address _user) { (uint256 depositedToken0, uint256 pendingToken0, ) = this.token0Balance(_user); (uint256 depositedToken1, uint256 pendingToken1, ) = this.token1Balance(_user); require( depositedToken0 + pendingToken0 + depositedToken1 + pendingToken1 > 0 || _isStrategist(_user), "NOT_PARTICIPANT_OR_STRATEGIST" ); _; } modifier whenDepositsEnabled() { require(depositsEnabled, "DEPOSITS_DISABLED"); _; } // ----------- Deposit Requests ----------- /// @notice schedules a deposit of TOKEN0 into the floor tranche /// @dev currently does not support fee on transfer / deflationary tokens. /// @param _amount the amount of the TOKEN0 to schedule-deposit if a non native vault, /// and unused if it's a native vault. msg.value must be zero if not a native vault /// typechain does not allow payable function overloading so we can either have 2 different /// names or consolidate them into the same function as we do here function depositToken0(uint256 _amount) external payable override whenDepositsEnabled whenNotPaused nonReentrant { if (isNativeVault) { IWrappy(address(token0)).deposit{ value: msg.value }(); _depositAccounting(token0Data, msg.value, TOKEN0); } else { require(msg.value == 0, "NOT_NATIVE_VAULT"); token0.safeTransferFrom(msg.sender, address(this), _amount); _depositAccounting(token0Data, _amount, TOKEN0); } } /// @notice schedules a deposit of the TOKEN1 into the ceiling tranche /// @dev currently does not support fee on transfer / deflationary tokens. /// @param _amount the amount of the TOKEN1 to schedule-deposit function depositToken1(uint256 _amount) external override whenDepositsEnabled whenNotPaused nonReentrant { token1.safeTransferFrom(msg.sender, address(this), _amount); _depositAccounting(token1Data, _amount, TOKEN1); } /// @dev handles the accounting for scheduling deposits in a way that abstracts the logic /// @param assetData storage reference to the data for the desired asset /// @param _depositAmount the amount of the asset to deposit /// @param assetCode code for the type of asset (either `TOKEN0` or `TOKEN1`) function _depositAccounting( AssetData storage assetData, uint256 _depositAmount, bytes32 assetCode ) private { require(_depositAmount > 0, "ZERO_AMOUNT"); uint256 currEpoch = epoch; // Check their prior deposit requests and flush to balanceDay0 if needed assetData.balanceDay0[msg.sender] = __updateDepositRequests(assetData, currEpoch, _depositAmount); // track total deposit requests assetData.depositRequestsTotal += _depositAmount; emit DepositScheduled(assetCode, msg.sender, _depositAmount, currEpoch); } /// @dev for updating the deposit requests with any new deposit amount /// or flushing the deposits to balanceDay0 if the epoch of the request has passed /// @param assetData storage reference to the data for the desired asset /// @param currEpoch current epoch (passed to save a storage read) /// @param _depositAmount amount of deposits /// @return newBalanceDay0 new balance day 0 of the user (returned to save a storage read) function __updateDepositRequests( AssetData storage assetData, uint256 currEpoch, uint256 _depositAmount ) private returns (uint256 newBalanceDay0) { Request storage req = assetData.depositRequests[msg.sender]; uint256 balance = assetData.balanceDay0[msg.sender]; uint256 reqAmount = req.amount; // If they have a prior request if (reqAmount > 0 && req.epoch < currEpoch) { // and if it was from a prior epoch // we now know the exchange rate at that epoch, // so we can add to their balance uint256 conversionRate = assetData.epochToRate[req.epoch]; // will not overflow even if value = total mc of crypto balance += (reqAmount * RAY) / conversionRate; reqAmount = 0; } if (_depositAmount > 0) { // if they don't have a prior request, store this one (if this is a non-zero deposit) reqAmount += _depositAmount; req.epoch = currEpoch; } req.amount = reqAmount; return balance; } // ----------- Withdraw Requests ----------- /// @notice schedules a withdrawal of TOKEN0 from the floor tranche /// @param _amount amount of Day 0 TOKEN0 to withdraw function withdrawToken0(uint256 _amount) external override whenNotPaused nonReentrant { _withdrawAccounting(token0Data, _amount, TOKEN0); } /// @notice schedules a withdrawal of the TOKEN1 from the ceiling tranche /// @param _amount amount of Day 0 TOKEN1 to withdraw function withdrawToken1(uint256 _amount) external override whenNotPaused nonReentrant { _withdrawAccounting(token1Data, _amount, TOKEN1); } /// @dev handles the accounting for schedules withdrawals in a way that abstracts the logic /// @param assetData storage reference to the data for the desired asset /// @param _withdrawAmountDay0 the amount of the asset to withdraw /// @param assetCode code for the type of asset (either `TOKEN0` or `TOKEN1`) function _withdrawAccounting( AssetData storage assetData, uint256 _withdrawAmountDay0, bytes32 assetCode ) private { require(_withdrawAmountDay0 > 0, "ZERO_AMOUNT"); uint256 currEpoch = epoch; // Check if they have any deposit request that // might not have been flushed to the deposit mapping yet uint256 userBalanceDay0 = __updateDepositRequests(assetData, currEpoch, 0); // See if there were any existing withdraw requests Request storage req = assetData.withdrawRequests[msg.sender]; if (req.amount > 0 && req.epoch < currEpoch) { // If there was a request from a previous epoch, we now know the corresponding amount // that was withdrawn and we can add it to the accumulated amount of claimable assets // tokenAmount * epochToRate will not overflow even if value = total mc of crypto & rate = 3.8e10 * RAY assetData.claimable[msg.sender] += (req.amount * assetData.epochToRate[req.epoch]) / RAY; req.amount = 0; } // Subtract the amount they way to withdraw from their deposit amount // Want to explicitly send out own reversion message require(userBalanceDay0 >= _withdrawAmountDay0, "INSUFFICIENT_BALANCE"); unchecked { assetData.balanceDay0[msg.sender] = userBalanceDay0 - _withdrawAmountDay0; } // Add it to their withdraw request and log the epoch req.amount = _withdrawAmountDay0 + req.amount; if (req.epoch < currEpoch) { req.epoch = currEpoch; } // track total withdraw requests assetData.withdrawRequestsTotal += _withdrawAmountDay0; emit WithdrawScheduled(assetCode, msg.sender, _withdrawAmountDay0, currEpoch); } // ----------- Claim Functions ----------- /// @notice allows the user (`msg.sender`) to claim the TOKEN0 they have a right to once /// withdrawal requests are processed function claimToken0() external override whenNotPaused nonReentrant { uint256 claim = _claimAccounting(token0Data, TOKEN0); if (isNativeVault) { IWrappy(address(token0)).withdraw(claim); (bool success, ) = msg.sender.call{ value: claim }(""); require(success, "TRANSFER_FAILED"); } else { token0.safeTransfer(msg.sender, claim); } } /// @notice allows the user (`msg.sender`) to claim the TOKEN1 they have a right to once /// withdrawal requests are processed function claimToken1() external override whenNotPaused nonReentrant { uint256 claim = _claimAccounting(token1Data, TOKEN1); token1.safeTransfer(msg.sender, claim); } /// @notice calculates the current amount of an asset the user (`msg.sender`) has claim to /// after withdrawal requests are processed and abstracts away the accounting logic /// @param assetData storage reference to the data for the desired asset /// @return _claim amount of the asset the user has a claim to /// @param assetCode code for the type of asset (either `TOKEN0` or `TOKEN1`) function _claimAccounting(AssetData storage assetData, bytes32 assetCode) private returns (uint256 _claim) { Request storage withdrawReq = assetData.withdrawRequests[msg.sender]; uint256 currEpoch = epoch; uint256 withdrawEpoch = withdrawReq.epoch; uint256 claimable = assetData.claimable[msg.sender]; if (withdrawEpoch < currEpoch) { // If epoch ended, calculate the amount they can withdraw uint256 withdrawAmountDay0 = withdrawReq.amount; if (withdrawAmountDay0 > 0) { delete assetData.withdrawRequests[msg.sender]; // tokenAmount * epochToRate will not overflow even if value = total mc of crypto & rate = 3.8e10 * RAY claimable += (withdrawAmountDay0 * assetData.epochToRate[withdrawEpoch]) / RAY; } } require(claimable > 0, "NO_CLAIM"); assetData.claimable[msg.sender] = 0; assetData.claimableTotal -= claimable; emit AssetsClaimed(assetCode, msg.sender, claimable); return claimable; } // ----------- Balance Functions ----------- /// @notice gets a user's current TOKEN0 balance /// @param user address of the user in which whose balance we are interested /// @return deposited amount of deposited TOKEN0 in the protocol /// @return pendingDeposit amount of TOKEN0 pending deposit /// @return claimable amount of TOKEN0 ready to be withdrawn function token0Balance(address user) external view override returns ( uint256 deposited, uint256 pendingDeposit, uint256 claimable ) { return _balance(token0Data, user); } /// @notice gets a user's current TOKEN1 balance /// @param user address of the user in which whose balance we are interested /// @return deposited amount of deposited TOKEN1 in the protocol /// @return pendingDeposit amount of TOKEN1 pending deposit /// @return claimable amount of TOKEN1 ready to be withdrawn function token1Balance(address user) external view override returns ( uint256 deposited, uint256 pendingDeposit, uint256 claimable ) { return _balance(token1Data, user); } /// @dev handles the balance calculations in a way that abstracts the logic /// @param assetData storage reference to the data for the desired asset /// @param user address of the user in which whose balance we are interested /// @return _deposited amount of their asset that is deposited in the protocol /// @return _pendingDeposit amount of their asset pending deposit /// @return _claimable amount of their asset ready to be withdrawn function _balance(AssetData storage assetData, address user) private view returns ( uint256 _deposited, uint256 _pendingDeposit, uint256 _claimable ) { uint256 currEpoch = epoch; uint256 balanceDay0 = assetData.balanceDay0[user]; // then check if they have any open deposit requests Request memory depositReq = assetData.depositRequests[user]; uint256 depositAmt = depositReq.amount; uint256 depositEpoch = depositReq.epoch; if (depositAmt > 0) { // if they have one from a previous epoch, add the Day 0 amount that // deposit is worth if (depositEpoch < currEpoch) { balanceDay0 += (depositAmt * RAY) / assetData.epochToRate[depositEpoch]; } else { // if they have one from this epoch, set the flat amount _pendingDeposit = depositAmt; } } // Check their withdraw requests, because if they made one // their deposit balances would have been flushed to here Request memory withdrawReq = assetData.withdrawRequests[user]; _claimable = assetData.claimable[user]; if (withdrawReq.amount > 0) { // if they have one from a previous epoch, calculate that // requests day 0 Value if (withdrawReq.epoch < currEpoch) { _claimable += (withdrawReq.amount * assetData.epochToRate[withdrawReq.epoch]) / RAY; } else { // if they have one from this epoch, that means the tokens are still active balanceDay0 += withdrawReq.amount; } } /* TODO: this would be better calculated if we simulated ending the epoch here because this doesn't consider the IL / profits from this current epoch but this is fine for now */ // Note that currEpoch >= 1 since it is initialized to 1 in the constructor uint256 currentConversionRate = assetData.epochToRate[currEpoch - 1]; // tokenAmount * epochToRate will not overflow even if value = total mc of crypto & rate = 3.8e10 * RAY return ((balanceDay0 * currentConversionRate) / RAY, _pendingDeposit, _claimable); } // ----------- Next Epoch Functions ----------- /// @notice Struct just for wrapper around local variables to avoid the stack limit in `nextEpoch()` struct NextEpochVariables { uint256 poolBalance; uint256 withdrawn; uint256 available; uint256 original; uint256 newRate; uint256 newClaimable; } /// @notice Initiates the next epoch /// @param expectedPoolToken0 the approximate amount of TOKEN0 expected to be in the pool (preventing frontrunning) /// @param expectedPoolToken1 the approximate amount of TOKEN1 expected to be in the pool (preventing frontrunning) function nextEpoch(uint256 expectedPoolToken0, uint256 expectedPoolToken1) external override onlyParticipantOrStrategist(msg.sender) whenNotPaused { require(block.timestamp - lastEpochStart >= epochDuration, "EPOCH_DURATION_UNMET"); AssetDataStatics memory _token0Data = _assetDataStatics(token0Data); AssetDataStatics memory _token1Data = _assetDataStatics(token1Data); // These are used to avoid hitting the local variable stack limit NextEpochVariables memory _token0; NextEpochVariables memory _token1; uint256 currEpoch = epoch; // Total tokens in the liquidity pool and our ownership of those tokens (_token0.poolBalance, _token1.poolBalance) = getPoolBalances(); // will not overflow with reasonable expectedPoolToken amount (DENOM = 10,000) require(_token0.poolBalance >= (expectedPoolToken0 * (DENOM - POOL_ERR)) / DENOM, "UNEXPECTED_POOL_BALANCES"); require(_token0.poolBalance <= (expectedPoolToken0 * (DENOM + POOL_ERR)) / DENOM, "UNEXPECTED_POOL_BALANCES"); require(_token1.poolBalance >= (expectedPoolToken1 * (DENOM - POOL_ERR)) / DENOM, "UNEXPECTED_POOL_BALANCES"); require(_token1.poolBalance <= (expectedPoolToken1 * (DENOM + POOL_ERR)) / DENOM, "UNEXPECTED_POOL_BALANCES"); // !!NOTE: After this point we don't need to worry about front-running anymore because the pool's state has been // verified (as long as there is no calls to untrusted external parties) // (1) Withdraw liquidity (_token0.withdrawn, _token1.withdrawn) = withdrawLiquidity(); (_token0.poolBalance, _token1.poolBalance) = getPoolBalances(); _token0.available = _token0.withdrawn + _token0Data.reserves; _token1.available = _token1.withdrawn + _token1Data.reserves; // (2) Perform the swap // Calculate the floor and ceiling returns for each side // will not overflow with reasonable amounts (token0/1FloorNum ~ 10,000) uint256 token0Floor = _token0Data.reserves + (_token0Data.active * token0FloorNum) / DENOM; uint256 token1Floor = _token1Data.reserves + (_token1Data.active * token1FloorNum) / DENOM; uint256 token1Ceiling = _token1Data.reserves + _token1Data.active; // Add interest to the token1 ceiling (but we don't for this version) // token1Ceiling += (_token1Data.active * timePassed * tokenInterest) / (RAY * 365 days); if (token0Floor > _token0.available) { // The min amount needed to reach the TOKEN0 floor uint256 token1NeededToSwap; uint256 token0Deficit = token0Floor - _token0.available; if (token0Deficit > _token0.poolBalance) { token1NeededToSwap = _token1.available; } else { token1NeededToSwap = calcAmountIn(token0Deficit, _token1.poolBalance, _token0.poolBalance); } // swap as much token1 as is necessary to get back to the token0 floor, without going // under the token1 floor uint256 swapAmount = (token1Ceiling + token1NeededToSwap < _token1.available) ? _token1.available - token1Ceiling : token1NeededToSwap + token1Floor > _token1.available ? _token1.available - token1Floor : token1NeededToSwap; (uint256 amountOut, uint256 amountConsumed) = swap(token1, token0, swapAmount); _token0.available += amountOut; _token1.available -= amountConsumed; } else if (_token1.available >= token1Ceiling) { // If we have more token0 than the floor and more token1 than the ceiling so we swap the excess amount // all to TOKEN0 (uint256 amountOut, uint256 amountConsumed) = swap(token1, token0, _token1.available - token1Ceiling); _token0.available += amountOut; _token1.available -= amountConsumed; } else { // We have more token0 than the floor but are below the token1 ceiling // Min amount of TOKEN0 needed to swap to hit the token1 ceiling uint256 token0NeededToSwap; uint256 token1Deficit = token1Ceiling - _token1.available; if (token1Deficit > _token1.poolBalance) { token0NeededToSwap = _token0.poolBalance; } else { token0NeededToSwap = calcAmountIn(token1Deficit, _token0.poolBalance, _token1.poolBalance); } if (token0Floor + token0NeededToSwap < _token0.available) { // If we can reach the token1 ceiling without going through the TOKEN0 floor (uint256 amountOut, uint256 amountConsumed) = swap(token0, token1, token0NeededToSwap); _token0.available -= amountConsumed; _token1.available += amountOut; } else { // We swap as much TOKEN0 as we can without going through the TOKEN0 floor (uint256 amountOut, uint256 amountConsumed) = swap(token0, token1, _token0.available - token0Floor); _token0.available -= amountConsumed; _token1.available += amountOut; } } // (3) Add in new deposits and subtract withdrawals _token0.original = _token0Data.reserves + _token0Data.active; _token1.original = _token1Data.reserves + _token1Data.active; // collect protocol fee if profitable if (_token0.available > _token0.original) { // will not overflow core.protocolFee() < 10,000 _token0.available -= ((_token0.available - _token0.original) * core.protocolFee()) / core.MAX_FEE(); } if (_token1.available > _token1.original) { // will not overflow core.protocolFee() < 10,000 _token1.available -= ((_token1.available - _token1.original) * core.protocolFee()) / core.MAX_FEE(); } // calculate new rate (before withdraws and deposits) as available tokens divided by // tokens that were available at the beginning of the epoch // and tally claimable amount (withdraws that are now accounted for) for this token // tokenAmount * epochToRate will not overflow even if value = total mc of crypto & rate = 3.8e10 * RAY _token0.newRate = _token0.original > 0 ? (token0Data.epochToRate[currEpoch - 1] * _token0.available) / _token0.original // no overflow : token0Data.epochToRate[currEpoch - 1]; token0Data.epochToRate[currEpoch] = _token0.newRate; _token0.newClaimable = (_token0Data.withdrawRequestsTotal * _token0.newRate) / RAY; // no overflow token0Data.claimableTotal += _token0.newClaimable; _token1.newRate = _token1.original > 0 ? (token1Data.epochToRate[currEpoch - 1] * _token1.available) / _token1.original // no overflow : token1Data.epochToRate[currEpoch - 1]; token1Data.epochToRate[currEpoch] = _token1.newRate; _token1.newClaimable = (_token1Data.withdrawRequestsTotal * _token1.newRate) / RAY; // no overflow token1Data.claimableTotal += _token1.newClaimable; // calculate available token after deposits and withdraws _token0.available = _token0.available + _token0Data.depositRequestsTotal - _token0.newClaimable; _token1.available = _token1.available + _token1Data.depositRequestsTotal - _token1.newClaimable; token0Data.depositRequestsTotal = 0; token0Data.withdrawRequestsTotal = 0; token1Data.depositRequestsTotal = 0; token1Data.withdrawRequestsTotal = 0; // (4) Deposit liquidity back in (token0Data.active, token1Data.active) = depositLiquidity(_token0.available, _token1.available); token0Data.reserves = _token0.available - token0Data.active; token1Data.reserves = _token1.available - token1Data.active; epoch += 1; lastEpochStart = block.timestamp; emit NextEpochStarted(epoch, msg.sender, block.timestamp); } function _assetDataStatics(AssetData storage assetData) internal view returns (AssetDataStatics memory) { return AssetDataStatics({ reserves: assetData.reserves, active: assetData.active, depositRequestsTotal: assetData.depositRequestsTotal, withdrawRequestsTotal: assetData.withdrawRequestsTotal }); } // ----------- Abstract Functions Implemented For Each DEX ----------- function getPoolBalances() internal view virtual returns (uint256 poolToken0, uint256 poolToken1); /// @dev This is provided automatically by the Uniswap router function calcAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) internal view virtual returns (uint256 amountIn); /// @dev Withdraws all liquidity function withdrawLiquidity() internal returns (uint256 token0Withdrawn, uint256 token1Withdrawn) { // the combination of `unstakeLiquidity` and `_withdrawLiquidity` should never result in a decreased // balance of either token. If they do, this transaction will revert. uint256 token0BalanceBefore = token0.balanceOf(address(this)); uint256 token1BalanceBefore = token1.balanceOf(address(this)); _unstakeLiquidity(); _withdrawLiquidity(); token0Withdrawn = token0.balanceOf(address(this)) - token0BalanceBefore; token1Withdrawn = token1.balanceOf(address(this)) - token1BalanceBefore; } function _withdrawLiquidity() internal virtual; /// @dev Deposits liquidity into the pool function depositLiquidity(uint256 availableToken0, uint256 availableToken1) internal returns (uint256 token0Deposited, uint256 token1Deposited) { // ensure sufficient liquidity is minted, if < MIN_LP don't activate those funds if ((availableToken0 < MIN_LP) || (availableToken1 < MIN_LP)) return (0, 0); (token0Deposited, token1Deposited) = _depositLiquidity(availableToken0, availableToken1); _stakeLiquidity(); } function _depositLiquidity(uint256 availableToken0, uint256 availableToken1) internal virtual returns (uint256 token0Deposited, uint256 token1Deposited); /// @dev Swaps tokens and handles the case where amountIn == 0 function swap( IERC20Upgradeable tokenIn, IERC20Upgradeable tokenOut, uint256 amountIn ) internal virtual returns (uint256 amountOut, uint256 amountConsumed); // ----------- Rescue Funds ----------- /// @notice rescues funds from this contract in dire situations, only when contract is paused /// @param tokens array of tokens to rescue /// @param amounts list of amounts for each token to rescue. If 0, the full balance function rescueTokens(address[] calldata tokens, uint256[] calldata amounts) external override nonReentrant onlyGuardian whenPaused { require(tokens.length == amounts.length, "INVALID_INPUTS"); for (uint256 i = 0; i < tokens.length; i++) { uint256 amount = amounts[i]; if (tokens[i] == address(0)) { amount = (amount == 0) ? address(this).balance : amount; (bool success, ) = msg.sender.call{ value: amount }(""); require(success, "TRANSFER_FAILED"); } else { amount = (amount == 0) ? IERC20Upgradeable(tokens[i]).balanceOf(address(this)) : amount; IERC20Upgradeable(tokens[i]).safeTransfer(msg.sender, amount); } } emit FundsRescued(msg.sender); } /// @notice A function that should be called by the guardian to unstake any liquidity before rescuing LP tokens function unstakeLiquidity() external override nonReentrant onlyGuardian whenPaused { _unstakeLiquidity(); } /// @notice stakes all LP tokens function _unstakeLiquidity() internal virtual; /// @notice unstakes all LP tokens function _stakeLiquidity() internal virtual; // ----------- Getter Functions ----------- function token0ValueLocked() external view override returns (uint256) { return token0.balanceOf(address(this)) + token0Data.active; } function token1ValueLocked() external view override returns (uint256) { return token1.balanceOf(address(this)) + token1Data.active; } function token0BalanceDay0(address user) external view override returns (uint256) { return __user_balanceDay0(token0Data, user); } function epochToToken0Rate(uint256 _epoch) external view override returns (uint256) { return token0Data.epochToRate[_epoch]; } function token0WithdrawRequests(address user) external view override returns (uint256) { return __user_requestView(token0Data.withdrawRequests[user]); } function token1BalanceDay0(address user) external view override returns (uint256) { return __user_balanceDay0(token1Data, user); } function epochToToken1Rate(uint256 _epoch) external view override returns (uint256) { return token1Data.epochToRate[_epoch]; } function token1WithdrawRequests(address user) external view override returns (uint256) { return __user_requestView(token1Data.withdrawRequests[user]); } /// @dev This function is used to convert the way balances are internally stored to /// what makes sense for the user function __user_balanceDay0(AssetData storage assetData, address user) internal view returns (uint256) { uint256 res = assetData.balanceDay0[user]; Request memory depositReq = assetData.depositRequests[user]; if (depositReq.epoch < epoch) { // will not overflow even if value = total mc of crypto res += (depositReq.amount * RAY) / assetData.epochToRate[depositReq.epoch]; } Request memory withdrawReq = assetData.withdrawRequests[user]; if (withdrawReq.epoch == epoch) { // This amount has not been withdrawn yet so this is still part of // their Day 0 Balance res += withdrawReq.amount; } return res; } /// @dev This function is used to convert the way requests are internally stored to /// what makes sense for the user function __user_requestView(Request memory req) internal view returns (uint256) { if (req.epoch < epoch) { return 0; } return req.amount; } /// @notice calculates current amount of fees accrued, as the current balance of each token /// less the amounts each tokens that are active user funds. token0Data.active is not /// included because they are currently in the DEX pool function feesAccrued() public view override returns (uint256 token0Fees, uint256 token1Fees) { token0Fees = token0.balanceOf(address(this)) - token0Data.claimableTotal - token0Data.reserves - token0Data.depositRequestsTotal; token1Fees = token1.balanceOf(address(this)) - token1Data.claimableTotal - token1Data.reserves - token1Data.depositRequestsTotal; } /// ------------------- Setters ------------------- /// @notice sets a new value for the token0 floor /// @param _token0FloorNum the new floor token0 returns (out of `DENOM`) function setToken0Floor(uint256 _token0FloorNum) external override onlyStrategist { require(_token0FloorNum > 0, "INVALID_TOKEN0_FLOOR"); token0FloorNum = _token0FloorNum; emit Token0FloorUpdated(_token0FloorNum); } /// @notice sets a new value for the token1 floor /// @param _token1FloorNum the new floor token1 returns (out of `DENOM`) function setToken1Floor(uint256 _token1FloorNum) external override onlyStrategist { require(_token1FloorNum > 0, "INVALID_TOKEN1_FLOOR"); token1FloorNum = _token1FloorNum; emit Token1FloorUpdated(_token1FloorNum); } function setEpochDuration(uint256 _epochDuration) external override onlyStrategist whenPaused { epochDuration = _epochDuration; emit EpochDurationUpdated(_epochDuration); } /// @notice sends accrued fees to the core.feeTo() address, the treasury function collectFees() external override { (uint256 token0Fees, uint256 token1Fees) = feesAccrued(); if (token0Fees > 0) { token0.safeTransfer(core.feeTo(), token0Fees); } if (token1Fees > 0) { token1.safeTransfer(core.feeTo(), token1Fees); } } function setDepositsEnabled() external onlyStrategist whenPaused { depositsEnabled = true; } function setDepositsDisabled() external onlyStrategist whenPaused { depositsEnabled = false; } // To receive any native token sent here (ex. from wrapped native withdraw) receive() external payable { // no logic upon reciept of native token required } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.11; // Need to use IERC20Upgradeable because that is what SafeERC20Upgradeable requires // but the interface is exactly the same as ERC20s so this still works with ERC20s import { IERC20Upgradeable } from "../../lib/openzeppelin-contracts-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol"; /// @notice Storage for Vault /// @author Recursive Research Inc abstract contract VaultStorageUnpadded { /// @notice struct for withdraw and deposit requests /// @param epoch the epoch when the request was submitted /// @param amount size of request, if deposit it's an absolute amount of the underlying. /// If withdraw, specified in "Day 0" amount struct Request { uint256 epoch; uint256 amount; } /// @notice struct to keep a copy of AssetData in memory during `nextEpoch` call struct AssetDataStatics { uint256 reserves; uint256 active; uint256 depositRequestsTotal; uint256 withdrawRequestsTotal; } /// @notice global struct to keep track of all info for an asset /// @param reserves total amount not active /// @param active total amount paired up in the Dex pool /// @param depositRequestsTotal total amount of queued up deposit requests /// @param withdrawRequestsTotal total amount of queued up withdraw requests /// @param balanceDay0 each user's deposited balance denominated in "day 0 tokens" /// @param claimable each user's amount that has been withdrawn from the LP pool and they can claim /// @param epochToRate exchange rate of token to day0 tokens by epoch /// @param depositRequests each users deposit requests /// @param withdrawRequests each users withdraw requests struct AssetData { uint256 reserves; uint256 active; uint256 depositRequestsTotal; uint256 withdrawRequestsTotal; uint256 claimableTotal; mapping(address => uint256) balanceDay0; mapping(address => uint256) claimable; mapping(uint256 => uint256) epochToRate; mapping(address => Request) depositRequests; mapping(address => Request) withdrawRequests; } /// @notice true if token0 is wrapped native bool public isNativeVault; /// @notice token that receives a "floor" return IERC20Upgradeable public token0; /// @notice token that receives a "ceiling" return IERC20Upgradeable public token1; /// @notice current epoch, set to 1 on initialization uint256 public epoch; /// @notice duration of each epoch uint256 public epochDuration; /// @notice start of last epoch, 0 on initialization uint256 public lastEpochStart; /// @notice keeps track of relevant data for TOKEN0 AssetData public token0Data; /// @notice keeps track of relevant data for TOKEN1 AssetData public token1Data; /// @notice minimum return for TOKEN0 (out of `vault.DENOM`) as long as TOKEN1 is above its minimum return uint256 public token0FloorNum; /// @notice minimum return for TOKEN1 (out of `vault.DENOM`) uint256 public token1FloorNum; /// @notice flag for enabling/disabling deposits bool public depositsEnabled; } abstract contract VaultStorage is VaultStorageUnpadded { // @dev Padding 100 words of storage for upgradeability. Follows OZ's guidance. // @dev storage var depositsEnabled has been added, and __gap reduced by 1 word to maintain overall storage size. uint256[99] private __gap; }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"assetCode","type":"bytes32"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AssetsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"assetCode","type":"bytes32"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"DepositScheduled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newEpochDuration","type":"uint256"}],"name":"EpochDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"guardian","type":"address"}],"name":"FundsRescued","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"newEpoch","type":"uint256"},{"indexed":true,"internalType":"address","name":"initiator","type":"address"},{"indexed":false,"internalType":"uint256","name":"startTime","type":"uint256"}],"name":"NextEpochStarted","type":"event"},{"anonymous":false,"inputs":[],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newFloor","type":"uint256"}],"name":"Token0FloorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newFloor","type":"uint256"}],"name":"Token1FloorUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"assetCode","type":"bytes32"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountDay0","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"WithdrawScheduled","type":"event"},{"inputs":[],"name":"DENOM","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_LP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POOL_ERR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN0","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN1","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimToken0","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimToken1","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collectFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"core","outputs":[{"internalType":"contract ICore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositToken0","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositToken1","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositsEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epoch","type":"uint256"}],"name":"epochToToken0Rate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epoch","type":"uint256"}],"name":"epochToToken1Rate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feesAccrued","outputs":[{"internalType":"uint256","name":"token0Fees","type":"uint256"},{"internalType":"uint256","name":"token1Fees","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coreAddress","type":"address"},{"internalType":"uint256","name":"_epochDuration","type":"uint256"},{"internalType":"address","name":"_token0","type":"address"},{"internalType":"address","name":"_token1","type":"address"},{"internalType":"uint256","name":"_token0FloorNum","type":"uint256"},{"internalType":"uint256","name":"_token1FloorNum","type":"uint256"},{"internalType":"address","name":"_uniswapFactory","type":"address"},{"internalType":"address","name":"_uniswapRouter","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isNativeVault","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastEpochStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"expectedPoolToken0","type":"uint256"},{"internalType":"uint256","name":"expectedPoolToken1","type":"uint256"}],"name":"nextEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"rescueTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"setDepositsDisabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setDepositsEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_epochDuration","type":"uint256"}],"name":"setEpochDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_token0FloorNum","type":"uint256"}],"name":"setToken0Floor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_token1FloorNum","type":"uint256"}],"name":"setToken1Floor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"token0Balance","outputs":[{"internalType":"uint256","name":"deposited","type":"uint256"},{"internalType":"uint256","name":"pendingDeposit","type":"uint256"},{"internalType":"uint256","name":"claimable","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"token0BalanceDay0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0Data","outputs":[{"internalType":"uint256","name":"reserves","type":"uint256"},{"internalType":"uint256","name":"active","type":"uint256"},{"internalType":"uint256","name":"depositRequestsTotal","type":"uint256"},{"internalType":"uint256","name":"withdrawRequestsTotal","type":"uint256"},{"internalType":"uint256","name":"claimableTotal","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0FloorNum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0ValueLocked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"token0WithdrawRequests","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"token1Balance","outputs":[{"internalType":"uint256","name":"deposited","type":"uint256"},{"internalType":"uint256","name":"pendingDeposit","type":"uint256"},{"internalType":"uint256","name":"claimable","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"token1BalanceDay0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1Data","outputs":[{"internalType":"uint256","name":"reserves","type":"uint256"},{"internalType":"uint256","name":"active","type":"uint256"},{"internalType":"uint256","name":"depositRequestsTotal","type":"uint256"},{"internalType":"uint256","name":"withdrawRequestsTotal","type":"uint256"},{"internalType":"uint256","name":"claimableTotal","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1FloorNum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1ValueLocked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"token1WithdrawRequests","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unstakeLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawToken0","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawToken1","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60806040523480156200001157600080fd5b50600062000020600162000087565b9050801562000039576000805461ff0019166101001790555b801562000080576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50620001a8565b60008054610100900460ff161562000120578160ff166001148015620000c05750620000be306200019960201b62002a4f1760201c565b155b620001185760405162461bcd60e51b815260206004820152602e602482015260008051602062004d1983398151915260448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b506000919050565b60005460ff8084169116106200017f5760405162461bcd60e51b815260206004820152602e602482015260008051602062004d1983398151915260448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016200010f565b506000805460ff191660ff92909216919091179055600190565b6001600160a01b03163b151590565b614b6180620001b86000396000f3fe6080604052600436106102e75760003560e01c806371210a0d11610190578063c2306acb116100dc578063e4ed711811610095578063f0365efb1161006f578063f0365efb146108b4578063f2f4eb26146108ca578063f878996a146108f0578063f887ea401461091057600080fd5b8063e4ed71181461085f578063ee86e1aa1461087f578063ef253eb61461089f57600080fd5b8063c2306acb146107be578063c45a0155146107d4578063c59197e3146107f4578063c879657214610814578063d21220a714610829578063d5bf91e31461084957600080fd5b806394db059511610149578063a5c0fd0511610123578063a5c0fd0514610737578063a624198014610757578063a8aa1b3114610777578063ac8969511461079757600080fd5b806394db0595146106e0578063971e3c431461070a578063a21b927f1461071d57600080fd5b806371210a0d146105f65780638456cb59146106165780638a8090951461062b5780638fd57d3e14610640578063900cf0cf1461067b578063930f7ee81461069157600080fd5b8063443ec74d1161024f578063552033c4116102085780635c08bfc2116101e25780635c08bfc21461058a5780635c975abb146105aa5780635ee04d78146105bf5780636e6c9041146105e157600080fd5b8063552033c41461052b57806355a723ed1461054a5780635a5c90481461056a57600080fd5b8063443ec74d1461048a578063470ea1d4146104ac578063486f0673146104c15780634b4c489b146104d65780634ff0876a146104eb5780635392fd1c1461050157600080fd5b80632addf608116102a15780632addf608146103d257806330024dfe146103ff5780633bf8d6201461041f5780633f4ba83a1461043f57806340f1d6e01461045457806341213a171461047457600080fd5b80622b34f9146102f3578063037a354c146103335780630dfe16811461034857806311e8416c1461038557806316343da4146103a757806318bf3844146103bd57600080fd5b366102ee57005b600080fd5b3480156102ff57600080fd5b5061032061030e366004614444565b60009081526049602052604090205490565b6040519081526020015b60405180910390f35b34801561033f57600080fd5b50610320610930565b34801561035457600080fd5b5060335461036d9061010090046001600160a01b031681565b6040516001600160a01b03909116815260200161032a565b34801561039157600080fd5b506103a56103a0366004614444565b6109b1565b005b3480156103b357600080fd5b5061032061271081565b3480156103c957600080fd5b50610320603281565b3480156103de57600080fd5b506103206103ed366004614444565b6000908152603f602052604090205490565b34801561040b57600080fd5b506103a561041a366004614444565b610a28565b34801561042b57600080fd5b506103a561043a3660046144a2565b610aad565b34801561044b57600080fd5b506103a5610e83565b34801561046057600080fd5b5061032061046f366004614523565b610ff7565b34801561048057600080fd5b50610320604c5481565b34801561049657600080fd5b50610320600080516020614b0c83398151915281565b3480156104b857600080fd5b506103a561100a565b3480156104cd57600080fd5b506103a5611062565b3480156104e257600080fd5b506103a56110b7565b3480156104f757600080fd5b5061032060365481565b34801561050d57600080fd5b50604e5461051b9060ff1681565b604051901515815260200161032a565b34801561053757600080fd5b50610320676765c793fa10079d601b1b81565b34801561055657600080fd5b50610320610565366004614523565b611225565b34801561057657600080fd5b506103a5610585366004614540565b611260565b34801561059657600080fd5b506103a56105a5366004614444565b6112e5565b3480156105b657600080fd5b5061051b611386565b3480156105cb57600080fd5b50610320600080516020614aec83398151915281565b3480156105ed57600080fd5b506103a5611415565b34801561060257600080fd5b506103a5610611366004614444565b611599565b34801561062257600080fd5b506103a561165e565b34801561063757600080fd5b506103a56117d9565b34801561064c57600080fd5b5061066061065b366004614523565b61185b565b6040805193845260208401929092529082015260600161032a565b34801561068757600080fd5b5061032060355481565b34801561069d57600080fd5b506042546043546044546045546046546106b8949392919085565b604080519586526020860194909452928401919091526060830152608082015260a00161032a565b3480156106ec57600080fd5b506106f5611878565b6040805192835260208301919091520161032a565b6103a5610718366004614444565b6119bc565b34801561072957600080fd5b5060335461051b9060ff1681565b34801561074357600080fd5b506103a5610752366004614444565b611b5a565b34801561076357600080fd5b50610660610772366004614523565b611bc1565b34801561078357600080fd5b5060b45461036d906001600160a01b031681565b3480156107a357600080fd5b50603854603954603a54603b54603c546106b8949392919085565b3480156107ca57600080fd5b50610320604d5481565b3480156107e057600080fd5b5060b25461036d906001600160a01b031681565b34801561080057600080fd5b506103a561080f366004614444565b611bd1565b34801561082057600080fd5b506103a5611c72565b34801561083557600080fd5b5060345461036d906001600160a01b031681565b34801561085557600080fd5b5061032060375481565b34801561086b57600080fd5b5061032061087a366004614523565b611db1565b34801561088b57600080fd5b5061032061089a366004614523565b611dec565b3480156108ab57600080fd5b50610320611df9565b3480156108c057600080fd5b506103206103e881565b3480156108d657600080fd5b5060005461036d906201000090046001600160a01b031681565b3480156108fc57600080fd5b506103a561090b3660046145ce565b611e33565b34801561091c57600080fd5b5060b35461036d906001600160a01b031681565b6043546034546040516370a0823160e01b8152306004820152600092916001600160a01b0316906370a08231906024015b602060405180830381865afa15801561097e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a291906145f0565b6109ac919061461f565b905090565b6109b9611386565b156109df5760405162461bcd60e51b81526004016109d690614637565b60405180910390fd5b60026001541415610a025760405162461bcd60e51b81526004016109d690614657565b6002600155610a21603882600080516020614b0c833981519152612a5e565b5060018055565b610a3133612c17565b610a4d5760405162461bcd60e51b81526004016109d69061468e565b610a55611386565b610a715760405162461bcd60e51b81526004016109d6906146b6565b60368190556040518181527fbfdcfb557a8f4a07f749e7d744a90c02e13eb5af308b561c2f4f17e58069c836906020015b60405180910390a150565b60026001541415610ad05760405162461bcd60e51b81526004016109d690614657565b60026001556000546040805163093a953d60e21b81529051620100009092046001600160a01b0316916391d148549183916324ea54f4916004808201926020929091908290030181865afa158015610b2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5091906145f0565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa158015610b92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb691906146da565b610bf15760405162461bcd60e51b815260206004820152600c60248201526b2727aa2fa3aaa0a92224a0a760a11b60448201526064016109d6565b610bf9611386565b610c155760405162461bcd60e51b81526004016109d6906146b6565b828114610c555760405162461bcd60e51b815260206004820152600e60248201526d494e56414c49445f494e5055545360901b60448201526064016109d6565b60005b83811015610e4d576000838383818110610c7457610c746146fc565b90506020020135905060006001600160a01b0316868684818110610c9a57610c9a6146fc565b9050602002016020810190610caf9190614523565b6001600160a01b03161415610d5f578015610cca5780610ccc565b475b604051909150600090339083908381818185875af1925050503d8060008114610d11576040519150601f19603f3d011682016040523d82523d6000602084013e610d16565b606091505b5050905080610d595760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b60448201526064016109d6565b50610e3a565b8015610d6b5780610dfc565b858583818110610d7d57610d7d6146fc565b9050602002016020810190610d929190614523565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015610dd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dfc91906145f0565b9050610e3a3382888886818110610e1557610e156146fc565b9050602002016020810190610e2a9190614523565b6001600160a01b03169190612d02565b5080610e4581614712565b915050610c58565b5060405133907f8d133fdaa7b1c86c6a04057392e7e94c6610ac87bb5b138cf2ce8a3605da342b90600090a25050600180555050565b6000546040805163389ed26760e01b81529051620100009092046001600160a01b0316916391d1485491839163389ed267916004808201926020929091908290030181865afa158015610eda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efe91906145f0565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa158015610f40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6491906146da565b610f9d5760405162461bcd60e51b815260206004820152600a6024820152692727aa2fa820aaa9a2a960b11b60448201526064016109d6565b610fa5611386565b610fc15760405162461bcd60e51b81526004016109d6906146b6565b6000805460ff60b01b191681556040517fa45f47fdea8a1efdd9029a5691c7f759c32b7c698632b563573e155625d169339190a1565b6000611004603883612d6a565b92915050565b61101333612c17565b61102f5760405162461bcd60e51b81526004016109d69061468e565b611037611386565b6110535760405162461bcd60e51b81526004016109d6906146b6565b604e805460ff19166001179055565b61106b33612c17565b6110875760405162461bcd60e51b81526004016109d69061468e565b61108f611386565b6110ab5760405162461bcd60e51b81526004016109d6906146b6565b604e805460ff19169055565b600260015414156110da5760405162461bcd60e51b81526004016109d690614657565b60026001556000546040805163093a953d60e21b81529051620100009092046001600160a01b0316916391d148549183916324ea54f4916004808201926020929091908290030181865afa158015611136573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115a91906145f0565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa15801561119c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c091906146da565b6111fb5760405162461bcd60e51b815260206004820152600c60248201526b2727aa2fa3aaa0a92224a0a760a11b60448201526064016109d6565b611203611386565b61121f5760405162461bcd60e51b81526004016109d6906146b6565b60018055565b6001600160a01b0381166000908152604b60209081526040808320815180830190925280548252600101549181019190915261100490612e5c565b600061126c6001612e7c565b90508015611284576000805461ff0019166101001790555b6112948989898989898989612f09565b80156112da576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6112ee33612c17565b61130a5760405162461bcd60e51b81526004016109d69061468e565b600081116113515760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22faa27a5a2a718afa32627a7a960611b60448201526064016109d6565b604d8190556040518181527f028ed94f731ed283cb15743fe60b6ec898df578786d87ea55565a79590c6864390602001610aa2565b60008060029054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113fe91906146da565b806109ac575050600054600160b01b900460ff1690565b61141d611386565b1561143a5760405162461bcd60e51b81526004016109d690614637565b6002600154141561145d5760405162461bcd60e51b81526004016109d690614657565b6002600155600061147d6038600080516020614b0c833981519152612f52565b60335490915060ff161561157d57603354604051632e1a7d4d60e01b8152600481018390526101009091046001600160a01b031690632e1a7d4d90602401600060405180830381600087803b1580156114d557600080fd5b505af11580156114e9573d6000803e3d6000fd5b50506040516000925033915083908381818185875af1925050503d806000811461152f576040519150601f19603f3d011682016040523d82523d6000602084013e611534565b606091505b50509050806115775760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b60448201526064016109d6565b50610a21565b603354610a219061010090046001600160a01b03163383612d02565b604e5460ff166115df5760405162461bcd60e51b815260206004820152601160248201527011115413d4d25514d7d11254d050931151607a1b60448201526064016109d6565b6115e7611386565b156116045760405162461bcd60e51b81526004016109d690614637565b600260015414156116275760405162461bcd60e51b81526004016109d690614657565b6002600155603454611644906001600160a01b031633308461308f565b610a21604282600080516020614aec8339815191526130cd565b6000546040805163389ed26760e01b81529051620100009092046001600160a01b0316916391d1485491839163389ed267916004808201926020929091908290030181865afa1580156116b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d991906145f0565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa15801561171b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061173f91906146da565b6117785760405162461bcd60e51b815260206004820152600a6024820152692727aa2fa820aaa9a2a960b11b60448201526064016109d6565b611780611386565b1561179d5760405162461bcd60e51b81526004016109d690614637565b6000805460ff60b01b1916600160b01b1781556040517f9e87fac88ff661f02d44f95383c817fece4bce600a3dab7a54406878b965e7529190a1565b6117e1611386565b156117fe5760405162461bcd60e51b81526004016109d690614637565b600260015414156118215760405162461bcd60e51b81526004016109d690614657565b600260015560006118416042600080516020614aec833981519152612f52565b603454909150610a21906001600160a01b03163383612d02565b600080600061186b604285613186565b9250925092509193909250565b603a54603854603c546033546040516370a0823160e01b815230600482015260009485949093909290916101009091046001600160a01b0316906370a0823190602401602060405180830381865afa1580156118d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118fc91906145f0565b611906919061472d565b611910919061472d565b61191a919061472d565b6044546042546046546034546040516370a0823160e01b81523060048201529496509293919290916001600160a01b03909116906370a0823190602401602060405180830381865afa158015611974573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199891906145f0565b6119a2919061472d565b6119ac919061472d565b6119b6919061472d565b90509091565b604e5460ff16611a025760405162461bcd60e51b815260206004820152601160248201527011115413d4d25514d7d11254d050931151607a1b60448201526064016109d6565b611a0a611386565b15611a275760405162461bcd60e51b81526004016109d690614637565b60026001541415611a4a5760405162461bcd60e51b81526004016109d690614657565b600260015560335460ff1615611ae257603360019054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611aaa57600080fd5b505af1158015611abe573d6000803e3d6000fd5b5050505050611add603834600080516020614b0c8339815191526130cd565b610a21565b3415611b235760405162461bcd60e51b815260206004820152601060248201526f1393d517d3905512559157d59055531560821b60448201526064016109d6565b603354611b409061010090046001600160a01b031633308461308f565b610a21603882600080516020614b0c8339815191526130cd565b611b62611386565b15611b7f5760405162461bcd60e51b81526004016109d690614637565b60026001541415611ba25760405162461bcd60e51b81526004016109d690614657565b6002600155610a21604282600080516020614aec833981519152612a5e565b600080600061186b603885613186565b611bda33612c17565b611bf65760405162461bcd60e51b81526004016109d69061468e565b60008111611c3d5760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22faa27a5a2a7182fa32627a7a960611b60448201526064016109d6565b604c8190556040518181527fedc83a6572b1f179b02829c85e794c5f926768aa8450ddd3b9dbfc55b09f9f3c90602001610aa2565b600080611c7d611878565b90925090508115611d1a57611d1a600060029054906101000a90046001600160a01b03166001600160a01b031663017e7e586040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d029190614744565b60335461010090046001600160a01b03169084612d02565b8015611dad57611dad600060029054906101000a90046001600160a01b03166001600160a01b031663017e7e586040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d9a9190614744565b6034546001600160a01b03169083612d02565b5050565b6001600160a01b0381166000908152604160209081526040808320815180830190925280548252600101549181019190915261100490612e5c565b6000611004604283612d6a565b6039546033546040516370a0823160e01b81523060048201526000929161010090046001600160a01b0316906370a0823190602401610961565b60405163014c483360e71b81523360048201819052906000908190309063a624198090602401606060405180830381865afa158015611e76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e9a9190614761565b506040516347eabe9f60e11b81526001600160a01b0386166004820152919350915060009081903090638fd57d3e90602401606060405180830381865afa158015611ee9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0d9190614761565b50909250905060008183611f21868861461f565b611f2b919061461f565b611f35919061461f565b1180611f455750611f4585612c17565b611f915760405162461bcd60e51b815260206004820152601d60248201527f4e4f545f5041525449434950414e545f4f525f5354524154454749535400000060448201526064016109d6565b611f99611386565b15611fb65760405162461bcd60e51b81526004016109d690614637565b603654603754611fc6904261472d565b101561200b5760405162461bcd60e51b8152602060048201526014602482015273115413d0d217d1155490551253d397d55393515560621b60448201526064016109d6565b6000612017603861332e565b90506000612025604261332e565b90506120606040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6120996040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6035546120a461338c565b835283526127106120b660328261472d565b6120c0908e61478f565b6120ca91906147ae565b835110156120ea5760405162461bcd60e51b81526004016109d6906147d0565b6127106120f860328261461f565b612102908e61478f565b61210c91906147ae565b8351111561212c5760405162461bcd60e51b81526004016109d6906147d0565b61271061213a60328261472d565b612144908d61478f565b61214e91906147ae565b8251101561216e5760405162461bcd60e51b81526004016109d6906147d0565b61271061217c60328261461f565b612186908d61478f565b61219091906147ae565b825111156121b05760405162461bcd60e51b81526004016109d6906147d0565b6121b86134b8565b6020848101919091528401526121cc61338c565b83528352845160208401516121e1919061461f565b6040840152835160208301516121f7919061461f565b6040830152604c54602086015160009161271091612215919061478f565b61221f91906147ae565b865161222b919061461f565b90506000612710604d548760200151612244919061478f565b61224e91906147ae565b865161225a919061461f565b9050600086602001518760000151612272919061461f565b9050856040015183111561237957600080876040015185612293919061472d565b88519091508111156122ab57866040015191506122bd565b865188516122ba9183916136a8565b91505b60408701516000906122cf848661461f565b106123035760408801516122e3868561461f565b116122ee5782612313565b8488604001516122fe919061472d565b612313565b838860400151612313919061472d565b603454603354919250600091829161233e916001600160a01b0391821691610100909104168561372e565b91509150818b604001818151612354919061461f565b90525060408a01805182919061236b90839061472d565b90525061250e945050505050565b808560400151106123f657603454603354604087015160009283926123be926001600160a01b0392831692610100909204909116906123b990879061472d565b61372e565b9150915081886040018181516123d4919061461f565b9052506040870180518291906123eb90839061472d565b90525061250e915050565b600080866040015183612409919061472d565b875190915081111561241e5787519150612430565b8751875161242d9183916136a8565b91505b604088015161243f838761461f565b10156124a457603354603454600091829161246c916001600160a01b03610100909104811691168661372e565b91509150808a604001818151612482919061472d565b90525060408901805183919061249990839061461f565b90525061250b915050565b60335460345460408a015160009283926124d8926101009092046001600160a01b03908116929116906123b9908b9061472d565b91509150808a6040018181516124ee919061472d565b90525060408901805183919061250590839061461f565b90525050505b50505b6020880151885161251f919061461f565b606087015260208701518751612535919061461f565b6060808701919091528601516040870151111561267757600060029054906101000a90046001600160a01b03166001600160a01b031663bc063e1a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561259f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125c391906145f0565b600060029054906101000a90046001600160a01b03166001600160a01b031663b0e21e8a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612616573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263a91906145f0565b8760600151886040015161264e919061472d565b612658919061478f565b61266291906147ae565b86604001818151612673919061472d565b9052505b8460600151856040015111156127b257600060029054906101000a90046001600160a01b03166001600160a01b031663bc063e1a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126fe91906145f0565b600060029054906101000a90046001600160a01b03166001600160a01b031663b0e21e8a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612751573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061277591906145f0565b86606001518760400151612789919061472d565b612793919061478f565b61279d91906147ae565b856040018181516127ae919061472d565b9052505b60008660600151116127e157603f60006127cd60018761472d565b81526020019081526020016000205461281d565b60608601516040870151603f60006127fa60018961472d565b815260200190815260200160002054612813919061478f565b61281d91906147ae565b608087018181526000868152603f6020526040902091909155516060890151676765c793fa10079d601b1b916128529161478f565b61285c91906147ae565b60a08701819052603c805460009061287590849061461f565b909155505060608501516128a6576049600061289260018761472d565b8152602001908152602001600020546128e2565b60608501516040860151604960006128bf60018961472d565b8152602001908152602001600020546128d8919061478f565b6128e291906147ae565b60808601818152600086815260496020526040902091909155516060880151676765c793fa10079d601b1b916129179161478f565b61292191906147ae565b60a086018190526046805460009061293a90849061461f565b909155505060a08601516040808a015190880151612958919061461f565b612962919061472d565b8660400181815250508460a0015187604001518660400151612984919061461f565b61298e919061472d565b60408087018290526000603a819055603b81905560448190556045558701516129b69161380a565b604355603981905560408701516129cd919061472d565b60385560435460408601516129e2919061472d565b60425560358054600191906000906129fb90849061461f565b909155505042603781905560355460405191825233917f9427bfed592ae6253fdc90424d4a4f3130787bd0bfa959312914f6eaf422e5799060200160405180910390a3505050505050505050505050505050565b6001600160a01b03163b151590565b60008211612a9c5760405162461bcd60e51b815260206004820152600b60248201526a16915493d7d05353d5539560aa1b60448201526064016109d6565b6035546000612aac858383613845565b336000908152600987016020526040902060018101549192509015801590612ad45750805483115b15612b3f57805460009081526007870160205260409020546001820154676765c793fa10079d601b1b91612b079161478f565b612b1191906147ae565b33600090815260068801602052604081208054909190612b3290849061461f565b9091555050600060018201555b84821015612b865760405162461bcd60e51b8152602060048201526014602482015273494e53554646494349454e545f42414c414e434560601b60448201526064016109d6565b336000908152600587016020526040902085830390556001810154612bab908661461f565b60018201558054831115612bbd578281555b84866003016000828254612bd1919061461f565b90915550506040518581528390339086907f52266201bc2fd6b76ef485c613769527c5ea4face1c63f7f9e806735b31d48fc9060200160405180910390a4505050505050565b60008054604080516328de28c960e21b81529051620100009092046001600160a01b0316916391d1485491839163a378a324916004808201926020929091908290030181865afa158015612c6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9391906145f0565b6040516001600160e01b031960e084901b16815260048101919091526001600160a01b0385166024820152604401602060405180830381865afa158015612cde573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100491906146da565b6040516001600160a01b038316602482015260448101829052612d6590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526138e9565b505050565b6001600160a01b0381166000908152600583016020908152604080832054600886018352818420825180840190935280548084526001909101549383019390935260355490921015612dfd578051600090815260078601602090815260409091205490820151612de690676765c793fa10079d601b1b9061478f565b612df091906147ae565b612dfa908361461f565b91505b6001600160a01b038416600090815260098601602090815260409182902082518084019093528054808452600190910154918301919091526035541415612e50576020810151612e4d908461461f565b92505b5090949350505050565b565b600060355482600001511015612e7457506000919050565b506020015190565b60008054610100900460ff1615612ec3578160ff166001148015612e9f5750303b155b612ebb5760405162461bcd60e51b81526004016109d690614807565b506000919050565b60005460ff808416911610612eea5760405162461bcd60e51b81526004016109d690614807565b506000805460ff191660ff92909216919091179055600190565b919050565b600054610100900460ff16612f305760405162461bcd60e51b81526004016109d690614855565b612f3e8888888888886139bb565b612f488282613a08565b5050505050505050565b33600090815260098301602090815260408083206035548154600688019094529184205490929082821015612fe65760018401548015612fe457336000908152600989016020908152604080832083815560010183905585835260078b01909152902054676765c793fa10079d601b1b90612fcd908361478f565b612fd791906147ae565b612fe1908361461f565b91505b505b600081116130215760405162461bcd60e51b81526020600482015260086024820152674e4f5f434c41494d60c01b60448201526064016109d6565b336000908152600688016020526040812081905560048801805483929061304990849061472d565b9091555050604051818152339087907fe269963e621a3253e62b91db52a65eed542266d831178ebc68ad61d54211aca69060200160405180910390a39695505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526130c79085906323b872dd60e01b90608401612d2e565b50505050565b6000821161310b5760405162461bcd60e51b815260206004820152600b60248201526a16915493d7d05353d5539560aa1b60448201526064016109d6565b603554613119848285613845565b33600090815260058601602052604081209190915560028501805485929061314290849061461f565b90915550506040518381528190339084907f1e6c0ff7d7fa524ca8d88cabca077adebbf64f902faa7f4b97aa5a1da2620faf9060200160405180910390a450505050565b6035546001600160a01b038216600090815260058401602090815260408083205460088701835281842082518084019093528054808452600190910154938301849052939485948594919391908115613226578481101561322257600081815260078b016020526040902054613207676765c793fa10079d601b1b8461478f565b61321191906147ae565b61321b908561461f565b9350613226565b8196505b6001600160a01b038916600081815260098c0160209081526040808320815180830183528154815260019091015481840190815294845260068f0190925290912054915191975090156132d95780518611156132c7578051600090815260078c01602090815260409091205490820151676765c793fa10079d601b1b916132ac9161478f565b6132b691906147ae565b6132c0908861461f565b96506132d9565b60208101516132d6908661461f565b94505b600060078c01816132eb60018a61472d565b8152602001908152602001600020549050676765c793fa10079d601b1b8187613314919061478f565b61331e91906147ae565b9950505050505050509250925092565b6133596040518060800160405280600081526020016000815260200160008152602001600081525090565b50604080516080810182528254815260018301546020820152600283015491810191909152600390910154606082015290565b60008060008060b460009054906101000a90046001600160a01b03166001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa1580156133e5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061340991906148b7565b5060335460b45460408051630dfe168160e01b815290516001600160701b0395861697509390941694506001600160a01b03610100909204821693911691630dfe1681916004808201926020929091908290030181865afa158015613472573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134969190614744565b6001600160a01b0316146134ab5780826134ae565b81815b9350935050509091565b6033546040516370a0823160e01b81523060048201526000918291829161010090046001600160a01b0316906370a0823190602401602060405180830381865afa15801561350a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061352e91906145f0565b6034546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561357c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135a091906145f0565b90506135aa613b35565b6033546040516370a0823160e01b8152306004820152839161010090046001600160a01b0316906370a0823190602401602060405180830381865afa1580156135f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061361b91906145f0565b613625919061472d565b6034546040516370a0823160e01b815230600482015291955082916001600160a01b03909116906370a0823190602401602060405180830381865afa158015613672573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061369691906145f0565b6136a0919061472d565b925050509091565b60b3546040516385f8c25960e01b81526004810185905260248101849052604481018390526000916001600160a01b0316906385f8c25990606401602060405180830381865afa158015613700573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061372491906145f0565b90505b9392505050565b6000808261374157506000905080613802565b60b35461375b906001600160a01b03878116911685613c6b565b60b3546001600160a01b03166338ed17398460006137798989613d1d565b30426040518663ffffffff1660e01b815260040161379b959493929190614907565b6000604051808303816000875af11580156137ba573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526137e2919081019061498e565b6001815181106137f4576137f46146fc565b602002602001015191508290505b935093915050565b6000806103e884108061381e57506103e883105b1561382e5750600090508061383e565b6138388484613dab565b90925090505b9250929050565b336000908152600884016020908152604080832060058701909252822054600182015480158015906138775750825486115b156138c15782546000908152600788016020526040902054806138a5676765c793fa10079d601b1b8461478f565b6138af91906147ae565b6138b9908461461f565b925060009150505b84156138d7576138d1858261461f565b86845590505b60019092019190915590509392505050565b600061393e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613ef09092919063ffffffff16565b805190915015612d65578080602001905181019061395c91906146da565b612d655760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109d6565b600054610100900460ff166139e25760405162461bcd60e51b81526004016109d690614855565b6139eb86613eff565b6139f3613f32565b613a008585858585613f61565b505050505050565b600054610100900460ff16613a2f5760405162461bcd60e51b81526004016109d690614855565b60335460345460405163e6a4390560e01b81526101009092046001600160a01b039081166004840152908116602483015283169063e6a4390590604401602060405180830381865afa158015613a89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613aad9190614744565b60b480546001600160a01b0319166001600160a01b03929092169182179055613b075760405162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b60448201526064016109d6565b60b280546001600160a01b039384166001600160a01b03199182161790915560b38054929093169116179055565b60b4546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015613b7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ba291906145f0565b905080613bac5750565b60b35460b454613bc9916001600160a01b03918216911683613c6b565b60b354603354603454604051635d5155ef60e11b81526001600160a01b036101009093048316600482015290821660248201526044810184905260006064820181905260848201523060a48201524260c482015291169063baa2abde9060e40160408051808303816000875af1158015613c47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d659190614a4c565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015613cbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ce091906145f0565b613cea919061461f565b6040516001600160a01b0385166024820152604481018290529091506130c790859063095ea7b360e01b90606401612d2e565b60408051600280825260608083018452926020830190803683370190505090508281600081518110613d5157613d516146fc565b60200260200101906001600160a01b031690816001600160a01b0316815250508181600181518110613d8557613d856146fc565b60200260200101906001600160a01b031690816001600160a01b03168152505092915050565b60b3546033546000918291613dd2916001600160a01b036101009092048216911686613c6b565b60b354603454613def916001600160a01b03918216911685613c6b565b60b35460335460345460405162e8e33760e81b81526001600160a01b03610100909304831660048201529082166024820152604481018790526064810186905260006084820181905260a48201523060c48201524260e482015291169063e8e3370090610104016060604051808303816000875af1158015613e75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e999190614761565b50909250905081841115613eca5760b354603354613eca916001600160a01b0361010090920482169116600061414d565b8083111561383e5760b35460345461383e916001600160a01b039182169116600061414d565b60606137248484600085614262565b600054610100900460ff16613f265760405162461bcd60e51b81526004016109d690614855565b613f2f81614393565b50565b600054610100900460ff16613f595760405162461bcd60e51b81526004016109d690614855565b612e5a6143e4565b600054610100900460ff16613f885760405162461bcd60e51b81526004016109d690614855565b60008211613fcf5760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22faa27a5a2a7182fa32627a7a960611b60448201526064016109d6565b600081116140165760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22faa27a5a2a718afa32627a7a960611b60448201526064016109d6565b600060029054906101000a90046001600160a01b03166001600160a01b031663eb6d3a116040518163ffffffff1660e01b8152600401602060405180830381865afa158015614069573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061408d9190614744565b603380546001600160a81b0319166001600160a01b03928316968316968714610100600160a81b031916176101009690960295909517909455603480546001600160a01b031916939094169290921790925560008052676765c793fa10079d601b1b7fe9090a6e551363283803e59daf1c144cd0ac55c420ac8519a53d83ef396a73b381905560496020527f9a0ca60aea446f0de2b73532837f00f56d3ae047e136f7838a520755c00b6e76556001603555603692909255604c55604d55565b8015806141c75750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa1580156141a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141c591906145f0565b155b6142325760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016109d6565b6040516001600160a01b038316602482015260448101829052612d6590849063095ea7b360e01b90606401612d2e565b6060824710156142c35760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109d6565b6001600160a01b0385163b61431a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109d6565b600080866001600160a01b031685876040516143369190614a9c565b60006040518083038185875af1925050503d8060008114614373576040519150601f19603f3d011682016040523d82523d6000602084013e614378565b606091505b509150915061438882828661440b565b979650505050505050565b600054610100900460ff166143ba5760405162461bcd60e51b81526004016109d690614855565b600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b600054610100900460ff1661121f5760405162461bcd60e51b81526004016109d690614855565b6060831561441a575081613727565b82511561442a5782518084602001fd5b8160405162461bcd60e51b81526004016109d69190614ab8565b60006020828403121561445657600080fd5b5035919050565b60008083601f84011261446f57600080fd5b50813567ffffffffffffffff81111561448757600080fd5b6020830191508360208260051b850101111561383e57600080fd5b600080600080604085870312156144b857600080fd5b843567ffffffffffffffff808211156144d057600080fd5b6144dc8883890161445d565b909650945060208701359150808211156144f557600080fd5b506145028782880161445d565b95989497509550505050565b6001600160a01b0381168114613f2f57600080fd5b60006020828403121561453557600080fd5b81356137278161450e565b600080600080600080600080610100898b03121561455d57600080fd5b88356145688161450e565b975060208901359650604089013561457f8161450e565b9550606089013561458f8161450e565b94506080890135935060a0890135925060c08901356145ad8161450e565b915060e08901356145bd8161450e565b809150509295985092959890939650565b600080604083850312156145e157600080fd5b50508035926020909101359150565b60006020828403121561460257600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000821982111561463257614632614609565b500190565b60208082526006908201526514105554d15160d21b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600e908201526d1393d517d4d51490551151d254d560921b604082015260600190565b6020808252600a90820152691393d517d4105554d15160b21b604082015260600190565b6000602082840312156146ec57600080fd5b8151801515811461372757600080fd5b634e487b7160e01b600052603260045260246000fd5b600060001982141561472657614726614609565b5060010190565b60008282101561473f5761473f614609565b500390565b60006020828403121561475657600080fd5b81516137278161450e565b60008060006060848603121561477657600080fd5b8351925060208401519150604084015190509250925092565b60008160001904831182151516156147a9576147a9614609565b500290565b6000826147cb57634e487b7160e01b600052601260045260246000fd5b500490565b60208082526018908201527f554e45585045435445445f504f4f4c5f42414c414e4345530000000000000000604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b80516001600160701b0381168114612f0457600080fd5b6000806000606084860312156148cc57600080fd5b6148d5846148a0565b92506148e3602085016148a0565b9150604084015163ffffffff811681146148fc57600080fd5b809150509250925092565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156149575784516001600160a01b031683529383019391830191600101614932565b50506001600160a01b03969096166060850152505050608001529392505050565b634e487b7160e01b600052604160045260246000fd5b600060208083850312156149a157600080fd5b825167ffffffffffffffff808211156149b957600080fd5b818501915085601f8301126149cd57600080fd5b8151818111156149df576149df614978565b8060051b604051601f19603f83011681018181108582111715614a0457614a04614978565b604052918252848201925083810185019188831115614a2257600080fd5b938501935b82851015614a4057845184529385019392850192614a27565b98975050505050505050565b60008060408385031215614a5f57600080fd5b505080516020909101519092909150565b60005b83811015614a8b578181015183820152602001614a73565b838111156130c75750506000910152565b60008251614aae818460208701614a70565b9190910192915050565b6020815260008251806020840152614ad7816040850160208701614a70565b601f01601f1916919091016040019291505056fe29904dc0060dfbfbdb4804f541ee5b0af0fb57e8edc680ea7b5d072a031ba9997641f496ba4346db02f2b22bd16e018492f6ace90a44ba1990c58f2989aaa42ba2646970667358221220638ff72d94f7b1b593818735e41563c5ee4961708fea527520b18fffdffa439364736f6c634300080b0033496e697469616c697a61626c653a20636f6e747261637420697320616c726561
Deployed Bytecode
0x6080604052600436106102e75760003560e01c806371210a0d11610190578063c2306acb116100dc578063e4ed711811610095578063f0365efb1161006f578063f0365efb146108b4578063f2f4eb26146108ca578063f878996a146108f0578063f887ea401461091057600080fd5b8063e4ed71181461085f578063ee86e1aa1461087f578063ef253eb61461089f57600080fd5b8063c2306acb146107be578063c45a0155146107d4578063c59197e3146107f4578063c879657214610814578063d21220a714610829578063d5bf91e31461084957600080fd5b806394db059511610149578063a5c0fd0511610123578063a5c0fd0514610737578063a624198014610757578063a8aa1b3114610777578063ac8969511461079757600080fd5b806394db0595146106e0578063971e3c431461070a578063a21b927f1461071d57600080fd5b806371210a0d146105f65780638456cb59146106165780638a8090951461062b5780638fd57d3e14610640578063900cf0cf1461067b578063930f7ee81461069157600080fd5b8063443ec74d1161024f578063552033c4116102085780635c08bfc2116101e25780635c08bfc21461058a5780635c975abb146105aa5780635ee04d78146105bf5780636e6c9041146105e157600080fd5b8063552033c41461052b57806355a723ed1461054a5780635a5c90481461056a57600080fd5b8063443ec74d1461048a578063470ea1d4146104ac578063486f0673146104c15780634b4c489b146104d65780634ff0876a146104eb5780635392fd1c1461050157600080fd5b80632addf608116102a15780632addf608146103d257806330024dfe146103ff5780633bf8d6201461041f5780633f4ba83a1461043f57806340f1d6e01461045457806341213a171461047457600080fd5b80622b34f9146102f3578063037a354c146103335780630dfe16811461034857806311e8416c1461038557806316343da4146103a757806318bf3844146103bd57600080fd5b366102ee57005b600080fd5b3480156102ff57600080fd5b5061032061030e366004614444565b60009081526049602052604090205490565b6040519081526020015b60405180910390f35b34801561033f57600080fd5b50610320610930565b34801561035457600080fd5b5060335461036d9061010090046001600160a01b031681565b6040516001600160a01b03909116815260200161032a565b34801561039157600080fd5b506103a56103a0366004614444565b6109b1565b005b3480156103b357600080fd5b5061032061271081565b3480156103c957600080fd5b50610320603281565b3480156103de57600080fd5b506103206103ed366004614444565b6000908152603f602052604090205490565b34801561040b57600080fd5b506103a561041a366004614444565b610a28565b34801561042b57600080fd5b506103a561043a3660046144a2565b610aad565b34801561044b57600080fd5b506103a5610e83565b34801561046057600080fd5b5061032061046f366004614523565b610ff7565b34801561048057600080fd5b50610320604c5481565b34801561049657600080fd5b50610320600080516020614b0c83398151915281565b3480156104b857600080fd5b506103a561100a565b3480156104cd57600080fd5b506103a5611062565b3480156104e257600080fd5b506103a56110b7565b3480156104f757600080fd5b5061032060365481565b34801561050d57600080fd5b50604e5461051b9060ff1681565b604051901515815260200161032a565b34801561053757600080fd5b50610320676765c793fa10079d601b1b81565b34801561055657600080fd5b50610320610565366004614523565b611225565b34801561057657600080fd5b506103a5610585366004614540565b611260565b34801561059657600080fd5b506103a56105a5366004614444565b6112e5565b3480156105b657600080fd5b5061051b611386565b3480156105cb57600080fd5b50610320600080516020614aec83398151915281565b3480156105ed57600080fd5b506103a5611415565b34801561060257600080fd5b506103a5610611366004614444565b611599565b34801561062257600080fd5b506103a561165e565b34801561063757600080fd5b506103a56117d9565b34801561064c57600080fd5b5061066061065b366004614523565b61185b565b6040805193845260208401929092529082015260600161032a565b34801561068757600080fd5b5061032060355481565b34801561069d57600080fd5b506042546043546044546045546046546106b8949392919085565b604080519586526020860194909452928401919091526060830152608082015260a00161032a565b3480156106ec57600080fd5b506106f5611878565b6040805192835260208301919091520161032a565b6103a5610718366004614444565b6119bc565b34801561072957600080fd5b5060335461051b9060ff1681565b34801561074357600080fd5b506103a5610752366004614444565b611b5a565b34801561076357600080fd5b50610660610772366004614523565b611bc1565b34801561078357600080fd5b5060b45461036d906001600160a01b031681565b3480156107a357600080fd5b50603854603954603a54603b54603c546106b8949392919085565b3480156107ca57600080fd5b50610320604d5481565b3480156107e057600080fd5b5060b25461036d906001600160a01b031681565b34801561080057600080fd5b506103a561080f366004614444565b611bd1565b34801561082057600080fd5b506103a5611c72565b34801561083557600080fd5b5060345461036d906001600160a01b031681565b34801561085557600080fd5b5061032060375481565b34801561086b57600080fd5b5061032061087a366004614523565b611db1565b34801561088b57600080fd5b5061032061089a366004614523565b611dec565b3480156108ab57600080fd5b50610320611df9565b3480156108c057600080fd5b506103206103e881565b3480156108d657600080fd5b5060005461036d906201000090046001600160a01b031681565b3480156108fc57600080fd5b506103a561090b3660046145ce565b611e33565b34801561091c57600080fd5b5060b35461036d906001600160a01b031681565b6043546034546040516370a0823160e01b8152306004820152600092916001600160a01b0316906370a08231906024015b602060405180830381865afa15801561097e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a291906145f0565b6109ac919061461f565b905090565b6109b9611386565b156109df5760405162461bcd60e51b81526004016109d690614637565b60405180910390fd5b60026001541415610a025760405162461bcd60e51b81526004016109d690614657565b6002600155610a21603882600080516020614b0c833981519152612a5e565b5060018055565b610a3133612c17565b610a4d5760405162461bcd60e51b81526004016109d69061468e565b610a55611386565b610a715760405162461bcd60e51b81526004016109d6906146b6565b60368190556040518181527fbfdcfb557a8f4a07f749e7d744a90c02e13eb5af308b561c2f4f17e58069c836906020015b60405180910390a150565b60026001541415610ad05760405162461bcd60e51b81526004016109d690614657565b60026001556000546040805163093a953d60e21b81529051620100009092046001600160a01b0316916391d148549183916324ea54f4916004808201926020929091908290030181865afa158015610b2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5091906145f0565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa158015610b92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb691906146da565b610bf15760405162461bcd60e51b815260206004820152600c60248201526b2727aa2fa3aaa0a92224a0a760a11b60448201526064016109d6565b610bf9611386565b610c155760405162461bcd60e51b81526004016109d6906146b6565b828114610c555760405162461bcd60e51b815260206004820152600e60248201526d494e56414c49445f494e5055545360901b60448201526064016109d6565b60005b83811015610e4d576000838383818110610c7457610c746146fc565b90506020020135905060006001600160a01b0316868684818110610c9a57610c9a6146fc565b9050602002016020810190610caf9190614523565b6001600160a01b03161415610d5f578015610cca5780610ccc565b475b604051909150600090339083908381818185875af1925050503d8060008114610d11576040519150601f19603f3d011682016040523d82523d6000602084013e610d16565b606091505b5050905080610d595760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b60448201526064016109d6565b50610e3a565b8015610d6b5780610dfc565b858583818110610d7d57610d7d6146fc565b9050602002016020810190610d929190614523565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa158015610dd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dfc91906145f0565b9050610e3a3382888886818110610e1557610e156146fc565b9050602002016020810190610e2a9190614523565b6001600160a01b03169190612d02565b5080610e4581614712565b915050610c58565b5060405133907f8d133fdaa7b1c86c6a04057392e7e94c6610ac87bb5b138cf2ce8a3605da342b90600090a25050600180555050565b6000546040805163389ed26760e01b81529051620100009092046001600160a01b0316916391d1485491839163389ed267916004808201926020929091908290030181865afa158015610eda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efe91906145f0565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa158015610f40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6491906146da565b610f9d5760405162461bcd60e51b815260206004820152600a6024820152692727aa2fa820aaa9a2a960b11b60448201526064016109d6565b610fa5611386565b610fc15760405162461bcd60e51b81526004016109d6906146b6565b6000805460ff60b01b191681556040517fa45f47fdea8a1efdd9029a5691c7f759c32b7c698632b563573e155625d169339190a1565b6000611004603883612d6a565b92915050565b61101333612c17565b61102f5760405162461bcd60e51b81526004016109d69061468e565b611037611386565b6110535760405162461bcd60e51b81526004016109d6906146b6565b604e805460ff19166001179055565b61106b33612c17565b6110875760405162461bcd60e51b81526004016109d69061468e565b61108f611386565b6110ab5760405162461bcd60e51b81526004016109d6906146b6565b604e805460ff19169055565b600260015414156110da5760405162461bcd60e51b81526004016109d690614657565b60026001556000546040805163093a953d60e21b81529051620100009092046001600160a01b0316916391d148549183916324ea54f4916004808201926020929091908290030181865afa158015611136573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115a91906145f0565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa15801561119c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c091906146da565b6111fb5760405162461bcd60e51b815260206004820152600c60248201526b2727aa2fa3aaa0a92224a0a760a11b60448201526064016109d6565b611203611386565b61121f5760405162461bcd60e51b81526004016109d6906146b6565b60018055565b6001600160a01b0381166000908152604b60209081526040808320815180830190925280548252600101549181019190915261100490612e5c565b600061126c6001612e7c565b90508015611284576000805461ff0019166101001790555b6112948989898989898989612f09565b80156112da576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6112ee33612c17565b61130a5760405162461bcd60e51b81526004016109d69061468e565b600081116113515760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22faa27a5a2a718afa32627a7a960611b60448201526064016109d6565b604d8190556040518181527f028ed94f731ed283cb15743fe60b6ec898df578786d87ea55565a79590c6864390602001610aa2565b60008060029054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113fe91906146da565b806109ac575050600054600160b01b900460ff1690565b61141d611386565b1561143a5760405162461bcd60e51b81526004016109d690614637565b6002600154141561145d5760405162461bcd60e51b81526004016109d690614657565b6002600155600061147d6038600080516020614b0c833981519152612f52565b60335490915060ff161561157d57603354604051632e1a7d4d60e01b8152600481018390526101009091046001600160a01b031690632e1a7d4d90602401600060405180830381600087803b1580156114d557600080fd5b505af11580156114e9573d6000803e3d6000fd5b50506040516000925033915083908381818185875af1925050503d806000811461152f576040519150601f19603f3d011682016040523d82523d6000602084013e611534565b606091505b50509050806115775760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b60448201526064016109d6565b50610a21565b603354610a219061010090046001600160a01b03163383612d02565b604e5460ff166115df5760405162461bcd60e51b815260206004820152601160248201527011115413d4d25514d7d11254d050931151607a1b60448201526064016109d6565b6115e7611386565b156116045760405162461bcd60e51b81526004016109d690614637565b600260015414156116275760405162461bcd60e51b81526004016109d690614657565b6002600155603454611644906001600160a01b031633308461308f565b610a21604282600080516020614aec8339815191526130cd565b6000546040805163389ed26760e01b81529051620100009092046001600160a01b0316916391d1485491839163389ed267916004808201926020929091908290030181865afa1580156116b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d991906145f0565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa15801561171b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061173f91906146da565b6117785760405162461bcd60e51b815260206004820152600a6024820152692727aa2fa820aaa9a2a960b11b60448201526064016109d6565b611780611386565b1561179d5760405162461bcd60e51b81526004016109d690614637565b6000805460ff60b01b1916600160b01b1781556040517f9e87fac88ff661f02d44f95383c817fece4bce600a3dab7a54406878b965e7529190a1565b6117e1611386565b156117fe5760405162461bcd60e51b81526004016109d690614637565b600260015414156118215760405162461bcd60e51b81526004016109d690614657565b600260015560006118416042600080516020614aec833981519152612f52565b603454909150610a21906001600160a01b03163383612d02565b600080600061186b604285613186565b9250925092509193909250565b603a54603854603c546033546040516370a0823160e01b815230600482015260009485949093909290916101009091046001600160a01b0316906370a0823190602401602060405180830381865afa1580156118d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118fc91906145f0565b611906919061472d565b611910919061472d565b61191a919061472d565b6044546042546046546034546040516370a0823160e01b81523060048201529496509293919290916001600160a01b03909116906370a0823190602401602060405180830381865afa158015611974573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199891906145f0565b6119a2919061472d565b6119ac919061472d565b6119b6919061472d565b90509091565b604e5460ff16611a025760405162461bcd60e51b815260206004820152601160248201527011115413d4d25514d7d11254d050931151607a1b60448201526064016109d6565b611a0a611386565b15611a275760405162461bcd60e51b81526004016109d690614637565b60026001541415611a4a5760405162461bcd60e51b81526004016109d690614657565b600260015560335460ff1615611ae257603360019054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611aaa57600080fd5b505af1158015611abe573d6000803e3d6000fd5b5050505050611add603834600080516020614b0c8339815191526130cd565b610a21565b3415611b235760405162461bcd60e51b815260206004820152601060248201526f1393d517d3905512559157d59055531560821b60448201526064016109d6565b603354611b409061010090046001600160a01b031633308461308f565b610a21603882600080516020614b0c8339815191526130cd565b611b62611386565b15611b7f5760405162461bcd60e51b81526004016109d690614637565b60026001541415611ba25760405162461bcd60e51b81526004016109d690614657565b6002600155610a21604282600080516020614aec833981519152612a5e565b600080600061186b603885613186565b611bda33612c17565b611bf65760405162461bcd60e51b81526004016109d69061468e565b60008111611c3d5760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22faa27a5a2a7182fa32627a7a960611b60448201526064016109d6565b604c8190556040518181527fedc83a6572b1f179b02829c85e794c5f926768aa8450ddd3b9dbfc55b09f9f3c90602001610aa2565b600080611c7d611878565b90925090508115611d1a57611d1a600060029054906101000a90046001600160a01b03166001600160a01b031663017e7e586040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d029190614744565b60335461010090046001600160a01b03169084612d02565b8015611dad57611dad600060029054906101000a90046001600160a01b03166001600160a01b031663017e7e586040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d9a9190614744565b6034546001600160a01b03169083612d02565b5050565b6001600160a01b0381166000908152604160209081526040808320815180830190925280548252600101549181019190915261100490612e5c565b6000611004604283612d6a565b6039546033546040516370a0823160e01b81523060048201526000929161010090046001600160a01b0316906370a0823190602401610961565b60405163014c483360e71b81523360048201819052906000908190309063a624198090602401606060405180830381865afa158015611e76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e9a9190614761565b506040516347eabe9f60e11b81526001600160a01b0386166004820152919350915060009081903090638fd57d3e90602401606060405180830381865afa158015611ee9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0d9190614761565b50909250905060008183611f21868861461f565b611f2b919061461f565b611f35919061461f565b1180611f455750611f4585612c17565b611f915760405162461bcd60e51b815260206004820152601d60248201527f4e4f545f5041525449434950414e545f4f525f5354524154454749535400000060448201526064016109d6565b611f99611386565b15611fb65760405162461bcd60e51b81526004016109d690614637565b603654603754611fc6904261472d565b101561200b5760405162461bcd60e51b8152602060048201526014602482015273115413d0d217d1155490551253d397d55393515560621b60448201526064016109d6565b6000612017603861332e565b90506000612025604261332e565b90506120606040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6120996040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6035546120a461338c565b835283526127106120b660328261472d565b6120c0908e61478f565b6120ca91906147ae565b835110156120ea5760405162461bcd60e51b81526004016109d6906147d0565b6127106120f860328261461f565b612102908e61478f565b61210c91906147ae565b8351111561212c5760405162461bcd60e51b81526004016109d6906147d0565b61271061213a60328261472d565b612144908d61478f565b61214e91906147ae565b8251101561216e5760405162461bcd60e51b81526004016109d6906147d0565b61271061217c60328261461f565b612186908d61478f565b61219091906147ae565b825111156121b05760405162461bcd60e51b81526004016109d6906147d0565b6121b86134b8565b6020848101919091528401526121cc61338c565b83528352845160208401516121e1919061461f565b6040840152835160208301516121f7919061461f565b6040830152604c54602086015160009161271091612215919061478f565b61221f91906147ae565b865161222b919061461f565b90506000612710604d548760200151612244919061478f565b61224e91906147ae565b865161225a919061461f565b9050600086602001518760000151612272919061461f565b9050856040015183111561237957600080876040015185612293919061472d565b88519091508111156122ab57866040015191506122bd565b865188516122ba9183916136a8565b91505b60408701516000906122cf848661461f565b106123035760408801516122e3868561461f565b116122ee5782612313565b8488604001516122fe919061472d565b612313565b838860400151612313919061472d565b603454603354919250600091829161233e916001600160a01b0391821691610100909104168561372e565b91509150818b604001818151612354919061461f565b90525060408a01805182919061236b90839061472d565b90525061250e945050505050565b808560400151106123f657603454603354604087015160009283926123be926001600160a01b0392831692610100909204909116906123b990879061472d565b61372e565b9150915081886040018181516123d4919061461f565b9052506040870180518291906123eb90839061472d565b90525061250e915050565b600080866040015183612409919061472d565b875190915081111561241e5787519150612430565b8751875161242d9183916136a8565b91505b604088015161243f838761461f565b10156124a457603354603454600091829161246c916001600160a01b03610100909104811691168661372e565b91509150808a604001818151612482919061472d565b90525060408901805183919061249990839061461f565b90525061250b915050565b60335460345460408a015160009283926124d8926101009092046001600160a01b03908116929116906123b9908b9061472d565b91509150808a6040018181516124ee919061472d565b90525060408901805183919061250590839061461f565b90525050505b50505b6020880151885161251f919061461f565b606087015260208701518751612535919061461f565b6060808701919091528601516040870151111561267757600060029054906101000a90046001600160a01b03166001600160a01b031663bc063e1a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561259f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125c391906145f0565b600060029054906101000a90046001600160a01b03166001600160a01b031663b0e21e8a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612616573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263a91906145f0565b8760600151886040015161264e919061472d565b612658919061478f565b61266291906147ae565b86604001818151612673919061472d565b9052505b8460600151856040015111156127b257600060029054906101000a90046001600160a01b03166001600160a01b031663bc063e1a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126fe91906145f0565b600060029054906101000a90046001600160a01b03166001600160a01b031663b0e21e8a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612751573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061277591906145f0565b86606001518760400151612789919061472d565b612793919061478f565b61279d91906147ae565b856040018181516127ae919061472d565b9052505b60008660600151116127e157603f60006127cd60018761472d565b81526020019081526020016000205461281d565b60608601516040870151603f60006127fa60018961472d565b815260200190815260200160002054612813919061478f565b61281d91906147ae565b608087018181526000868152603f6020526040902091909155516060890151676765c793fa10079d601b1b916128529161478f565b61285c91906147ae565b60a08701819052603c805460009061287590849061461f565b909155505060608501516128a6576049600061289260018761472d565b8152602001908152602001600020546128e2565b60608501516040860151604960006128bf60018961472d565b8152602001908152602001600020546128d8919061478f565b6128e291906147ae565b60808601818152600086815260496020526040902091909155516060880151676765c793fa10079d601b1b916129179161478f565b61292191906147ae565b60a086018190526046805460009061293a90849061461f565b909155505060a08601516040808a015190880151612958919061461f565b612962919061472d565b8660400181815250508460a0015187604001518660400151612984919061461f565b61298e919061472d565b60408087018290526000603a819055603b81905560448190556045558701516129b69161380a565b604355603981905560408701516129cd919061472d565b60385560435460408601516129e2919061472d565b60425560358054600191906000906129fb90849061461f565b909155505042603781905560355460405191825233917f9427bfed592ae6253fdc90424d4a4f3130787bd0bfa959312914f6eaf422e5799060200160405180910390a3505050505050505050505050505050565b6001600160a01b03163b151590565b60008211612a9c5760405162461bcd60e51b815260206004820152600b60248201526a16915493d7d05353d5539560aa1b60448201526064016109d6565b6035546000612aac858383613845565b336000908152600987016020526040902060018101549192509015801590612ad45750805483115b15612b3f57805460009081526007870160205260409020546001820154676765c793fa10079d601b1b91612b079161478f565b612b1191906147ae565b33600090815260068801602052604081208054909190612b3290849061461f565b9091555050600060018201555b84821015612b865760405162461bcd60e51b8152602060048201526014602482015273494e53554646494349454e545f42414c414e434560601b60448201526064016109d6565b336000908152600587016020526040902085830390556001810154612bab908661461f565b60018201558054831115612bbd578281555b84866003016000828254612bd1919061461f565b90915550506040518581528390339086907f52266201bc2fd6b76ef485c613769527c5ea4face1c63f7f9e806735b31d48fc9060200160405180910390a4505050505050565b60008054604080516328de28c960e21b81529051620100009092046001600160a01b0316916391d1485491839163a378a324916004808201926020929091908290030181865afa158015612c6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9391906145f0565b6040516001600160e01b031960e084901b16815260048101919091526001600160a01b0385166024820152604401602060405180830381865afa158015612cde573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100491906146da565b6040516001600160a01b038316602482015260448101829052612d6590849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526138e9565b505050565b6001600160a01b0381166000908152600583016020908152604080832054600886018352818420825180840190935280548084526001909101549383019390935260355490921015612dfd578051600090815260078601602090815260409091205490820151612de690676765c793fa10079d601b1b9061478f565b612df091906147ae565b612dfa908361461f565b91505b6001600160a01b038416600090815260098601602090815260409182902082518084019093528054808452600190910154918301919091526035541415612e50576020810151612e4d908461461f565b92505b5090949350505050565b565b600060355482600001511015612e7457506000919050565b506020015190565b60008054610100900460ff1615612ec3578160ff166001148015612e9f5750303b155b612ebb5760405162461bcd60e51b81526004016109d690614807565b506000919050565b60005460ff808416911610612eea5760405162461bcd60e51b81526004016109d690614807565b506000805460ff191660ff92909216919091179055600190565b919050565b600054610100900460ff16612f305760405162461bcd60e51b81526004016109d690614855565b612f3e8888888888886139bb565b612f488282613a08565b5050505050505050565b33600090815260098301602090815260408083206035548154600688019094529184205490929082821015612fe65760018401548015612fe457336000908152600989016020908152604080832083815560010183905585835260078b01909152902054676765c793fa10079d601b1b90612fcd908361478f565b612fd791906147ae565b612fe1908361461f565b91505b505b600081116130215760405162461bcd60e51b81526020600482015260086024820152674e4f5f434c41494d60c01b60448201526064016109d6565b336000908152600688016020526040812081905560048801805483929061304990849061472d565b9091555050604051818152339087907fe269963e621a3253e62b91db52a65eed542266d831178ebc68ad61d54211aca69060200160405180910390a39695505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526130c79085906323b872dd60e01b90608401612d2e565b50505050565b6000821161310b5760405162461bcd60e51b815260206004820152600b60248201526a16915493d7d05353d5539560aa1b60448201526064016109d6565b603554613119848285613845565b33600090815260058601602052604081209190915560028501805485929061314290849061461f565b90915550506040518381528190339084907f1e6c0ff7d7fa524ca8d88cabca077adebbf64f902faa7f4b97aa5a1da2620faf9060200160405180910390a450505050565b6035546001600160a01b038216600090815260058401602090815260408083205460088701835281842082518084019093528054808452600190910154938301849052939485948594919391908115613226578481101561322257600081815260078b016020526040902054613207676765c793fa10079d601b1b8461478f565b61321191906147ae565b61321b908561461f565b9350613226565b8196505b6001600160a01b038916600081815260098c0160209081526040808320815180830183528154815260019091015481840190815294845260068f0190925290912054915191975090156132d95780518611156132c7578051600090815260078c01602090815260409091205490820151676765c793fa10079d601b1b916132ac9161478f565b6132b691906147ae565b6132c0908861461f565b96506132d9565b60208101516132d6908661461f565b94505b600060078c01816132eb60018a61472d565b8152602001908152602001600020549050676765c793fa10079d601b1b8187613314919061478f565b61331e91906147ae565b9950505050505050509250925092565b6133596040518060800160405280600081526020016000815260200160008152602001600081525090565b50604080516080810182528254815260018301546020820152600283015491810191909152600390910154606082015290565b60008060008060b460009054906101000a90046001600160a01b03166001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa1580156133e5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061340991906148b7565b5060335460b45460408051630dfe168160e01b815290516001600160701b0395861697509390941694506001600160a01b03610100909204821693911691630dfe1681916004808201926020929091908290030181865afa158015613472573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134969190614744565b6001600160a01b0316146134ab5780826134ae565b81815b9350935050509091565b6033546040516370a0823160e01b81523060048201526000918291829161010090046001600160a01b0316906370a0823190602401602060405180830381865afa15801561350a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061352e91906145f0565b6034546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561357c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135a091906145f0565b90506135aa613b35565b6033546040516370a0823160e01b8152306004820152839161010090046001600160a01b0316906370a0823190602401602060405180830381865afa1580156135f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061361b91906145f0565b613625919061472d565b6034546040516370a0823160e01b815230600482015291955082916001600160a01b03909116906370a0823190602401602060405180830381865afa158015613672573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061369691906145f0565b6136a0919061472d565b925050509091565b60b3546040516385f8c25960e01b81526004810185905260248101849052604481018390526000916001600160a01b0316906385f8c25990606401602060405180830381865afa158015613700573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061372491906145f0565b90505b9392505050565b6000808261374157506000905080613802565b60b35461375b906001600160a01b03878116911685613c6b565b60b3546001600160a01b03166338ed17398460006137798989613d1d565b30426040518663ffffffff1660e01b815260040161379b959493929190614907565b6000604051808303816000875af11580156137ba573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526137e2919081019061498e565b6001815181106137f4576137f46146fc565b602002602001015191508290505b935093915050565b6000806103e884108061381e57506103e883105b1561382e5750600090508061383e565b6138388484613dab565b90925090505b9250929050565b336000908152600884016020908152604080832060058701909252822054600182015480158015906138775750825486115b156138c15782546000908152600788016020526040902054806138a5676765c793fa10079d601b1b8461478f565b6138af91906147ae565b6138b9908461461f565b925060009150505b84156138d7576138d1858261461f565b86845590505b60019092019190915590509392505050565b600061393e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613ef09092919063ffffffff16565b805190915015612d65578080602001905181019061395c91906146da565b612d655760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109d6565b600054610100900460ff166139e25760405162461bcd60e51b81526004016109d690614855565b6139eb86613eff565b6139f3613f32565b613a008585858585613f61565b505050505050565b600054610100900460ff16613a2f5760405162461bcd60e51b81526004016109d690614855565b60335460345460405163e6a4390560e01b81526101009092046001600160a01b039081166004840152908116602483015283169063e6a4390590604401602060405180830381865afa158015613a89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613aad9190614744565b60b480546001600160a01b0319166001600160a01b03929092169182179055613b075760405162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b60448201526064016109d6565b60b280546001600160a01b039384166001600160a01b03199182161790915560b38054929093169116179055565b60b4546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015613b7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ba291906145f0565b905080613bac5750565b60b35460b454613bc9916001600160a01b03918216911683613c6b565b60b354603354603454604051635d5155ef60e11b81526001600160a01b036101009093048316600482015290821660248201526044810184905260006064820181905260848201523060a48201524260c482015291169063baa2abde9060e40160408051808303816000875af1158015613c47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d659190614a4c565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015613cbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ce091906145f0565b613cea919061461f565b6040516001600160a01b0385166024820152604481018290529091506130c790859063095ea7b360e01b90606401612d2e565b60408051600280825260608083018452926020830190803683370190505090508281600081518110613d5157613d516146fc565b60200260200101906001600160a01b031690816001600160a01b0316815250508181600181518110613d8557613d856146fc565b60200260200101906001600160a01b031690816001600160a01b03168152505092915050565b60b3546033546000918291613dd2916001600160a01b036101009092048216911686613c6b565b60b354603454613def916001600160a01b03918216911685613c6b565b60b35460335460345460405162e8e33760e81b81526001600160a01b03610100909304831660048201529082166024820152604481018790526064810186905260006084820181905260a48201523060c48201524260e482015291169063e8e3370090610104016060604051808303816000875af1158015613e75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e999190614761565b50909250905081841115613eca5760b354603354613eca916001600160a01b0361010090920482169116600061414d565b8083111561383e5760b35460345461383e916001600160a01b039182169116600061414d565b60606137248484600085614262565b600054610100900460ff16613f265760405162461bcd60e51b81526004016109d690614855565b613f2f81614393565b50565b600054610100900460ff16613f595760405162461bcd60e51b81526004016109d690614855565b612e5a6143e4565b600054610100900460ff16613f885760405162461bcd60e51b81526004016109d690614855565b60008211613fcf5760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22faa27a5a2a7182fa32627a7a960611b60448201526064016109d6565b600081116140165760405162461bcd60e51b815260206004820152601460248201527324a72b20a624a22faa27a5a2a718afa32627a7a960611b60448201526064016109d6565b600060029054906101000a90046001600160a01b03166001600160a01b031663eb6d3a116040518163ffffffff1660e01b8152600401602060405180830381865afa158015614069573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061408d9190614744565b603380546001600160a81b0319166001600160a01b03928316968316968714610100600160a81b031916176101009690960295909517909455603480546001600160a01b031916939094169290921790925560008052676765c793fa10079d601b1b7fe9090a6e551363283803e59daf1c144cd0ac55c420ac8519a53d83ef396a73b381905560496020527f9a0ca60aea446f0de2b73532837f00f56d3ae047e136f7838a520755c00b6e76556001603555603692909255604c55604d55565b8015806141c75750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa1580156141a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141c591906145f0565b155b6142325760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016109d6565b6040516001600160a01b038316602482015260448101829052612d6590849063095ea7b360e01b90606401612d2e565b6060824710156142c35760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109d6565b6001600160a01b0385163b61431a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109d6565b600080866001600160a01b031685876040516143369190614a9c565b60006040518083038185875af1925050503d8060008114614373576040519150601f19603f3d011682016040523d82523d6000602084013e614378565b606091505b509150915061438882828661440b565b979650505050505050565b600054610100900460ff166143ba5760405162461bcd60e51b81526004016109d690614855565b600080546001600160a01b03909216620100000262010000600160b01b0319909216919091179055565b600054610100900460ff1661121f5760405162461bcd60e51b81526004016109d690614855565b6060831561441a575081613727565b82511561442a5782518084602001fd5b8160405162461bcd60e51b81526004016109d69190614ab8565b60006020828403121561445657600080fd5b5035919050565b60008083601f84011261446f57600080fd5b50813567ffffffffffffffff81111561448757600080fd5b6020830191508360208260051b850101111561383e57600080fd5b600080600080604085870312156144b857600080fd5b843567ffffffffffffffff808211156144d057600080fd5b6144dc8883890161445d565b909650945060208701359150808211156144f557600080fd5b506145028782880161445d565b95989497509550505050565b6001600160a01b0381168114613f2f57600080fd5b60006020828403121561453557600080fd5b81356137278161450e565b600080600080600080600080610100898b03121561455d57600080fd5b88356145688161450e565b975060208901359650604089013561457f8161450e565b9550606089013561458f8161450e565b94506080890135935060a0890135925060c08901356145ad8161450e565b915060e08901356145bd8161450e565b809150509295985092959890939650565b600080604083850312156145e157600080fd5b50508035926020909101359150565b60006020828403121561460257600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000821982111561463257614632614609565b500190565b60208082526006908201526514105554d15160d21b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600e908201526d1393d517d4d51490551151d254d560921b604082015260600190565b6020808252600a90820152691393d517d4105554d15160b21b604082015260600190565b6000602082840312156146ec57600080fd5b8151801515811461372757600080fd5b634e487b7160e01b600052603260045260246000fd5b600060001982141561472657614726614609565b5060010190565b60008282101561473f5761473f614609565b500390565b60006020828403121561475657600080fd5b81516137278161450e565b60008060006060848603121561477657600080fd5b8351925060208401519150604084015190509250925092565b60008160001904831182151516156147a9576147a9614609565b500290565b6000826147cb57634e487b7160e01b600052601260045260246000fd5b500490565b60208082526018908201527f554e45585045435445445f504f4f4c5f42414c414e4345530000000000000000604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b80516001600160701b0381168114612f0457600080fd5b6000806000606084860312156148cc57600080fd5b6148d5846148a0565b92506148e3602085016148a0565b9150604084015163ffffffff811681146148fc57600080fd5b809150509250925092565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156149575784516001600160a01b031683529383019391830191600101614932565b50506001600160a01b03969096166060850152505050608001529392505050565b634e487b7160e01b600052604160045260246000fd5b600060208083850312156149a157600080fd5b825167ffffffffffffffff808211156149b957600080fd5b818501915085601f8301126149cd57600080fd5b8151818111156149df576149df614978565b8060051b604051601f19603f83011681018181108582111715614a0457614a04614978565b604052918252848201925083810185019188831115614a2257600080fd5b938501935b82851015614a4057845184529385019392850192614a27565b98975050505050505050565b60008060408385031215614a5f57600080fd5b505080516020909101519092909150565b60005b83811015614a8b578181015183820152602001614a73565b838111156130c75750506000910152565b60008251614aae818460208701614a70565b9190910192915050565b6020815260008251806020840152614ad7816040850160208701614a70565b601f01601f1916919091016040019291505056fe29904dc0060dfbfbdb4804f541ee5b0af0fb57e8edc680ea7b5d072a031ba9997641f496ba4346db02f2b22bd16e018492f6ace90a44ba1990c58f2989aaa42ba2646970667358221220638ff72d94f7b1b593818735e41563c5ee4961708fea527520b18fffdffa439364736f6c634300080b0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 27 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.