Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
Vault
Compiler Version
v0.8.16+commit.07a7930e
Optimization Enabled:
Yes with 2000000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; import {ERC4626Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; import {IERC20MetadataUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import {MathUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol"; import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {SafeTransferLib} from "solmate/src/utils/SafeTransferLib.sol"; import {FixedPointMathLib} from "solmate/src/utils/FixedPointMathLib.sol"; import {AffineVault} from "src/vaults/AffineVault.sol"; import {DetailedShare} from "src/utils/Detailed.sol"; contract Vault is AffineVault, ERC4626Upgradeable, PausableUpgradeable, DetailedShare { using SafeTransferLib for ERC20; using MathUpgradeable for uint256; function initialize(address _governance, address vaultAsset, string memory _name, string memory _symbol) external initializer { AffineVault.baseInitialize(_governance, ERC20(vaultAsset)); __ERC20_init(_name, _symbol); __ERC4626_init(IERC20MetadataUpgradeable(vaultAsset)); _grantRole(GUARDIAN_ROLE, governance); } function asset() public view override(AffineVault, ERC4626Upgradeable) returns (address) { return AffineVault.asset(); } function decimals() public view virtual override(ERC20Upgradeable, IERC20MetadataUpgradeable) returns (uint8) { return 18; } /// @notice See {IERC4626-totalAssets} function totalAssets() public view virtual override returns (uint256) { return vaultTVL() - lockedProfit(); } bytes32 public constant GUARDIAN_ROLE = keccak256("GUARDIAN"); /// @notice Pause the contract function pause() external onlyRole(GUARDIAN_ROLE) { _pause(); } /// @notice Unpause the contract function unpause() external onlyRole(GUARDIAN_ROLE) { _unpause(); } function maxDeposit(address) public view virtual override returns (uint256) { return type(uint256).max; } /** * @dev See {IERC4262-deposit}. */ function deposit(uint256 assets, address receiver) public virtual override whenNotPaused returns (uint256) { uint256 shares = previewDeposit(assets); _deposit(_msgSender(), receiver, assets, shares); return shares; } /** * @dev See {IERC4262-mint}. */ function mint(uint256 shares, address receiver) public virtual override whenNotPaused returns (uint256) { uint256 assets = previewMint(shares); _deposit(_msgSender(), receiver, assets, shares); return assets; } /** * @dev See {IERC4262-withdraw}. */ function withdraw(uint256 assets, address receiver, address owner) public virtual override whenNotPaused returns (uint256) { uint256 shares = _convertToShares(assets, MathUpgradeable.Rounding.Up); _withdraw(_msgSender(), receiver, owner, assets, shares); return shares; } /** * @dev See {IERC4262-redeem}. */ function redeem(uint256 shares, address receiver, address owner) public virtual override whenNotPaused returns (uint256) { uint256 assets = _convertToAssets(shares, MathUpgradeable.Rounding.Down); _withdraw(_msgSender(), receiver, owner, assets, shares); return assets; } function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual override { require(shares > 0, "Vault: zero shares"); _mint(receiver, shares); _asset.safeTransferFrom(caller, address(this), assets); emit Deposit(caller, receiver, assets, shares); } function _withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares) internal virtual override { _liquidate(assets); // Slippage during liquidation means we might get less than `assets` amount of `_asset` assets = Math.min(_asset.balanceOf(address(this)), assets); uint256 assetsFee = _getWithdrawalFee(assets); uint256 assetsToUser = assets - assetsFee; // Burn shares and give user equivalent value in `_asset` (minus withdrawal fees) if (caller != owner) _spendAllowance(owner, caller, shares); _burn(owner, shares); emit Withdraw(caller, receiver, owner, assets, shares); _asset.safeTransfer(receiver, assetsToUser); _asset.safeTransfer(governance, assetsFee); } /*////////////////////////////////////////////////////////////// EXCHANGE RATES //////////////////////////////////////////////////////////////*/ /** * @dev See {IERC4262-previewWithdraw}. */ function previewWithdraw(uint256 assetsToUser) public view virtual override returns (uint256) { // assets * ((1 - feeBps) / 1e4) = assetsToUser // assets * ((1e4 - feeBps) / 1e4) = assetsToUser uint256 assets = assetsToUser.mulDiv(MAX_BPS, MAX_BPS - withdrawalFee, MathUpgradeable.Rounding.Up); return _convertToShares(assets, MathUpgradeable.Rounding.Up); } /** * @dev See {IERC4262-previewRedeem}. */ function previewRedeem(uint256 shares) public view virtual override returns (uint256) { uint256 assets = _convertToAssets(shares, MathUpgradeable.Rounding.Down); return assets - _getWithdrawalFee(assets); } function initialSharesPerAsset() public pure virtual returns (uint256) { // E.g. for USDC, we want the initial price of a share to be $100. // For an initial price of 1 USDC / share we would have 1e6 * 1e10 / 1 = 1e16 shares. // This a 1:0.01 ratio of assets:shares if this vault has 18 decimals return 1e10; } function _convertToShares(uint256 assets, MathUpgradeable.Rounding rounding) internal view virtual override returns (uint256 shares) { uint256 _totalSupply = totalSupply() + initialSharesPerAsset(); uint256 _totalAssets = totalAssets() + 1; return assets.mulDiv(_totalSupply, _totalAssets, rounding); } function _convertToAssets(uint256 shares, MathUpgradeable.Rounding rounding) internal view virtual override returns (uint256 assets) { uint256 _totalSupply = totalSupply() + initialSharesPerAsset(); uint256 _totalAssets = totalAssets() + 1; return shares.mulDiv(_totalAssets, _totalSupply, rounding); } /*////////////////////////////////////////////////////////////// FEES //////////////////////////////////////////////////////////////*/ /// @notice Fee charged to vault over a year, number is in bps uint256 public managementFee; /// @notice Fee charged on redemption of shares, number is in bps uint256 public withdrawalFee; event ManagementFeeSet(uint256 oldFee, uint256 newFee); event WithdrawalFeeSet(uint256 oldFee, uint256 newFee); function setManagementFee(uint256 feeBps) external onlyGovernance { emit ManagementFeeSet({oldFee: managementFee, newFee: feeBps}); managementFee = feeBps; } function setWithdrawalFee(uint256 feeBps) external onlyGovernance { emit WithdrawalFeeSet({oldFee: withdrawalFee, newFee: feeBps}); withdrawalFee = feeBps; } uint256 constant SECS_PER_YEAR = 365 days; function _assessFees() internal virtual override { // duration / SECS_PER_YEAR * feebps / MAX_BPS * totalSupply uint256 duration = block.timestamp - lastHarvest; uint256 feesBps = (duration * managementFee) / SECS_PER_YEAR; uint256 numSharesToMint = (feesBps * totalSupply()) / MAX_BPS; if (numSharesToMint == 0) { return; } _mint(governance, numSharesToMint); } /// @dev Return amount of `asset` to be given to user after applying withdrawal fee function _getWithdrawalFee(uint256 assets) internal view virtual returns (uint256) { return assets.mulDiv(withdrawalFee, MAX_BPS, MathUpgradeable.Rounding.Up); } /*////////////////////////////////////////////////////////////// CAPITAL MANAGEMENT //////////////////////////////////////////////////////////////*/ /** * @notice Deposit idle assets into strategies. */ function depositIntoStrategies(uint256 amount) external whenNotPaused onlyRole(HARVESTER) { // Deposit entire balance of `_asset` into strategies _depositIntoStrategies(amount); } /*////////////////////////////////////////////////////////////// DETAILED PRICE INFO //////////////////////////////////////////////////////////////*/ function detailedTVL() external view override returns (Number memory tvl) { tvl = Number({num: totalAssets(), decimals: _asset.decimals()}); } function detailedPrice() external view override returns (Number memory price) { price = Number({num: convertToAssets(10 ** decimals()), decimals: _asset.decimals()}); } function detailedTotalSupply() external view override returns (Number memory supply) { supply = Number({num: totalSupply(), decimals: decimals()}); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`. // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`. // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a // good first aproximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1; uint256 x = a; if (x >> 128 > 0) { x >>= 128; result <<= 64; } if (x >> 64 > 0) { x >>= 64; result <<= 32; } if (x >> 32 > 0) { x >>= 32; result <<= 16; } if (x >> 16 > 0) { x >>= 16; result <<= 8; } if (x >> 8 > 0) { x >>= 8; result <<= 4; } if (x >> 4 > 0) { x >>= 4; result <<= 2; } if (x >> 2 > 0) { result <<= 1; } // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { uint256 result = sqrt(a); if (rounding == Rounding.Up && result * result < a) { result += 1; } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// 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.7.0) (interfaces/IERC4626.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20Upgradeable.sol"; import "../token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; /** * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. * * _Available since v4.7._ */ interface IERC4626Upgradeable is IERC20Upgradeable, IERC20MetadataUpgradeable { event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares); event Withdraw( address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /** * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing. * * - MUST be an ERC-20 token contract. * - MUST NOT revert. */ function asset() external view returns (address assetTokenAddress); /** * @dev Returns the total amount of the underlying asset that is “managed” by Vault. * * - SHOULD include any compounding that occurs from yield. * - MUST be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT revert. */ function totalAssets() external view returns (uint256 totalManagedAssets); /** * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToShares(uint256 assets) external view returns (uint256 shares); /** * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToAssets(uint256 shares) external view returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, * through a deposit call. * * - MUST return a limited value if receiver is subject to some deposit limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited. * - MUST NOT revert. */ function maxDeposit(address receiver) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given * current on-chain conditions. * * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called * in the same transaction. * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the * deposit would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewDeposit(uint256 assets) external view returns (uint256 shares); /** * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * deposit execution, and are accounted for during deposit. * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function deposit(uint256 assets, address receiver) external returns (uint256 shares); /** * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. * - MUST return a limited value if receiver is subject to some mint limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. * - MUST NOT revert. */ function maxMint(address receiver) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given * current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the * same transaction. * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint * would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by minting. */ function previewMint(uint256 shares) external view returns (uint256 assets); /** * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint * execution, and are accounted for during mint. * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function mint(uint256 shares, address receiver) external returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the * Vault, through a withdraw call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST NOT revert. */ function maxWithdraw(address owner) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, * given current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if * called * in the same transaction. * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though * the withdrawal would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewWithdraw(uint256 assets) external view returns (uint256 shares); /** * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * withdraw execution, and are accounted for during withdraw. * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function withdraw( uint256 assets, address receiver, address owner ) external returns (uint256 shares); /** * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, * through a redeem call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock. * - MUST NOT revert. */ function maxRedeem(address owner) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, * given current on-chain conditions. * * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the * same transaction. * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the * redemption would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by redeeming. */ function previewRedeem(uint256 shares) external view returns (uint256 assets); /** * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * redeem execution, and are accounted for during redeem. * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function redeem( uint256 shares, address receiver, address owner ) external returns (uint256 assets); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original * initialization step. This is essential to configure modules that are added through upgrades and that require * initialization. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @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[45] 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 (last updated v4.7.0) (token/ERC20/extensions/ERC4626.sol) pragma solidity ^0.8.0; import "../ERC20Upgradeable.sol"; import "../utils/SafeERC20Upgradeable.sol"; import "../../../interfaces/IERC4626Upgradeable.sol"; import "../../../utils/math/MathUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the ERC4626 "Tokenized Vault Standard" as defined in * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626]. * * This extension allows the minting and burning of "shares" (represented using the ERC20 inheritance) in exchange for * underlying "assets" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends * the ERC20 standard. Any additional extensions included along it would affect the "shares" token represented by this * contract and not the "assets" token which is an independent contract. * * CAUTION: Deposits and withdrawals may incur unexpected slippage. Users should verify that the amount received of * shares or assets is as expected. EOAs should operate through a wrapper that performs these checks such as * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router]. * * _Available since v4.7._ */ abstract contract ERC4626Upgradeable is Initializable, ERC20Upgradeable, IERC4626Upgradeable { using MathUpgradeable for uint256; IERC20MetadataUpgradeable private _asset; /** * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777). */ function __ERC4626_init(IERC20MetadataUpgradeable asset_) internal onlyInitializing { __ERC4626_init_unchained(asset_); } function __ERC4626_init_unchained(IERC20MetadataUpgradeable asset_) internal onlyInitializing { _asset = asset_; } /** @dev See {IERC4262-asset}. */ function asset() public view virtual override returns (address) { return address(_asset); } /** @dev See {IERC4262-totalAssets}. */ function totalAssets() public view virtual override returns (uint256) { return _asset.balanceOf(address(this)); } /** @dev See {IERC4262-convertToShares}. */ function convertToShares(uint256 assets) public view virtual override returns (uint256 shares) { return _convertToShares(assets, MathUpgradeable.Rounding.Down); } /** @dev See {IERC4262-convertToAssets}. */ function convertToAssets(uint256 shares) public view virtual override returns (uint256 assets) { return _convertToAssets(shares, MathUpgradeable.Rounding.Down); } /** @dev See {IERC4262-maxDeposit}. */ function maxDeposit(address) public view virtual override returns (uint256) { return _isVaultCollateralized() ? type(uint256).max : 0; } /** @dev See {IERC4262-maxMint}. */ function maxMint(address) public view virtual override returns (uint256) { return type(uint256).max; } /** @dev See {IERC4262-maxWithdraw}. */ function maxWithdraw(address owner) public view virtual override returns (uint256) { return _convertToAssets(balanceOf(owner), MathUpgradeable.Rounding.Down); } /** @dev See {IERC4262-maxRedeem}. */ function maxRedeem(address owner) public view virtual override returns (uint256) { return balanceOf(owner); } /** @dev See {IERC4262-previewDeposit}. */ function previewDeposit(uint256 assets) public view virtual override returns (uint256) { return _convertToShares(assets, MathUpgradeable.Rounding.Down); } /** @dev See {IERC4262-previewMint}. */ function previewMint(uint256 shares) public view virtual override returns (uint256) { return _convertToAssets(shares, MathUpgradeable.Rounding.Up); } /** @dev See {IERC4262-previewWithdraw}. */ function previewWithdraw(uint256 assets) public view virtual override returns (uint256) { return _convertToShares(assets, MathUpgradeable.Rounding.Up); } /** @dev See {IERC4262-previewRedeem}. */ function previewRedeem(uint256 shares) public view virtual override returns (uint256) { return _convertToAssets(shares, MathUpgradeable.Rounding.Down); } /** @dev See {IERC4262-deposit}. */ function deposit(uint256 assets, address receiver) public virtual override returns (uint256) { require(assets <= maxDeposit(receiver), "ERC4626: deposit more than max"); uint256 shares = previewDeposit(assets); _deposit(_msgSender(), receiver, assets, shares); return shares; } /** @dev See {IERC4262-mint}. */ function mint(uint256 shares, address receiver) public virtual override returns (uint256) { require(shares <= maxMint(receiver), "ERC4626: mint more than max"); uint256 assets = previewMint(shares); _deposit(_msgSender(), receiver, assets, shares); return assets; } /** @dev See {IERC4262-withdraw}. */ function withdraw( uint256 assets, address receiver, address owner ) public virtual override returns (uint256) { require(assets <= maxWithdraw(owner), "ERC4626: withdraw more than max"); uint256 shares = previewWithdraw(assets); _withdraw(_msgSender(), receiver, owner, assets, shares); return shares; } /** @dev See {IERC4262-redeem}. */ function redeem( uint256 shares, address receiver, address owner ) public virtual override returns (uint256) { require(shares <= maxRedeem(owner), "ERC4626: redeem more than max"); uint256 assets = previewRedeem(shares); _withdraw(_msgSender(), receiver, owner, assets, shares); return assets; } /** * @dev Internal conversion function (from assets to shares) with support for rounding direction. * * Will revert if assets > 0, totalSupply > 0 and totalAssets = 0. That corresponds to a case where any asset * would represent an infinite amout of shares. */ function _convertToShares(uint256 assets, MathUpgradeable.Rounding rounding) internal view virtual returns (uint256 shares) { uint256 supply = totalSupply(); return (assets == 0 || supply == 0) ? assets.mulDiv(10**decimals(), 10**_asset.decimals(), rounding) : assets.mulDiv(supply, totalAssets(), rounding); } /** * @dev Internal conversion function (from shares to assets) with support for rounding direction. */ function _convertToAssets(uint256 shares, MathUpgradeable.Rounding rounding) internal view virtual returns (uint256 assets) { uint256 supply = totalSupply(); return (supply == 0) ? shares.mulDiv(10**_asset.decimals(), 10**decimals(), rounding) : shares.mulDiv(totalAssets(), supply, rounding); } /** * @dev Deposit/mint common workflow. */ function _deposit( address caller, address receiver, uint256 assets, uint256 shares ) internal virtual { // If _asset is ERC777, `transferFrom` can trigger a reenterancy BEFORE the transfer happens through the // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer, // calls the vault, which is assumed not malicious. // // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the // assets are transfered and before the shares are minted, which is a valid state. // slither-disable-next-line reentrancy-no-eth SafeERC20Upgradeable.safeTransferFrom(_asset, caller, address(this), assets); _mint(receiver, shares); emit Deposit(caller, receiver, assets, shares); } /** * @dev Withdraw/redeem common workflow. */ function _withdraw( address caller, address receiver, address owner, uint256 assets, uint256 shares ) internal virtual { if (caller != owner) { _spendAllowance(owner, caller, shares); } // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer, // calls the vault, which is assumed not malicious. // // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the // shares are burned and after the assets are transfered, which is a valid state. _burn(owner, shares); SafeERC20Upgradeable.safeTransfer(_asset, receiver, assets); emit Withdraw(caller, receiver, owner, assets, shares); } function _isVaultCollateralized() private view returns (bool) { return totalAssets() > 0 || totalSupply() == 0; } /** * @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 v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/draft-IERC20PermitUpgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`. // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`. // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a // good first aproximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1; uint256 x = a; if (x >> 128 > 0) { x >>= 128; result <<= 64; } if (x >> 64 > 0) { x >>= 64; result <<= 32; } if (x >> 32 > 0) { x >>= 32; result <<= 16; } if (x >> 16 > 0) { x >>= 16; result <<= 8; } if (x >> 8 > 0) { x >>= 8; result <<= 4; } if (x >> 4 > 0) { x >>= 4; result <<= 2; } if (x >> 2 > 0) { result <<= 1; } // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { uint256 result = sqrt(a); if (rounding == Rounding.Up && result * result < a) { result += 1; } return result; } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ), v, r, s ); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Arithmetic library with operations for fixed-point numbers. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol) /// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol) library FixedPointMathLib { /*////////////////////////////////////////////////////////////// SIMPLIFIED FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s. function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down. } function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up. } function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down. } function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up. } /*////////////////////////////////////////////////////////////// LOW LEVEL FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ function mulDivDown( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // Divide z by the denominator. z := div(z, denominator) } } function mulDivUp( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // First, divide z - 1 by the denominator and add 1. // We allow z - 1 to underflow if z is 0, because we multiply the // end result by 0 if z is zero, ensuring we return 0 if z is zero. z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1)) } } function rpow( uint256 x, uint256 n, uint256 scalar ) internal pure returns (uint256 z) { assembly { switch x case 0 { switch n case 0 { // 0 ** 0 = 1 z := scalar } default { // 0 ** n = 0 z := 0 } } default { switch mod(n, 2) case 0 { // If n is even, store scalar in z for now. z := scalar } default { // If n is odd, store x in z for now. z := x } // Shifting right by 1 is like dividing by 2. let half := shr(1, scalar) for { // Shift n right by 1 before looping to halve it. n := shr(1, n) } n { // Shift n right by 1 each iteration to halve it. n := shr(1, n) } { // Revert immediately if x ** 2 would overflow. // Equivalent to iszero(eq(div(xx, x), x)) here. if shr(128, x) { revert(0, 0) } // Store x squared. let xx := mul(x, x) // Round to the nearest number. let xxRound := add(xx, half) // Revert if xx + half overflowed. if lt(xxRound, xx) { revert(0, 0) } // Set x to scaled xxRound. x := div(xxRound, scalar) // If n is even: if mod(n, 2) { // Compute z * x. let zx := mul(z, x) // If z * x overflowed: if iszero(eq(div(zx, x), z)) { // Revert if x is non-zero. if iszero(iszero(x)) { revert(0, 0) } } // Round to the nearest number. let zxRound := add(zx, half) // Revert if zx + half overflowed. if lt(zxRound, zx) { revert(0, 0) } // Return properly scaled zxRound. z := div(zxRound, scalar) } } } } } /*////////////////////////////////////////////////////////////// GENERAL NUMBER UTILITIES //////////////////////////////////////////////////////////////*/ function sqrt(uint256 x) internal pure returns (uint256 z) { assembly { // Start off with z at 1. z := 1 // Used below to help find a nearby power of 2. let y := x // Find the lowest power of 2 that is at least sqrt(x). if iszero(lt(y, 0x100000000000000000000000000000000)) { y := shr(128, y) // Like dividing by 2 ** 128. z := shl(64, z) // Like multiplying by 2 ** 64. } if iszero(lt(y, 0x10000000000000000)) { y := shr(64, y) // Like dividing by 2 ** 64. z := shl(32, z) // Like multiplying by 2 ** 32. } if iszero(lt(y, 0x100000000)) { y := shr(32, y) // Like dividing by 2 ** 32. z := shl(16, z) // Like multiplying by 2 ** 16. } if iszero(lt(y, 0x10000)) { y := shr(16, y) // Like dividing by 2 ** 16. z := shl(8, z) // Like multiplying by 2 ** 8. } if iszero(lt(y, 0x100)) { y := shr(8, y) // Like dividing by 2 ** 8. z := shl(4, z) // Like multiplying by 2 ** 4. } if iszero(lt(y, 0x10)) { y := shr(4, y) // Like dividing by 2 ** 4. z := shl(2, z) // Like multiplying by 2 ** 2. } if iszero(lt(y, 0x8)) { // Equivalent to 2 ** z. z := shl(1, z) } // Shifting right by 1 is like dividing by 2. z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) // Compute a rounded down version of z. let zRoundDown := div(x, z) // If zRoundDown is smaller, use it. if lt(zRoundDown, z) { z := zRoundDown } } } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from "../tokens/ERC20.sol"; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. library SafeTransferLib { /*////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, amount, 0, 0, 0, 0) } require(success, "ETH_TRANSFER_FAILED"); } /*////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument. mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) ) } require(success, "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool success; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } require(success, "APPROVE_FAILED"); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; /* solhint-disable func-visibility */ function uncheckedInc(uint256 i) pure returns (uint256) { unchecked { return i + 1; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {AffineVault} from "src/vaults/AffineVault.sol"; import {SafeTransferLib} from "solmate/src/utils/SafeTransferLib.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; /// @notice Base strategy contract abstract contract BaseStrategy { using SafeTransferLib for ERC20; constructor(AffineVault _vault) { vault = _vault; asset = ERC20(_vault.asset()); } /// @notice The vault which will deposit/withdraw from the this contract AffineVault public immutable vault; modifier onlyVault() { require(msg.sender == address(vault), "BS: only vault"); _; } modifier onlyGovernance() { require(msg.sender == vault.governance(), "BS: only governance"); _; } /// @notice Returns the underlying ERC20 asset the strategy accepts. ERC20 public immutable asset; /// @notice Strategy's balance of underlying asset. /// @return assets Strategy's balance. function balanceOfAsset() public view returns (uint256 assets) { assets = asset.balanceOf(address(this)); } /// @notice Deposit vault's underlying asset into strategy. /// @param amount The amount to invest. /// @dev This function must revert if investment fails. function invest(uint256 amount) external { asset.safeTransferFrom(msg.sender, address(this), amount); _afterInvest(amount); } /// @notice After getting money from the vault, do something with it. /// @param amount The amount received from the vault. /// @dev Since investment is often gas-intensive and may require off-chain data, this will often be unimplemented. /// @dev Strategists will call custom functions for handling deployment of capital. function _afterInvest(uint256 amount) internal virtual {} /// @notice Withdraw vault's underlying asset from strategy. /// @param amount The amount to withdraw. /// @return The amount of `asset` divested from the strategy function divest(uint256 amount) external onlyVault returns (uint256) { return _divest(amount); } /// @dev This function should not revert if we get less than `amount` out of the strategy function _divest(uint256 amount) internal virtual returns (uint256) {} /// @notice The total amount of `asset` that the strategy is managing /// @dev This should not overestimate, and should account for slippage during divestment /// @return The strategy tvl function totalLockedValue() external virtual returns (uint256); function sweep(ERC20 token) external onlyGovernance { token.safeTransfer(vault.governance(), token.balanceOf(address(this))); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; contract AffineGovernable { /// @notice The governance address address public governance; modifier onlyGovernance() { _onlyGovernance(); _; } function _onlyGovernance() internal view { require(msg.sender == governance, "Only Governance."); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; abstract contract DetailedShare { /** * @notice A representation of a floating point number. * `decimals` is the number of digits before the where the decimal point would be placeds */ struct Number { uint256 num; uint8 decimals; } /// @notice The tvl is a dollar amount representing the total value locked in the vault. function detailedTVL() external virtual returns (Number memory); /** * @notice The number of dollars that "one" share is worth. * @dev "One" share is always 1 * 10 ^ (decimals). Note that `decimals` refers * to the ERC20 property. */ function detailedPrice() external virtual returns (Number memory); /** * @notice The total supply of the token. The value of Number.num here is the same as `totalSupply()` * @dev detailedTVL() / detailedTotalSupply() == detailedPrice() */ function detailedTotalSupply() external virtual returns (Number memory); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.16; import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {ERC20} from "solmate/src/tokens/ERC20.sol"; import {SafeTransferLib} from "solmate/src/utils/SafeTransferLib.sol"; import {AffineGovernable} from "src/utils/AffineGovernable.sol"; import {BaseStrategy as Strategy} from "src/strategies/BaseStrategy.sol"; import {uncheckedInc} from "src/libs/Unchecked.sol"; /** * @notice A core contract to be inherited by the L1 and L2 vault contracts. This contract handles adding * and removing strategies, investing in (and divesting from) strategies, harvesting gains/losses, and * strategy liquidation. */ contract AffineVault is AffineGovernable, AccessControlUpgradeable { using SafeTransferLib for ERC20; /*////////////////////////////////////////////////////////////// INITIALIZATION //////////////////////////////////////////////////////////////*/ ERC20 _asset; /// @notice The token that the vault takes in and tries to get more of, e.g. USDC function asset() public view virtual returns (address) { return address(_asset); } /** * @dev Initialize the vault. * @param _governance The governance address. * @param vaultAsset The vault's input asset. */ function baseInitialize(address _governance, ERC20 vaultAsset) internal virtual { governance = _governance; _asset = vaultAsset; // All roles use the default admin role // Governance has the admin role and all roles _grantRole(DEFAULT_ADMIN_ROLE, governance); _grantRole(HARVESTER, governance); lastHarvest = uint128(block.timestamp); } /*////////////////////////////////////////////////////////////// AUTHENTICATION //////////////////////////////////////////////////////////////*/ /// @notice Role with authority to call "harvest", i.e. update this vault's tvl bytes32 public constant HARVESTER = keccak256("HARVESTER"); /*////////////////////////////////////////////////////////////// WITHDRAWAL QUEUE //////////////////////////////////////////////////////////////*/ uint8 constant MAX_STRATEGIES = 20; /** * @notice An ordered array of strategies representing the withdrawal queue. The withdrawal queue is used * whenever the vault wants to pull money out of strategies. * @dev The first strategy in the array (index 0) is withdrawn from first. * This is a list of the currently active strategies (all non-zero addresses are active). */ Strategy[MAX_STRATEGIES] public withdrawalQueue; /** * @notice Gets the full withdrawal queue. * @return The withdrawal queue. * @dev This gives easy access to the whole array (by default we can only get one index at a time) */ function getWithdrawalQueue() external view returns (Strategy[MAX_STRATEGIES] memory) { return withdrawalQueue; } /** * @notice Sets a new withdrawal queue. * @param newQueue The new withdrawal queue. */ function setWithdrawalQueue(Strategy[MAX_STRATEGIES] calldata newQueue) external onlyGovernance { // Maintain queue size require(newQueue.length == MAX_STRATEGIES, "BV: bad qu size"); // Replace the withdrawal queue. withdrawalQueue = newQueue; emit WithdrawalQueueSet(newQueue); } /** * @notice Emitted when the withdrawal queue is updated. * @param newQueue The new withdrawal queue. */ event WithdrawalQueueSet(Strategy[MAX_STRATEGIES] newQueue); /*////////////////////////////////////////////////////////////// STRATEGIES //////////////////////////////////////////////////////////////*/ /// @notice The total amount of underlying assets held in strategies at the time of the last harvest. uint256 public totalStrategyHoldings; struct StrategyInfo { bool isActive; uint16 tvlBps; uint232 balance; } /// @notice A map of strategy addresses to details mapping(Strategy => StrategyInfo) public strategies; uint256 constant MAX_BPS = 10_000; /// @notice The number of bps of the vault's tvl which may be given to strategies (at most MAX_BPS) uint256 public totalBps; /// @notice Emitted when a strategy is added by governance event StrategyAdded(Strategy indexed strategy); /// @notice Emitted when a strategy is removed by governance event StrategyRemoved(Strategy indexed strategy); /** * @notice Add a strategy * @param strategy The strategy to add * @param tvlBps The number of bps of our tvl the strategy will get when funds are distributed to strategies */ function addStrategy(Strategy strategy, uint16 tvlBps) external onlyGovernance { _increaseTVLBps(tvlBps); strategies[strategy] = StrategyInfo({isActive: true, tvlBps: tvlBps, balance: 0}); // Add strategy to withdrawal queue withdrawalQueue[MAX_STRATEGIES - 1] = strategy; emit StrategyAdded(strategy); _organizeWithdrawalQueue(); } /// @notice A helper function for increasing `totalBps`. Used when adding strategies or updating strategy allocs function _increaseTVLBps(uint256 tvlBps) internal { uint256 newTotalBps = totalBps + tvlBps; require(newTotalBps <= MAX_BPS, "BV: too many bps"); totalBps = newTotalBps; } /** * @notice Push all zero addresses to the end of the array. This function is used whenever a strategy is * added or removed from the withdrawal queue * @dev Relative ordering of non-zero values is maintained. */ function _organizeWithdrawalQueue() internal { // number or empty values we've seen iterating from left to right uint256 offset; for (uint256 i = 0; i < MAX_STRATEGIES; i = uncheckedInc(i)) { Strategy strategy = withdrawalQueue[i]; if (address(strategy) == address(0)) { offset += 1; } else if (offset > 0) { // index of first empty value seen takes on value of `strategy` withdrawalQueue[i - offset] = strategy; withdrawalQueue[i] = Strategy(address(0)); } } } /** * @notice Remove a strategy from the withdrawal queue. Fully divest from the strategy. * @param strategy The strategy to remove * @dev removeStrategy MUST be called with harvest via multicall. This helps get the most accurate tvl numbers * and allows us to add any realized profits to our lockedProfit */ function removeStrategy(Strategy strategy) external onlyGovernance { for (uint256 i = 0; i < MAX_STRATEGIES; i = uncheckedInc(i)) { if (strategy != withdrawalQueue[i]) { continue; } strategies[strategy].isActive = false; // The vault can re-allocate bps to a new strategy totalBps -= strategies[strategy].tvlBps; strategies[strategy].tvlBps = 0; // Remove strategy from withdrawal queue withdrawalQueue[i] = Strategy(address(0)); emit StrategyRemoved(strategy); _organizeWithdrawalQueue(); // Take all money out of strategy. _withdrawFromStrategy(strategy, strategy.totalLockedValue()); break; } } /** * @notice Update tvl bps assigned to the given list of strategies * @param strategyList The list of strategies * @param strategyBps The new bps */ function updateStrategyAllocations(Strategy[] calldata strategyList, uint16[] calldata strategyBps) external onlyRole(HARVESTER) { for (uint256 i = 0; i < strategyList.length; i = uncheckedInc(i)) { // Get the strategy at the current index. Strategy strategy = strategyList[i]; // Ignore inactive (removed) strategies if (!strategies[strategy].isActive) continue; // update tvl bps totalBps -= strategies[strategy].tvlBps; _increaseTVLBps(strategyBps[i]); strategies[strategy].tvlBps = strategyBps[i]; } emit StrategyAllocsUpdated(strategyList, strategyBps); } /** * @notice Emitted when we update tvl bps for a list of strategies. * @param strategyList The list of strategies. * @param strategyBps The new tvl bps for the strategies */ event StrategyAllocsUpdated(Strategy[] strategyList, uint16[] strategyBps); /*////////////////////////////////////////////////////////////// STRATEGY DEPOSIT/WITHDRAWAL //////////////////////////////////////////////////////////////*/ /** * @notice Emitted after the Vault deposits into a strategy contract. * @param strategy The strategy that was deposited into. * @param assets The amount of assets deposited. */ event StrategyDeposit(Strategy indexed strategy, uint256 assets); /** * @notice Emitted after the Vault withdraws funds from a strategy contract. * @param strategy The strategy that was withdrawn from. * @param assetsRequested The amount of assets we tried to divest from the strategy. * @param assetsReceived The amount of assets actually withdrawn. */ event StrategyWithdrawal(Strategy indexed strategy, uint256 assetsRequested, uint256 assetsReceived); /// @notice Deposit `assetAmount` amount of `asset` into strategies according to each strategy's `tvlBps`. function _depositIntoStrategies(uint256 assetAmount) internal { // All non-zero strategies are active for (uint256 i = 0; i < MAX_STRATEGIES; i = uncheckedInc(i)) { Strategy strategy = withdrawalQueue[i]; if (address(strategy) == address(0)) { break; } _depositIntoStrategy(strategy, (assetAmount * strategies[strategy].tvlBps) / MAX_BPS); } } function _depositIntoStrategy(Strategy strategy, uint256 assets) internal { // Don't allow empty investments if (assets == 0) return; // Increase totalStrategyHoldings to account for the deposit. totalStrategyHoldings += assets; unchecked { // Without this the next harvest would count the deposit as profit. // Cannot overflow as the balance of one strategy can't exceed the sum of all. strategies[strategy].balance += uint232(assets); } // Approve assets to the strategy so we can deposit. _asset.safeApprove(address(strategy), assets); // Deposit into the strategy, will revert upon failure strategy.invest(assets); emit StrategyDeposit(strategy, assets); } /** * @notice Withdraw a specific amount of underlying tokens from a strategy. * @dev This is a "best effort" withdrawal. It could potentially withdraw nothing. * @param strategy The strategy to withdraw from. * @param assets The amount of underlying tokens to withdraw. * @return The amount of assets actually received. */ function _withdrawFromStrategy(Strategy strategy, uint256 assets) internal returns (uint256) { // Withdraw from the strategy uint256 amountWithdrawn = _divest(strategy, assets); // Without this the next harvest would count the withdrawal as a loss. // We update the balance to the current tvl because a withdrawal can reduce the tvl by more than the amount // withdrawn (e.g. fees during a swap) uint256 oldStratTVL = strategies[strategy].balance; uint256 newStratTvl = strategy.totalLockedValue(); strategies[strategy].balance = uint232(newStratTvl); // Decrease totalStrategyHoldings to account for the withdrawal. // If we haven't harvested in a long time, newStratTvl could be bigger than oldStratTvl totalStrategyHoldings -= oldStratTVL > newStratTvl ? oldStratTVL - newStratTvl : 0; emit StrategyWithdrawal({strategy: strategy, assetsRequested: assets, assetsReceived: amountWithdrawn}); return amountWithdrawn; } /// @dev A small wrapper around divest(). We try-catch to make sure that a bad strategy does not pause withdrawals. function _divest(Strategy strategy, uint256 assets) internal returns (uint256) { try strategy.divest(assets) returns (uint256 amountDivested) { return amountDivested; } catch { return 0; } } /*////////////////////////////////////////////////////////////// HARVESTING //////////////////////////////////////////////////////////////*/ /** * @notice A timestamp representing when the most recent harvest occurred. * @dev Since the time since the last harvest is used to calculate management fees, this is set * to `block.timestamp` (instead of 0) during initialization. */ uint128 public lastHarvest; /// @notice The amount of profit *originally* locked after harvesting from a strategy uint128 public maxLockedProfit; /// @notice Amount of time in seconds that profit takes to fully unlock. See lockedProfit(). uint256 public constant LOCK_INTERVAL = 24 hours; /** * @notice Emitted after a successful harvest. * @param user The authorized user who triggered the harvest. * @param strategies The trusted strategies that were harvested. */ event Harvest(address indexed user, Strategy[] strategies); /** * @notice Harvest a set of trusted strategies. * @param strategyList The trusted strategies to harvest. * @dev Will always revert if profit from last harvest has not finished unlocking. */ function harvest(Strategy[] calldata strategyList) external onlyRole(HARVESTER) { // Profit must not be unlocking require(block.timestamp >= lastHarvest + LOCK_INTERVAL, "BV: profit unlocking"); // Get the Vault's current total strategy holdings. uint256 oldTotalStrategyHoldings = totalStrategyHoldings; // Used to store the new total strategy holdings after harvesting. uint256 newTotalStrategyHoldings = oldTotalStrategyHoldings; // Used to store the total profit accrued by the strategies. uint256 totalProfitAccrued; // Will revert if any of the specified strategies are untrusted. for (uint256 i = 0; i < strategyList.length; i = uncheckedInc(i)) { // Get the strategy at the current index. Strategy strategy = strategyList[i]; // Ignore inactive (removed) strategies if (!strategies[strategy].isActive) { continue; } // Get the strategy's previous and current balance. uint232 balanceLastHarvest = strategies[strategy].balance; uint256 balanceThisHarvest = strategy.totalLockedValue(); // Update the strategy's stored balance. strategies[strategy].balance = uint232(balanceThisHarvest); // Increase/decrease newTotalStrategyHoldings based on the profit/loss registered. // We cannot wrap the subtraction in parenthesis as it would underflow if the strategy had a loss. newTotalStrategyHoldings = newTotalStrategyHoldings + balanceThisHarvest - balanceLastHarvest; unchecked { // Update the total profit accrued while counting losses as zero profit. // Cannot overflow as we already increased total holdings without reverting. totalProfitAccrued += balanceThisHarvest > balanceLastHarvest ? balanceThisHarvest - balanceLastHarvest // Profits since last harvest. : 0; // If the strategy registered a net loss we don't have any new profit. } } // Update max unlocked profit based on any remaining locked profit plus new profit. maxLockedProfit = uint128(lockedProfit() + totalProfitAccrued); // Set strategy holdings to our new total. totalStrategyHoldings = newTotalStrategyHoldings; // Assess fees (using old lastHarvest) and update the last harvest timestamp. _assessFees(); lastHarvest = uint128(block.timestamp); emit Harvest(msg.sender, strategyList); } /** * @notice Current locked profit amount. * @dev Profit unlocks uniformly over `LOCK_INTERVAL` seconds after the last harvest */ function lockedProfit() public view virtual returns (uint256) { if (block.timestamp >= lastHarvest + LOCK_INTERVAL) { return 0; } uint256 unlockedProfit = (maxLockedProfit * (block.timestamp - lastHarvest)) / LOCK_INTERVAL; return maxLockedProfit - unlockedProfit; } /*////////////////////////////////////////////////////////////// LIQUIDATION/REBALANCING //////////////////////////////////////////////////////////////*/ /// @notice The total amount of the underlying asset the vault has. function vaultTVL() public view returns (uint256) { return _asset.balanceOf(address(this)) + totalStrategyHoldings; } /** * @notice Emitted when the vault must make a certain amount of assets available * @dev We liquidate during cross chain rebalancing or withdrawals. * @param assetsRequested The amount we wanted to make available for withdrawal. * @param assetsLiquidated The amount we actually liquidated. */ event Liquidation(uint256 assetsRequested, uint256 assetsLiquidated); /** * @notice Withdraw `amount` of underlying asset from strategies. * @dev Always check the return value when using this function, we might not liquidate anything! * @param amount The amount we want to liquidate * @return The amount we actually liquidated */ function _liquidate(uint256 amount) internal returns (uint256) { uint256 amountLiquidated; for (uint256 i = 0; i < MAX_STRATEGIES; i = uncheckedInc(i)) { Strategy strategy = withdrawalQueue[i]; if (address(strategy) == address(0)) { break; } uint256 balance = _asset.balanceOf(address(this)); if (balance >= amount) { break; } uint256 amountNeeded = amount - balance; amountNeeded = Math.min(amountNeeded, strategies[strategy].balance); // Force withdraw of token from strategy uint256 withdrawn = _withdrawFromStrategy(strategy, amountNeeded); amountLiquidated += withdrawn; } emit Liquidation({assetsRequested: amount, assetsLiquidated: amountLiquidated}); return amountLiquidated; } /** * @notice Assess fees. * @dev This is called during harvest() to assess management fees. */ function _assessFees() internal virtual {} /** * @notice Emitted when we do a strategy rebalance, i.e. when we make the strategy tvls match their tvl bps * @param caller The caller */ event Rebalance(address indexed caller); /// @notice Rebalance strategies according to given tvl bps function rebalance() external onlyRole(HARVESTER) { uint256 tvl = vaultTVL(); // Loop through all strategies. Divesting from those whose tvl is too high, // Invest in those whose tvl is too low // MAX_STRATEGIES is always equal to withdrawalQueue.length uint256[MAX_STRATEGIES] memory amountsToInvest; for (uint256 i = 0; i < MAX_STRATEGIES; i = uncheckedInc(i)) { Strategy strategy = withdrawalQueue[i]; if (address(strategy) == address(0)) { break; } uint256 idealStrategyTVL = (tvl * strategies[strategy].tvlBps) / MAX_BPS; uint256 currStrategyTVL = strategy.totalLockedValue(); if (idealStrategyTVL < currStrategyTVL) { _withdrawFromStrategy(strategy, currStrategyTVL - idealStrategyTVL); } if (idealStrategyTVL > currStrategyTVL) { amountsToInvest[i] = idealStrategyTVL - currStrategyTVL; } } // Loop through the strategies to invest in, and invest in them for (uint256 i = 0; i < MAX_STRATEGIES; i = uncheckedInc(i)) { uint256 amountToInvest = amountsToInvest[i]; if (amountToInvest == 0) { continue; } // We aren't guaranteed that the vault has `amountToInvest` since there can be slippage // when divesting from strategies // NOTE: Strategies closer to the start of the queue are more likely to get the exact // amount of money needed amountToInvest = Math.min(amountToInvest, _asset.balanceOf(address(this))); if (amountToInvest == 0) { break; } // Deposit into strategy, making sure to not count this investment as a profit _depositIntoStrategy(withdrawalQueue[i], amountToInvest); } emit Rebalance(msg.sender); } }
{ "remappings": [ "@opengsn/=node_modules/@opengsn/", "@openzeppelin/=node_modules/@openzeppelin/", "@uniswap/=node_modules/@uniswap/", "base64-sol/=node_modules/base64-sol/", "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "hardhat/=node_modules/hardhat/", "script/=script/", "solady/=node_modules/solady/", "solmate/=node_modules/solmate/", "src/=src/" ], "optimizer": { "enabled": true, "runs": 2000000 }, "metadata": { "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"contract BaseStrategy[]","name":"strategies","type":"address[]"}],"name":"Harvest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"assetsRequested","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetsLiquidated","type":"uint256"}],"name":"Liquidation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"ManagementFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"Rebalance","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract BaseStrategy","name":"strategy","type":"address"}],"name":"StrategyAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract BaseStrategy[]","name":"strategyList","type":"address[]"},{"indexed":false,"internalType":"uint16[]","name":"strategyBps","type":"uint16[]"}],"name":"StrategyAllocsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract BaseStrategy","name":"strategy","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"}],"name":"StrategyDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract BaseStrategy","name":"strategy","type":"address"}],"name":"StrategyRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract BaseStrategy","name":"strategy","type":"address"},{"indexed":false,"internalType":"uint256","name":"assetsRequested","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetsReceived","type":"uint256"}],"name":"StrategyWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"WithdrawalFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract BaseStrategy[20]","name":"newQueue","type":"address[20]"}],"name":"WithdrawalQueueSet","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GUARDIAN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HARVESTER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LOCK_INTERVAL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract BaseStrategy","name":"strategy","type":"address"},{"internalType":"uint16","name":"tvlBps","type":"uint16"}],"name":"addStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"convertToAssets","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"convertToShares","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositIntoStrategies","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"detailedPrice","outputs":[{"components":[{"internalType":"uint256","name":"num","type":"uint256"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"internalType":"struct DetailedShare.Number","name":"price","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"detailedTVL","outputs":[{"components":[{"internalType":"uint256","name":"num","type":"uint256"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"internalType":"struct DetailedShare.Number","name":"tvl","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"detailedTotalSupply","outputs":[{"components":[{"internalType":"uint256","name":"num","type":"uint256"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"internalType":"struct DetailedShare.Number","name":"supply","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWithdrawalQueue","outputs":[{"internalType":"contract BaseStrategy[20]","name":"","type":"address[20]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract BaseStrategy[]","name":"strategyList","type":"address[]"}],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialSharesPerAsset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_governance","type":"address"},{"internalType":"address","name":"vaultAsset","type":"address"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastHarvest","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockedProfit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"managementFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxLockedProfit","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":"uint256","name":"assets","type":"uint256"}],"name":"previewDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assetsToUser","type":"uint256"}],"name":"previewWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract BaseStrategy","name":"strategy","type":"address"}],"name":"removeStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"feeBps","type":"uint256"}],"name":"setManagementFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"feeBps","type":"uint256"}],"name":"setWithdrawalFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract BaseStrategy[20]","name":"newQueue","type":"address[20]"}],"name":"setWithdrawalQueue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract BaseStrategy","name":"","type":"address"}],"name":"strategies","outputs":[{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"uint16","name":"tvlBps","type":"uint16"},{"internalType":"uint232","name":"balance","type":"uint232"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStrategyHoldings","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract BaseStrategy[]","name":"strategyList","type":"address[]"},{"internalType":"uint16[]","name":"strategyBps","type":"uint16[]"}],"name":"updateStrategyAllocations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vaultTVL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawalFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"withdrawalQueue","outputs":[{"internalType":"contract BaseStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506151c4806100206000396000f3fe608060405234801561001057600080fd5b50600436106104065760003560e01c80637d7c2a1c1161021a578063c6e6f59211610135578063d905777e116100c8578063f1a392da11610097578063f26edf351161007c578063f26edf35146109f6578063f6df5a78146109fe578063fe56e23214610a0957600080fd5b8063f1a392da146109d1578063f20dd15d146109ed57600080fd5b8063d905777e1461096f578063dd62ed3e14610982578063ecad9565146109c8578063ef8b30f71461088557600080fd5b8063ce96cb7711610104578063ce96cb77146108e5578063d00364be146108f8578063d11f519c14610949578063d547741f1461095c57600080fd5b8063c6e6f59214610885578063c822adda14610898578063c89d3460146108ab578063cb9d9fa7146108be57600080fd5b8063a457c2d7116101ad578063b3d7f6b91161017c578063b3d7f6b91461084c578063b460af941461085f578063ba08765214610872578063c63d75b61461068357600080fd5b8063a457c2d714610809578063a6f7f5d61461081c578063a9059cbb14610826578063ac1e50251461083957600080fd5b806394148415116101e957806394148415146107d357806394bf804d146107e657806395d89b41146107f9578063a217fddf1461080157600080fd5b80637d7c2a1c146107735780638456cb591461077b5780638bc7e8c41461078357806391d148541461078d57600080fd5b8063313ce567116103255780634cdad506116102b85780635da6a6911161028757806368bb9a971161026c57806368bb9a97146107205780636e553f651461072a57806370a082311461073d57600080fd5b80635da6a691146107055780636071abed1461071857600080fd5b80634cdad506146106be5780634e637ba9146106d15780635aa6e675146106d95780635c975abb146106f957600080fd5b806339ebf823116102f457806339ebf823146105e75780633f4ba83a1461067b578063402d267d1461068357806344b81396146106b657600080fd5b8063313ce5671461058557806336568abe1461059457806338d52e0f146105a757806339509351146105d457600080fd5b80630e73ecef1161039d57806323b872dd1161036c57806323b872dd14610515578063248a9ca31461052857806324ea54f41461054b5780632f2ff15d1461057257600080fd5b80630e73ecef146104d2578063175188e8146104e757806318160ddd146104fa5780632016a0d21461050257600080fd5b806306fdde03116103d957806306fdde031461048457806307a2d13a14610499578063095ea7b3146104ac5780630a28a477146104bf57600080fd5b806301106d4d1461040b57806301e1d1141461043657806301ffc9a71461044c57806305efa8761461046f575b600080fd5b610413610a1c565b604080518251815260209283015160ff1692810192909252015b60405180910390f35b61043e610af2565b60405190815260200161042d565b61045f61045a3660046145db565b610b13565b604051901515815260200161042d565b61048261047d36600461461d565b610bac565b005b61048c610beb565b60405161042d919061465a565b61043e6104a736600461461d565b610c7d565b61045f6104ba3660046146cd565b610c8a565b61043e6104cd36600461461d565b610ca2565b6104da610cda565b60405161042d91906146f9565b6104826104f5366004614741565b610d2d565b60b25461043e565b610482610510366004614838565b610f3e565b61045f6105233660046148c1565b61119e565b61043e61053636600461461d565b60009081526065602052604090206001015490565b61043e7f8b5b16d04624687fcf0d0228f19993c9157c1ed07b41d8d430fd9100eb099fe881565b610482610580366004614902565b6111c2565b6040516012815260200161042d565b6104826105a2366004614902565b6111e7565b6105af611296565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161042d565b61045f6105e23660046146cd565b6112b7565b61063c6105f5366004614741565b60ad6020526000908152604090205460ff811690610100810461ffff1690630100000090047cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1683565b60408051931515845261ffff90921660208401527cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff169082015260600161042d565b610482611303565b61043e610691366004614741565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90565b61043e611338565b61043e6106cc36600461461d565b61140b565b61043e61142e565b6000546105af9073ffffffffffffffffffffffffffffffffffffffff1681565b6101145460ff1661045f565b61048261071336600461497e565b6114cf565b6104136116a1565b61043e6201518081565b61043e610738366004614902565b6116c8565b61043e61074b366004614741565b73ffffffffffffffffffffffffffffffffffffffff16600090815260b0602052604090205490565b6104826116eb565b6104826119d5565b61043e6101475481565b61045f61079b366004614902565b600091825260656020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b6104826107e13660046149ea565b611a07565b61043e6107f4366004614902565b611a57565b61048c611a7a565b61043e600081565b61045f6108173660046146cd565b611a89565b61043e6101465481565b61045f6108343660046146cd565b611b5a565b61048261084736600461461d565b611b68565b61043e61085a36600461461d565b611bb3565b61043e61086d366004614a15565b611bc0565b61043e610880366004614a15565b611bee565b61043e61089336600461461d565b611c14565b6105af6108a636600461461d565b611c21565b6104826108b9366004614a57565b611c4e565b61043e7f27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884c81565b61043e6108f3366004614741565b611fe2565b60af546109289070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1681565b6040516fffffffffffffffffffffffffffffffff909116815260200161042d565b610482610957366004614ab0565b612013565b61048261096a366004614902565b61219a565b61043e61097d366004614741565b6121bf565b61043e610990366004614ae5565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260b16020908152604080832093909416825291909152205490565b61043e60ac5481565b60af54610928906fffffffffffffffffffffffffffffffff1681565b61043e60ae5481565b6104136121ea565b6402540be40061043e565b610482610a1736600461461d565b61221e565b60408051808201909152600080825260208201526040518060400160405280610a51610a46601290565b6104a790600a614c62565b8152609754604080517f313ce567000000000000000000000000000000000000000000000000000000008152905160209384019373ffffffffffffffffffffffffffffffffffffffff9093169263313ce56792600480820193918290030181865afa158015610ac4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae89190614c71565b60ff169052919050565b6000610afc611338565b610b0461142e565b610b0e9190614c94565b905090565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b000000000000000000000000000000000000000000000000000000001480610ba657507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b610bb4612269565b7f27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884c610bde816122d9565b610be7826122e3565b5050565b606060b38054610bfa90614ca7565b80601f0160208091040260200160405190810160405280929190818152602001828054610c2690614ca7565b8015610c735780601f10610c4857610100808354040283529160200191610c73565b820191906000526020600020905b815481529060010190602001808311610c5657829003601f168201915b5050505050905090565b6000610ba6826000612383565b600033610c988185856123c7565b5060019392505050565b600080610cc661271061014754612710610cbc9190614c94565b859190600161257a565b9050610cd38160016125d5565b9392505050565b610ce261452c565b604080516102808101918290529060989060149082845b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610cf9575050505050905090565b610d35612610565b60005b6014811015610be75760988160148110610d5457610d54614cfa565b015473ffffffffffffffffffffffffffffffffffffffff90811690831603610f365773ffffffffffffffffffffffffffffffffffffffff8216600090815260ad6020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169081905560ae805461010090920461ffff16929091610ddf908490614c94565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600090815260ad6020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ff16905560988260148110610e4257610e42614cfa565b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff928316179055604051908316907f09a1db4b80c32706328728508c941a6b954f31eb5affd32f236c1fd405f8fea490600090a2610eb7612691565b610f31828373ffffffffffffffffffffffffffffffffffffffff1663357be4466040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610f08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2c9190614d29565b6127ae565b505050565b600101610d38565b6000547501000000000000000000000000000000000000000000900460ff1615808015610f89575060005460017401000000000000000000000000000000000000000090910460ff16105b80610fbb5750303b158015610fbb575060005474010000000000000000000000000000000000000000900460ff166001145b61104c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000017905580156110d257600080547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff1675010000000000000000000000000000000000000000001790555b6110dc8585612965565b6110e68383612a46565b6110ef84612afb565b600054611133907f8b5b16d04624687fcf0d0228f19993c9157c1ed07b41d8d430fd9100eb099fe89073ffffffffffffffffffffffffffffffffffffffff16612baf565b801561119757600080547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050505050565b6000336111ac858285612ca3565b6111b7858585612d7a565b506001949350505050565b6000828152606560205260409020600101546111dd816122d9565b610f318383612baf565b73ffffffffffffffffffffffffffffffffffffffff8116331461128c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401611043565b610be7828261302d565b6000610b0e60975473ffffffffffffffffffffffffffffffffffffffff1690565b33600081815260b16020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152812054909190610c9890829086906112fe908790614d42565b6123c7565b7f8b5b16d04624687fcf0d0228f19993c9157c1ed07b41d8d430fd9100eb099fe861132d816122d9565b6113356130e8565b50565b60af5460009061135e9062015180906fffffffffffffffffffffffffffffffff16614d42565b421061136a5750600090565b60af546000906201518090611391906fffffffffffffffffffffffffffffffff1642614c94565b60af546113c4919070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16614d55565b6113ce9190614dc1565b60af5490915061140590829070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16614c94565b91505090565b600080611419836000612383565b905061142481613166565b610cd39082614c94565b60ac546097546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000929173ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa1580156114a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c59190614d29565b610b0e9190614d42565b7f27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884c6114f9816122d9565b60005b8481101561166b57600086868381811061151857611518614cfa565b905060200201602081019061152d9190614741565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260ad602052604090205490915060ff166115635750611663565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260ad602052604081205460ae805461010090920461ffff169290916115a5908490614c94565b909155506115de90508585848181106115c0576115c0614cfa565b90506020020160208101906115d59190614dfc565b61ffff1661317d565b8484838181106115f0576115f0614cfa565b90506020020160208101906116059190614dfc565b73ffffffffffffffffffffffffffffffffffffffff909116600090815260ad60205260409020805461ffff92909216610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ff9092169190911790555b6001016114fc565b507f545a2901c84c72b5a338684cd0228cbc2663ed302c4cede1041a4cb05d4abe0b8585858560405161118e9493929190614e6d565b60408051808201909152600080825260208201526040518060400160405280610a51610af2565b60006116d2612269565b60006116dd84611c14565b9050610cd333848684613201565b7f27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884c611715816122d9565b600061171f61142e565b905061172961452c565b60005b60148110156118835760006098826014811061174a5761174a614cfa565b015473ffffffffffffffffffffffffffffffffffffffff1690508061176f5750611883565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260ad6020526040812054612710906117ac90610100900461ffff1687614d55565b6117b69190614dc1565b905060008273ffffffffffffffffffffffffffffffffffffffff1663357be4466040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611807573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182b9190614d29565b9050808210156118455761184383610f2c8484614c94565b505b8082111561186f576118578183614c94565b85856014811061186957611869614cfa565b60200201525b50505061187c8160010190565b905061172c565b5060005b60148110156119a45760008282601481106118a4576118a4614cfa565b60200201519050806000036118b9575061199c565b6097546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015261195691839173ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa15801561192d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119519190614d29565b613310565b90508060000361196657506119a4565b61199a6098836014811061197c5761197c614cfa565b015473ffffffffffffffffffffffffffffffffffffffff1682613326565b505b600101611887565b5060405133907fa61bd16ebda9d1c8ec2a61970b39e6640e55ed8433a22765a1b5217b72c4a81290600090a2505050565b7f8b5b16d04624687fcf0d0228f19993c9157c1ed07b41d8d430fd9100eb099fe86119ff816122d9565b61133561348c565b611a0f612610565b611a1c609882601461454b565b507fc90c5dd90d97be559acbfb4e6798e48198fe77071c419afcaa6bd25f4d3d2ef581604051611a4c9190614ecb565b60405180910390a150565b6000611a61612269565b6000611a6c84611bb3565b9050610cd333848387613201565b606060b48054610bfa90614ca7565b33600081815260b16020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015611b4d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401611043565b6111b782868684036123c7565b600033610c98818585612d7a565b611b70612610565b6101475460408051918252602082018390527f28a572c8c759d40c2d26dcdaaefd9650e9e37ff11ee147ce0f645cd7664048cb910160405180910390a161014755565b6000610ba6826001612383565b6000611bca612269565b6000611bd78560016125d5565b9050611be633858588856134e8565b949350505050565b6000611bf8612269565b6000611c05856000612383565b9050611be633858584896134e8565b6000610ba68260006125d5565b60988160148110611c3157600080fd5b015473ffffffffffffffffffffffffffffffffffffffff16905081565b7f27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884c611c78816122d9565b60af54611c9b9062015180906fffffffffffffffffffffffffffffffff16614d42565b421015611d04576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f42563a2070726f66697420756e6c6f636b696e670000000000000000000000006044820152606401611043565b60ac54806000805b85811015611f0e576000878783818110611d2857611d28614cfa565b9050602002016020810190611d3d9190614741565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260ad602052604090205490915060ff16611d735750611f06565b73ffffffffffffffffffffffffffffffffffffffff8116600081815260ad602090815260408083205481517f357be446000000000000000000000000000000000000000000000000000000008152915163010000009091047cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16949263357be4469260048082019391829003018187875af1158015611e13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e379190614d29565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260ad6020526040902080547cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80841663010000000262ffffff909216919091179091559091508216611ea28288614d42565b611eac9190614c94565b9550817cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168111611edb576000611efe565b817cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1681035b850194505050505b600101611d0c565b5080611f18611338565b611f229190614d42565b60af80546fffffffffffffffffffffffffffffffff92831670010000000000000000000000000000000002921691909117905560ac829055611f626136cf565b60af80547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016426fffffffffffffffffffffffffffffffff1617905560405133907f69e9c71f6799744a94d9897e77c3ed426cc2f92ba0ef3300785368209b6f4b2d90611fd29089908990614f14565b60405180910390a2505050505050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260b06020526040812054610ba6906000612383565b61201b612610565b6120288161ffff1661317d565b60408051606081018252600180825261ffff8481166020808501918252600085870181815273ffffffffffffffffffffffffffffffffffffffff8a16825260ad9092529590952093518454915195517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000009092169015157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ff161761010095909216949094021762ffffff1663010000007cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909416939093029290921790558290609890612112906014614f28565b60ff166014811061212557612125614cfa565b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff928316179055604051908316907f3f008fd510eae7a9e7bee13513d7b83bef8003d488b5a3d0b0da4de71d6846f190600090a2610be7612691565b6000828152606560205260409020600101546121b5816122d9565b610f31838361302d565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260b06020526040812054610ba6565b6040805180820190915260008082526020820152604051806040016040528061221260b25490565b81526020016012610ae8565b612226612610565b6101465460408051918252602082018390527f4e874b007ab14f7e263baefd44951834c8266f4f224d1092e49e9c254354cc54910160405180910390a161014655565b6101145460ff16156122d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401611043565b565b6113358133613769565b60005b6014811015610be75760006098826014811061230457612304614cfa565b015473ffffffffffffffffffffffffffffffffffffffff1690508061232857505050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260ad602052604090205461237a9082906127109061236b90610100900461ffff1687614d55565b6123759190614dc1565b613326565b506001016122e6565b6000806402540be40060b2546123999190614d42565b905060006123a5610af2565b6123b0906001614d42565b90506123be8582848761257a565b95945050505050565b73ffffffffffffffffffffffffffffffffffffffff8316612469576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff821661250c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff838116600081815260b1602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60008061258886868661383b565b9050600183600281111561259e5761259e614f41565b1480156125bb5750600084806125b6576125b6614d92565b868809115b156123be576125cb600182614d42565b9695505050505050565b6000806402540be40060b2546125eb9190614d42565b905060006125f7610af2565b612602906001614d42565b90506123be8583838761257a565b60005473ffffffffffffffffffffffffffffffffffffffff1633146122d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4f6e6c7920476f7665726e616e63652e000000000000000000000000000000006044820152606401611043565b6000805b6014811015610be7576000609882601481106126b3576126b3614cfa565b015473ffffffffffffffffffffffffffffffffffffffff169050806126e4576126dd600184614d42565b92506127a5565b82156127a5578060986126f78585614c94565b6014811061270757612707614cfa565b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905560006098836014811061276057612760614cfa565b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff929092169190911790555b50600101612695565b6000806127bb8484613908565b73ffffffffffffffffffffffffffffffffffffffff8516600081815260ad602090815260408083205481517f357be4460000000000000000000000000000000000000000000000000000000081529151959650630100000090047cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff169492939263357be44692600480840193919291829003018187875af1158015612861573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128859190614d29565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260ad60205260409020805462ffffff1663010000007cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84160217905590508082116128ea5760006128f4565b6128f48183614c94565b60ac60008282546129059190614c94565b9091555050604080518681526020810185905273ffffffffffffffffffffffffffffffffffffffff8816917f88f0c01d2402991a2098e1cf989cb2c54cefe3b20ccb83c55989866f419a6ff5910160405180910390a25090949350505050565b600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff858116918217845560978054909316908516179091556129c29190612baf565b600054612a06907f27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884c9073ffffffffffffffffffffffffffffffffffffffff16612baf565b505060af80547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016426fffffffffffffffffffffffffffffffff16179055565b6000547501000000000000000000000000000000000000000000900460ff16612af1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611043565b610be782826139c5565b6000547501000000000000000000000000000000000000000000900460ff16612ba6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611043565b61133581613a89565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610be757600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055612c453390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b73ffffffffffffffffffffffffffffffffffffffff838116600090815260b160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114612d745781811015612d67576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401611043565b612d7484848484036123c7565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316612e1d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff8216612ec0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260b0602052604090205481811015612f76576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260b06020526040808220858503905591851681529081208054849290612fba908490614d42565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161302091815260200190565b60405180910390a3612d74565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615610be757600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6130f0613b7b565b61011480547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b61014754600090610ba6908390612710600161257a565b60008160ae5461318d9190614d42565b90506127108111156131fb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f42563a20746f6f206d616e7920627073000000000000000000000000000000006044820152606401611043565b60ae5550565b6000811161326b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f5661756c743a207a65726f2073686172657300000000000000000000000000006044820152606401611043565b6132758382613be8565b60975461329a9073ffffffffffffffffffffffffffffffffffffffff16853085613d08565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78484604051613302929190918252602082015260400190565b60405180910390a350505050565b600081831061331f5781610cd3565b5090919050565b80600003613332575050565b8060ac60008282546133449190614d42565b909155505073ffffffffffffffffffffffffffffffffffffffff808316600090815260ad6020526040902080547cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6301000000808304821686019091160262ffffff9091161790556097546133b891168383613dc7565b6040517f2afcf4800000000000000000000000000000000000000000000000000000000081526004810182905273ffffffffffffffffffffffffffffffffffffffff831690632afcf48090602401600060405180830381600087803b15801561342057600080fd5b505af1158015613434573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff167fc6f6f91a48277d76f232cc08a9a30f6b05b3fd9b92c3180c25936e17a22a10258260405161348091815260200190565b60405180910390a25050565b613494612269565b61011480547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861313c3390565b6134f182613e80565b506097546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015261358c9173ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015613562573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135869190614d29565b83613310565b9150600061359983613166565b905060006135a78285614c94565b90508473ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff16146135e7576135e7858885612ca3565b6135f18584614043565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db8787604051613670929190918252602082015260400190565b60405180910390a460975461369c9073ffffffffffffffffffffffffffffffffffffffff168783614230565b6000546097546136c69173ffffffffffffffffffffffffffffffffffffffff918216911684614230565b50505050505050565b60af546000906136f1906fffffffffffffffffffffffffffffffff1642614c94565b905060006301e1338061014654836137099190614d55565b6137139190614dc1565b9050600061271061372360b25490565b61372d9084614d55565b6137379190614dc1565b90508060000361374657505050565b600054610f319073ffffffffffffffffffffffffffffffffffffffff1682613be8565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610be7576137c18173ffffffffffffffffffffffffffffffffffffffff1660146142e9565b6137cc8360206142e9565b6040516020016137dd929190614f70565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526110439160040161465a565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff858709858702925082811083820303915050806000036138935783828161388957613889614d92565b0492505050610cd3565b80841161389f57600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b6040517f8ca179950000000000000000000000000000000000000000000000000000000081526004810182905260009073ffffffffffffffffffffffffffffffffffffffff841690638ca17995906024016020604051808303816000875af19250505080156139b2575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526139af91810190614d29565b60015b6139be57506000610ba6565b9050610ba6565b6000547501000000000000000000000000000000000000000000900460ff16613a70576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611043565b60b3613a7c838261503f565b5060b4610f31828261503f565b6000547501000000000000000000000000000000000000000000900460ff16613b34576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611043565b60e280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6101145460ff166122d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401611043565b73ffffffffffffffffffffffffffffffffffffffff8216613c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401611043565b8060b26000828254613c779190614d42565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600090815260b0602052604081208054839290613cb1908490614d42565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b60006040517f23b872dd0000000000000000000000000000000000000000000000000000000081528460048201528360248201528260448201526020600060648360008a5af13d15601f3d1160016000511416171691505080611197576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c45440000000000000000000000006044820152606401611043565b60006040517f095ea7b3000000000000000000000000000000000000000000000000000000008152836004820152826024820152602060006044836000895af13d15601f3d1160016000511416171691505080612d74576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f415050524f56455f4641494c45440000000000000000000000000000000000006044820152606401611043565b60008060005b601481101561400357600060988260148110613ea457613ea4614cfa565b015473ffffffffffffffffffffffffffffffffffffffff16905080613ec95750614003565b6097546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009173ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015613f38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f5c9190614d29565b9050858110613f6c575050614003565b6000613f788288614c94565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260ad6020526040902054909150613fd2908290630100000090047cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16613310565b90506000613fe084836127ae565b9050613fec8187614d42565b955050505050613ffc8160010190565b9050613e86565b5060408051848152602081018390527fd2f6618ba448f8b76ee0e823f8bb8c568b748f1687e1bc6bd625306fc4fb5035910160405180910390a192915050565b73ffffffffffffffffffffffffffffffffffffffff82166140e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260b060205260409020548181101561419c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260b060205260408120838303905560b280548492906141d8908490614c94565b909155505060405182815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b60006040517fa9059cbb000000000000000000000000000000000000000000000000000000008152836004820152826024820152602060006044836000895af13d15601f3d1160016000511416171691505080612d74576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5452414e534645525f4641494c454400000000000000000000000000000000006044820152606401611043565b606060006142f8836002614d55565b614303906002614d42565b67ffffffffffffffff81111561431b5761431b61475e565b6040519080825280601f01601f191660200182016040528015614345576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061437c5761437c614cfa565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106143df576143df614cfa565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600061441b846002614d55565b614426906001614d42565b90505b60018111156144c3577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061446757614467614cfa565b1a60f81b82828151811061447d5761447d614cfa565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c936144bc81615159565b9050614429565b508315610cd3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401611043565b6040518061028001604052806014906020820280368337509192915050565b82601481019282156145b6579160200282015b828111156145b65781547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84351617825560209092019160019091019061455e565b506145c29291506145c6565b5090565b5b808211156145c257600081556001016145c7565b6000602082840312156145ed57600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610cd357600080fd5b60006020828403121561462f57600080fd5b5035919050565b60005b83811015614651578181015183820152602001614639565b50506000910152565b6020815260008251806020840152614679816040850160208701614636565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b73ffffffffffffffffffffffffffffffffffffffff8116811461133557600080fd5b600080604083850312156146e057600080fd5b82356146eb816146ab565b946020939093013593505050565b6102808101818360005b601481101561473857815173ffffffffffffffffffffffffffffffffffffffff16835260209283019290910190600101614703565b50505092915050565b60006020828403121561475357600080fd5b8135610cd3816146ab565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261479e57600080fd5b813567ffffffffffffffff808211156147b9576147b961475e565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156147ff576147ff61475e565b8160405283815286602085880101111561481857600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561484e57600080fd5b8435614859816146ab565b93506020850135614869816146ab565b9250604085013567ffffffffffffffff8082111561488657600080fd5b6148928883890161478d565b935060608701359150808211156148a857600080fd5b506148b58782880161478d565b91505092959194509250565b6000806000606084860312156148d657600080fd5b83356148e1816146ab565b925060208401356148f1816146ab565b929592945050506040919091013590565b6000806040838503121561491557600080fd5b823591506020830135614927816146ab565b809150509250929050565b60008083601f84011261494457600080fd5b50813567ffffffffffffffff81111561495c57600080fd5b6020830191508360208260051b850101111561497757600080fd5b9250929050565b6000806000806040858703121561499457600080fd5b843567ffffffffffffffff808211156149ac57600080fd5b6149b888838901614932565b909650945060208701359150808211156149d157600080fd5b506149de87828801614932565b95989497509550505050565b60006102808083850312156149fe57600080fd5b838184011115614a0d57600080fd5b509092915050565b600080600060608486031215614a2a57600080fd5b833592506020840135614a3c816146ab565b91506040840135614a4c816146ab565b809150509250925092565b60008060208385031215614a6a57600080fd5b823567ffffffffffffffff811115614a8157600080fd5b614a8d85828601614932565b90969095509350505050565b803561ffff81168114614aab57600080fd5b919050565b60008060408385031215614ac357600080fd5b8235614ace816146ab565b9150614adc60208401614a99565b90509250929050565b60008060408385031215614af857600080fd5b8235614b03816146ab565b91506020830135614927816146ab565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600181815b80851115614b9b57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115614b8157614b81614b13565b80851615614b8e57918102915b93841c9390800290614b47565b509250929050565b600082614bb257506001610ba6565b81614bbf57506000610ba6565b8160018114614bd55760028114614bdf57614bfb565b6001915050610ba6565b60ff841115614bf057614bf0614b13565b50506001821b610ba6565b5060208310610133831016604e8410600b8410161715614c1e575081810a610ba6565b614c288383614b42565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115614c5a57614c5a614b13565b029392505050565b6000610cd360ff841683614ba3565b600060208284031215614c8357600080fd5b815160ff81168114610cd357600080fd5b81810381811115610ba657610ba6614b13565b600181811c90821680614cbb57607f821691505b602082108103614cf4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215614d3b57600080fd5b5051919050565b80820180821115610ba657610ba6614b13565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614d8d57614d8d614b13565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082614df7577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600060208284031215614e0e57600080fd5b610cd382614a99565b8183526000602080850194508260005b85811015614e62578135614e3a816146ab565b73ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101614e27565b509495945050505050565b604081526000614e81604083018688614e17565b8281036020848101919091528482528591810160005b86811015614ebe5761ffff614eab85614a99565b1682529282019290820190600101614e97565b5098975050505050505050565b6102808101818360005b6014811015614738578135614ee9816146ab565b73ffffffffffffffffffffffffffffffffffffffff1683526020928301929190910190600101614ed5565b602081526000611be6602083018486614e17565b60ff8281168282160390811115610ba657610ba6614b13565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351614fa8816017850160208801614636565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351614fe5816028840160208801614636565b01602801949350505050565b601f821115610f3157600081815260208120601f850160051c810160208610156150185750805b601f850160051c820191505b8181101561503757828155600101615024565b505050505050565b815167ffffffffffffffff8111156150595761505961475e565b61506d816150678454614ca7565b84614ff1565b602080601f8311600181146150c0576000841561508a5750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555615037565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b8281101561510d578886015182559484019460019091019084016150ee565b508582101561514957878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b60008161516857615168614b13565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea2646970667358221220b135383a4edbe5586100627257c0ae8509380f5dd897abe5da0edcb43d0bafc264736f6c63430008100033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106104065760003560e01c80637d7c2a1c1161021a578063c6e6f59211610135578063d905777e116100c8578063f1a392da11610097578063f26edf351161007c578063f26edf35146109f6578063f6df5a78146109fe578063fe56e23214610a0957600080fd5b8063f1a392da146109d1578063f20dd15d146109ed57600080fd5b8063d905777e1461096f578063dd62ed3e14610982578063ecad9565146109c8578063ef8b30f71461088557600080fd5b8063ce96cb7711610104578063ce96cb77146108e5578063d00364be146108f8578063d11f519c14610949578063d547741f1461095c57600080fd5b8063c6e6f59214610885578063c822adda14610898578063c89d3460146108ab578063cb9d9fa7146108be57600080fd5b8063a457c2d7116101ad578063b3d7f6b91161017c578063b3d7f6b91461084c578063b460af941461085f578063ba08765214610872578063c63d75b61461068357600080fd5b8063a457c2d714610809578063a6f7f5d61461081c578063a9059cbb14610826578063ac1e50251461083957600080fd5b806394148415116101e957806394148415146107d357806394bf804d146107e657806395d89b41146107f9578063a217fddf1461080157600080fd5b80637d7c2a1c146107735780638456cb591461077b5780638bc7e8c41461078357806391d148541461078d57600080fd5b8063313ce567116103255780634cdad506116102b85780635da6a6911161028757806368bb9a971161026c57806368bb9a97146107205780636e553f651461072a57806370a082311461073d57600080fd5b80635da6a691146107055780636071abed1461071857600080fd5b80634cdad506146106be5780634e637ba9146106d15780635aa6e675146106d95780635c975abb146106f957600080fd5b806339ebf823116102f457806339ebf823146105e75780633f4ba83a1461067b578063402d267d1461068357806344b81396146106b657600080fd5b8063313ce5671461058557806336568abe1461059457806338d52e0f146105a757806339509351146105d457600080fd5b80630e73ecef1161039d57806323b872dd1161036c57806323b872dd14610515578063248a9ca31461052857806324ea54f41461054b5780632f2ff15d1461057257600080fd5b80630e73ecef146104d2578063175188e8146104e757806318160ddd146104fa5780632016a0d21461050257600080fd5b806306fdde03116103d957806306fdde031461048457806307a2d13a14610499578063095ea7b3146104ac5780630a28a477146104bf57600080fd5b806301106d4d1461040b57806301e1d1141461043657806301ffc9a71461044c57806305efa8761461046f575b600080fd5b610413610a1c565b604080518251815260209283015160ff1692810192909252015b60405180910390f35b61043e610af2565b60405190815260200161042d565b61045f61045a3660046145db565b610b13565b604051901515815260200161042d565b61048261047d36600461461d565b610bac565b005b61048c610beb565b60405161042d919061465a565b61043e6104a736600461461d565b610c7d565b61045f6104ba3660046146cd565b610c8a565b61043e6104cd36600461461d565b610ca2565b6104da610cda565b60405161042d91906146f9565b6104826104f5366004614741565b610d2d565b60b25461043e565b610482610510366004614838565b610f3e565b61045f6105233660046148c1565b61119e565b61043e61053636600461461d565b60009081526065602052604090206001015490565b61043e7f8b5b16d04624687fcf0d0228f19993c9157c1ed07b41d8d430fd9100eb099fe881565b610482610580366004614902565b6111c2565b6040516012815260200161042d565b6104826105a2366004614902565b6111e7565b6105af611296565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161042d565b61045f6105e23660046146cd565b6112b7565b61063c6105f5366004614741565b60ad6020526000908152604090205460ff811690610100810461ffff1690630100000090047cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1683565b60408051931515845261ffff90921660208401527cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff169082015260600161042d565b610482611303565b61043e610691366004614741565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90565b61043e611338565b61043e6106cc36600461461d565b61140b565b61043e61142e565b6000546105af9073ffffffffffffffffffffffffffffffffffffffff1681565b6101145460ff1661045f565b61048261071336600461497e565b6114cf565b6104136116a1565b61043e6201518081565b61043e610738366004614902565b6116c8565b61043e61074b366004614741565b73ffffffffffffffffffffffffffffffffffffffff16600090815260b0602052604090205490565b6104826116eb565b6104826119d5565b61043e6101475481565b61045f61079b366004614902565b600091825260656020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b6104826107e13660046149ea565b611a07565b61043e6107f4366004614902565b611a57565b61048c611a7a565b61043e600081565b61045f6108173660046146cd565b611a89565b61043e6101465481565b61045f6108343660046146cd565b611b5a565b61048261084736600461461d565b611b68565b61043e61085a36600461461d565b611bb3565b61043e61086d366004614a15565b611bc0565b61043e610880366004614a15565b611bee565b61043e61089336600461461d565b611c14565b6105af6108a636600461461d565b611c21565b6104826108b9366004614a57565b611c4e565b61043e7f27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884c81565b61043e6108f3366004614741565b611fe2565b60af546109289070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1681565b6040516fffffffffffffffffffffffffffffffff909116815260200161042d565b610482610957366004614ab0565b612013565b61048261096a366004614902565b61219a565b61043e61097d366004614741565b6121bf565b61043e610990366004614ae5565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260b16020908152604080832093909416825291909152205490565b61043e60ac5481565b60af54610928906fffffffffffffffffffffffffffffffff1681565b61043e60ae5481565b6104136121ea565b6402540be40061043e565b610482610a1736600461461d565b61221e565b60408051808201909152600080825260208201526040518060400160405280610a51610a46601290565b6104a790600a614c62565b8152609754604080517f313ce567000000000000000000000000000000000000000000000000000000008152905160209384019373ffffffffffffffffffffffffffffffffffffffff9093169263313ce56792600480820193918290030181865afa158015610ac4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae89190614c71565b60ff169052919050565b6000610afc611338565b610b0461142e565b610b0e9190614c94565b905090565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b000000000000000000000000000000000000000000000000000000001480610ba657507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b610bb4612269565b7f27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884c610bde816122d9565b610be7826122e3565b5050565b606060b38054610bfa90614ca7565b80601f0160208091040260200160405190810160405280929190818152602001828054610c2690614ca7565b8015610c735780601f10610c4857610100808354040283529160200191610c73565b820191906000526020600020905b815481529060010190602001808311610c5657829003601f168201915b5050505050905090565b6000610ba6826000612383565b600033610c988185856123c7565b5060019392505050565b600080610cc661271061014754612710610cbc9190614c94565b859190600161257a565b9050610cd38160016125d5565b9392505050565b610ce261452c565b604080516102808101918290529060989060149082845b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610cf9575050505050905090565b610d35612610565b60005b6014811015610be75760988160148110610d5457610d54614cfa565b015473ffffffffffffffffffffffffffffffffffffffff90811690831603610f365773ffffffffffffffffffffffffffffffffffffffff8216600090815260ad6020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169081905560ae805461010090920461ffff16929091610ddf908490614c94565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600090815260ad6020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ff16905560988260148110610e4257610e42614cfa565b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff928316179055604051908316907f09a1db4b80c32706328728508c941a6b954f31eb5affd32f236c1fd405f8fea490600090a2610eb7612691565b610f31828373ffffffffffffffffffffffffffffffffffffffff1663357be4466040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610f08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2c9190614d29565b6127ae565b505050565b600101610d38565b6000547501000000000000000000000000000000000000000000900460ff1615808015610f89575060005460017401000000000000000000000000000000000000000090910460ff16105b80610fbb5750303b158015610fbb575060005474010000000000000000000000000000000000000000900460ff166001145b61104c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000017905580156110d257600080547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff1675010000000000000000000000000000000000000000001790555b6110dc8585612965565b6110e68383612a46565b6110ef84612afb565b600054611133907f8b5b16d04624687fcf0d0228f19993c9157c1ed07b41d8d430fd9100eb099fe89073ffffffffffffffffffffffffffffffffffffffff16612baf565b801561119757600080547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050505050565b6000336111ac858285612ca3565b6111b7858585612d7a565b506001949350505050565b6000828152606560205260409020600101546111dd816122d9565b610f318383612baf565b73ffffffffffffffffffffffffffffffffffffffff8116331461128c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401611043565b610be7828261302d565b6000610b0e60975473ffffffffffffffffffffffffffffffffffffffff1690565b33600081815260b16020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152812054909190610c9890829086906112fe908790614d42565b6123c7565b7f8b5b16d04624687fcf0d0228f19993c9157c1ed07b41d8d430fd9100eb099fe861132d816122d9565b6113356130e8565b50565b60af5460009061135e9062015180906fffffffffffffffffffffffffffffffff16614d42565b421061136a5750600090565b60af546000906201518090611391906fffffffffffffffffffffffffffffffff1642614c94565b60af546113c4919070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16614d55565b6113ce9190614dc1565b60af5490915061140590829070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff16614c94565b91505090565b600080611419836000612383565b905061142481613166565b610cd39082614c94565b60ac546097546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000929173ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa1580156114a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114c59190614d29565b610b0e9190614d42565b7f27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884c6114f9816122d9565b60005b8481101561166b57600086868381811061151857611518614cfa565b905060200201602081019061152d9190614741565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260ad602052604090205490915060ff166115635750611663565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260ad602052604081205460ae805461010090920461ffff169290916115a5908490614c94565b909155506115de90508585848181106115c0576115c0614cfa565b90506020020160208101906115d59190614dfc565b61ffff1661317d565b8484838181106115f0576115f0614cfa565b90506020020160208101906116059190614dfc565b73ffffffffffffffffffffffffffffffffffffffff909116600090815260ad60205260409020805461ffff92909216610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ff9092169190911790555b6001016114fc565b507f545a2901c84c72b5a338684cd0228cbc2663ed302c4cede1041a4cb05d4abe0b8585858560405161118e9493929190614e6d565b60408051808201909152600080825260208201526040518060400160405280610a51610af2565b60006116d2612269565b60006116dd84611c14565b9050610cd333848684613201565b7f27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884c611715816122d9565b600061171f61142e565b905061172961452c565b60005b60148110156118835760006098826014811061174a5761174a614cfa565b015473ffffffffffffffffffffffffffffffffffffffff1690508061176f5750611883565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260ad6020526040812054612710906117ac90610100900461ffff1687614d55565b6117b69190614dc1565b905060008273ffffffffffffffffffffffffffffffffffffffff1663357be4466040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611807573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182b9190614d29565b9050808210156118455761184383610f2c8484614c94565b505b8082111561186f576118578183614c94565b85856014811061186957611869614cfa565b60200201525b50505061187c8160010190565b905061172c565b5060005b60148110156119a45760008282601481106118a4576118a4614cfa565b60200201519050806000036118b9575061199c565b6097546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015261195691839173ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa15801561192d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119519190614d29565b613310565b90508060000361196657506119a4565b61199a6098836014811061197c5761197c614cfa565b015473ffffffffffffffffffffffffffffffffffffffff1682613326565b505b600101611887565b5060405133907fa61bd16ebda9d1c8ec2a61970b39e6640e55ed8433a22765a1b5217b72c4a81290600090a2505050565b7f8b5b16d04624687fcf0d0228f19993c9157c1ed07b41d8d430fd9100eb099fe86119ff816122d9565b61133561348c565b611a0f612610565b611a1c609882601461454b565b507fc90c5dd90d97be559acbfb4e6798e48198fe77071c419afcaa6bd25f4d3d2ef581604051611a4c9190614ecb565b60405180910390a150565b6000611a61612269565b6000611a6c84611bb3565b9050610cd333848387613201565b606060b48054610bfa90614ca7565b33600081815260b16020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015611b4d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401611043565b6111b782868684036123c7565b600033610c98818585612d7a565b611b70612610565b6101475460408051918252602082018390527f28a572c8c759d40c2d26dcdaaefd9650e9e37ff11ee147ce0f645cd7664048cb910160405180910390a161014755565b6000610ba6826001612383565b6000611bca612269565b6000611bd78560016125d5565b9050611be633858588856134e8565b949350505050565b6000611bf8612269565b6000611c05856000612383565b9050611be633858584896134e8565b6000610ba68260006125d5565b60988160148110611c3157600080fd5b015473ffffffffffffffffffffffffffffffffffffffff16905081565b7f27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884c611c78816122d9565b60af54611c9b9062015180906fffffffffffffffffffffffffffffffff16614d42565b421015611d04576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f42563a2070726f66697420756e6c6f636b696e670000000000000000000000006044820152606401611043565b60ac54806000805b85811015611f0e576000878783818110611d2857611d28614cfa565b9050602002016020810190611d3d9190614741565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260ad602052604090205490915060ff16611d735750611f06565b73ffffffffffffffffffffffffffffffffffffffff8116600081815260ad602090815260408083205481517f357be446000000000000000000000000000000000000000000000000000000008152915163010000009091047cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16949263357be4469260048082019391829003018187875af1158015611e13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e379190614d29565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260ad6020526040902080547cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80841663010000000262ffffff909216919091179091559091508216611ea28288614d42565b611eac9190614c94565b9550817cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff168111611edb576000611efe565b817cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1681035b850194505050505b600101611d0c565b5080611f18611338565b611f229190614d42565b60af80546fffffffffffffffffffffffffffffffff92831670010000000000000000000000000000000002921691909117905560ac829055611f626136cf565b60af80547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016426fffffffffffffffffffffffffffffffff1617905560405133907f69e9c71f6799744a94d9897e77c3ed426cc2f92ba0ef3300785368209b6f4b2d90611fd29089908990614f14565b60405180910390a2505050505050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260b06020526040812054610ba6906000612383565b61201b612610565b6120288161ffff1661317d565b60408051606081018252600180825261ffff8481166020808501918252600085870181815273ffffffffffffffffffffffffffffffffffffffff8a16825260ad9092529590952093518454915195517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000009092169015157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ff161761010095909216949094021762ffffff1663010000007cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909416939093029290921790558290609890612112906014614f28565b60ff166014811061212557612125614cfa565b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff928316179055604051908316907f3f008fd510eae7a9e7bee13513d7b83bef8003d488b5a3d0b0da4de71d6846f190600090a2610be7612691565b6000828152606560205260409020600101546121b5816122d9565b610f31838361302d565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260b06020526040812054610ba6565b6040805180820190915260008082526020820152604051806040016040528061221260b25490565b81526020016012610ae8565b612226612610565b6101465460408051918252602082018390527f4e874b007ab14f7e263baefd44951834c8266f4f224d1092e49e9c254354cc54910160405180910390a161014655565b6101145460ff16156122d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401611043565b565b6113358133613769565b60005b6014811015610be75760006098826014811061230457612304614cfa565b015473ffffffffffffffffffffffffffffffffffffffff1690508061232857505050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260ad602052604090205461237a9082906127109061236b90610100900461ffff1687614d55565b6123759190614dc1565b613326565b506001016122e6565b6000806402540be40060b2546123999190614d42565b905060006123a5610af2565b6123b0906001614d42565b90506123be8582848761257a565b95945050505050565b73ffffffffffffffffffffffffffffffffffffffff8316612469576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff821661250c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff838116600081815260b1602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60008061258886868661383b565b9050600183600281111561259e5761259e614f41565b1480156125bb5750600084806125b6576125b6614d92565b868809115b156123be576125cb600182614d42565b9695505050505050565b6000806402540be40060b2546125eb9190614d42565b905060006125f7610af2565b612602906001614d42565b90506123be8583838761257a565b60005473ffffffffffffffffffffffffffffffffffffffff1633146122d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f4f6e6c7920476f7665726e616e63652e000000000000000000000000000000006044820152606401611043565b6000805b6014811015610be7576000609882601481106126b3576126b3614cfa565b015473ffffffffffffffffffffffffffffffffffffffff169050806126e4576126dd600184614d42565b92506127a5565b82156127a5578060986126f78585614c94565b6014811061270757612707614cfa565b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905560006098836014811061276057612760614cfa565b0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff929092169190911790555b50600101612695565b6000806127bb8484613908565b73ffffffffffffffffffffffffffffffffffffffff8516600081815260ad602090815260408083205481517f357be4460000000000000000000000000000000000000000000000000000000081529151959650630100000090047cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff169492939263357be44692600480840193919291829003018187875af1158015612861573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128859190614d29565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260ad60205260409020805462ffffff1663010000007cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84160217905590508082116128ea5760006128f4565b6128f48183614c94565b60ac60008282546129059190614c94565b9091555050604080518681526020810185905273ffffffffffffffffffffffffffffffffffffffff8816917f88f0c01d2402991a2098e1cf989cb2c54cefe3b20ccb83c55989866f419a6ff5910160405180910390a25090949350505050565b600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff858116918217845560978054909316908516179091556129c29190612baf565b600054612a06907f27e3e4d29d60af3ae6456513164bb5db737d6fc8610aa36ad458736c9efb884c9073ffffffffffffffffffffffffffffffffffffffff16612baf565b505060af80547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016426fffffffffffffffffffffffffffffffff16179055565b6000547501000000000000000000000000000000000000000000900460ff16612af1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611043565b610be782826139c5565b6000547501000000000000000000000000000000000000000000900460ff16612ba6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611043565b61133581613a89565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610be757600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055612c453390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b73ffffffffffffffffffffffffffffffffffffffff838116600090815260b160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114612d745781811015612d67576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401611043565b612d7484848484036123c7565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316612e1d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff8216612ec0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260b0602052604090205481811015612f76576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260b06020526040808220858503905591851681529081208054849290612fba908490614d42565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161302091815260200190565b60405180910390a3612d74565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615610be757600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6130f0613b7b565b61011480547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b61014754600090610ba6908390612710600161257a565b60008160ae5461318d9190614d42565b90506127108111156131fb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f42563a20746f6f206d616e7920627073000000000000000000000000000000006044820152606401611043565b60ae5550565b6000811161326b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f5661756c743a207a65726f2073686172657300000000000000000000000000006044820152606401611043565b6132758382613be8565b60975461329a9073ffffffffffffffffffffffffffffffffffffffff16853085613d08565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d78484604051613302929190918252602082015260400190565b60405180910390a350505050565b600081831061331f5781610cd3565b5090919050565b80600003613332575050565b8060ac60008282546133449190614d42565b909155505073ffffffffffffffffffffffffffffffffffffffff808316600090815260ad6020526040902080547cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6301000000808304821686019091160262ffffff9091161790556097546133b891168383613dc7565b6040517f2afcf4800000000000000000000000000000000000000000000000000000000081526004810182905273ffffffffffffffffffffffffffffffffffffffff831690632afcf48090602401600060405180830381600087803b15801561342057600080fd5b505af1158015613434573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff167fc6f6f91a48277d76f232cc08a9a30f6b05b3fd9b92c3180c25936e17a22a10258260405161348091815260200190565b60405180910390a25050565b613494612269565b61011480547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861313c3390565b6134f182613e80565b506097546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015261358c9173ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015613562573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135869190614d29565b83613310565b9150600061359983613166565b905060006135a78285614c94565b90508473ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff16146135e7576135e7858885612ca3565b6135f18584614043565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db8787604051613670929190918252602082015260400190565b60405180910390a460975461369c9073ffffffffffffffffffffffffffffffffffffffff168783614230565b6000546097546136c69173ffffffffffffffffffffffffffffffffffffffff918216911684614230565b50505050505050565b60af546000906136f1906fffffffffffffffffffffffffffffffff1642614c94565b905060006301e1338061014654836137099190614d55565b6137139190614dc1565b9050600061271061372360b25490565b61372d9084614d55565b6137379190614dc1565b90508060000361374657505050565b600054610f319073ffffffffffffffffffffffffffffffffffffffff1682613be8565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610be7576137c18173ffffffffffffffffffffffffffffffffffffffff1660146142e9565b6137cc8360206142e9565b6040516020016137dd929190614f70565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526110439160040161465a565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff858709858702925082811083820303915050806000036138935783828161388957613889614d92565b0492505050610cd3565b80841161389f57600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b6040517f8ca179950000000000000000000000000000000000000000000000000000000081526004810182905260009073ffffffffffffffffffffffffffffffffffffffff841690638ca17995906024016020604051808303816000875af19250505080156139b2575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526139af91810190614d29565b60015b6139be57506000610ba6565b9050610ba6565b6000547501000000000000000000000000000000000000000000900460ff16613a70576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611043565b60b3613a7c838261503f565b5060b4610f31828261503f565b6000547501000000000000000000000000000000000000000000900460ff16613b34576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611043565b60e280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6101145460ff166122d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401611043565b73ffffffffffffffffffffffffffffffffffffffff8216613c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401611043565b8060b26000828254613c779190614d42565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600090815260b0602052604081208054839290613cb1908490614d42565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b60006040517f23b872dd0000000000000000000000000000000000000000000000000000000081528460048201528360248201528260448201526020600060648360008a5af13d15601f3d1160016000511416171691505080611197576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c45440000000000000000000000006044820152606401611043565b60006040517f095ea7b3000000000000000000000000000000000000000000000000000000008152836004820152826024820152602060006044836000895af13d15601f3d1160016000511416171691505080612d74576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f415050524f56455f4641494c45440000000000000000000000000000000000006044820152606401611043565b60008060005b601481101561400357600060988260148110613ea457613ea4614cfa565b015473ffffffffffffffffffffffffffffffffffffffff16905080613ec95750614003565b6097546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009173ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015613f38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f5c9190614d29565b9050858110613f6c575050614003565b6000613f788288614c94565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260ad6020526040902054909150613fd2908290630100000090047cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16613310565b90506000613fe084836127ae565b9050613fec8187614d42565b955050505050613ffc8160010190565b9050613e86565b5060408051848152602081018390527fd2f6618ba448f8b76ee0e823f8bb8c568b748f1687e1bc6bd625306fc4fb5035910160405180910390a192915050565b73ffffffffffffffffffffffffffffffffffffffff82166140e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260b060205260409020548181101561419c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401611043565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260b060205260408120838303905560b280548492906141d8908490614c94565b909155505060405182815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b60006040517fa9059cbb000000000000000000000000000000000000000000000000000000008152836004820152826024820152602060006044836000895af13d15601f3d1160016000511416171691505080612d74576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5452414e534645525f4641494c454400000000000000000000000000000000006044820152606401611043565b606060006142f8836002614d55565b614303906002614d42565b67ffffffffffffffff81111561431b5761431b61475e565b6040519080825280601f01601f191660200182016040528015614345576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061437c5761437c614cfa565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106143df576143df614cfa565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600061441b846002614d55565b614426906001614d42565b90505b60018111156144c3577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061446757614467614cfa565b1a60f81b82828151811061447d5761447d614cfa565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c936144bc81615159565b9050614429565b508315610cd3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401611043565b6040518061028001604052806014906020820280368337509192915050565b82601481019282156145b6579160200282015b828111156145b65781547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84351617825560209092019160019091019061455e565b506145c29291506145c6565b5090565b5b808211156145c257600081556001016145c7565b6000602082840312156145ed57600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610cd357600080fd5b60006020828403121561462f57600080fd5b5035919050565b60005b83811015614651578181015183820152602001614639565b50506000910152565b6020815260008251806020840152614679816040850160208701614636565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b73ffffffffffffffffffffffffffffffffffffffff8116811461133557600080fd5b600080604083850312156146e057600080fd5b82356146eb816146ab565b946020939093013593505050565b6102808101818360005b601481101561473857815173ffffffffffffffffffffffffffffffffffffffff16835260209283019290910190600101614703565b50505092915050565b60006020828403121561475357600080fd5b8135610cd3816146ab565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261479e57600080fd5b813567ffffffffffffffff808211156147b9576147b961475e565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156147ff576147ff61475e565b8160405283815286602085880101111561481857600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561484e57600080fd5b8435614859816146ab565b93506020850135614869816146ab565b9250604085013567ffffffffffffffff8082111561488657600080fd5b6148928883890161478d565b935060608701359150808211156148a857600080fd5b506148b58782880161478d565b91505092959194509250565b6000806000606084860312156148d657600080fd5b83356148e1816146ab565b925060208401356148f1816146ab565b929592945050506040919091013590565b6000806040838503121561491557600080fd5b823591506020830135614927816146ab565b809150509250929050565b60008083601f84011261494457600080fd5b50813567ffffffffffffffff81111561495c57600080fd5b6020830191508360208260051b850101111561497757600080fd5b9250929050565b6000806000806040858703121561499457600080fd5b843567ffffffffffffffff808211156149ac57600080fd5b6149b888838901614932565b909650945060208701359150808211156149d157600080fd5b506149de87828801614932565b95989497509550505050565b60006102808083850312156149fe57600080fd5b838184011115614a0d57600080fd5b509092915050565b600080600060608486031215614a2a57600080fd5b833592506020840135614a3c816146ab565b91506040840135614a4c816146ab565b809150509250925092565b60008060208385031215614a6a57600080fd5b823567ffffffffffffffff811115614a8157600080fd5b614a8d85828601614932565b90969095509350505050565b803561ffff81168114614aab57600080fd5b919050565b60008060408385031215614ac357600080fd5b8235614ace816146ab565b9150614adc60208401614a99565b90509250929050565b60008060408385031215614af857600080fd5b8235614b03816146ab565b91506020830135614927816146ab565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600181815b80851115614b9b57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115614b8157614b81614b13565b80851615614b8e57918102915b93841c9390800290614b47565b509250929050565b600082614bb257506001610ba6565b81614bbf57506000610ba6565b8160018114614bd55760028114614bdf57614bfb565b6001915050610ba6565b60ff841115614bf057614bf0614b13565b50506001821b610ba6565b5060208310610133831016604e8410600b8410161715614c1e575081810a610ba6565b614c288383614b42565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115614c5a57614c5a614b13565b029392505050565b6000610cd360ff841683614ba3565b600060208284031215614c8357600080fd5b815160ff81168114610cd357600080fd5b81810381811115610ba657610ba6614b13565b600181811c90821680614cbb57607f821691505b602082108103614cf4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215614d3b57600080fd5b5051919050565b80820180821115610ba657610ba6614b13565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614d8d57614d8d614b13565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082614df7577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600060208284031215614e0e57600080fd5b610cd382614a99565b8183526000602080850194508260005b85811015614e62578135614e3a816146ab565b73ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101614e27565b509495945050505050565b604081526000614e81604083018688614e17565b8281036020848101919091528482528591810160005b86811015614ebe5761ffff614eab85614a99565b1682529282019290820190600101614e97565b5098975050505050505050565b6102808101818360005b6014811015614738578135614ee9816146ab565b73ffffffffffffffffffffffffffffffffffffffff1683526020928301929190910190600101614ed5565b602081526000611be6602083018486614e17565b60ff8281168282160390811115610ba657610ba6614b13565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351614fa8816017850160208801614636565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351614fe5816028840160208801614636565b01602801949350505050565b601f821115610f3157600081815260208120601f850160051c810160208610156150185750805b601f850160051c820191505b8181101561503757828155600101615024565b505050505050565b815167ffffffffffffffff8111156150595761505961475e565b61506d816150678454614ca7565b84614ff1565b602080601f8311600181146150c0576000841561508a5750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555615037565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b8281101561510d578886015182559484019460019091019084016150ee565b508582101561514957878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b60008161516857615168614b13565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea2646970667358221220b135383a4edbe5586100627257c0ae8509380f5dd897abe5da0edcb43d0bafc264736f6c63430008100033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.