Contract Overview
Balance:
0 MATIC
MATIC Value:
$0.00
My Name Tag:
Not Available, login to update
Txn Hash |
Method
|
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x3edf84aa206146551362ddbb251620b7370cdeca6bebaa2e7b1b23bd477ad25e | 0x60806040 | 31243878 | 245 days 16 hrs ago | 0x07883ebd6f178420f24969279bd425ab0b99f10b | IN | Contract Creation | 0 MATIC | 0.201100648975 |
[ Download CSV Export ]
Similar Match Source Code
Note: This contract matches the deployed ByteCode of the Source Code for Contract 0xb346B250a4C75bB0EdC80E6B7baAcEBD9626dF8A
Contract Name:
MellowVault
Compiler Version
v0.8.9+commit.e5eed63a
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @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 v4.4.0 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/Clones.sol) pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. * * _Available since v3.4._ */ library Clones { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create2(0, ptr, 0x37, salt) } require(instance != address(0), "ERC1167: create2 failed"); } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt, address deployer ) internal pure returns (address predicted) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000) mstore(add(ptr, 0x38), shl(0x60, deployer)) mstore(add(ptr, 0x4c), salt) mstore(add(ptr, 0x6c), keccak256(ptr, 0x37)) predicted := keccak256(add(ptr, 0x37), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.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 ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (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 IERC165 { /** * @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 pragma solidity 0.8.9; import "./utils/IDefaultAccessControl.sol"; import "./IUnitPricesGovernance.sol"; interface IProtocolGovernance is IDefaultAccessControl, IUnitPricesGovernance { /// @notice CommonLibrary protocol params. /// @param maxTokensPerVault Max different token addresses that could be managed by the vault /// @param governanceDelay The delay (in secs) that must pass before setting new pending params to commiting them /// @param protocolTreasury The address that collects protocolFees, if protocolFee is not zero /// @param forceAllowMask If a permission bit is set in this mask it forces all addresses to have this permission as true /// @param withdrawLimit Withdraw limit (in unit prices, i.e. usd) struct Params { uint256 maxTokensPerVault; uint256 governanceDelay; address protocolTreasury; uint256 forceAllowMask; uint256 withdrawLimit; } // ------------------- EXTERNAL, VIEW ------------------- /// @notice Timestamp after which staged granted permissions for the given address can be committed. /// @param target The given address /// @return Zero if there are no staged permission grants, timestamp otherwise function stagedPermissionGrantsTimestamps(address target) external view returns (uint256); /// @notice Staged granted permission bitmask for the given address. /// @param target The given address /// @return Bitmask function stagedPermissionGrantsMasks(address target) external view returns (uint256); /// @notice Permission bitmask for the given address. /// @param target The given address /// @return Bitmask function permissionMasks(address target) external view returns (uint256); /// @notice Timestamp after which staged pending protocol parameters can be committed /// @return Zero if there are no staged parameters, timestamp otherwise. function stagedParamsTimestamp() external view returns (uint256); /// @notice Staged pending protocol parameters. function stagedParams() external view returns (Params memory); /// @notice Current protocol parameters. function params() external view returns (Params memory); /// @notice Addresses for which non-zero permissions are set. function permissionAddresses() external view returns (address[] memory); /// @notice Permission addresses staged for commit. function stagedPermissionGrantsAddresses() external view returns (address[] memory); /// @notice Return all addresses where rawPermissionMask bit for permissionId is set to 1. /// @param permissionId Id of the permission to check. /// @return A list of dirty addresses. function addressesByPermission(uint8 permissionId) external view returns (address[] memory); /// @notice Checks if address has permission or given permission is force allowed for any address. /// @param addr Address to check /// @param permissionId Permission to check function hasPermission(address addr, uint8 permissionId) external view returns (bool); /// @notice Checks if address has all permissions. /// @param target Address to check /// @param permissionIds A list of permissions to check function hasAllPermissions(address target, uint8[] calldata permissionIds) external view returns (bool); /// @notice Max different ERC20 token addresses that could be managed by the protocol. function maxTokensPerVault() external view returns (uint256); /// @notice The delay for committing any governance params. function governanceDelay() external view returns (uint256); /// @notice The address of the protocol treasury. function protocolTreasury() external view returns (address); /// @notice Permissions mask which defines if ordinary permission should be reverted. /// This bitmask is xored with ordinary mask. function forceAllowMask() external view returns (uint256); /// @notice Withdraw limit per token per block. /// @param token Address of the token /// @return Withdraw limit per token per block function withdrawLimit(address token) external view returns (uint256); /// @notice Addresses that has staged validators. function stagedValidatorsAddresses() external view returns (address[] memory); /// @notice Timestamp after which staged granted permissions for the given address can be committed. /// @param target The given address /// @return Zero if there are no staged permission grants, timestamp otherwise function stagedValidatorsTimestamps(address target) external view returns (uint256); /// @notice Staged validator for the given address. /// @param target The given address /// @return Validator function stagedValidators(address target) external view returns (address); /// @notice Addresses that has validators. function validatorsAddresses() external view returns (address[] memory); /// @notice Address that has validators. /// @param i The number of address /// @return Validator address function validatorsAddress(uint256 i) external view returns (address); /// @notice Validator for the given address. /// @param target The given address /// @return Validator function validators(address target) external view returns (address); // ------------------- EXTERNAL, MUTATING, GOVERNANCE, IMMEDIATE ------------------- /// @notice Rollback all staged validators. function rollbackStagedValidators() external; /// @notice Revoke validator instantly from the given address. /// @param target The given address function revokeValidator(address target) external; /// @notice Stages a new validator for the given address /// @param target The given address /// @param validator The validator for the given address function stageValidator(address target, address validator) external; /// @notice Commits validator for the given address. /// @dev Reverts if governance delay has not passed yet. /// @param target The given address. function commitValidator(address target) external; /// @notice Commites all staged validators for which governance delay passed /// @return Addresses for which validators were committed function commitAllValidatorsSurpassedDelay() external returns (address[] memory); /// @notice Rollback all staged granted permission grant. function rollbackStagedPermissionGrants() external; /// @notice Commits permission grants for the given address. /// @dev Reverts if governance delay has not passed yet. /// @param target The given address. function commitPermissionGrants(address target) external; /// @notice Commites all staged permission grants for which governance delay passed. /// @return An array of addresses for which permission grants were committed. function commitAllPermissionGrantsSurpassedDelay() external returns (address[] memory); /// @notice Revoke permission instantly from the given address. /// @param target The given address. /// @param permissionIds A list of permission ids to revoke. function revokePermissions(address target, uint8[] memory permissionIds) external; /// @notice Commits staged protocol params. /// Reverts if governance delay has not passed yet. function commitParams() external; // ------------------- EXTERNAL, MUTATING, GOVERNANCE, DELAY ------------------- /// @notice Sets new pending params that could have been committed after governance delay expires. /// @param newParams New protocol parameters to set. function stageParams(Params memory newParams) external; /// @notice Stage granted permissions that could have been committed after governance delay expires. /// Resets commit delay and permissions if there are already staged permissions for this address. /// @param target Target address /// @param permissionIds A list of permission ids to grant function stagePermissionGrants(address target, uint8[] memory permissionIds) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import "./utils/IDefaultAccessControl.sol"; interface IUnitPricesGovernance is IDefaultAccessControl, IERC165 { // ------------------- EXTERNAL, VIEW ------------------- /// @notice Estimated amount of token worth 1 USD staged for commit. /// @param token Address of the token /// @return The amount of token function stagedUnitPrices(address token) external view returns (uint256); /// @notice Timestamp after which staged unit prices for the given token can be committed. /// @param token Address of the token /// @return Timestamp function stagedUnitPricesTimestamps(address token) external view returns (uint256); /// @notice Estimated amount of token worth 1 USD. /// @param token Address of the token /// @return The amount of token function unitPrices(address token) external view returns (uint256); // ------------------- EXTERNAL, MUTATING ------------------- /// @notice Stage estimated amount of token worth 1 USD staged for commit. /// @param token Address of the token /// @param value The amount of token function stageUnitPrice(address token, uint256 value) external; /// @notice Reset staged value /// @param token Address of the token function rollbackUnitPrice(address token) external; /// @notice Commit staged unit price /// @param token Address of the token function commitUnitPrice(address token) external; }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "./IProtocolGovernance.sol"; interface IVaultRegistry is IERC721 { /// @notice Get Vault for the giver NFT ID. /// @param nftId NFT ID /// @return vault Address of the Vault contract function vaultForNft(uint256 nftId) external view returns (address vault); /// @notice Get NFT ID for given Vault contract address. /// @param vault Address of the Vault contract /// @return nftId NFT ID function nftForVault(address vault) external view returns (uint256 nftId); /// @notice Checks if the nft is locked for all transfers /// @param nft NFT to check for lock /// @return `true` if locked, false otherwise function isLocked(uint256 nft) external view returns (bool); /// @notice Register new Vault and mint NFT. /// @param vault address of the vault /// @param owner owner of the NFT /// @return nft Nft minted for the given Vault function registerVault(address vault, address owner) external returns (uint256 nft); /// @notice Number of Vaults registered. function vaultsCount() external view returns (uint256); /// @notice All Vaults registered. function vaults() external view returns (address[] memory); /// @notice Address of the ProtocolGovernance. function protocolGovernance() external view returns (IProtocolGovernance); /// @notice Address of the staged ProtocolGovernance. function stagedProtocolGovernance() external view returns (IProtocolGovernance); /// @notice Minimal timestamp when staged ProtocolGovernance can be applied. function stagedProtocolGovernanceTimestamp() external view returns (uint256); /// @notice Stage new ProtocolGovernance. /// @param newProtocolGovernance new ProtocolGovernance function stageProtocolGovernance(IProtocolGovernance newProtocolGovernance) external; /// @notice Commit new ProtocolGovernance. function commitStagedProtocolGovernance() external; /// @notice Lock NFT for transfers /// @dev Use this method when vault structure is set up and should become immutable. Can be called by owner. /// @param nft - NFT to lock function lockNft(uint256 nft) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.9; library DataTypes { // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; } struct ReserveConfigurationMap { //bit 0-15: LTV //bit 16-31: Liq. threshold //bit 32-47: Liq. bonus //bit 48-55: Decimals //bit 56: Reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled //bit 59: stable rate borrowing enabled //bit 60-63: reserved //bit 64-79: reserve factor uint256 data; } struct UserConfigurationMap { uint256 data; } enum InterestRateMode { NONE, STABLE, VARIABLE } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.9; pragma experimental ABIEncoderV2; import {ILendingPoolAddressesProvider} from "./ILendingPoolAddressesProvider.sol"; import {DataTypes} from "./DataTypes.sol"; interface ILendingPool { /** * @dev Emitted on deposit() * @param reserve The address of the underlying asset of the reserve * @param user The address initiating the deposit * @param onBehalfOf The beneficiary of the deposit, receiving the aTokens * @param amount The amount deposited * @param referral The referral code used **/ event Deposit( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint16 indexed referral ); /** * @dev Emitted on withdraw() * @param reserve The address of the underlyng asset being withdrawn * @param user The address initiating the withdrawal, owner of aTokens * @param to Address that will receive the underlying * @param amount The amount to be withdrawn **/ event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount); /** * @dev Emitted on borrow() and flashLoan() when debt needs to be opened * @param reserve The address of the underlying asset being borrowed * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just * initiator of the transaction on flashLoan() * @param onBehalfOf The address that will be getting the debt * @param amount The amount borrowed out * @param borrowRateMode The rate mode: 1 for Stable, 2 for Variable * @param borrowRate The numeric rate at which the user has borrowed * @param referral The referral code used **/ event Borrow( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint256 borrowRateMode, uint256 borrowRate, uint16 indexed referral ); /** * @dev Emitted on repay() * @param reserve The address of the underlying asset of the reserve * @param user The beneficiary of the repayment, getting his debt reduced * @param repayer The address of the user initiating the repay(), providing the funds * @param amount The amount repaid **/ event Repay(address indexed reserve, address indexed user, address indexed repayer, uint256 amount); /** * @dev Emitted on swapBorrowRateMode() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user swapping his rate mode * @param rateMode The rate mode that the user wants to swap to **/ event Swap(address indexed reserve, address indexed user, uint256 rateMode); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral **/ event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral **/ event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); /** * @dev Emitted on rebalanceStableBorrowRate() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user for which the rebalance has been executed **/ event RebalanceStableBorrowRate(address indexed reserve, address indexed user); /** * @dev Emitted on flashLoan() * @param target The address of the flash loan receiver contract * @param initiator The address initiating the flash loan * @param asset The address of the asset being flash borrowed * @param amount The amount flash borrowed * @param premium The fee flash borrowed * @param referralCode The referral code used **/ event FlashLoan( address indexed target, address indexed initiator, address indexed asset, uint256 amount, uint256 premium, uint16 referralCode ); /** * @dev Emitted when the pause is triggered. */ event Paused(); /** * @dev Emitted when the pause is lifted. */ event Unpaused(); /** * @dev Emitted when a borrower is liquidated. This event is emitted by the LendingPool via * LendingPoolCollateral manager using a DELEGATECALL * This allows to have the events in the generated ABI for LendingPool. * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param liquidatedCollateralAmount The amount of collateral received by the liiquidator * @param liquidator The address of the liquidator * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly **/ event LiquidationCall( address indexed collateralAsset, address indexed debtAsset, address indexed user, uint256 debtToCover, uint256 liquidatedCollateralAmount, address liquidator, bool receiveAToken ); /** * @dev Emitted when the state of a reserve is updated. NOTE: This event is actually declared * in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal, * the event will actually be fired by the LendingPool contract. The event is therefore replicated here so it * gets added to the LendingPool ABI * @param reserve The address of the underlying asset of the reserve * @param liquidityRate The new liquidity rate * @param stableBorrowRate The new stable borrow rate * @param variableBorrowRate The new variable borrow rate * @param liquidityIndex The new liquidity index * @param variableBorrowIndex The new variable borrow index **/ event ReserveDataUpdated( address indexed reserve, uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex ); /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function deposit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to ) external returns (uint256); /** * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower * already deposited enough collateral, or he was given enough allowance by a credit delegator on the * corresponding debt token (StableDebtToken or VariableDebtToken) * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet * and 100 stable/variable debt tokens, depending on the `interestRateMode` * @param asset The address of the underlying asset to borrow * @param amount The amount to be borrowed * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man * @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator * if he has been given credit delegation allowance **/ function borrow( address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf ) external; /** * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` * @param rateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed * @return The final amount repaid **/ function repay( address asset, uint256 amount, uint256 rateMode, address onBehalfOf ) external returns (uint256); /** * @dev Allows a borrower to swap his debt between stable and variable mode, or viceversa * @param asset The address of the underlying asset borrowed * @param rateMode The rate mode that the user wants to swap to **/ function swapBorrowRateMode(address asset, uint256 rateMode) external; /** * @dev Rebalances the stable interest rate of a user to the current stable rate defined on the reserve. * - Users can be rebalanced if the following conditions are satisfied: * 1. Usage ratio is above 95% * 2. the current deposit APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too much has been * borrowed at a stable rate and depositors are not earning enough * @param asset The address of the underlying asset borrowed * @param user The address of the user to be rebalanced **/ function rebalanceStableBorrowRate(address asset, address user) external; /** * @dev Allows depositors to enable/disable a specific deposited asset as collateral * @param asset The address of the underlying asset deposited * @param useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise **/ function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external; /** * @dev Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1 * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly **/ function liquidationCall( address collateralAsset, address debtAsset, address user, uint256 debtToCover, bool receiveAToken ) external; /** * @dev Allows smartcontracts to access the liquidity of the pool within one transaction, * as long as the amount taken plus a fee is returned. * IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration. * For further details please visit https://developers.aave.com * @param receiverAddress The address of the contract receiving the funds, implementing the IFlashLoanReceiver interface * @param assets The addresses of the assets being flash-borrowed * @param amounts The amounts amounts being flash-borrowed * @param modes Types of the debt to open if the flash loan is not returned: * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2 * @param params Variadic packed params to pass to the receiver as extra information * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function flashLoan( address receiverAddress, address[] calldata assets, uint256[] calldata amounts, uint256[] calldata modes, address onBehalfOf, bytes calldata params, uint16 referralCode ) external; /** * @dev Returns the user account data across all the reserves * @param user The address of the user * @return totalCollateralETH the total collateral in ETH of the user * @return totalDebtETH the total debt in ETH of the user * @return availableBorrowsETH the borrowing power left of the user * @return currentLiquidationThreshold the liquidation threshold of the user * @return ltv the loan to value of the user * @return healthFactor the current health factor of the user **/ function getUserAccountData(address user) external view returns ( uint256 totalCollateralETH, uint256 totalDebtETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor ); function initReserve( address reserve, address aTokenAddress, address stableDebtAddress, address variableDebtAddress, address interestRateStrategyAddress ) external; function setReserveInterestRateStrategyAddress(address reserve, address rateStrategyAddress) external; function setConfiguration(address reserve, uint256 configuration) external; /** * @dev Returns the configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The configuration of the reserve **/ function getConfiguration(address asset) external view returns (DataTypes.ReserveConfigurationMap memory); /** * @dev Returns the configuration of the user across all the reserves * @param user The user address * @return The configuration of the user **/ function getUserConfiguration(address user) external view returns (DataTypes.UserConfigurationMap memory); /** * @dev Returns the normalized income normalized income of the reserve * @param asset The address of the underlying asset of the reserve * @return The reserve's normalized income */ function getReserveNormalizedIncome(address asset) external view returns (uint256); /** * @dev Returns the normalized variable debt per unit of asset * @param asset The address of the underlying asset of the reserve * @return The reserve normalized variable debt */ function getReserveNormalizedVariableDebt(address asset) external view returns (uint256); /** * @dev Returns the state and configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The state of the reserve **/ function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); function finalizeTransfer( address asset, address from, address to, uint256 amount, uint256 balanceFromAfter, uint256 balanceToBefore ) external; function getReservesList() external view returns (address[] memory); function getAddressesProvider() external view returns (ILendingPoolAddressesProvider); function setPause(bool val) external; function paused() external view returns (bool); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.9; /** * @title LendingPoolAddressesProvider contract * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles * - Acting also as factory of proxies and admin of those, so with right to change its implementations * - Owned by the Aave Governance * @author Aave **/ interface ILendingPoolAddressesProvider { event MarketIdSet(string newMarketId); event LendingPoolUpdated(address indexed newAddress); event ConfigurationAdminUpdated(address indexed newAddress); event EmergencyAdminUpdated(address indexed newAddress); event LendingPoolConfiguratorUpdated(address indexed newAddress); event LendingPoolCollateralManagerUpdated(address indexed newAddress); event PriceOracleUpdated(address indexed newAddress); event LendingRateOracleUpdated(address indexed newAddress); event ProxyCreated(bytes32 id, address indexed newAddress); event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy); function getMarketId() external view returns (string memory); function setMarketId(string calldata marketId) external; function setAddress(bytes32 id, address newAddress) external; function setAddressAsProxy(bytes32 id, address impl) external; function getAddress(bytes32 id) external view returns (address); function getLendingPool() external view returns (address); function setLendingPoolImpl(address pool) external; function getLendingPoolConfigurator() external view returns (address); function setLendingPoolConfiguratorImpl(address configurator) external; function getLendingPoolCollateralManager() external view returns (address); function setLendingPoolCollateralManager(address manager) external; function getPoolAdmin() external view returns (address); function setPoolAdmin(address admin) external; function getEmergencyAdmin() external view returns (address); function setEmergencyAdmin(address admin) external; function getPriceOracle() external view returns (address); function setPriceOracle(address priceOracle) external; function getLendingRateOracle() external view returns (address); function setLendingRateOracle(address lendingRateOracle) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; interface IERC1271 { /// @notice Verifies offchain signature. /// @dev Should return whether the signature provided is valid for the provided hash /// /// MUST return the bytes4 magic value 0x1626ba7e when function passes. /// /// MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5) /// /// MUST allow external calls /// @param _hash Hash of the data to be signed /// @param _signature Signature byte array associated with _hash /// @return magicValue 0x1626ba7e if valid, 0xffffffff otherwise function isValidSignature(bytes32 _hash, bytes memory _signature) external view returns (bytes4 magicValue); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; interface IOracle { /// @notice Oracle price for tokens as a Q64.96 value. /// @notice Returns pricing information based on the indexes of non-zero bits in safetyIndicesSet. /// @notice It is possible that not all indices will have their respective prices returned. /// @dev The price is token1 / token0 i.e. how many weis of token1 required for 1 wei of token0. /// The safety indexes are: /// /// 1 - unsafe, this is typically a spot price that can be easily manipulated, /// /// 2 - 4 - more or less safe, this is typically a uniV3 oracle, where the safety is defined by the timespan of the average price /// /// 5 - safe - this is typically a chailink oracle /// @param token0 Reference to token0 /// @param token1 Reference to token1 /// @param safetyIndicesSet Bitmask of safety indices that are allowed for the return prices. For set of safety indexes = { 1 }, safetyIndicesSet = 0x2 /// @return pricesX96 Prices that satisfy safetyIndex and tokens /// @return safetyIndices Safety indices for those prices function priceX96( address token0, address token1, uint256 safetyIndicesSet ) external view returns (uint256[] memory pricesX96, uint256[] memory safetyIndices); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "@openzeppelin/contracts/access/IAccessControlEnumerable.sol"; interface IDefaultAccessControl is IAccessControlEnumerable { /// @notice Checks that the address is contract admin. /// @param who Address to check /// @return `true` if who is admin, `false` otherwise function isAdmin(address who) external view returns (bool); /// @notice Checks that the address is contract admin. /// @param who Address to check /// @return `true` if who is operator, `false` otherwise function isOperator(address who) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../oracles/IOracle.sol"; interface IERC20RootVaultHelper { function getTvlToken0( uint256[] calldata tvls, address[] calldata tokens, IOracle oracle ) external view returns (uint256 tvl0); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../IProtocolGovernance.sol"; interface IBaseValidator { /// @notice Validator parameters /// @param protocolGovernance Reference to Protocol Governance struct ValidatorParams { IProtocolGovernance protocolGovernance; } /// @notice Validator params staged to commit. function stagedValidatorParams() external view returns (ValidatorParams memory); /// @notice Timestamp after which validator params can be committed. function stagedValidatorParamsTimestamp() external view returns (uint256); /// @notice Current validator params. function validatorParams() external view returns (ValidatorParams memory); /// @notice Stage new validator params for commit. /// @param newParams New params for commit function stageValidatorParams(ValidatorParams calldata newParams) external; /// @notice Commit new validator params. function commitValidatorParams() external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import "./IBaseValidator.sol"; interface IValidator is IBaseValidator, IERC165 { // @notice Validate if call can be made to external contract. // @dev Reverts if validation failed. Returns nothing if validation is ok // @param sender Sender of the externalCall method // @param addr Address of the called contract // @param value Ether value for the call // @param selector Selector of the called method // @param data Call data after selector function validate( address sender, address addr, uint256 value, bytes4 selector, bytes calldata data ) external view; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "./IVault.sol"; import "./IVaultRoot.sol"; interface IAggregateVault is IVault, IVaultRoot {}
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./IAggregateVault.sol"; import "../utils/IERC20RootVaultHelper.sol"; interface IERC20RootVault is IAggregateVault, IERC20 { /// @notice Initialized a new contract. /// @dev Can only be initialized by vault governance /// @param nft_ NFT of the vault in the VaultRegistry /// @param vaultTokens_ ERC20 tokens that will be managed by this Vault /// @param strategy_ The address that will have approvals for subvaultNfts /// @param subvaultNfts_ The NFTs of the subvaults that will be aggregated by this ERC20RootVault function initialize( uint256 nft_, address[] memory vaultTokens_, address strategy_, uint256[] memory subvaultNfts_, IERC20RootVaultHelper helper_ ) external; /// @notice The timestamp of last charging of fees function lastFeeCharge() external view returns (uint64); /// @notice The timestamp of last updating totalWithdrawnAmounts array function totalWithdrawnAmountsTimestamp() external view returns (uint64); /// @notice Returns value from totalWithdrawnAmounts array by _index /// @param _index The index at which the value will be returned function totalWithdrawnAmounts(uint256 _index) external view returns (uint256); /// @notice LP parameter that controls the charge in performance fees function lpPriceHighWaterMarkD18() external view returns (uint256); /// @notice List of addresses of depositors from which interaction with private vaults is allowed function depositorsAllowlist() external view returns (address[] memory); /// @notice Add new depositors in the depositorsAllowlist /// @param depositors Array of new depositors /// @dev The action can be done only by user with admins, owners or by approved rights function addDepositorsToAllowlist(address[] calldata depositors) external; /// @notice Remove depositors from the depositorsAllowlist /// @param depositors Array of depositors for remove /// @dev The action can be done only by user with admins, owners or by approved rights function removeDepositorsFromAllowlist(address[] calldata depositors) external; /// @notice The function of depositing the amount of tokens in exchange /// @param tokenAmounts Array of amounts of tokens for deposit /// @param minLpTokens Minimal value of LP tokens /// @param vaultOptions Options of vaults /// @return actualTokenAmounts Arrays of actual token amounts after deposit function deposit( uint256[] memory tokenAmounts, uint256 minLpTokens, bytes memory vaultOptions ) external returns (uint256[] memory actualTokenAmounts); /// @notice The function of withdrawing the amount of tokens in exchange /// @param to Address to which the withdrawal will be sent /// @param lpTokenAmount LP token amount, that requested for withdraw /// @param minTokenAmounts Array of minmal remining wtoken amounts after withdrawal /// @param vaultsOptions Options of vaults /// @return actualTokenAmounts Arrays of actual token amounts after withdrawal function withdraw( address to, uint256 lpTokenAmount, uint256[] memory minTokenAmounts, bytes[] memory vaultsOptions ) external returns (uint256[] memory actualTokenAmounts); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../external/erc/IERC1271.sol"; import "./IVault.sol"; interface IIntegrationVault is IVault, IERC1271 { /// @notice Pushes tokens on the vault balance to the underlying protocol. For example, for Yearn this operation will take USDC from /// the contract balance and convert it to yUSDC. /// @dev Tokens **must** be a subset of Vault Tokens. However, the convention is that if tokenAmount == 0 it is the same as token is missing. /// /// Also notice that this operation doesn't guarantee that tokenAmounts will be invested in full. /// @param tokens Tokens to push /// @param tokenAmounts Amounts of tokens to push /// @param options Additional options that could be needed for some vaults. E.g. for Uniswap this could be `deadline` param. For the exact bytes structure see concrete vault descriptions /// @return actualTokenAmounts The amounts actually invested. It could be less than tokenAmounts (but not higher) function push( address[] memory tokens, uint256[] memory tokenAmounts, bytes memory options ) external returns (uint256[] memory actualTokenAmounts); /// @notice The same as `push` method above but transfers tokens to vault balance prior to calling push. /// After the `push` it returns all the leftover tokens back (`push` method doesn't guarantee that tokenAmounts will be invested in full). /// @param tokens Tokens to push /// @param tokenAmounts Amounts of tokens to push /// @param options Additional options that could be needed for some vaults. E.g. for Uniswap this could be `deadline` param. For the exact bytes structure see concrete vault descriptions /// @return actualTokenAmounts The amounts actually invested. It could be less than tokenAmounts (but not higher) function transferAndPush( address from, address[] memory tokens, uint256[] memory tokenAmounts, bytes memory options ) external returns (uint256[] memory actualTokenAmounts); /// @notice Pulls tokens from the underlying protocol to the `to` address. /// @dev Can only be called but Vault Owner or Strategy. Vault owner is the owner of NFT for this vault in VaultManager. /// Strategy is approved address for the vault NFT. /// When called by vault owner this method just pulls the tokens from the protocol to the `to` address /// When called by strategy on vault other than zero vault it pulls the tokens to zero vault (required `to` == zero vault) /// When called by strategy on zero vault it pulls the tokens to zero vault, pushes tokens on the `to` vault, and reclaims everything that's left. /// Thus any vault other than zero vault cannot have any tokens on it /// /// Tokens **must** be a subset of Vault Tokens. However, the convention is that if tokenAmount == 0 it is the same as token is missing. /// /// Pull is fulfilled on the best effort basis, i.e. if the tokenAmounts overflows available funds it withdraws all the funds. /// @param to Address to receive the tokens /// @param tokens Tokens to pull /// @param tokenAmounts Amounts of tokens to pull /// @param options Additional options that could be needed for some vaults. E.g. for Uniswap this could be `deadline` param. For the exact bytes structure see concrete vault descriptions /// @return actualTokenAmounts The amounts actually withdrawn. It could be less than tokenAmounts (but not higher) function pull( address to, address[] memory tokens, uint256[] memory tokenAmounts, bytes memory options ) external returns (uint256[] memory actualTokenAmounts); /// @notice Claim ERC20 tokens from vault balance to zero vault. /// @dev Cannot be called from zero vault. /// @param tokens Tokens to claim /// @return actualTokenAmounts Amounts reclaimed function reclaimTokens(address[] memory tokens) external returns (uint256[] memory actualTokenAmounts); /// @notice Execute one of whitelisted calls. /// @dev Can only be called by Vault Owner or Strategy. Vault owner is the owner of NFT for this vault in VaultManager. /// Strategy is approved address for the vault NFT. /// /// Since this method allows sending arbitrary transactions, the destinations of the calls /// are whitelisted by Protocol Governance. /// @param to Address of the reward pool /// @param selector Selector of the call /// @param data Abi encoded parameters to `to::selector` /// @return result Result of execution of the call function externalCall( address to, bytes4 selector, bytes memory data ) external payable returns (bytes memory result); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../external/aave/ILendingPool.sol"; import "./IERC20RootVault.sol"; import "./IIntegrationVault.sol"; interface IMellowVault is IIntegrationVault { /// @notice Reference to mellow root vault function vault() external view returns (IERC20RootVault); /// @notice Initialized a new contract. /// @dev Can only be initialized by vault governance /// @param nft_ NFT of the vault in the VaultRegistry /// @param vaultTokens_ ERC20 tokens that will be managed by this Vault /// @param rootVault_ Reference to mellow root vault function initialize( uint256 nft_, address[] memory vaultTokens_, IERC20RootVault rootVault_ ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "./IVaultGovernance.sol"; interface IVault is IERC165 { /// @notice Checks if the vault is initialized function initialized() external view returns (bool); /// @notice VaultRegistry NFT for this vault function nft() external view returns (uint256); /// @notice Address of the Vault Governance for this contract. function vaultGovernance() external view returns (IVaultGovernance); /// @notice ERC20 tokens under Vault management. function vaultTokens() external view returns (address[] memory); /// @notice Checks if a token is vault token /// @param token Address of the token to check /// @return `true` if this token is managed by Vault function isVaultToken(address token) external view returns (bool); /// @notice Total value locked for this contract. /// @dev Generally it is the underlying token value of this contract in some /// other DeFi protocol. For example, for USDC Yearn Vault this would be total USDC balance that could be withdrawn for Yearn to this contract. /// The tvl itself is estimated in some range. Sometimes the range is exact, sometimes it's not /// @return minTokenAmounts Lower bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens) /// @return maxTokenAmounts Upper bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens) function tvl() external view returns (uint256[] memory minTokenAmounts, uint256[] memory maxTokenAmounts); /// @notice Existential amounts for each token function pullExistentials() external view returns (uint256[] memory); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../IProtocolGovernance.sol"; import "../IVaultRegistry.sol"; import "./IVault.sol"; interface IVaultGovernance { /// @notice Internal references of the contract. /// @param protocolGovernance Reference to Protocol Governance /// @param registry Reference to Vault Registry struct InternalParams { IProtocolGovernance protocolGovernance; IVaultRegistry registry; IVault singleton; } // ------------------- EXTERNAL, VIEW ------------------- /// @notice Timestamp in unix time seconds after which staged Delayed Strategy Params could be committed. /// @param nft Nft of the vault function delayedStrategyParamsTimestamp(uint256 nft) external view returns (uint256); /// @notice Timestamp in unix time seconds after which staged Delayed Protocol Params could be committed. function delayedProtocolParamsTimestamp() external view returns (uint256); /// @notice Timestamp in unix time seconds after which staged Delayed Protocol Params Per Vault could be committed. /// @param nft Nft of the vault function delayedProtocolPerVaultParamsTimestamp(uint256 nft) external view returns (uint256); /// @notice Timestamp in unix time seconds after which staged Internal Params could be committed. function internalParamsTimestamp() external view returns (uint256); /// @notice Internal Params of the contract. function internalParams() external view returns (InternalParams memory); /// @notice Staged new Internal Params. /// @dev The Internal Params could be committed after internalParamsTimestamp function stagedInternalParams() external view returns (InternalParams memory); // ------------------- EXTERNAL, MUTATING ------------------- /// @notice Stage new Internal Params. /// @param newParams New Internal Params function stageInternalParams(InternalParams memory newParams) external; /// @notice Commit staged Internal Params. function commitInternalParams() external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; interface IVaultRoot { /// @notice Checks if subvault is present /// @param nft_ index of subvault for check /// @return `true` if subvault present, `false` otherwise function hasSubvault(uint256 nft_) external view returns (bool); /// @notice Get subvault by index /// @param index Index of subvault /// @return address Address of the contract function subvaultAt(uint256 index) external view returns (address); /// @notice Get index of subvault by nft /// @param nft_ Nft for getting subvault /// @return index Index of subvault function subvaultOneBasedIndex(uint256 nft_) external view returns (uint256); /// @notice Get all subvalutNfts in the current Vault /// @return subvaultNfts Subvaults of NTFs function subvaultNfts() external view returns (uint256[] memory); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "./external/FullMath.sol"; import "./ExceptionsLibrary.sol"; /// @notice CommonLibrary shared utilities library CommonLibrary { uint256 constant DENOMINATOR = 10**9; uint256 constant D18 = 10**18; uint256 constant YEAR = 365 * 24 * 3600; uint256 constant Q128 = 2**128; uint256 constant Q96 = 2**96; uint256 constant Q48 = 2**48; uint256 constant Q160 = 2**160; uint256 constant UNI_FEE_DENOMINATOR = 10**6; /// @notice Sort uint256 using bubble sort. The sorting is done in-place. /// @param arr Array of uint256 function sortUint(uint256[] memory arr) internal pure { uint256 l = arr.length; for (uint256 i = 0; i < l; ++i) { for (uint256 j = i + 1; j < l; ++j) { if (arr[i] > arr[j]) { uint256 temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } } /// @notice Checks if array of addresses is sorted and all adresses are unique /// @param tokens A set of addresses to check /// @return `true` if all addresses are sorted and unique, `false` otherwise function isSortedAndUnique(address[] memory tokens) internal pure returns (bool) { if (tokens.length < 2) { return true; } for (uint256 i = 0; i < tokens.length - 1; ++i) { if (tokens[i] >= tokens[i + 1]) { return false; } } return true; } /// @notice Projects tokenAmounts onto subset or superset of tokens /// @dev /// Requires both sets of tokens to be sorted. When tokens are not sorted, it's undefined behavior. /// If there is a token in tokensToProject that is not part of tokens and corresponding tokenAmountsToProject > 0, reverts. /// Zero token amount is eqiuvalent to missing token function projectTokenAmounts( address[] memory tokens, address[] memory tokensToProject, uint256[] memory tokenAmountsToProject ) internal pure returns (uint256[] memory) { uint256[] memory res = new uint256[](tokens.length); uint256 t = 0; uint256 tp = 0; while ((t < tokens.length) && (tp < tokensToProject.length)) { if (tokens[t] < tokensToProject[tp]) { res[t] = 0; t++; } else if (tokens[t] > tokensToProject[tp]) { if (tokenAmountsToProject[tp] == 0) { tp++; } else { revert("TPS"); } } else { res[t] = tokenAmountsToProject[tp]; t++; tp++; } } while (t < tokens.length) { res[t] = 0; t++; } return res; } /// @notice Calculated sqrt of uint in X96 format /// @param xX96 input number in X96 format /// @return sqrt of xX96 in X96 format function sqrtX96(uint256 xX96) internal pure returns (uint256) { uint256 sqX96 = sqrt(xX96); return sqX96 << 48; } /// @notice Calculated sqrt of uint /// @param x input number /// @return sqrt of x function sqrt(uint256 x) internal pure returns (uint256) { if (x == 0) return 0; uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; uint256 r1 = x / r; return (r < r1 ? r : r1); } /// @notice Recovers signer address from signed message hash /// @param _ethSignedMessageHash signed message /// @param _signature contatenated ECDSA r, s, v (65 bytes) /// @return Recovered address if the signature is valid, address(0) otherwise function recoverSigner(bytes32 _ethSignedMessageHash, bytes memory _signature) internal pure returns (address) { (bytes32 r, bytes32 s, uint8 v) = splitSignature(_signature); return ecrecover(_ethSignedMessageHash, v, r, s); } /// @notice Get ECDSA r, s, v from signature /// @param sig signature (65 bytes) /// @return r ECDSA r /// @return s ECDSA s /// @return v ECDSA v function splitSignature(bytes memory sig) internal pure returns ( bytes32 r, bytes32 s, uint8 v ) { require(sig.length == 65, ExceptionsLibrary.INVALID_LENGTH); assembly { r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; /// @notice Exceptions stores project`s smart-contracts exceptions library ExceptionsLibrary { string constant ADDRESS_ZERO = "AZ"; string constant VALUE_ZERO = "VZ"; string constant EMPTY_LIST = "EMPL"; string constant NOT_FOUND = "NF"; string constant INIT = "INIT"; string constant DUPLICATE = "DUP"; string constant NULL = "NULL"; string constant TIMESTAMP = "TS"; string constant FORBIDDEN = "FRB"; string constant ALLOWLIST = "ALL"; string constant LIMIT_OVERFLOW = "LIMO"; string constant LIMIT_UNDERFLOW = "LIMU"; string constant INVALID_VALUE = "INV"; string constant INVARIANT = "INVA"; string constant INVALID_TARGET = "INVTR"; string constant INVALID_TOKEN = "INVTO"; string constant INVALID_INTERFACE = "INVI"; string constant INVALID_SELECTOR = "INVS"; string constant INVALID_STATE = "INVST"; string constant INVALID_LENGTH = "INVL"; string constant LOCK = "LCKD"; string constant DISABLED = "DIS"; }
//SPDX-License-Identifier: MIT pragma solidity 0.8.9; /// @notice Stores permission ids for addresses library PermissionIdsLibrary { // The msg.sender is allowed to register vault uint8 constant REGISTER_VAULT = 0; // The msg.sender is allowed to create vaults uint8 constant CREATE_VAULT = 1; // The token is allowed to be transfered by vault uint8 constant ERC20_TRANSFER = 2; // The token is allowed to be added to vault uint8 constant ERC20_VAULT_TOKEN = 3; // Trusted protocols that are allowed to be approved of vault ERC20 tokens by any strategy uint8 constant ERC20_APPROVE = 4; // Trusted protocols that are allowed to be approved of vault ERC20 tokens by trusted strategy uint8 constant ERC20_APPROVE_RESTRICTED = 5; // Strategy allowed using restricted API uint8 constant TRUSTED_STRATEGY = 6; }
// SPDX-License-Identifier: MIT pragma solidity =0.8.9; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { // diff: original lib works under 0.7.6 with overflows enabled unchecked { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then 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(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // 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] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. // diff: original uint256 twos = -denominator & denominator; uint256 twos = uint256(-int256(denominator)) & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } 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 // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use 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. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // 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 precoditions 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 * inv; return result; } } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { // diff: original lib works under 0.7.6 with overflows enabled unchecked { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } } }
// SPDX-License-Identifier: BSL-1.1 pragma solidity 0.8.9; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "../interfaces/external/erc/IERC1271.sol"; import "../interfaces/vaults/IVaultRoot.sol"; import "../interfaces/vaults/IIntegrationVault.sol"; import "../interfaces/validators/IValidator.sol"; import "../libraries/CommonLibrary.sol"; import "../libraries/ExceptionsLibrary.sol"; import "../libraries/PermissionIdsLibrary.sol"; import "./VaultGovernance.sol"; import "./Vault.sol"; /// @notice Abstract contract that has logic common for every Vault. /// @dev Notes: /// ### ERC-721 /// /// Each Vault should be registered in VaultRegistry and get corresponding VaultRegistry NFT. /// /// ### Access control /// /// `push` and `pull` methods are only allowed for owner / approved person of the NFT. However, /// `pull` for approved person also checks that pull destination is another vault of the Vault System. /// /// The semantics is: NFT owner owns all Vault liquidity, Approved person is liquidity manager. /// ApprovedForAll person cannot do anything except ERC-721 token transfers. /// /// Both NFT owner and approved person can call externalCall method which claims liquidity mining rewards (if any) /// /// `reclaimTokens` for claiming rewards given by an underlying protocol to erc20Vault in order to sell them there abstract contract IntegrationVault is IIntegrationVault, ReentrancyGuard, Vault { using SafeERC20 for IERC20; // ------------------- EXTERNAL, VIEW ------------------- /// @inheritdoc IERC165 function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, Vault) returns (bool) { return super.supportsInterface(interfaceId) || (interfaceId == type(IIntegrationVault).interfaceId) || (interfaceId == type(IERC1271).interfaceId); } // ------------------- EXTERNAL, MUTATING ------------------- /// @inheritdoc IIntegrationVault function push( address[] memory tokens, uint256[] memory tokenAmounts, bytes memory options ) public nonReentrant returns (uint256[] memory actualTokenAmounts) { uint256 nft_ = _nft; require(nft_ != 0, ExceptionsLibrary.INIT); IVaultRegistry vaultRegistry = _vaultGovernance.internalParams().registry; IVault ownerVault = IVault(vaultRegistry.ownerOf(nft_)); // Also checks that the token exists uint256 ownerNft = vaultRegistry.nftForVault(address(ownerVault)); require(ownerNft != 0, ExceptionsLibrary.NOT_FOUND); // require deposits only through Vault uint256[] memory pTokenAmounts = _validateAndProjectTokens(tokens, tokenAmounts); uint256[] memory pActualTokenAmounts = _push(pTokenAmounts, options); actualTokenAmounts = CommonLibrary.projectTokenAmounts(tokens, _vaultTokens, pActualTokenAmounts); emit Push(pActualTokenAmounts); } /// @inheritdoc IIntegrationVault function transferAndPush( address from, address[] memory tokens, uint256[] memory tokenAmounts, bytes memory options ) external returns (uint256[] memory actualTokenAmounts) { uint256 len = tokens.length; for (uint256 i = 0; i < len; ++i) if (tokenAmounts[i] != 0) { IERC20(tokens[i]).safeTransferFrom(from, address(this), tokenAmounts[i]); } actualTokenAmounts = push(tokens, tokenAmounts, options); for (uint256 i = 0; i < tokens.length; ++i) { uint256 leftover = actualTokenAmounts[i] < tokenAmounts[i] ? tokenAmounts[i] - actualTokenAmounts[i] : 0; if (leftover != 0) IERC20(tokens[i]).safeTransfer(from, leftover); } } /// @inheritdoc IIntegrationVault function pull( address to, address[] memory tokens, uint256[] memory tokenAmounts, bytes memory options ) external nonReentrant returns (uint256[] memory actualTokenAmounts) { uint256 nft_ = _nft; require(nft_ != 0, ExceptionsLibrary.INIT); require(_isApprovedOrOwner(msg.sender), ExceptionsLibrary.FORBIDDEN); // Also checks that the token exists IVaultRegistry registry = _vaultGovernance.internalParams().registry; address owner = registry.ownerOf(nft_); IVaultRoot root = _root(registry, nft_, owner); if (owner != msg.sender) { address zeroVault = root.subvaultAt(0); if (zeroVault == address(this)) { // If we pull from zero vault require( root.hasSubvault(registry.nftForVault(to)) && to != address(this), ExceptionsLibrary.INVALID_TARGET ); } else { // If we pull from other vault require(zeroVault == to, ExceptionsLibrary.INVALID_TARGET); } } uint256[] memory pTokenAmounts = _validateAndProjectTokens(tokens, tokenAmounts); uint256[] memory pActualTokenAmounts = _pull(to, pTokenAmounts, options); actualTokenAmounts = CommonLibrary.projectTokenAmounts(tokens, _vaultTokens, pActualTokenAmounts); emit Pull(to, actualTokenAmounts); } /// @inheritdoc IIntegrationVault function reclaimTokens(address[] memory tokens) external virtual nonReentrant returns (uint256[] memory actualTokenAmounts) { uint256 nft_ = _nft; require(nft_ != 0, ExceptionsLibrary.INIT); IVaultGovernance.InternalParams memory params = _vaultGovernance.internalParams(); IProtocolGovernance governance = params.protocolGovernance; IVaultRegistry registry = params.registry; address owner = registry.ownerOf(nft_); address to = _root(registry, nft_, owner).subvaultAt(0); actualTokenAmounts = new uint256[](tokens.length); if (to == address(this)) { return actualTokenAmounts; } for (uint256 i = 0; i < tokens.length; ++i) { if ( _isReclaimForbidden(tokens[i]) || !governance.hasPermission(tokens[i], PermissionIdsLibrary.ERC20_TRANSFER) ) { continue; } IERC20 token = IERC20(tokens[i]); actualTokenAmounts[i] = token.balanceOf(address(this)); token.safeTransfer(to, actualTokenAmounts[i]); } emit ReclaimTokens(to, tokens, actualTokenAmounts); } /// @inheritdoc IERC1271 function isValidSignature(bytes32 _hash, bytes memory _signature) external view returns (bytes4 magicValue) { IVaultGovernance.InternalParams memory params = _vaultGovernance.internalParams(); IVaultRegistry registry = params.registry; IProtocolGovernance protocolGovernance = params.protocolGovernance; uint256 nft_ = _nft; if (nft_ == 0) { return 0xffffffff; } address strategy = registry.getApproved(nft_); if (!protocolGovernance.hasPermission(strategy, PermissionIdsLibrary.TRUSTED_STRATEGY)) { return 0xffffffff; } uint32 size; assembly { size := extcodesize(strategy) } if (size > 0) { if (IERC165(strategy).supportsInterface(type(IERC1271).interfaceId)) { return IERC1271(strategy).isValidSignature(_hash, _signature); } else { return 0xffffffff; } } if (CommonLibrary.recoverSigner(_hash, _signature) == strategy) { return 0x1626ba7e; } return 0xffffffff; } /// @inheritdoc IIntegrationVault function externalCall( address to, bytes4 selector, bytes calldata data ) external payable nonReentrant returns (bytes memory result) { require(_nft != 0, ExceptionsLibrary.INIT); require(_isApprovedOrOwner(msg.sender), ExceptionsLibrary.FORBIDDEN); IProtocolGovernance protocolGovernance = _vaultGovernance.internalParams().protocolGovernance; IValidator validator = IValidator(protocolGovernance.validators(to)); require(address(validator) != address(0), ExceptionsLibrary.FORBIDDEN); validator.validate(msg.sender, to, msg.value, selector, data); (bool res, bytes memory returndata) = to.call{value: msg.value}(abi.encodePacked(selector, data)); if (!res) { assembly { let returndata_size := mload(returndata) // Bubble up revert reason revert(add(32, returndata), returndata_size) } } result = returndata; } // ------------------- INTERNAL, VIEW ------------------- function _validateAndProjectTokens(address[] memory tokens, uint256[] memory tokenAmounts) internal view returns (uint256[] memory pTokenAmounts) { require(CommonLibrary.isSortedAndUnique(tokens), ExceptionsLibrary.INVARIANT); require(tokens.length == tokenAmounts.length, ExceptionsLibrary.INVALID_VALUE); pTokenAmounts = CommonLibrary.projectTokenAmounts(_vaultTokens, tokens, tokenAmounts); } function _root( IVaultRegistry registry, uint256 thisNft, address thisOwner ) internal view returns (IVaultRoot) { uint256 thisOwnerNft = registry.nftForVault(thisOwner); require((thisNft != 0) && (thisOwnerNft != 0), ExceptionsLibrary.INIT); return IVaultRoot(thisOwner); } function _isApprovedOrOwner(address sender) internal view returns (bool) { IVaultRegistry registry = _vaultGovernance.internalParams().registry; uint256 nft_ = _nft; if (nft_ == 0) { return false; } return registry.getApproved(nft_) == sender || registry.ownerOf(nft_) == sender; } /// @notice check if token is forbidden to transfer under reclaim /// @dev it is done in order to prevent reclaiming internal protocol tokens /// for example to prevent YEarn tokens to reclaimed /// if our vault is managing tokens, depositing it in YEarn /// @param token The address of token to check /// @return if token is forbidden function _isReclaimForbidden(address token) internal view virtual returns (bool); // ------------------- INTERNAL, MUTATING ------------------- /// Guaranteed to have exact signature matchinn vault tokens function _push(uint256[] memory tokenAmounts, bytes memory options) internal virtual returns (uint256[] memory actualTokenAmounts); /// Guaranteed to have exact signature matchinn vault tokens function _pull( address to, uint256[] memory tokenAmounts, bytes memory options ) internal virtual returns (uint256[] memory actualTokenAmounts); // -------------------------- EVENTS -------------------------- /// @notice Emitted on successful push /// @param tokenAmounts The amounts of tokens to pushed event Push(uint256[] tokenAmounts); /// @notice Emitted on successful pull /// @param to The target address for pulled tokens /// @param tokenAmounts The amounts of tokens to pull event Pull(address to, uint256[] tokenAmounts); /// @notice Emitted when tokens are reclaimed /// @param to The target address for pulled tokens /// @param tokens ERC20 tokens to be reclaimed /// @param tokenAmounts The amounts of reclaims event ReclaimTokens(address to, address[] tokens, uint256[] tokenAmounts); }
// SPDX-License-Identifier: BSL-1.1 pragma solidity =0.8.9; import "../interfaces/IProtocolGovernance.sol"; import "../interfaces/vaults/IMellowVault.sol"; import "../interfaces/vaults/IERC20RootVault.sol"; import "../libraries/ExceptionsLibrary.sol"; import "./IntegrationVault.sol"; /// @notice Vault that stores ERC20 tokens. contract MellowVault is IMellowVault, IntegrationVault { using SafeERC20 for IERC20; /// @inheritdoc IMellowVault IERC20RootVault public vault; // ------------------- EXTERNAL, VIEW ------------------- /// @inheritdoc IVault function tvl() public view returns (uint256[] memory minTokenAmounts, uint256[] memory maxTokenAmounts) { IERC20RootVault vault_ = vault; uint256 balance = vault_.balanceOf(address(this)); uint256 supply = vault_.totalSupply(); (minTokenAmounts, maxTokenAmounts) = vault_.tvl(); for (uint256 i = 0; i < minTokenAmounts.length; i++) { minTokenAmounts[i] = FullMath.mulDiv(balance, minTokenAmounts[i], supply); maxTokenAmounts[i] = FullMath.mulDiv(balance, maxTokenAmounts[i], supply); } } // ------------------- EXTERNAL, MUTATING ------------------- /// @inheritdoc IMellowVault function initialize( uint256 nft_, address[] memory vaultTokens_, IERC20RootVault vault_ ) external { _initialize(vaultTokens_, nft_); address[] memory mTokens = vault_.vaultTokens(); for (uint256 i = 0; i < vaultTokens_.length; i++) { require(mTokens[i] == vaultTokens_[i], ExceptionsLibrary.INVALID_TOKEN); } IVaultRegistry registry = _vaultGovernance.internalParams().registry; require(registry.nftForVault(address(vault)) > 0, ExceptionsLibrary.INVALID_INTERFACE); vault = vault_; } // ------------------- INTERNAL, VIEW ----------------------- function _isReclaimForbidden(address token) internal view override returns (bool) { address[] memory mTokens = vault.vaultTokens(); for (uint256 i = 0; i < mTokens.length; ++i) { if (mTokens[i] == token) { return true; } } return false; } // ------------------- INTERNAL, MUTATING ------------------- function _push(uint256[] memory tokenAmounts, bytes memory options) internal override returns (uint256[] memory actualTokenAmounts) { uint256 minLpTokens; assembly { minLpTokens := mload(add(options, 0x20)) } for (uint256 i = 0; i < tokenAmounts.length; i++) { IERC20(_vaultTokens[i]).safeIncreaseAllowance(address(vault), tokenAmounts[i]); } actualTokenAmounts = vault.deposit(tokenAmounts, minLpTokens, ""); for (uint256 i = 0; i < tokenAmounts.length; i++) { IERC20(_vaultTokens[i]).safeApprove(address(vault), 0); } } function _pull( address to, uint256[] memory tokenAmounts, bytes memory options ) internal override returns (uint256[] memory actualTokenAmounts) { IERC20RootVault vault_ = vault; uint256[] memory minTokenAmounts = abi.decode(options, (uint256[])); (uint256[] memory minTvl, ) = tvl(); uint256 totalLpTokens = vault.balanceOf(address(this)); uint256 lpTokenAmount = type(uint256).max; for (uint256 i = 0; i < tokenAmounts.length; i++) { uint256 newAmount = FullMath.mulDiv(totalLpTokens, tokenAmounts[i], minTvl[i]); if (newAmount < lpTokenAmount) { lpTokenAmount = newAmount; } } if (lpTokenAmount > totalLpTokens) { lpTokenAmount = totalLpTokens; } bytes[] memory emptyOptions = new bytes[](vault.subvaultNfts().length); for (uint256 i = 0; i < emptyOptions.length; ++i) { emptyOptions[i] = ""; } actualTokenAmounts = vault_.withdraw(to, lpTokenAmount, minTokenAmounts, emptyOptions); } }
// SPDX-License-Identifier: BSL-1.1 pragma solidity 0.8.9; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "../libraries/CommonLibrary.sol"; import "../libraries/ExceptionsLibrary.sol"; import "../interfaces/vaults/IVault.sol"; import "./VaultGovernance.sol"; /// @notice Abstract contract that has logic common for every Vault. /// @dev Notes: /// ### ERC-721 /// /// Each Vault should be registered in VaultRegistry and get corresponding VaultRegistry NFT. /// /// ### Access control /// /// `push` and `pull` methods are only allowed for owner / approved person of the NFT. However, /// `pull` for approved person also checks that pull destination is another vault of the Vault System. /// /// The semantics is: NFT owner owns all Vault liquidity, Approved person is liquidity manager. /// ApprovedForAll person cannot do anything except ERC-721 token transfers. /// /// Both NFT owner and approved person can call externalCall method which claims liquidity mining rewards (if any) /// /// `reclaimTokens` for mistakenly transfered tokens (not included into vaultTokens) additionally can be withdrawn by /// the protocol admin abstract contract Vault is IVault, ERC165 { using SafeERC20 for IERC20; IVaultGovernance internal _vaultGovernance; address[] internal _vaultTokens; mapping(address => int256) internal _vaultTokensIndex; uint256 internal _nft; uint256[] internal _pullExistentials; constructor() { // lock initialization and thus all mutations for any deployed Vault _nft = type(uint256).max; } // ------------------- EXTERNAL, VIEW ------------------- /// @inheritdoc IVault function initialized() external view returns (bool) { return _nft != 0; } /// @inheritdoc IVault function isVaultToken(address token) public view returns (bool) { return _vaultTokensIndex[token] != 0; } /// @inheritdoc IVault function vaultGovernance() external view returns (IVaultGovernance) { return _vaultGovernance; } /// @inheritdoc IVault function vaultTokens() external view returns (address[] memory) { return _vaultTokens; } /// @inheritdoc IVault function nft() external view returns (uint256) { return _nft; } /// @inheritdoc IVault function tvl() public view virtual returns (uint256[] memory minTokenAmounts, uint256[] memory maxTokenAmounts); /// @inheritdoc IVault function pullExistentials() external view returns (uint256[] memory) { return _pullExistentials; } /// @inheritdoc IERC165 function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) { return super.supportsInterface(interfaceId) || (interfaceId == type(IVault).interfaceId); } // ------------------- INTERNAL, MUTATING ------------------- function _initialize(address[] memory vaultTokens_, uint256 nft_) internal virtual { require(_nft == 0, ExceptionsLibrary.INIT); require(CommonLibrary.isSortedAndUnique(vaultTokens_), ExceptionsLibrary.INVARIANT); require(nft_ != 0, ExceptionsLibrary.VALUE_ZERO); // guarantees that this method can only be called once IProtocolGovernance governance = IVaultGovernance(msg.sender).internalParams().protocolGovernance; require( vaultTokens_.length > 0 && vaultTokens_.length <= governance.maxTokensPerVault(), ExceptionsLibrary.INVALID_VALUE ); for (uint256 i = 0; i < vaultTokens_.length; i++) { require( governance.hasPermission(vaultTokens_[i], PermissionIdsLibrary.ERC20_VAULT_TOKEN), ExceptionsLibrary.FORBIDDEN ); } _vaultGovernance = IVaultGovernance(msg.sender); _vaultTokens = vaultTokens_; _nft = nft_; uint256 len = _vaultTokens.length; for (uint256 i = 0; i < len; ++i) { _vaultTokensIndex[vaultTokens_[i]] = int256(i + 1); IERC20Metadata token = IERC20Metadata(vaultTokens_[i]); _pullExistentials.push(10**(token.decimals() / 2)); } emit Initialized(tx.origin, msg.sender, vaultTokens_, nft_); } // -------------------------- EVENTS -------------------------- /// @notice Emitted when Vault is intialized /// @param origin Origin of the transaction (tx.origin) /// @param sender Sender of the call (msg.sender) /// @param vaultTokens_ ERC20 tokens under the vault management /// @param nft_ VaultRegistry NFT assigned to the vault event Initialized(address indexed origin, address indexed sender, address[] vaultTokens_, uint256 nft_); }
// SPDX-License-Identifier: BSL-1.1 pragma solidity 0.8.9; import "@openzeppelin/contracts/proxy/Clones.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "../interfaces/IProtocolGovernance.sol"; import "../interfaces/vaults/IVaultGovernance.sol"; import "../libraries/ExceptionsLibrary.sol"; import "../libraries/PermissionIdsLibrary.sol"; /// @notice Internal contract for managing different params. /// @dev The contract should be overriden by the concrete VaultGovernance, /// define different params structs and use abi.decode / abi.encode to serialize /// to bytes in this contract. It also should emit events on params change. abstract contract VaultGovernance is IVaultGovernance, ERC165 { InternalParams internal _internalParams; InternalParams private _stagedInternalParams; uint256 internal _internalParamsTimestamp; mapping(uint256 => bytes) internal _delayedStrategyParams; mapping(uint256 => bytes) internal _stagedDelayedStrategyParams; mapping(uint256 => uint256) internal _delayedStrategyParamsTimestamp; mapping(uint256 => bytes) internal _delayedProtocolPerVaultParams; mapping(uint256 => bytes) internal _stagedDelayedProtocolPerVaultParams; mapping(uint256 => uint256) internal _delayedProtocolPerVaultParamsTimestamp; bytes internal _delayedProtocolParams; bytes internal _stagedDelayedProtocolParams; uint256 internal _delayedProtocolParamsTimestamp; mapping(uint256 => bytes) internal _strategyParams; bytes internal _protocolParams; bytes internal _operatorParams; /// @notice Creates a new contract. /// @param internalParams_ Initial Internal Params constructor(InternalParams memory internalParams_) { require(address(internalParams_.protocolGovernance) != address(0), ExceptionsLibrary.ADDRESS_ZERO); require(address(internalParams_.registry) != address(0), ExceptionsLibrary.ADDRESS_ZERO); require(address(internalParams_.singleton) != address(0), ExceptionsLibrary.ADDRESS_ZERO); _internalParams = internalParams_; } // ------------------- EXTERNAL, VIEW ------------------- /// @inheritdoc IVaultGovernance function delayedStrategyParamsTimestamp(uint256 nft) external view returns (uint256) { return _delayedStrategyParamsTimestamp[nft]; } /// @inheritdoc IVaultGovernance function delayedProtocolPerVaultParamsTimestamp(uint256 nft) external view returns (uint256) { return _delayedProtocolPerVaultParamsTimestamp[nft]; } /// @inheritdoc IVaultGovernance function delayedProtocolParamsTimestamp() external view returns (uint256) { return _delayedProtocolParamsTimestamp; } /// @inheritdoc IVaultGovernance function internalParamsTimestamp() external view returns (uint256) { return _internalParamsTimestamp; } /// @inheritdoc IVaultGovernance function internalParams() external view returns (InternalParams memory) { return _internalParams; } /// @inheritdoc IVaultGovernance function stagedInternalParams() external view returns (InternalParams memory) { return _stagedInternalParams; } function supportsInterface(bytes4 interfaceID) public view virtual override(ERC165) returns (bool) { return super.supportsInterface(interfaceID) || interfaceID == type(IVaultGovernance).interfaceId; } // ------------------- EXTERNAL, MUTATING ------------------- /// @inheritdoc IVaultGovernance function stageInternalParams(InternalParams memory newParams) external { _requireProtocolAdmin(); require(address(newParams.protocolGovernance) != address(0), ExceptionsLibrary.ADDRESS_ZERO); require(address(newParams.registry) != address(0), ExceptionsLibrary.ADDRESS_ZERO); require(address(newParams.singleton) != address(0), ExceptionsLibrary.ADDRESS_ZERO); _stagedInternalParams = newParams; _internalParamsTimestamp = block.timestamp + _internalParams.protocolGovernance.governanceDelay(); emit StagedInternalParams(tx.origin, msg.sender, newParams, _internalParamsTimestamp); } /// @inheritdoc IVaultGovernance function commitInternalParams() external { _requireProtocolAdmin(); require(_internalParamsTimestamp != 0, ExceptionsLibrary.NULL); require(block.timestamp >= _internalParamsTimestamp, ExceptionsLibrary.TIMESTAMP); _internalParams = _stagedInternalParams; delete _internalParamsTimestamp; delete _stagedInternalParams; emit CommitedInternalParams(tx.origin, msg.sender, _internalParams); } // ------------------- INTERNAL, VIEW ------------------- function _requireAtLeastStrategy(uint256 nft) internal view { require( (_internalParams.protocolGovernance.isAdmin(msg.sender) || _internalParams.registry.getApproved(nft) == msg.sender || (_internalParams.registry.ownerOf(nft) == msg.sender)), ExceptionsLibrary.FORBIDDEN ); } function _requireProtocolAdmin() internal view { require(_internalParams.protocolGovernance.isAdmin(msg.sender), ExceptionsLibrary.FORBIDDEN); } function _requireAtLeastOperator() internal view { IProtocolGovernance governance = _internalParams.protocolGovernance; require(governance.isAdmin(msg.sender) || governance.isOperator(msg.sender), ExceptionsLibrary.FORBIDDEN); } // ------------------- INTERNAL, MUTATING ------------------- function _createVault(address owner) internal returns (address vault, uint256 nft) { IProtocolGovernance protocolGovernance = IProtocolGovernance(_internalParams.protocolGovernance); require( protocolGovernance.hasPermission(msg.sender, PermissionIdsLibrary.CREATE_VAULT), ExceptionsLibrary.FORBIDDEN ); IVaultRegistry vaultRegistry = _internalParams.registry; nft = vaultRegistry.vaultsCount() + 1; vault = Clones.cloneDeterministic(address(_internalParams.singleton), bytes32(nft)); vaultRegistry.registerVault(address(vault), owner); } /// @notice Set Delayed Strategy Params /// @param nft Nft of the vault /// @param params New params function _stageDelayedStrategyParams(uint256 nft, bytes memory params) internal { _requireAtLeastStrategy(nft); _stagedDelayedStrategyParams[nft] = params; uint256 delayFactor = _delayedStrategyParams[nft].length == 0 ? 0 : 1; _delayedStrategyParamsTimestamp[nft] = block.timestamp + _internalParams.protocolGovernance.governanceDelay() * delayFactor; } /// @notice Commit Delayed Strategy Params function _commitDelayedStrategyParams(uint256 nft) internal { _requireAtLeastStrategy(nft); uint256 thisDelayedStrategyParamsTimestamp = _delayedStrategyParamsTimestamp[nft]; require(thisDelayedStrategyParamsTimestamp != 0, ExceptionsLibrary.NULL); require(block.timestamp >= thisDelayedStrategyParamsTimestamp, ExceptionsLibrary.TIMESTAMP); _delayedStrategyParams[nft] = _stagedDelayedStrategyParams[nft]; delete _stagedDelayedStrategyParams[nft]; delete _delayedStrategyParamsTimestamp[nft]; } /// @notice Set Delayed Protocol Per Vault Params /// @param nft Nft of the vault /// @param params New params function _stageDelayedProtocolPerVaultParams(uint256 nft, bytes memory params) internal { _requireProtocolAdmin(); _stagedDelayedProtocolPerVaultParams[nft] = params; uint256 delayFactor = _delayedProtocolPerVaultParams[nft].length == 0 ? 0 : 1; _delayedProtocolPerVaultParamsTimestamp[nft] = block.timestamp + _internalParams.protocolGovernance.governanceDelay() * delayFactor; } /// @notice Commit Delayed Protocol Per Vault Params function _commitDelayedProtocolPerVaultParams(uint256 nft) internal { _requireProtocolAdmin(); uint256 thisDelayedProtocolPerVaultParamsTimestamp = _delayedProtocolPerVaultParamsTimestamp[nft]; require(thisDelayedProtocolPerVaultParamsTimestamp != 0, ExceptionsLibrary.NULL); require(block.timestamp >= thisDelayedProtocolPerVaultParamsTimestamp, ExceptionsLibrary.TIMESTAMP); _delayedProtocolPerVaultParams[nft] = _stagedDelayedProtocolPerVaultParams[nft]; delete _stagedDelayedProtocolPerVaultParams[nft]; delete _delayedProtocolPerVaultParamsTimestamp[nft]; } /// @notice Set Delayed Protocol Params /// @param params New params function _stageDelayedProtocolParams(bytes memory params) internal { _requireProtocolAdmin(); uint256 delayFactor = _delayedProtocolParams.length == 0 ? 0 : 1; _stagedDelayedProtocolParams = params; _delayedProtocolParamsTimestamp = block.timestamp + _internalParams.protocolGovernance.governanceDelay() * delayFactor; } /// @notice Commit Delayed Protocol Params function _commitDelayedProtocolParams() internal { _requireProtocolAdmin(); require(_delayedProtocolParamsTimestamp != 0, ExceptionsLibrary.NULL); require(block.timestamp >= _delayedProtocolParamsTimestamp, ExceptionsLibrary.TIMESTAMP); _delayedProtocolParams = _stagedDelayedProtocolParams; delete _stagedDelayedProtocolParams; delete _delayedProtocolParamsTimestamp; } /// @notice Set immediate strategy params /// @dev Should require nft > 0 /// @param nft Nft of the vault /// @param params New params function _setStrategyParams(uint256 nft, bytes memory params) internal { _requireAtLeastStrategy(nft); _strategyParams[nft] = params; } /// @notice Set immediate operator params /// @param params New params function _setOperatorParams(bytes memory params) internal { _requireAtLeastOperator(); _operatorParams = params; } /// @notice Set immediate protocol params /// @param params New params function _setProtocolParams(bytes memory params) internal { _requireProtocolAdmin(); _protocolParams = params; } // -------------------------- EVENTS -------------------------- /// @notice Emitted when InternalParams are staged for commit /// @param origin Origin of the transaction (tx.origin) /// @param sender Sender of the call (msg.sender) /// @param params New params that were staged for commit /// @param when When the params could be committed event StagedInternalParams(address indexed origin, address indexed sender, InternalParams params, uint256 when); /// @notice Emitted when InternalParams are staged for commit /// @param origin Origin of the transaction (tx.origin) /// @param sender Sender of the call (msg.sender) /// @param params New params that were staged for commit event CommitedInternalParams(address indexed origin, address indexed sender, InternalParams params); /// @notice Emitted when New Vault is deployed /// @param origin Origin of the transaction (tx.origin) /// @param sender Sender of the call (msg.sender) /// @param vaultTokens Vault tokens for this vault /// @param options Options for deploy. The details of the options structure are specified in subcontracts /// @param owner Owner of the VaultRegistry NFT for this vault /// @param vaultAddress Address of the new Vault /// @param vaultNft VaultRegistry NFT for the new Vault event DeployedVault( address indexed origin, address indexed sender, address[] vaultTokens, bytes options, address owner, address vaultAddress, uint256 vaultNft ); }
{ "evmVersion": "istanbul", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"origin","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address[]","name":"vaultTokens_","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"nft_","type":"uint256"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"}],"name":"Pull","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"}],"name":"Push","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"}],"name":"ReclaimTokens","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes4","name":"selector","type":"bytes4"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"externalCall","outputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nft_","type":"uint256"},{"internalType":"address[]","name":"vaultTokens_","type":"address[]"},{"internalType":"contract IERC20RootVault","name":"vault_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_hash","type":"bytes32"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bytes4","name":"magicValue","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isVaultToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nft","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"pull","outputs":[{"internalType":"uint256[]","name":"actualTokenAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pullExistentials","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"push","outputs":[{"internalType":"uint256[]","name":"actualTokenAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"reclaimTokens","outputs":[{"internalType":"uint256[]","name":"actualTokenAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"tokenAmounts","type":"uint256[]"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"transferAndPush","outputs":[{"internalType":"uint256[]","name":"actualTokenAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tvl","outputs":[{"internalType":"uint256[]","name":"minTokenAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"maxTokenAmounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"contract IERC20RootVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultGovernance","outputs":[{"internalType":"contract IVaultGovernance","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50600160005560001960045561401a8061002b6000396000f3fe6080604052600436106100f35760003560e01c806347ccca021161008a578063d2c219b011610059578063d2c219b0146102c4578063e5328e06146102d9578063fbfa77cf146102fc578063fe255a5e1461033457600080fd5b806347ccca021461024257806352af719f14610260578063566ca6b41461028257806369722233146102a257600080fd5b80632062d754116100c65780632062d754146101aa57806327a35e5a146101ca5780632e2f4cc2146101ea578063338c4ccb1461020a57600080fd5b806301ffc9a7146100f857806305e1c9421461012d578063158ef93e1461015a5780631626ba7e14610171575b600080fd5b34801561010457600080fd5b506101186101133660046133e8565b610352565b60405190151581526020015b60405180910390f35b34801561013957600080fd5b5061014d6101483660046134f7565b610399565b6040516101249190613566565b34801561016657600080fd5b506004541515610118565b34801561017d57600080fd5b5061019161018c3660046135e8565b610831565b6040516001600160e01b03199091168152602001610124565b3480156101b657600080fd5b5061014d6101c5366004613689565b610b7e565b3480156101d657600080fd5b5061014d6101e5366004613689565b611046565b6101fd6101f8366004613723565b6111cd565b604051610124919061380c565b34801561021657600080fd5b5061011861022536600461381f565b6001600160a01b0316600090815260036020526040902054151590565b34801561024e57600080fd5b50600454604051908152602001610124565b34801561026c57600080fd5b5061028061027b36600461383c565b6114c2565b005b34801561028e57600080fd5b5061014d61029d366004613896565b611750565b3480156102ae57600080fd5b506102b7611a3c565b6040516101249190613956565b3480156102d057600080fd5b5061014d611a9e565b3480156102e557600080fd5b506102ee611af5565b604051610124929190613969565b34801561030857600080fd5b5060065461031c906001600160a01b031681565b6040516001600160a01b039091168152602001610124565b34801561034057600080fd5b506001546001600160a01b031661031c565b600061035d82611d06565b8061037857506001600160e01b03198216633d31d51d60e11b145b8061039357506001600160e01b03198216630b135d3f60e11b145b92915050565b6060600260005414156103c75760405162461bcd60e51b81526004016103be90613997565b60405180910390fd5b60026000556004805460408051808201909152918252631253925560e21b602083015290816104095760405162461bcd60e51b81526004016103be919061380c565b5060015460408051637ac46fbb60e01b815290516000926001600160a01b031691637ac46fbb916004808301926060929190829003018186803b15801561044f57600080fd5b505afa158015610463573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061048791906139ce565b805160208201516040516331a9108f60e11b81526004810186905292935090916000906001600160a01b03831690636352211e9060240160206040518083038186803b1580156104d657600080fd5b505afa1580156104ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050e9190613a3f565b9050600061051d838784611d3c565b604051639bd0911b60e01b8152600060048201526001600160a01b039190911690639bd0911b9060240160206040518083038186803b15801561055f57600080fd5b505afa158015610573573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105979190613a3f565b905087516001600160401b038111156105b2576105b2613405565b6040519080825280602002602001820160405280156105db578160200160208202803683370190505b5096506001600160a01b0381163014156105fa57505050505050610827565b60005b88518110156107e45761062889828151811061061b5761061b613a5c565b6020026020010151611e12565b806106da5750846001600160a01b03166363e85d2d8a838151811061064f5761064f613a5c565b60209081029190910101516040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526002602482015260440160206040518083038186803b1580156106a057600080fd5b505afa1580156106b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d89190613a72565b155b156106e4576107d4565b60008982815181106106f8576106f8613a5c565b60209081029190910101516040516370a0823160e01b81523060048201529091506001600160a01b038216906370a082319060240160206040518083038186803b15801561074557600080fd5b505afa158015610759573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061077d9190613a94565b89838151811061078f5761078f613a5c565b6020026020010181815250506107d2838a84815181106107b1576107b1613a5c565b6020026020010151836001600160a01b0316611f049092919063ffffffff16565b505b6107dd81613ac3565b90506105fd565b507f9efcb26e0cf572bd9171640e114f387cef91cd3e38532ed6b3f80c7f2e758f8781898960405161081893929190613ade565b60405180910390a15050505050505b6001600055919050565b600080600160009054906101000a90046001600160a01b03166001600160a01b0316637ac46fbb6040518163ffffffff1660e01b815260040160606040518083038186803b15801561088257600080fd5b505afa158015610896573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ba91906139ce565b602081015181516004549293509091806108e357506001600160e01b0319935061039392505050565b60405163020604bf60e21b8152600481018290526000906001600160a01b0385169063081812fc9060240160206040518083038186803b15801561092657600080fd5b505afa15801561093a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095e9190613a3f565b6040516363e85d2d60e01b81526001600160a01b03808316600483015260066024830152919250908416906363e85d2d9060440160206040518083038186803b1580156109aa57600080fd5b505afa1580156109be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e29190613a72565b6109fc57506001600160e01b031994506103939350505050565b803b63ffffffff811615610b2f576040516301ffc9a760e01b8152630b135d3f60e11b60048201526001600160a01b038316906301ffc9a79060240160206040518083038186803b158015610a5057600080fd5b505afa158015610a64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a889190613a72565b15610b1857604051630b135d3f60e11b81526001600160a01b03831690631626ba7e90610abb908c908c90600401613b1e565b60206040518083038186803b158015610ad357600080fd5b505afa158015610ae7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0b9190613b37565b9650505050505050610393565b506001600160e01b03199550610393945050505050565b816001600160a01b0316610b438a8a611f6c565b6001600160a01b03161415610b685750630b135d3f60e11b9550610393945050505050565b506001600160e01b031998975050505050505050565b606060026000541415610ba35760405162461bcd60e51b81526004016103be90613997565b60026000556004805460408051808201909152918252631253925560e21b60208301529081610be55760405162461bcd60e51b81526004016103be919061380c565b50610bef33611feb565b6040518060400160405280600381526020016223292160e91b81525090610c295760405162461bcd60e51b81526004016103be919061380c565b5060015460408051637ac46fbb60e01b815290516000926001600160a01b031691637ac46fbb916004808301926060929190829003018186803b158015610c6f57600080fd5b505afa158015610c83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca791906139ce565b602001516040516331a9108f60e11b8152600481018490529091506000906001600160a01b03831690636352211e9060240160206040518083038186803b158015610cf157600080fd5b505afa158015610d05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d299190613a3f565b90506000610d38838584611d3c565b90506001600160a01b0382163314610f7557604051639bd0911b60e01b8152600060048201819052906001600160a01b03831690639bd0911b9060240160206040518083038186803b158015610d8d57600080fd5b505afa158015610da1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc59190613a3f565b90506001600160a01b038116301415610f205760405163fcdabd2760e01b81526001600160a01b038b8116600483015280841691639d9fd0d99187169063fcdabd279060240160206040518083038186803b158015610e2357600080fd5b505afa158015610e37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5b9190613a94565b6040518263ffffffff1660e01b8152600401610e7991815260200190565b60206040518083038186803b158015610e9157600080fd5b505afa158015610ea5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec99190613a72565b8015610ede57506001600160a01b038a163014155b6040518060400160405280600581526020016424a72b2a2960d91b81525090610f1a5760405162461bcd60e51b81526004016103be919061380c565b50610f73565b896001600160a01b0316816001600160a01b0316146040518060400160405280600581526020016424a72b2a2960d91b81525090610f715760405162461bcd60e51b81526004016103be919061380c565b505b505b6000610f8189896121aa565b90506000610f908b838a612296565b9050610ff78a6002805480602002602001604051908101604052809291908181526020018280548015610fec57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610fce575b505050505083612578565b96507f54f9e6ef58e36de62f59f9ee6c4b878af84989c53a3642eba415ac3ac4e11cda8b8860405161102a929190613b54565b60405180910390a1505060016000555092979650505050505050565b825160609060005b818110156110d95784818151811061106857611068613a5c565b60200260200101516000146110c9576110c9873087848151811061108e5761108e613a5c565b60200260200101518985815181106110a8576110a8613a5c565b60200260200101516001600160a01b0316612799909392919063ffffffff16565b6110d281613ac3565b905061104e565b506110e5858585611750565b915060005b85518110156111c357600085828151811061110757611107613a5c565b602002602001015184838151811061112157611121613a5c565b602002602001015110611135576000611173565b83828151811061114757611147613a5c565b602002602001015186838151811061116157611161613a5c565b60200260200101516111739190613b78565b905080156111b2576111b2888289858151811061119257611192613a5c565b60200260200101516001600160a01b0316611f049092919063ffffffff16565b506111bc81613ac3565b90506110ea565b5050949350505050565b6060600260005414156111f25760405162461bcd60e51b81526004016103be90613997565b60026000556004805460408051808201909152918252631253925560e21b60208301526112325760405162461bcd60e51b81526004016103be919061380c565b5061123c33611feb565b6040518060400160405280600381526020016223292160e91b815250906112765760405162461bcd60e51b81526004016103be919061380c565b5060015460408051637ac46fbb60e01b815290516000926001600160a01b031691637ac46fbb916004808301926060929190829003018186803b1580156112bc57600080fd5b505afa1580156112d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f491906139ce565b51604051631f4a58fb60e31b81526001600160a01b03888116600483015291925060009183169063fa52c7d89060240160206040518083038186803b15801561133c57600080fd5b505afa158015611350573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113749190613a3f565b60408051808201909152600381526223292160e91b60208201529091506001600160a01b0382166113b85760405162461bcd60e51b81526004016103be919061380c565b50604051631796170d60e21b81526001600160a01b03821690635e585c34906113ef9033908b9034908c908c908c90600401613b8f565b60006040518083038186803b15801561140757600080fd5b505afa15801561141b573d6000803e3d6000fd5b50505050600080886001600160a01b03163489898960405160200161144293929190613bf4565b60408051601f198184030181529082905261145c91613c18565b60006040518083038185875af1925050503d8060008114611499576040519150601f19603f3d011682016040523d82523d6000602084013e61149e565b606091505b5091509150816114b15780518082602001fd5b600160005598975050505050505050565b6114cc82846127d7565b6000816001600160a01b031663697222336040518163ffffffff1660e01b815260040160006040518083038186803b15801561150757600080fd5b505afa15801561151b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115439190810190613c34565b905060005b83518110156115e75783818151811061156357611563613a5c565b60200260200101516001600160a01b031682828151811061158657611586613a5c565b60200260200101516001600160a01b03161460405180604001604052806005815260200164494e56544f60d81b815250906115d45760405162461bcd60e51b81526004016103be919061380c565b50806115df81613ac3565b915050611548565b5060015460408051637ac46fbb60e01b815290516000926001600160a01b031691637ac46fbb916004808301926060929190829003018186803b15801561162d57600080fd5b505afa158015611641573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061166591906139ce565b6020015160065460405163fcdabd2760e01b81526001600160a01b0391821660048201529192506000919083169063fcdabd279060240160206040518083038186803b1580156116b457600080fd5b505afa1580156116c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ec9190613a94565b1160405180604001604052806004815260200163494e564960e01b815250906117285760405162461bcd60e51b81526004016103be919061380c565b5050600680546001600160a01b0319166001600160a01b039390931692909217909155505050565b6060600260005414156117755760405162461bcd60e51b81526004016103be90613997565b60026000556004805460408051808201909152918252631253925560e21b602083015290816117b75760405162461bcd60e51b81526004016103be919061380c565b5060015460408051637ac46fbb60e01b815290516000926001600160a01b031691637ac46fbb916004808301926060929190829003018186803b1580156117fd57600080fd5b505afa158015611811573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183591906139ce565b602001516040516331a9108f60e11b8152600481018490529091506000906001600160a01b03831690636352211e9060240160206040518083038186803b15801561187f57600080fd5b505afa158015611893573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b79190613a3f565b60405163fcdabd2760e01b81526001600160a01b03808316600483015291925060009184169063fcdabd279060240160206040518083038186803b1580156118fe57600080fd5b505afa158015611912573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119369190613a94565b604080518082019091526002815261272360f11b6020820152909150816119705760405162461bcd60e51b81526004016103be919061380c565b50600061197d89896121aa565b9050600061198b8289612c62565b90506119f08a6002805480602002602001604051908101604052809291908181526020018280548015610fec576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311610fce57505050505083612578565b96507f08e404e978692dd1b8275016b7a7b0b3ae4afd06b0cec7228060bb2da18c84fd81604051611a219190613566565b60405180910390a15050600160005550929695505050505050565b60606002805480602002602001604051908101604052809291908181526020018280548015611a9457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611a76575b5050505050905090565b60606005805480602002602001604051908101604052809291908181526020018280548015611a9457602002820191906000526020600020905b815481526020019060010190808311611ad8575050505050905090565b6006546040516370a0823160e01b815230600482015260609182916001600160a01b039091169060009082906370a082319060240160206040518083038186803b158015611b4257600080fd5b505afa158015611b56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b7a9190613a94565b90506000826001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611bb757600080fd5b505afa158015611bcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bef9190613a94565b9050826001600160a01b031663e5328e066040518163ffffffff1660e01b815260040160006040518083038186803b158015611c2a57600080fd5b505afa158015611c3e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c669190810190613d1d565b909550935060005b8551811015611cfe57611c9b83878381518110611c8d57611c8d613a5c565b602002602001015184612dd9565b868281518110611cad57611cad613a5c565b602002602001018181525050611ccf83868381518110611c8d57611c8d613a5c565b858281518110611ce157611ce1613a5c565b602090810291909101015280611cf681613ac3565b915050611c6e565b505050509091565b60006301ffc9a760e01b6001600160e01b03198316148061039357506001600160e01b0319821663305a640b60e21b1492915050565b60405163fcdabd2760e01b81526001600160a01b038281166004830152600091829186169063fcdabd279060240160206040518083038186803b158015611d8257600080fd5b505afa158015611d96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dba9190613a94565b90508315801590611dca57508015155b604051806040016040528060048152602001631253925560e21b81525090611e055760405162461bcd60e51b81526004016103be919061380c565b50829150505b9392505050565b600080600660009054906101000a90046001600160a01b03166001600160a01b031663697222336040518163ffffffff1660e01b815260040160006040518083038186803b158015611e6357600080fd5b505afa158015611e77573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e9f9190810190613c34565b905060005b8151811015611efa57836001600160a01b0316828281518110611ec957611ec9613a5c565b60200260200101516001600160a01b03161415611eea575060019392505050565b611ef381613ac3565b9050611ea4565b5060009392505050565b6040516001600160a01b038316602482015260448101829052611f6790849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612e8c565b505050565b600080600080611f7b85612f5e565b6040805160008152602081018083528b905260ff8316918101919091526060810184905260808101839052929550909350915060019060a0016020604051602081039080840390855afa158015611fd6573d6000803e3d6000fd5b5050604051601f190151979650505050505050565b600080600160009054906101000a90046001600160a01b03166001600160a01b0316637ac46fbb6040518163ffffffff1660e01b815260040160606040518083038186803b15801561203c57600080fd5b505afa158015612050573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207491906139ce565b602001516004549091508061208d575060009392505050565b60405163020604bf60e21b8152600481018290526001600160a01b03808616919084169063081812fc9060240160206040518083038186803b1580156120d257600080fd5b505afa1580156120e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210a9190613a3f565b6001600160a01b031614806121a257506040516331a9108f60e11b8152600481018290526001600160a01b038086169190841690636352211e9060240160206040518083038186803b15801561215f57600080fd5b505afa158015612173573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121979190613a3f565b6001600160a01b0316145b949350505050565b60606121b583612fc2565b60405180604001604052806004815260200163494e564160e01b815250906121f05760405162461bcd60e51b81526004016103be919061380c565b5081518351146040518060400160405280600381526020016224a72b60e91b815250906122305760405162461bcd60e51b81526004016103be919061380c565b50611e0b600280548060200260200160405190810160405280929190818152602001828054801561228a57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161226c575b50505050508484612578565b60065481516060916001600160a01b0316906000906122be9085016020908101908601613d76565b905060006122ca611af5565b506006546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a082319060240160206040518083038186803b15801561231457600080fd5b505afa158015612328573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061234c9190613a94565b905060001960005b88518110156123bd57600061239c848b848151811061237557612375613a5c565b602002602001015187858151811061238f5761238f613a5c565b6020026020010151612dd9565b9050828110156123aa578092505b50806123b581613ac3565b915050612354565b50818111156123c95750805b60065460408051637918397360e01b815290516000926001600160a01b03169163791839739160048083019286929190829003018186803b15801561240d57600080fd5b505afa158015612421573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526124499190810190613d76565b516001600160401b0381111561246157612461613405565b60405190808252806020026020018201604052801561249457816020015b606081526020019060019003908161247f5790505b50905060005b81518110156124e157604051806020016040528060008152508282815181106124c5576124c5613a5c565b6020026020010181905250806124da90613ac3565b905061249a565b5060405163209247eb60e21b81526001600160a01b038716906382491fac90612514908d9086908a908790600401613daa565b600060405180830381600087803b15801561252e57600080fd5b505af1158015612542573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261256a9190810190613d76565b9a9950505050505050505050565b6060600084516001600160401b0381111561259557612595613405565b6040519080825280602002602001820160405280156125be578160200160208202803683370190505b5090506000805b8651821080156125d55750855181105b15612754578581815181106125ec576125ec613a5c565b60200260200101516001600160a01b031687838151811061260f5761260f613a5c565b60200260200101516001600160a01b0316101561265757600083838151811061263a5761263a613a5c565b60209081029190910101528161264f81613ac3565b9250506125c5565b85818151811061266957612669613a5c565b60200260200101516001600160a01b031687838151811061268c5761268c613a5c565b60200260200101516001600160a01b03161115612705578481815181106126b5576126b5613a5c565b6020026020010151600014156126d757806126cf81613ac3565b9150506125c5565b60405162461bcd60e51b815260206004820152600360248201526254505360e81b60448201526064016103be565b84818151811061271757612717613a5c565b602002602001015183838151811061273157612731613a5c565b60209081029190910101528161274681613ac3565b92505080806126cf90613ac3565b865182101561278e57600083838151811061277157612771613a5c565b60209081029190910101528161278681613ac3565b925050612754565b509095945050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526127d19085906323b872dd60e01b90608401611f30565b50505050565b6004805460408051808201909152918252631253925560e21b6020830152156128135760405162461bcd60e51b81526004016103be919061380c565b5061281d82612fc2565b60405180604001604052806004815260200163494e564160e01b815250906128585760405162461bcd60e51b81526004016103be919061380c565b506040805180820190915260028152612b2d60f11b6020820152816128905760405162461bcd60e51b81526004016103be919061380c565b506000336001600160a01b0316637ac46fbb6040518163ffffffff1660e01b815260040160606040518083038186803b1580156128cc57600080fd5b505afa1580156128e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061290491906139ce565b518351909150158015906129895750806001600160a01b03166378546fa26040518163ffffffff1660e01b815260040160206040518083038186803b15801561294c57600080fd5b505afa158015612960573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129849190613a94565b835111155b6040518060400160405280600381526020016224a72b60e91b815250906129c35760405162461bcd60e51b81526004016103be919061380c565b5060005b8351811015612ac757816001600160a01b03166363e85d2d8583815181106129f1576129f1613a5c565b60209081029190910101516040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526003602482015260440160206040518083038186803b158015612a4257600080fd5b505afa158015612a56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7a9190613a72565b6040518060400160405280600381526020016223292160e91b81525090612ab45760405162461bcd60e51b81526004016103be919061380c565b5080612abf81613ac3565b9150506129c7565b50600180546001600160a01b031916331790558251612aed906002906020860190613355565b50600482905560025460005b81811015612c1d57612b0c816001613e31565b60036000878481518110612b2257612b22613a5c565b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020819055506000858281518110612b6257612b62613a5c565b6020026020010151905060056002826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612ba957600080fd5b505afa158015612bbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be19190613e49565b612beb9190613e6c565b612bf690600a613f80565b8154600181018355600092835260209092209091015550612c1681613ac3565b9050612af9565b50604051339032907f0f043e55a1ce0d7ce25125ccbc2800b540d83e21abf7250f0156c2091a28b22190612c549088908890613f8f565b60405180910390a350505050565b602081015160609060005b8451811015612ce4576006548551612cd2916001600160a01b031690879084908110612c9b57612c9b613a5c565b602002602001015160028481548110612cb657612cb6613a5c565b6000918252602090912001546001600160a01b03169190613065565b80612cdc81613ac3565b915050612c6d565b50600654604051631528fd1d60e21b81526001600160a01b03909116906354a3f47490612d179087908590600401613fb1565b600060405180830381600087803b158015612d3157600080fd5b505af1158015612d45573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612d6d9190810190613d76565b915060005b8451811015612dd15760065460028054612dbf926001600160a01b03169160009185908110612da357612da3613a5c565b6000918252602090912001546001600160a01b03169190613126565b80612dc981613ac3565b915050612d72565b505092915050565b600080806000198587098587029250828110838203039150508060001415612e135760008411612e0857600080fd5b508290049050611e0b565b808411612e1f57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6000612ee1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661324a9092919063ffffffff16565b805190915015611f675780806020019051810190612eff9190613a72565b611f675760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103be565b60008060008351604114604051806040016040528060048152602001631253959360e21b81525090612fa35760405162461bcd60e51b81526004016103be919061380c565b5050505060208101516040820151606090920151909260009190911a90565b6000600282511015612fd657506001919050565b60005b60018351612fe79190613b78565b81101561305c5782612ffa826001613e31565b8151811061300a5761300a613a5c565b60200260200101516001600160a01b031683828151811061302d5761302d613a5c565b60200260200101516001600160a01b03161061304c5750600092915050565b61305581613ac3565b9050612fd9565b50600192915050565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e9060440160206040518083038186803b1580156130b157600080fd5b505afa1580156130c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130e99190613a94565b6130f39190613e31565b6040516001600160a01b0385166024820152604481018290529091506127d190859063095ea7b360e01b90606401611f30565b8015806131af5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561317557600080fd5b505afa158015613189573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131ad9190613a94565b155b61321a5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016103be565b6040516001600160a01b038316602482015260448101829052611f6790849063095ea7b360e01b90606401611f30565b60606121a2848460008585843b6132a35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103be565b600080866001600160a01b031685876040516132bf9190613c18565b60006040518083038185875af1925050503d80600081146132fc576040519150601f19603f3d011682016040523d82523d6000602084013e613301565b606091505b509150915061331182828661331c565b979650505050505050565b6060831561332b575081611e0b565b82511561333b5782518084602001fd5b8160405162461bcd60e51b81526004016103be919061380c565b8280548282559060005260206000209081019282156133aa579160200282015b828111156133aa57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613375565b506133b69291506133ba565b5090565b5b808211156133b657600081556001016133bb565b6001600160e01b0319811681146133e557600080fd5b50565b6000602082840312156133fa57600080fd5b8135611e0b816133cf565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561344357613443613405565b604052919050565b60006001600160401b0382111561346457613464613405565b5060051b60200190565b6001600160a01b03811681146133e557600080fd5b600082601f83011261349457600080fd5b813560206134a96134a48361344b565b61341b565b82815260059290921b840181019181810190868411156134c857600080fd5b8286015b848110156134ec5780356134df8161346e565b83529183019183016134cc565b509695505050505050565b60006020828403121561350957600080fd5b81356001600160401b0381111561351f57600080fd5b6121a284828501613483565b600081518084526020808501945080840160005b8381101561355b5781518752958201959082019060010161353f565b509495945050505050565b602081526000611e0b602083018461352b565b600082601f83011261358a57600080fd5b81356001600160401b038111156135a3576135a3613405565b6135b6601f8201601f191660200161341b565b8181528460208386010111156135cb57600080fd5b816020850160208301376000918101602001919091529392505050565b600080604083850312156135fb57600080fd5b8235915060208301356001600160401b0381111561361857600080fd5b61362485828601613579565b9150509250929050565b600082601f83011261363f57600080fd5b8135602061364f6134a48361344b565b82815260059290921b8401810191818101908684111561366e57600080fd5b8286015b848110156134ec5780358352918301918301613672565b6000806000806080858703121561369f57600080fd5b84356136aa8161346e565b935060208501356001600160401b03808211156136c657600080fd5b6136d288838901613483565b945060408701359150808211156136e857600080fd5b6136f48883890161362e565b9350606087013591508082111561370a57600080fd5b5061371787828801613579565b91505092959194509250565b6000806000806060858703121561373957600080fd5b84356137448161346e565b93506020850135613754816133cf565b925060408501356001600160401b038082111561377057600080fd5b818701915087601f83011261378457600080fd5b81358181111561379357600080fd5b8860208285010111156137a557600080fd5b95989497505060200194505050565b60005b838110156137cf5781810151838201526020016137b7565b838111156127d15750506000910152565b600081518084526137f88160208601602086016137b4565b601f01601f19169290920160200192915050565b602081526000611e0b60208301846137e0565b60006020828403121561383157600080fd5b8135611e0b8161346e565b60008060006060848603121561385157600080fd5b8335925060208401356001600160401b0381111561386e57600080fd5b61387a86828701613483565b925050604084013561388b8161346e565b809150509250925092565b6000806000606084860312156138ab57600080fd5b83356001600160401b03808211156138c257600080fd5b6138ce87838801613483565b945060208601359150808211156138e457600080fd5b6138f08783880161362e565b9350604086013591508082111561390657600080fd5b5061391386828701613579565b9150509250925092565b600081518084526020808501945080840160005b8381101561355b5781516001600160a01b031687529582019590820190600101613931565b602081526000611e0b602083018461391d565b60408152600061397c604083018561352b565b828103602084015261398e818561352b565b95945050505050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6000606082840312156139e057600080fd5b604051606081018181106001600160401b0382111715613a0257613a02613405565b6040528251613a108161346e565b81526020830151613a208161346e565b60208201526040830151613a338161346e565b60408201529392505050565b600060208284031215613a5157600080fd5b8151611e0b8161346e565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613a8457600080fd5b81518015158114611e0b57600080fd5b600060208284031215613aa657600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000600019821415613ad757613ad7613aad565b5060010190565b6001600160a01b0384168152606060208201819052600090613b029083018561391d565b8281036040840152613b14818561352b565b9695505050505050565b8281526040602082015260006121a260408301846137e0565b600060208284031215613b4957600080fd5b8151611e0b816133cf565b6001600160a01b03831681526040602082018190526000906121a29083018461352b565b600082821015613b8a57613b8a613aad565b500390565b6001600160a01b03878116825286166020820152604081018590526001600160e01b03198416606082015260a06080820181905281018290526000828460c0840137600060c0848401015260c0601f19601f8501168301019050979650505050505050565b6001600160e01b031984168152818360048301376000910160040190815292915050565b60008251613c2a8184602087016137b4565b9190910192915050565b60006020808385031215613c4757600080fd5b82516001600160401b03811115613c5d57600080fd5b8301601f81018513613c6e57600080fd5b8051613c7c6134a48261344b565b81815260059190911b82018301908381019087831115613c9b57600080fd5b928401925b82841015613311578351613cb38161346e565b82529284019290840190613ca0565b600082601f830112613cd357600080fd5b81516020613ce36134a48361344b565b82815260059290921b84018101918181019086841115613d0257600080fd5b8286015b848110156134ec5780518352918301918301613d06565b60008060408385031215613d3057600080fd5b82516001600160401b0380821115613d4757600080fd5b613d5386838701613cc2565b93506020850151915080821115613d6957600080fd5b5061362485828601613cc2565b600060208284031215613d8857600080fd5b81516001600160401b03811115613d9e57600080fd5b6121a284828501613cc2565b60018060a01b038516815260006020858184015260806040840152613dd2608084018661352b565b8381036060850152845180825282820190600581901b8301840184880160005b83811015613e2057601f19868403018552613e0e8383516137e0565b94870194925090860190600101613df2565b50909b9a5050505050505050505050565b60008219821115613e4457613e44613aad565b500190565b600060208284031215613e5b57600080fd5b815160ff81168114611e0b57600080fd5b600060ff831680613e8d57634e487b7160e01b600052601260045260246000fd5b8060ff84160491505092915050565b600181815b80851115613ed7578160001904821115613ebd57613ebd613aad565b80851615613eca57918102915b93841c9390800290613ea1565b509250929050565b600082613eee57506001610393565b81613efb57506000610393565b8160018114613f115760028114613f1b57613f37565b6001915050610393565b60ff841115613f2c57613f2c613aad565b50506001821b610393565b5060208310610133831016604e8410600b8410161715613f5a575081810a610393565b613f648383613e9c565b8060001904821115613f7857613f78613aad565b029392505050565b6000611e0b60ff841683613edf565b604081526000613fa2604083018561391d565b90508260208301529392505050565b606081526000613fc4606083018561352b565b83602084015282810360408401526000815260208101915050939250505056fea264697066735822122075f3c6522be63c24555327a464e1fcdd72579c6654e67e20d19010e01f6f78e064736f6c63430008090033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.