Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- TimelockAuthorizerMigrator
- Optimization enabled
- true
- Compiler version
- v0.7.1+commit.f4a555be
- Optimization runs
- 9999
- EVM Version
- default
- Verified at
- 2023-05-17T16:15:40.986058Z
Constructor Arguments
0x000000000000000000000000c34b35b9b1986aca2008c719500d4a58829f3c6e00000000000000000000000078d76296f1ae44f2dd9cc6c42837d15d4249b16c000000000000000000000000a685eee123b87dc3152651454f8a64ac949e69fd0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000c34b35b9b1986aca2008c719500d4a58829f3c6e7cec8c486992a4606bfb1e2d603d1750d55bf3f86720955da5ad5e7aa7e4c3a6000000000000000000000000ffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d1bbb3d44c814935f60561af6f45f4098e276a079945715aaf9b0e6f0c73fed20000000000000000000000000000000000000000000000000000000000278d00190a4cc815dd4870fb4e24edae69f6413d2a80864cb893c3810a35dbbc9b32290000000000000000000000000000000000000000000000000000000000127500000000000000000000000000000000000000000000000000000000000000000ba149cacd04b8ae4a926000bea0301f64f0be0786064ee6b3ae1da1b57eaeadbf0000000000000000000000000000000000000000000000000000000000278d00706e3e1e6289c5e790014b3ea331522f53f9a74f45cb3ecb46dd1fd4e40f6d030000000000000000000000000000000000000000000000000000000000278d0049ab6b886a8049936c526dc5be20dc19bc6293d6bc123d656f16c8a706c9e2090000000000000000000000000000000000000000000000000000000000127500273f2ddda67c8534d4497582efee72fc2a895aadf62d0002e41b33ce2ade2fde000000000000000000000000000000000000000000000000000000000012750079922681fd17c90b4f3409d605f5b059ffcbcef7b5440321ae93b87f3b5c1c780000000000000000000000000000000000000000000000000000000000093a8034f1dc41ca994152374a5c44fae714bce9db65db63b0eb0bcb5aa55a7bff62190000000000000000000000000000000000000000000000000000000000093a80bf9a8d654fde1e2f1891f07fa956278c8265e8048352ff4002b4d62892583ba40000000000000000000000000000000000000000000000000000000000093a80e2ae0774a123c4bf5321ab994df4e425499258b456a9d5ed08ef632100b7a8b00000000000000000000000000000000000000000000000000000000000093a80c768e5cafec3474b335504ab77e14d12354bb3991d92de39ec636092ff0449c90000000000000000000000000000000000000000000000000000000000093a80a8513b600d1bc757c89614a4a6537d35de96b450825b001da4873ea53028cafa0000000000000000000000000000000000000000000000000000000000093a80bdce9837efbaa5ecb8c57c3798534c48e76027c7460ffc59e8331656706c349c0000000000000000000000000000000000000000000000000000000000093a80
contracts/TimelockAuthorizerMigrator.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
import "@balancer-labs/v2-interfaces/contracts/vault/IBasicAuthorizer.sol";
import "@balancer-labs/v2-interfaces/contracts/vault/IVault.sol";
import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol";
import "@balancer-labs/v2-vault/contracts/authorizer/TimelockAuthorizer.sol";
contract TimelockAuthorizerMigrator {
bytes32
public constant GENERAL_PERMISSION_SPECIFIER = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
// solhint-disable-previous-line max-line-length
address public constant EVERYWHERE = address(-1);
uint256 public constant CHANGE_ROOT_DELAY = 4 weeks;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
IVault public immutable vault;
address public immutable root;
IBasicAuthorizer public immutable oldAuthorizer;
TimelockAuthorizer public immutable newAuthorizer;
uint256 public rootChangeExecutionId;
struct RoleData {
address grantee;
bytes32 role;
address target;
}
struct DelayData {
bytes32 actionId;
uint256 newDelay;
}
/**
* @dev Reverts if _rolesData contains a role for an account which doesn't hold the same role on the old Authorizer.
*/
constructor(
address _root,
IBasicAuthorizer _oldAuthorizer,
IAuthorizerAdaptorEntrypoint _authorizerAdaptorEntrypoint,
RoleData[] memory _rolesData,
RoleData[] memory _grantersData,
RoleData[] memory _revokersData,
DelayData[] memory _executeDelaysData,
DelayData[] memory _grantDelaysData
) {
// At creation, the migrator will be the root of the TimelockAuthorizer.
// Once the migration is complete, the root permission will be transferred to `_root`.
TimelockAuthorizer _newAuthorizer = new TimelockAuthorizer(
address(this),
_authorizerAdaptorEntrypoint,
CHANGE_ROOT_DELAY
);
newAuthorizer = _newAuthorizer;
oldAuthorizer = _oldAuthorizer;
root = _root;
vault = _authorizerAdaptorEntrypoint.getVault();
for (uint256 i = 0; i < _rolesData.length; i++) {
RoleData memory roleData = _rolesData[i];
// We require that any permissions being copied from the old Authorizer must exist on the old Authorizer.
// This simplifies verification of the permissions being added to the new TimelockAuthorizer.
require(_oldAuthorizer.canPerform(roleData.role, roleData.grantee, roleData.target), "UNEXPECTED_ROLE");
_newAuthorizer.grantPermissions(_arr(roleData.role), roleData.grantee, _arr(roleData.target));
}
for (uint256 i = 0; i < _grantersData.length; i++) {
// There's no concept of a "granter" on the old Authorizer so we cannot verify these onchain.
// We must manually verify that these permissions are set sensibly.
_newAuthorizer.manageGranter(
_grantersData[i].role,
_grantersData[i].grantee,
_grantersData[i].target,
true
);
}
for (uint256 i = 0; i < _revokersData.length; i++) {
// Similarly to granters, we must manually verify that these permissions are set sensibly.
_newAuthorizer.manageRevoker(
_revokersData[i].role,
_revokersData[i].grantee,
_revokersData[i].target,
true
);
}
// Setting the initial value for a delay requires us to wait 3 days before we can complete setting it.
// We schedule them now to ensure that they're ready to execute once `CHANGE_ROOT_DELAY` has passed.
for (uint256 i = 0; i < _executeDelaysData.length; i++) {
// We're not wanting to set a delay greater than 1 month initially so fail early if we're doing so.
require(_executeDelaysData[i].newDelay <= 30 days, "UNEXPECTED_LARGE_DELAY");
_newAuthorizer.scheduleDelayChange(
_executeDelaysData[i].actionId,
_executeDelaysData[i].newDelay,
_arr(address(this))
);
}
for (uint256 i = 0; i < _grantDelaysData.length; i++) {
// We're not wanting to set a delay greater than 1 month initially so fail early if we're doing so.
require(_grantDelaysData[i].newDelay <= 30 days, "UNEXPECTED_LARGE_DELAY");
_newAuthorizer.scheduleDelayChange(
_newAuthorizer.getGrantPermissionActionId(_grantDelaysData[i].actionId),
_grantDelaysData[i].newDelay,
_arr(address(this))
);
}
// Enqueue a root change execution in the new authorizer to set it to the desired root address.
// We only allow the migrator to execute this transaction to avoid it being triggered too early.
rootChangeExecutionId = _newAuthorizer.scheduleRootChange(_root, _arr(address(this)));
}
/**
* @notice Executes the scheduled setup of delays on the new authorizer
*/
function executeDelays() external {
require(newAuthorizer.canExecute(0), "CANNOT_TRIGGER_DELAYS_MIGRATION_YET");
// As execution IDs are sequential, we can just iterate from 0 to the first non-delay (root transfer) execution.
for (uint256 i = 0; i < rootChangeExecutionId; i++) {
newAuthorizer.execute(i);
}
}
/**
* @notice Begins transfer of root powers from the migrator to the specified address.
* @dev The setup of delays on the new authorizer must be executed before calling this function.
*/
function startRootTransfer() external {
// Check that the delays have been set up on the new authorizer.
// Checking the first delay has been set is sufficient.
// This check is shortcircuited if there are no delays to set up (`rootChangeExecutionId == 0`).
require(
rootChangeExecutionId == 0 || newAuthorizer.getScheduledExecution(0).executed,
"DELAYS_NOT_MIGRATED_YET"
);
// Finally trigger the first step of transferring root ownership over the TimelockAuthorizer to `root`.
// Before the migration can be finalized, `root` must call `claimRoot` on the `TimelockAuthorizer`.
require(newAuthorizer.canExecute(rootChangeExecutionId), "CANNOT_TRIGGER_ROOT_CHANGE_YET");
newAuthorizer.execute(rootChangeExecutionId);
}
/**
* @notice Complete the authorizer migration by updating the Vault to point to the new authorizer.
* @dev `root` must call `claimRoot` on `newAuthorizer` before we update the Vault to point at it.
*/
function finalizeMigration() external {
// Safety check to avoid us migrating to a authorizer with an invalid root.
// `root` must call `claimRoot` on `newAuthorizer` before we update the Vault to point at it.
require(newAuthorizer.isRoot(root), "ROOT_NOT_CLAIMED_YET");
// Ensure the migrator contract has authority to change the vault's authorizer
bytes32 setAuthorizerId = IAuthentication(address(vault)).getActionId(IVault.setAuthorizer.selector);
bool canSetAuthorizer = oldAuthorizer.canPerform(setAuthorizerId, address(this), address(vault));
require(canSetAuthorizer, "MIGRATOR_CANNOT_SET_AUTHORIZER");
// Finally change the authorizer in the vault.
vault.setAuthorizer(newAuthorizer);
}
// Helper functions
function _arr(bytes32 a) internal pure returns (bytes32[] memory arr) {
arr = new bytes32[](1);
arr[0] = a;
}
function _arr(address a) internal pure returns (address[] memory arr) {
arr = new address[](1);
arr[0] = a;
}
}
@balancer-labs/v2-interfaces/contracts/liquidity-mining/IAuthorizerAdaptor.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.7.0 <0.9.0;
import "../solidity-utils/helpers/IAuthentication.sol";
import "../vault/IVault.sol";
interface IAuthorizerAdaptor is IAuthentication {
/**
* @notice Returns the Balancer Vault
*/
function getVault() external view returns (IVault);
/**
* @notice Returns the Authorizer
*/
function getAuthorizer() external view returns (IAuthorizer);
/**
* @notice Performs an arbitrary function call on a target contract, provided the caller is authorized to do so.
* @param target - Address of the contract to be called
* @param data - Calldata to be sent to the target contract
* @return The bytes encoded return value from the performed function call
*/
function performAction(address target, bytes calldata data) external payable returns (bytes memory);
}
@balancer-labs/v2-interfaces/contracts/liquidity-mining/IAuthorizerAdaptorEntrypoint.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.7.0 <0.9.0;
import "./IAuthorizerAdaptor.sol";
/**
* @notice Interface for `AuthorizerAdaptorEntrypoint`.
*/
interface IAuthorizerAdaptorEntrypoint is IAuthorizerAdaptor {
/**
* @notice Returns the Authorizer Adaptor
*/
function getAuthorizerAdaptor() external view returns (IAuthorizerAdaptor);
}
@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/BalancerErrors.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.7.0 <0.9.0;
// solhint-disable
/**
* @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 999 are
* supported.
* Uses the default 'BAL' prefix for the error code
*/
function _require(bool condition, uint256 errorCode) pure {
if (!condition) _revert(errorCode);
}
/**
* @dev Reverts if `condition` is false, with a revert reason containing `errorCode`. Only codes up to 999 are
* supported.
*/
function _require(
bool condition,
uint256 errorCode,
bytes3 prefix
) pure {
if (!condition) _revert(errorCode, prefix);
}
/**
* @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported.
* Uses the default 'BAL' prefix for the error code
*/
function _revert(uint256 errorCode) pure {
_revert(errorCode, 0x42414c); // This is the raw byte representation of "BAL"
}
/**
* @dev Reverts with a revert reason containing `errorCode`. Only codes up to 999 are supported.
*/
function _revert(uint256 errorCode, bytes3 prefix) pure {
uint256 prefixUint = uint256(uint24(prefix));
// We're going to dynamically create a revert string based on the error code, with the following format:
// 'BAL#{errorCode}'
// where the code is left-padded with zeroes to three digits (so they range from 000 to 999).
//
// We don't have revert strings embedded in the contract to save bytecode size: it takes much less space to store a
// number (8 to 16 bits) than the individual string characters.
//
// The dynamic string creation algorithm that follows could be implemented in Solidity, but assembly allows for a
// much denser implementation, again saving bytecode size. Given this function unconditionally reverts, this is a
// safe place to rely on it without worrying about how its usage might affect e.g. memory contents.
assembly {
// First, we need to compute the ASCII representation of the error code. We assume that it is in the 0-999
// range, so we only need to convert three digits. To convert the digits to ASCII, we add 0x30, the value for
// the '0' character.
let units := add(mod(errorCode, 10), 0x30)
errorCode := div(errorCode, 10)
let tenths := add(mod(errorCode, 10), 0x30)
errorCode := div(errorCode, 10)
let hundreds := add(mod(errorCode, 10), 0x30)
// With the individual characters, we can now construct the full string.
// We first append the '#' character (0x23) to the prefix. In the case of 'BAL', it results in 0x42414c23 ('BAL#')
// Then, we shift this by 24 (to provide space for the 3 bytes of the error code), and add the
// characters to it, each shifted by a multiple of 8.
// The revert reason is then shifted left by 200 bits (256 minus the length of the string, 7 characters * 8 bits
// per character = 56) to locate it in the most significant part of the 256 slot (the beginning of a byte
// array).
let formattedPrefix := shl(24, add(0x23, shl(8, prefixUint)))
let revertReason := shl(200, add(formattedPrefix, add(add(units, shl(8, tenths)), shl(16, hundreds))))
// We can now encode the reason in memory, which can be safely overwritten as we're about to revert. The encoded
// message will have the following layout:
// [ revert reason identifier ] [ string location offset ] [ string length ] [ string contents ]
// The Solidity revert reason identifier is 0x08c739a0, the function selector of the Error(string) function. We
// also write zeroes to the next 28 bytes of memory, but those are about to be overwritten.
mstore(0x0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
// Next is the offset to the location of the string, which will be placed immediately after (20 bytes away).
mstore(0x04, 0x0000000000000000000000000000000000000000000000000000000000000020)
// The string length is fixed: 7 characters.
mstore(0x24, 7)
// Finally, the string itself is stored.
mstore(0x44, revertReason)
// Even if the string is only 7 bytes long, we need to return a full 32 byte slot containing it. The length of
// the encoded message is therefore 4 + 32 + 32 + 32 = 100.
revert(0, 100)
}
}
library Errors {
// Math
uint256 internal constant ADD_OVERFLOW = 0;
uint256 internal constant SUB_OVERFLOW = 1;
uint256 internal constant SUB_UNDERFLOW = 2;
uint256 internal constant MUL_OVERFLOW = 3;
uint256 internal constant ZERO_DIVISION = 4;
uint256 internal constant DIV_INTERNAL = 5;
uint256 internal constant X_OUT_OF_BOUNDS = 6;
uint256 internal constant Y_OUT_OF_BOUNDS = 7;
uint256 internal constant PRODUCT_OUT_OF_BOUNDS = 8;
uint256 internal constant INVALID_EXPONENT = 9;
// Input
uint256 internal constant OUT_OF_BOUNDS = 100;
uint256 internal constant UNSORTED_ARRAY = 101;
uint256 internal constant UNSORTED_TOKENS = 102;
uint256 internal constant INPUT_LENGTH_MISMATCH = 103;
uint256 internal constant ZERO_TOKEN = 104;
uint256 internal constant INSUFFICIENT_DATA = 105;
// Shared pools
uint256 internal constant MIN_TOKENS = 200;
uint256 internal constant MAX_TOKENS = 201;
uint256 internal constant MAX_SWAP_FEE_PERCENTAGE = 202;
uint256 internal constant MIN_SWAP_FEE_PERCENTAGE = 203;
uint256 internal constant MINIMUM_BPT = 204;
uint256 internal constant CALLER_NOT_VAULT = 205;
uint256 internal constant UNINITIALIZED = 206;
uint256 internal constant BPT_IN_MAX_AMOUNT = 207;
uint256 internal constant BPT_OUT_MIN_AMOUNT = 208;
uint256 internal constant EXPIRED_PERMIT = 209;
uint256 internal constant NOT_TWO_TOKENS = 210;
uint256 internal constant DISABLED = 211;
// Pools
uint256 internal constant MIN_AMP = 300;
uint256 internal constant MAX_AMP = 301;
uint256 internal constant MIN_WEIGHT = 302;
uint256 internal constant MAX_STABLE_TOKENS = 303;
uint256 internal constant MAX_IN_RATIO = 304;
uint256 internal constant MAX_OUT_RATIO = 305;
uint256 internal constant MIN_BPT_IN_FOR_TOKEN_OUT = 306;
uint256 internal constant MAX_OUT_BPT_FOR_TOKEN_IN = 307;
uint256 internal constant NORMALIZED_WEIGHT_INVARIANT = 308;
uint256 internal constant INVALID_TOKEN = 309;
uint256 internal constant UNHANDLED_JOIN_KIND = 310;
uint256 internal constant ZERO_INVARIANT = 311;
uint256 internal constant ORACLE_INVALID_SECONDS_QUERY = 312;
uint256 internal constant ORACLE_NOT_INITIALIZED = 313;
uint256 internal constant ORACLE_QUERY_TOO_OLD = 314;
uint256 internal constant ORACLE_INVALID_INDEX = 315;
uint256 internal constant ORACLE_BAD_SECS = 316;
uint256 internal constant AMP_END_TIME_TOO_CLOSE = 317;
uint256 internal constant AMP_ONGOING_UPDATE = 318;
uint256 internal constant AMP_RATE_TOO_HIGH = 319;
uint256 internal constant AMP_NO_ONGOING_UPDATE = 320;
uint256 internal constant STABLE_INVARIANT_DIDNT_CONVERGE = 321;
uint256 internal constant STABLE_GET_BALANCE_DIDNT_CONVERGE = 322;
uint256 internal constant RELAYER_NOT_CONTRACT = 323;
uint256 internal constant BASE_POOL_RELAYER_NOT_CALLED = 324;
uint256 internal constant REBALANCING_RELAYER_REENTERED = 325;
uint256 internal constant GRADUAL_UPDATE_TIME_TRAVEL = 326;
uint256 internal constant SWAPS_DISABLED = 327;
uint256 internal constant CALLER_IS_NOT_LBP_OWNER = 328;
uint256 internal constant PRICE_RATE_OVERFLOW = 329;
uint256 internal constant INVALID_JOIN_EXIT_KIND_WHILE_SWAPS_DISABLED = 330;
uint256 internal constant WEIGHT_CHANGE_TOO_FAST = 331;
uint256 internal constant LOWER_GREATER_THAN_UPPER_TARGET = 332;
uint256 internal constant UPPER_TARGET_TOO_HIGH = 333;
uint256 internal constant UNHANDLED_BY_LINEAR_POOL = 334;
uint256 internal constant OUT_OF_TARGET_RANGE = 335;
uint256 internal constant UNHANDLED_EXIT_KIND = 336;
uint256 internal constant UNAUTHORIZED_EXIT = 337;
uint256 internal constant MAX_MANAGEMENT_SWAP_FEE_PERCENTAGE = 338;
uint256 internal constant UNHANDLED_BY_MANAGED_POOL = 339;
uint256 internal constant UNHANDLED_BY_PHANTOM_POOL = 340;
uint256 internal constant TOKEN_DOES_NOT_HAVE_RATE_PROVIDER = 341;
uint256 internal constant INVALID_INITIALIZATION = 342;
uint256 internal constant OUT_OF_NEW_TARGET_RANGE = 343;
uint256 internal constant FEATURE_DISABLED = 344;
uint256 internal constant UNINITIALIZED_POOL_CONTROLLER = 345;
uint256 internal constant SET_SWAP_FEE_DURING_FEE_CHANGE = 346;
uint256 internal constant SET_SWAP_FEE_PENDING_FEE_CHANGE = 347;
uint256 internal constant CHANGE_TOKENS_DURING_WEIGHT_CHANGE = 348;
uint256 internal constant CHANGE_TOKENS_PENDING_WEIGHT_CHANGE = 349;
uint256 internal constant MAX_WEIGHT = 350;
uint256 internal constant UNAUTHORIZED_JOIN = 351;
uint256 internal constant MAX_MANAGEMENT_AUM_FEE_PERCENTAGE = 352;
uint256 internal constant FRACTIONAL_TARGET = 353;
uint256 internal constant ADD_OR_REMOVE_BPT = 354;
uint256 internal constant INVALID_CIRCUIT_BREAKER_BOUNDS = 355;
uint256 internal constant CIRCUIT_BREAKER_TRIPPED = 356;
uint256 internal constant MALICIOUS_QUERY_REVERT = 357;
// Lib
uint256 internal constant REENTRANCY = 400;
uint256 internal constant SENDER_NOT_ALLOWED = 401;
uint256 internal constant PAUSED = 402;
uint256 internal constant PAUSE_WINDOW_EXPIRED = 403;
uint256 internal constant MAX_PAUSE_WINDOW_DURATION = 404;
uint256 internal constant MAX_BUFFER_PERIOD_DURATION = 405;
uint256 internal constant INSUFFICIENT_BALANCE = 406;
uint256 internal constant INSUFFICIENT_ALLOWANCE = 407;
uint256 internal constant ERC20_TRANSFER_FROM_ZERO_ADDRESS = 408;
uint256 internal constant ERC20_TRANSFER_TO_ZERO_ADDRESS = 409;
uint256 internal constant ERC20_MINT_TO_ZERO_ADDRESS = 410;
uint256 internal constant ERC20_BURN_FROM_ZERO_ADDRESS = 411;
uint256 internal constant ERC20_APPROVE_FROM_ZERO_ADDRESS = 412;
uint256 internal constant ERC20_APPROVE_TO_ZERO_ADDRESS = 413;
uint256 internal constant ERC20_TRANSFER_EXCEEDS_ALLOWANCE = 414;
uint256 internal constant ERC20_DECREASED_ALLOWANCE_BELOW_ZERO = 415;
uint256 internal constant ERC20_TRANSFER_EXCEEDS_BALANCE = 416;
uint256 internal constant ERC20_BURN_EXCEEDS_ALLOWANCE = 417;
uint256 internal constant SAFE_ERC20_CALL_FAILED = 418;
uint256 internal constant ADDRESS_INSUFFICIENT_BALANCE = 419;
uint256 internal constant ADDRESS_CANNOT_SEND_VALUE = 420;
uint256 internal constant SAFE_CAST_VALUE_CANT_FIT_INT256 = 421;
uint256 internal constant GRANT_SENDER_NOT_ADMIN = 422;
uint256 internal constant REVOKE_SENDER_NOT_ADMIN = 423;
uint256 internal constant RENOUNCE_SENDER_NOT_ALLOWED = 424;
uint256 internal constant BUFFER_PERIOD_EXPIRED = 425;
uint256 internal constant CALLER_IS_NOT_OWNER = 426;
uint256 internal constant NEW_OWNER_IS_ZERO = 427;
uint256 internal constant CODE_DEPLOYMENT_FAILED = 428;
uint256 internal constant CALL_TO_NON_CONTRACT = 429;
uint256 internal constant LOW_LEVEL_CALL_FAILED = 430;
uint256 internal constant NOT_PAUSED = 431;
uint256 internal constant ADDRESS_ALREADY_ALLOWLISTED = 432;
uint256 internal constant ADDRESS_NOT_ALLOWLISTED = 433;
uint256 internal constant ERC20_BURN_EXCEEDS_BALANCE = 434;
uint256 internal constant INVALID_OPERATION = 435;
uint256 internal constant CODEC_OVERFLOW = 436;
uint256 internal constant IN_RECOVERY_MODE = 437;
uint256 internal constant NOT_IN_RECOVERY_MODE = 438;
uint256 internal constant INDUCED_FAILURE = 439;
uint256 internal constant EXPIRED_SIGNATURE = 440;
uint256 internal constant MALFORMED_SIGNATURE = 441;
uint256 internal constant SAFE_CAST_VALUE_CANT_FIT_UINT64 = 442;
uint256 internal constant UNHANDLED_FEE_TYPE = 443;
uint256 internal constant BURN_FROM_ZERO = 444;
// Vault
uint256 internal constant INVALID_POOL_ID = 500;
uint256 internal constant CALLER_NOT_POOL = 501;
uint256 internal constant SENDER_NOT_ASSET_MANAGER = 502;
uint256 internal constant USER_DOESNT_ALLOW_RELAYER = 503;
uint256 internal constant INVALID_SIGNATURE = 504;
uint256 internal constant EXIT_BELOW_MIN = 505;
uint256 internal constant JOIN_ABOVE_MAX = 506;
uint256 internal constant SWAP_LIMIT = 507;
uint256 internal constant SWAP_DEADLINE = 508;
uint256 internal constant CANNOT_SWAP_SAME_TOKEN = 509;
uint256 internal constant UNKNOWN_AMOUNT_IN_FIRST_SWAP = 510;
uint256 internal constant MALCONSTRUCTED_MULTIHOP_SWAP = 511;
uint256 internal constant INTERNAL_BALANCE_OVERFLOW = 512;
uint256 internal constant INSUFFICIENT_INTERNAL_BALANCE = 513;
uint256 internal constant INVALID_ETH_INTERNAL_BALANCE = 514;
uint256 internal constant INVALID_POST_LOAN_BALANCE = 515;
uint256 internal constant INSUFFICIENT_ETH = 516;
uint256 internal constant UNALLOCATED_ETH = 517;
uint256 internal constant ETH_TRANSFER = 518;
uint256 internal constant CANNOT_USE_ETH_SENTINEL = 519;
uint256 internal constant TOKENS_MISMATCH = 520;
uint256 internal constant TOKEN_NOT_REGISTERED = 521;
uint256 internal constant TOKEN_ALREADY_REGISTERED = 522;
uint256 internal constant TOKENS_ALREADY_SET = 523;
uint256 internal constant TOKENS_LENGTH_MUST_BE_2 = 524;
uint256 internal constant NONZERO_TOKEN_BALANCE = 525;
uint256 internal constant BALANCE_TOTAL_OVERFLOW = 526;
uint256 internal constant POOL_NO_TOKENS = 527;
uint256 internal constant INSUFFICIENT_FLASH_LOAN_BALANCE = 528;
// Fees
uint256 internal constant SWAP_FEE_PERCENTAGE_TOO_HIGH = 600;
uint256 internal constant FLASH_LOAN_FEE_PERCENTAGE_TOO_HIGH = 601;
uint256 internal constant INSUFFICIENT_FLASH_LOAN_FEE_AMOUNT = 602;
uint256 internal constant AUM_FEE_PERCENTAGE_TOO_HIGH = 603;
// FeeSplitter
uint256 internal constant SPLITTER_FEE_PERCENTAGE_TOO_HIGH = 700;
// Misc
uint256 internal constant UNIMPLEMENTED = 998;
uint256 internal constant SHOULD_NOT_HAPPEN = 999;
}
@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/IAuthentication.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.7.0 <0.9.0;
interface IAuthentication {
/**
* @dev Returns the action identifier associated with the external function described by `selector`.
*/
function getActionId(bytes4 selector) external view returns (bytes32);
}
@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/ISignaturesValidator.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.7.0 <0.9.0;
/**
* @dev Interface for the SignatureValidator helper, used to support meta-transactions.
*/
interface ISignaturesValidator {
/**
* @dev Returns the EIP712 domain separator.
*/
function getDomainSeparator() external view returns (bytes32);
/**
* @dev Returns the next nonce used by an address to sign messages.
*/
function getNextNonce(address user) external view returns (uint256);
}
@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/ITemporarilyPausable.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.7.0 <0.9.0;
/**
* @dev Interface for the TemporarilyPausable helper.
*/
interface ITemporarilyPausable {
/**
* @dev Emitted every time the pause state changes by `_setPaused`.
*/
event PausedStateChanged(bool paused);
/**
* @dev Returns the current paused state.
*/
function getPausedState()
external
view
returns (
bool paused,
uint256 pauseWindowEndTime,
uint256 bufferPeriodEndTime
);
}
@balancer-labs/v2-interfaces/contracts/solidity-utils/misc/IWETH.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.7.0 <0.9.0;
import "../openzeppelin/IERC20.sol";
/**
* @dev Interface for WETH9.
* See https://github.com/gnosis/canonical-weth/blob/0dd1ea3e295eef916d0c6223ec63141137d22d67/contracts/WETH9.sol
*/
interface IWETH is IERC20 {
function deposit() external payable;
function withdraw(uint256 amount) external;
}
@balancer-labs/v2-interfaces/contracts/solidity-utils/openzeppelin/IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.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);
}
@balancer-labs/v2-interfaces/contracts/vault/IAsset.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.7.0 <0.9.0;
/**
* @dev This is an empty interface used to represent either ERC20-conforming token contracts or ETH (using the zero
* address sentinel value). We're just relying on the fact that `interface` can be used to declare new address-like
* types.
*
* This concept is unrelated to a Pool's Asset Managers.
*/
interface IAsset {
// solhint-disable-previous-line no-empty-blocks
}
@balancer-labs/v2-interfaces/contracts/vault/IAuthorizer.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.7.0 <0.9.0;
interface IAuthorizer {
/**
* @dev Returns true if `account` can perform the action described by `actionId` in the contract `where`.
*/
function canPerform(
bytes32 actionId,
address account,
address where
) external view returns (bool);
}
@balancer-labs/v2-interfaces/contracts/vault/IBasicAuthorizer.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.7.0 <0.9.0;
import "./IAuthorizer.sol";
interface IBasicAuthorizer is IAuthorizer {
// solhint-disable-next-line func-name-mixedcase
function DEFAULT_ADMIN_ROLE() external returns (bytes32);
function getRoleAdmin(bytes32 role) external view returns (bytes32);
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
@balancer-labs/v2-interfaces/contracts/vault/IFlashLoanRecipient.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.7.0 <0.9.0;
// Inspired by Aave Protocol's IFlashLoanReceiver.
import "../solidity-utils/openzeppelin/IERC20.sol";
interface IFlashLoanRecipient {
/**
* @dev When `flashLoan` is called on the Vault, it invokes the `receiveFlashLoan` hook on the recipient.
*
* At the time of the call, the Vault will have transferred `amounts` for `tokens` to the recipient. Before this
* call returns, the recipient must have transferred `amounts` plus `feeAmounts` for each token back to the
* Vault, or else the entire flash loan will revert.
*
* `userData` is the same value passed in the `IVault.flashLoan` call.
*/
function receiveFlashLoan(
IERC20[] memory tokens,
uint256[] memory amounts,
uint256[] memory feeAmounts,
bytes memory userData
) external;
}
@balancer-labs/v2-interfaces/contracts/vault/IProtocolFeesCollector.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.7.0 <0.9.0;
pragma experimental ABIEncoderV2;
import "../solidity-utils/openzeppelin/IERC20.sol";
import "./IVault.sol";
import "./IAuthorizer.sol";
interface IProtocolFeesCollector {
event SwapFeePercentageChanged(uint256 newSwapFeePercentage);
event FlashLoanFeePercentageChanged(uint256 newFlashLoanFeePercentage);
function withdrawCollectedFees(
IERC20[] calldata tokens,
uint256[] calldata amounts,
address recipient
) external;
function setSwapFeePercentage(uint256 newSwapFeePercentage) external;
function setFlashLoanFeePercentage(uint256 newFlashLoanFeePercentage) external;
function getSwapFeePercentage() external view returns (uint256);
function getFlashLoanFeePercentage() external view returns (uint256);
function getCollectedFeeAmounts(IERC20[] memory tokens) external view returns (uint256[] memory feeAmounts);
function getAuthorizer() external view returns (IAuthorizer);
function vault() external view returns (IVault);
}
@balancer-labs/v2-interfaces/contracts/vault/IVault.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma experimental ABIEncoderV2;
import "../solidity-utils/openzeppelin/IERC20.sol";
import "../solidity-utils/helpers/IAuthentication.sol";
import "../solidity-utils/helpers/ISignaturesValidator.sol";
import "../solidity-utils/helpers/ITemporarilyPausable.sol";
import "../solidity-utils/misc/IWETH.sol";
import "./IAsset.sol";
import "./IAuthorizer.sol";
import "./IFlashLoanRecipient.sol";
import "./IProtocolFeesCollector.sol";
pragma solidity >=0.7.0 <0.9.0;
/**
* @dev Full external interface for the Vault core contract - no external or public methods exist in the contract that
* don't override one of these declarations.
*/
interface IVault is ISignaturesValidator, ITemporarilyPausable, IAuthentication {
// Generalities about the Vault:
//
// - Whenever documentation refers to 'tokens', it strictly refers to ERC20-compliant token contracts. Tokens are
// transferred out of the Vault by calling the `IERC20.transfer` function, and transferred in by calling
// `IERC20.transferFrom`. In these cases, the sender must have previously allowed the Vault to use their tokens by
// calling `IERC20.approve`. The only deviation from the ERC20 standard that is supported is functions not returning
// a boolean value: in these scenarios, a non-reverting call is assumed to be successful.
//
// - All non-view functions in the Vault are non-reentrant: calling them while another one is mid-execution (e.g.
// while execution control is transferred to a token contract during a swap) will result in a revert. View
// functions can be called in a re-reentrant way, but doing so might cause them to return inconsistent results.
// Contracts calling view functions in the Vault must make sure the Vault has not already been entered.
//
// - View functions revert if referring to either unregistered Pools, or unregistered tokens for registered Pools.
// Authorizer
//
// Some system actions are permissioned, like setting and collecting protocol fees. This permissioning system exists
// outside of the Vault in the Authorizer contract: the Vault simply calls the Authorizer to check if the caller
// can perform a given action.
/**
* @dev Returns the Vault's Authorizer.
*/
function getAuthorizer() external view returns (IAuthorizer);
/**
* @dev Sets a new Authorizer for the Vault. The caller must be allowed by the current Authorizer to do this.
*
* Emits an `AuthorizerChanged` event.
*/
function setAuthorizer(IAuthorizer newAuthorizer) external;
/**
* @dev Emitted when a new authorizer is set by `setAuthorizer`.
*/
event AuthorizerChanged(IAuthorizer indexed newAuthorizer);
// Relayers
//
// Additionally, it is possible for an account to perform certain actions on behalf of another one, using their
// Vault ERC20 allowance and Internal Balance. These accounts are said to be 'relayers' for these Vault functions,
// and are expected to be smart contracts with sound authentication mechanisms. For an account to be able to wield
// this power, two things must occur:
// - The Authorizer must grant the account the permission to be a relayer for the relevant Vault function. This
// means that Balancer governance must approve each individual contract to act as a relayer for the intended
// functions.
// - Each user must approve the relayer to act on their behalf.
// This double protection means users cannot be tricked into approving malicious relayers (because they will not
// have been allowed by the Authorizer via governance), nor can malicious relayers approved by a compromised
// Authorizer or governance drain user funds, since they would also need to be approved by each individual user.
/**
* @dev Returns true if `user` has approved `relayer` to act as a relayer for them.
*/
function hasApprovedRelayer(address user, address relayer) external view returns (bool);
/**
* @dev Allows `relayer` to act as a relayer for `sender` if `approved` is true, and disallows it otherwise.
*
* Emits a `RelayerApprovalChanged` event.
*/
function setRelayerApproval(
address sender,
address relayer,
bool approved
) external;
/**
* @dev Emitted every time a relayer is approved or disapproved by `setRelayerApproval`.
*/
event RelayerApprovalChanged(address indexed relayer, address indexed sender, bool approved);
// Internal Balance
//
// Users can deposit tokens into the Vault, where they are allocated to their Internal Balance, and later
// transferred or withdrawn. It can also be used as a source of tokens when joining Pools, as a destination
// when exiting them, and as either when performing swaps. This usage of Internal Balance results in greatly reduced
// gas costs when compared to relying on plain ERC20 transfers, leading to large savings for frequent users.
//
// Internal Balance management features batching, which means a single contract call can be used to perform multiple
// operations of different kinds, with different senders and recipients, at once.
/**
* @dev Returns `user`'s Internal Balance for a set of tokens.
*/
function getInternalBalance(address user, IERC20[] memory tokens) external view returns (uint256[] memory);
/**
* @dev Performs a set of user balance operations, which involve Internal Balance (deposit, withdraw or transfer)
* and plain ERC20 transfers using the Vault's allowance. This last feature is particularly useful for relayers, as
* it lets integrators reuse a user's Vault allowance.
*
* For each operation, if the caller is not `sender`, it must be an authorized relayer for them.
*/
function manageUserBalance(UserBalanceOp[] memory ops) external payable;
/**
* @dev Data for `manageUserBalance` operations, which include the possibility for ETH to be sent and received
without manual WETH wrapping or unwrapping.
*/
struct UserBalanceOp {
UserBalanceOpKind kind;
IAsset asset;
uint256 amount;
address sender;
address payable recipient;
}
// There are four possible operations in `manageUserBalance`:
//
// - DEPOSIT_INTERNAL
// Increases the Internal Balance of the `recipient` account by transferring tokens from the corresponding
// `sender`. The sender must have allowed the Vault to use their tokens via `IERC20.approve()`.
//
// ETH can be used by passing the ETH sentinel value as the asset and forwarding ETH in the call: it will be wrapped
// and deposited as WETH. Any ETH amount remaining will be sent back to the caller (not the sender, which is
// relevant for relayers).
//
// Emits an `InternalBalanceChanged` event.
//
//
// - WITHDRAW_INTERNAL
// Decreases the Internal Balance of the `sender` account by transferring tokens to the `recipient`.
//
// ETH can be used by passing the ETH sentinel value as the asset. This will deduct WETH instead, unwrap it and send
// it to the recipient as ETH.
//
// Emits an `InternalBalanceChanged` event.
//
//
// - TRANSFER_INTERNAL
// Transfers tokens from the Internal Balance of the `sender` account to the Internal Balance of `recipient`.
//
// Reverts if the ETH sentinel value is passed.
//
// Emits an `InternalBalanceChanged` event.
//
//
// - TRANSFER_EXTERNAL
// Transfers tokens from `sender` to `recipient`, using the Vault's ERC20 allowance. This is typically used by
// relayers, as it lets them reuse a user's Vault allowance.
//
// Reverts if the ETH sentinel value is passed.
//
// Emits an `ExternalBalanceTransfer` event.
enum UserBalanceOpKind { DEPOSIT_INTERNAL, WITHDRAW_INTERNAL, TRANSFER_INTERNAL, TRANSFER_EXTERNAL }
/**
* @dev Emitted when a user's Internal Balance changes, either from calls to `manageUserBalance`, or through
* interacting with Pools using Internal Balance.
*
* Because Internal Balance works exclusively with ERC20 tokens, ETH deposits and withdrawals will use the WETH
* address.
*/
event InternalBalanceChanged(address indexed user, IERC20 indexed token, int256 delta);
/**
* @dev Emitted when a user's Vault ERC20 allowance is used by the Vault to transfer tokens to an external account.
*/
event ExternalBalanceTransfer(IERC20 indexed token, address indexed sender, address recipient, uint256 amount);
// Pools
//
// There are three specialization settings for Pools, which allow for cheaper swaps at the cost of reduced
// functionality:
//
// - General: no specialization, suited for all Pools. IGeneralPool is used for swap request callbacks, passing the
// balance of all tokens in the Pool. These Pools have the largest swap costs (because of the extra storage reads),
// which increase with the number of registered tokens.
//
// - Minimal Swap Info: IMinimalSwapInfoPool is used instead of IGeneralPool, which saves gas by only passing the
// balance of the two tokens involved in the swap. This is suitable for some pricing algorithms, like the weighted
// constant product one popularized by Balancer V1. Swap costs are smaller compared to general Pools, and are
// independent of the number of registered tokens.
//
// - Two Token: only allows two tokens to be registered. This achieves the lowest possible swap gas cost. Like
// minimal swap info Pools, these are called via IMinimalSwapInfoPool.
enum PoolSpecialization { GENERAL, MINIMAL_SWAP_INFO, TWO_TOKEN }
/**
* @dev Registers the caller account as a Pool with a given specialization setting. Returns the Pool's ID, which
* is used in all Pool-related functions. Pools cannot be deregistered, nor can the Pool's specialization be
* changed.
*
* The caller is expected to be a smart contract that implements either `IGeneralPool` or `IMinimalSwapInfoPool`,
* depending on the chosen specialization setting. This contract is known as the Pool's contract.
*
* Note that the same contract may register itself as multiple Pools with unique Pool IDs, or in other words,
* multiple Pools may share the same contract.
*
* Emits a `PoolRegistered` event.
*/
function registerPool(PoolSpecialization specialization) external returns (bytes32);
/**
* @dev Emitted when a Pool is registered by calling `registerPool`.
*/
event PoolRegistered(bytes32 indexed poolId, address indexed poolAddress, PoolSpecialization specialization);
/**
* @dev Returns a Pool's contract address and specialization setting.
*/
function getPool(bytes32 poolId) external view returns (address, PoolSpecialization);
/**
* @dev Registers `tokens` for the `poolId` Pool. Must be called by the Pool's contract.
*
* Pools can only interact with tokens they have registered. Users join a Pool by transferring registered tokens,
* exit by receiving registered tokens, and can only swap registered tokens.
*
* Each token can only be registered once. For Pools with the Two Token specialization, `tokens` must have a length
* of two, that is, both tokens must be registered in the same `registerTokens` call, and they must be sorted in
* ascending order.
*
* The `tokens` and `assetManagers` arrays must have the same length, and each entry in these indicates the Asset
* Manager for the corresponding token. Asset Managers can manage a Pool's tokens via `managePoolBalance`,
* depositing and withdrawing them directly, and can even set their balance to arbitrary amounts. They are therefore
* expected to be highly secured smart contracts with sound design principles, and the decision to register an
* Asset Manager should not be made lightly.
*
* Pools can choose not to assign an Asset Manager to a given token by passing in the zero address. Once an Asset
* Manager is set, it cannot be changed except by deregistering the associated token and registering again with a
* different Asset Manager.
*
* Emits a `TokensRegistered` event.
*/
function registerTokens(
bytes32 poolId,
IERC20[] memory tokens,
address[] memory assetManagers
) external;
/**
* @dev Emitted when a Pool registers tokens by calling `registerTokens`.
*/
event TokensRegistered(bytes32 indexed poolId, IERC20[] tokens, address[] assetManagers);
/**
* @dev Deregisters `tokens` for the `poolId` Pool. Must be called by the Pool's contract.
*
* Only registered tokens (via `registerTokens`) can be deregistered. Additionally, they must have zero total
* balance. For Pools with the Two Token specialization, `tokens` must have a length of two, that is, both tokens
* must be deregistered in the same `deregisterTokens` call.
*
* A deregistered token can be re-registered later on, possibly with a different Asset Manager.
*
* Emits a `TokensDeregistered` event.
*/
function deregisterTokens(bytes32 poolId, IERC20[] memory tokens) external;
/**
* @dev Emitted when a Pool deregisters tokens by calling `deregisterTokens`.
*/
event TokensDeregistered(bytes32 indexed poolId, IERC20[] tokens);
/**
* @dev Returns detailed information for a Pool's registered token.
*
* `cash` is the number of tokens the Vault currently holds for the Pool. `managed` is the number of tokens
* withdrawn and held outside the Vault by the Pool's token Asset Manager. The Pool's total balance for `token`
* equals the sum of `cash` and `managed`.
*
* Internally, `cash` and `managed` are stored using 112 bits. No action can ever cause a Pool's token `cash`,
* `managed` or `total` balance to be greater than 2^112 - 1.
*
* `lastChangeBlock` is the number of the block in which `token`'s total balance was last modified (via either a
* join, exit, swap, or Asset Manager update). This value is useful to avoid so-called 'sandwich attacks', for
* example when developing price oracles. A change of zero (e.g. caused by a swap with amount zero) is considered a
* change for this purpose, and will update `lastChangeBlock`.
*
* `assetManager` is the Pool's token Asset Manager.
*/
function getPoolTokenInfo(bytes32 poolId, IERC20 token)
external
view
returns (
uint256 cash,
uint256 managed,
uint256 lastChangeBlock,
address assetManager
);
/**
* @dev Returns a Pool's registered tokens, the total balance for each, and the latest block when *any* of
* the tokens' `balances` changed.
*
* The order of the `tokens` array is the same order that will be used in `joinPool`, `exitPool`, as well as in all
* Pool hooks (where applicable). Calls to `registerTokens` and `deregisterTokens` may change this order.
*
* If a Pool only registers tokens once, and these are sorted in ascending order, they will be stored in the same
* order as passed to `registerTokens`.
*
* Total balances include both tokens held by the Vault and those withdrawn by the Pool's Asset Managers. These are
* the amounts used by joins, exits and swaps. For a detailed breakdown of token balances, use `getPoolTokenInfo`
* instead.
*/
function getPoolTokens(bytes32 poolId)
external
view
returns (
IERC20[] memory tokens,
uint256[] memory balances,
uint256 lastChangeBlock
);
/**
* @dev Called by users to join a Pool, which transfers tokens from `sender` into the Pool's balance. This will
* trigger custom Pool behavior, which will typically grant something in return to `recipient` - often tokenized
* Pool shares.
*
* If the caller is not `sender`, it must be an authorized relayer for them.
*
* The `assets` and `maxAmountsIn` arrays must have the same length, and each entry indicates the maximum amount
* to send for each asset. The amounts to send are decided by the Pool and not the Vault: it just enforces
* these maximums.
*
* If joining a Pool that holds WETH, it is possible to send ETH directly: the Vault will do the wrapping. To enable
* this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead of the
* WETH address. Note that it is not possible to combine ETH and WETH in the same join. Any excess ETH will be sent
* back to the caller (not the sender, which is important for relayers).
*
* `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when
* interacting with Pools that register and deregister tokens frequently. If sending ETH however, the array must be
* sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the final
* `assets` array might not be sorted. Pools with no registered tokens cannot be joined.
*
* If `fromInternalBalance` is true, the caller's Internal Balance will be preferred: ERC20 transfers will only
* be made for the difference between the requested amount and Internal Balance (if any). Note that ETH cannot be
* withdrawn from Internal Balance: attempting to do so will trigger a revert.
*
* This causes the Vault to call the `IBasePool.onJoinPool` hook on the Pool's contract, where Pools implement
* their own custom logic. This typically requires additional information from the user (such as the expected number
* of Pool shares). This can be encoded in the `userData` argument, which is ignored by the Vault and passed
* directly to the Pool's contract, as is `recipient`.
*
* Emits a `PoolBalanceChanged` event.
*/
function joinPool(
bytes32 poolId,
address sender,
address recipient,
JoinPoolRequest memory request
) external payable;
struct JoinPoolRequest {
IAsset[] assets;
uint256[] maxAmountsIn;
bytes userData;
bool fromInternalBalance;
}
/**
* @dev Called by users to exit a Pool, which transfers tokens from the Pool's balance to `recipient`. This will
* trigger custom Pool behavior, which will typically ask for something in return from `sender` - often tokenized
* Pool shares. The amount of tokens that can be withdrawn is limited by the Pool's `cash` balance (see
* `getPoolTokenInfo`).
*
* If the caller is not `sender`, it must be an authorized relayer for them.
*
* The `tokens` and `minAmountsOut` arrays must have the same length, and each entry in these indicates the minimum
* token amount to receive for each token contract. The amounts to send are decided by the Pool and not the Vault:
* it just enforces these minimums.
*
* If exiting a Pool that holds WETH, it is possible to receive ETH directly: the Vault will do the unwrapping. To
* enable this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead
* of the WETH address. Note that it is not possible to combine ETH and WETH in the same exit.
*
* `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when
* interacting with Pools that register and deregister tokens frequently. If receiving ETH however, the array must
* be sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the
* final `assets` array might not be sorted. Pools with no registered tokens cannot be exited.
*
* If `toInternalBalance` is true, the tokens will be deposited to `recipient`'s Internal Balance. Otherwise,
* an ERC20 transfer will be performed. Note that ETH cannot be deposited to Internal Balance: attempting to
* do so will trigger a revert.
*
* `minAmountsOut` is the minimum amount of tokens the user expects to get out of the Pool, for each token in the
* `tokens` array. This array must match the Pool's registered tokens.
*
* This causes the Vault to call the `IBasePool.onExitPool` hook on the Pool's contract, where Pools implement
* their own custom logic. This typically requires additional information from the user (such as the expected number
* of Pool shares to return). This can be encoded in the `userData` argument, which is ignored by the Vault and
* passed directly to the Pool's contract.
*
* Emits a `PoolBalanceChanged` event.
*/
function exitPool(
bytes32 poolId,
address sender,
address payable recipient,
ExitPoolRequest memory request
) external;
struct ExitPoolRequest {
IAsset[] assets;
uint256[] minAmountsOut;
bytes userData;
bool toInternalBalance;
}
/**
* @dev Emitted when a user joins or exits a Pool by calling `joinPool` or `exitPool`, respectively.
*/
event PoolBalanceChanged(
bytes32 indexed poolId,
address indexed liquidityProvider,
IERC20[] tokens,
int256[] deltas,
uint256[] protocolFeeAmounts
);
enum PoolBalanceChangeKind { JOIN, EXIT }
// Swaps
//
// Users can swap tokens with Pools by calling the `swap` and `batchSwap` functions. To do this,
// they need not trust Pool contracts in any way: all security checks are made by the Vault. They must however be
// aware of the Pools' pricing algorithms in order to estimate the prices Pools will quote.
//
// The `swap` function executes a single swap, while `batchSwap` can perform multiple swaps in sequence.
// In each individual swap, tokens of one kind are sent from the sender to the Pool (this is the 'token in'),
// and tokens of another kind are sent from the Pool to the recipient in exchange (this is the 'token out').
// More complex swaps, such as one token in to multiple tokens out can be achieved by batching together
// individual swaps.
//
// There are two swap kinds:
// - 'given in' swaps, where the amount of tokens in (sent to the Pool) is known, and the Pool determines (via the
// `onSwap` hook) the amount of tokens out (to send to the recipient).
// - 'given out' swaps, where the amount of tokens out (received from the Pool) is known, and the Pool determines
// (via the `onSwap` hook) the amount of tokens in (to receive from the sender).
//
// Additionally, it is possible to chain swaps using a placeholder input amount, which the Vault replaces with
// the calculated output of the previous swap. If the previous swap was 'given in', this will be the calculated
// tokenOut amount. If the previous swap was 'given out', it will use the calculated tokenIn amount. These extended
// swaps are known as 'multihop' swaps, since they 'hop' through a number of intermediate tokens before arriving at
// the final intended token.
//
// In all cases, tokens are only transferred in and out of the Vault (or withdrawn from and deposited into Internal
// Balance) after all individual swaps have been completed, and the net token balance change computed. This makes
// certain swap patterns, such as multihops, or swaps that interact with the same token pair in multiple Pools, cost
// much less gas than they would otherwise.
//
// It also means that under certain conditions it is possible to perform arbitrage by swapping with multiple
// Pools in a way that results in net token movement out of the Vault (profit), with no tokens being sent in (only
// updating the Pool's internal accounting).
//
// To protect users from front-running or the market changing rapidly, they supply a list of 'limits' for each token
// involved in the swap, where either the maximum number of tokens to send (by passing a positive value) or the
// minimum amount of tokens to receive (by passing a negative value) is specified.
//
// Additionally, a 'deadline' timestamp can also be provided, forcing the swap to fail if it occurs after
// this point in time (e.g. if the transaction failed to be included in a block promptly).
//
// If interacting with Pools that hold WETH, it is possible to both send and receive ETH directly: the Vault will do
// the wrapping and unwrapping. To enable this mechanism, the IAsset sentinel value (the zero address) must be
// passed in the `assets` array instead of the WETH address. Note that it is possible to combine ETH and WETH in the
// same swap. Any excess ETH will be sent back to the caller (not the sender, which is relevant for relayers).
//
// Finally, Internal Balance can be used when either sending or receiving tokens.
enum SwapKind { GIVEN_IN, GIVEN_OUT }
/**
* @dev Performs a swap with a single Pool.
*
* If the swap is 'given in' (the number of tokens to send to the Pool is known), it returns the amount of tokens
* taken from the Pool, which must be greater than or equal to `limit`.
*
* If the swap is 'given out' (the number of tokens to take from the Pool is known), it returns the amount of tokens
* sent to the Pool, which must be less than or equal to `limit`.
*
* Internal Balance usage and the recipient are determined by the `funds` struct.
*
* Emits a `Swap` event.
*/
function swap(
SingleSwap memory singleSwap,
FundManagement memory funds,
uint256 limit,
uint256 deadline
) external payable returns (uint256);
/**
* @dev Data for a single swap executed by `swap`. `amount` is either `amountIn` or `amountOut` depending on
* the `kind` value.
*
* `assetIn` and `assetOut` are either token addresses, or the IAsset sentinel value for ETH (the zero address).
* Note that Pools never interact with ETH directly: it will be wrapped to or unwrapped from WETH by the Vault.
*
* The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be
* used to extend swap behavior.
*/
struct SingleSwap {
bytes32 poolId;
SwapKind kind;
IAsset assetIn;
IAsset assetOut;
uint256 amount;
bytes userData;
}
/**
* @dev Performs a series of swaps with one or multiple Pools. In each individual swap, the caller determines either
* the amount of tokens sent to or received from the Pool, depending on the `kind` value.
*
* Returns an array with the net Vault asset balance deltas. Positive amounts represent tokens (or ETH) sent to the
* Vault, and negative amounts represent tokens (or ETH) sent by the Vault. Each delta corresponds to the asset at
* the same index in the `assets` array.
*
* Swaps are executed sequentially, in the order specified by the `swaps` array. Each array element describes a
* Pool, the token to be sent to this Pool, the token to receive from it, and an amount that is either `amountIn` or
* `amountOut` depending on the swap kind.
*
* Multihop swaps can be executed by passing an `amount` value of zero for a swap. This will cause the amount in/out
* of the previous swap to be used as the amount in for the current one. In a 'given in' swap, 'tokenIn' must equal
* the previous swap's `tokenOut`. For a 'given out' swap, `tokenOut` must equal the previous swap's `tokenIn`.
*
* The `assets` array contains the addresses of all assets involved in the swaps. These are either token addresses,
* or the IAsset sentinel value for ETH (the zero address). Each entry in the `swaps` array specifies tokens in and
* out by referencing an index in `assets`. Note that Pools never interact with ETH directly: it will be wrapped to
* or unwrapped from WETH by the Vault.
*
* Internal Balance usage, sender, and recipient are determined by the `funds` struct. The `limits` array specifies
* the minimum or maximum amount of each token the vault is allowed to transfer.
*
* `batchSwap` can be used to make a single swap, like `swap` does, but doing so requires more gas than the
* equivalent `swap` call.
*
* Emits `Swap` events.
*/
function batchSwap(
SwapKind kind,
BatchSwapStep[] memory swaps,
IAsset[] memory assets,
FundManagement memory funds,
int256[] memory limits,
uint256 deadline
) external payable returns (int256[] memory);
/**
* @dev Data for each individual swap executed by `batchSwap`. The asset in and out fields are indexes into the
* `assets` array passed to that function, and ETH assets are converted to WETH.
*
* If `amount` is zero, the multihop mechanism is used to determine the actual amount based on the amount in/out
* from the previous swap, depending on the swap kind.
*
* The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be
* used to extend swap behavior.
*/
struct BatchSwapStep {
bytes32 poolId;
uint256 assetInIndex;
uint256 assetOutIndex;
uint256 amount;
bytes userData;
}
/**
* @dev Emitted for each individual swap performed by `swap` or `batchSwap`.
*/
event Swap(
bytes32 indexed poolId,
IERC20 indexed tokenIn,
IERC20 indexed tokenOut,
uint256 amountIn,
uint256 amountOut
);
/**
* @dev All tokens in a swap are either sent from the `sender` account to the Vault, or from the Vault to the
* `recipient` account.
*
* If the caller is not `sender`, it must be an authorized relayer for them.
*
* If `fromInternalBalance` is true, the `sender`'s Internal Balance will be preferred, performing an ERC20
* transfer for the difference between the requested amount and the User's Internal Balance (if any). The `sender`
* must have allowed the Vault to use their tokens via `IERC20.approve()`. This matches the behavior of
* `joinPool`.
*
* If `toInternalBalance` is true, tokens will be deposited to `recipient`'s internal balance instead of
* transferred. This matches the behavior of `exitPool`.
*
* Note that ETH cannot be deposited to or withdrawn from Internal Balance: attempting to do so will trigger a
* revert.
*/
struct FundManagement {
address sender;
bool fromInternalBalance;
address payable recipient;
bool toInternalBalance;
}
/**
* @dev Simulates a call to `batchSwap`, returning an array of Vault asset deltas. Calls to `swap` cannot be
* simulated directly, but an equivalent `batchSwap` call can and will yield the exact same result.
*
* Each element in the array corresponds to the asset at the same index, and indicates the number of tokens (or ETH)
* the Vault would take from the sender (if positive) or send to the recipient (if negative). The arguments it
* receives are the same that an equivalent `batchSwap` call would receive.
*
* Unlike `batchSwap`, this function performs no checks on the sender or recipient field in the `funds` struct.
* This makes it suitable to be called by off-chain applications via eth_call without needing to hold tokens,
* approve them for the Vault, or even know a user's address.
*
* Note that this function is not 'view' (due to implementation details): the client code must explicitly execute
* eth_call instead of eth_sendTransaction.
*/
function queryBatchSwap(
SwapKind kind,
BatchSwapStep[] memory swaps,
IAsset[] memory assets,
FundManagement memory funds
) external returns (int256[] memory assetDeltas);
// Flash Loans
/**
* @dev Performs a 'flash loan', sending tokens to `recipient`, executing the `receiveFlashLoan` hook on it,
* and then reverting unless the tokens plus a proportional protocol fee have been returned.
*
* The `tokens` and `amounts` arrays must have the same length, and each entry in these indicates the loan amount
* for each token contract. `tokens` must be sorted in ascending order.
*
* The 'userData' field is ignored by the Vault, and forwarded as-is to `recipient` as part of the
* `receiveFlashLoan` call.
*
* Emits `FlashLoan` events.
*/
function flashLoan(
IFlashLoanRecipient recipient,
IERC20[] memory tokens,
uint256[] memory amounts,
bytes memory userData
) external;
/**
* @dev Emitted for each individual flash loan performed by `flashLoan`.
*/
event FlashLoan(IFlashLoanRecipient indexed recipient, IERC20 indexed token, uint256 amount, uint256 feeAmount);
// Asset Management
//
// Each token registered for a Pool can be assigned an Asset Manager, which is able to freely withdraw the Pool's
// tokens from the Vault, deposit them, or assign arbitrary values to its `managed` balance (see
// `getPoolTokenInfo`). This makes them extremely powerful and dangerous. Even if an Asset Manager only directly
// controls one of the tokens in a Pool, a malicious manager could set that token's balance to manipulate the
// prices of the other tokens, and then drain the Pool with swaps. The risk of using Asset Managers is therefore
// not constrained to the tokens they are managing, but extends to the entire Pool's holdings.
//
// However, a properly designed Asset Manager smart contract can be safely used for the Pool's benefit,
// for example by lending unused tokens out for interest, or using them to participate in voting protocols.
//
// This concept is unrelated to the IAsset interface.
/**
* @dev Performs a set of Pool balance operations, which may be either withdrawals, deposits or updates.
*
* Pool Balance management features batching, which means a single contract call can be used to perform multiple
* operations of different kinds, with different Pools and tokens, at once.
*
* For each operation, the caller must be registered as the Asset Manager for `token` in `poolId`.
*/
function managePoolBalance(PoolBalanceOp[] memory ops) external;
struct PoolBalanceOp {
PoolBalanceOpKind kind;
bytes32 poolId;
IERC20 token;
uint256 amount;
}
/**
* Withdrawals decrease the Pool's cash, but increase its managed balance, leaving the total balance unchanged.
*
* Deposits increase the Pool's cash, but decrease its managed balance, leaving the total balance unchanged.
*
* Updates don't affect the Pool's cash balance, but because the managed balance changes, it does alter the total.
* The external amount can be either increased or decreased by this call (i.e., reporting a gain or a loss).
*/
enum PoolBalanceOpKind { WITHDRAW, DEPOSIT, UPDATE }
/**
* @dev Emitted when a Pool's token Asset Manager alters its balance via `managePoolBalance`.
*/
event PoolBalanceManaged(
bytes32 indexed poolId,
address indexed assetManager,
IERC20 indexed token,
int256 cashDelta,
int256 managedDelta
);
// Protocol Fees
//
// Some operations cause the Vault to collect tokens in the form of protocol fees, which can then be withdrawn by
// permissioned accounts.
//
// There are two kinds of protocol fees:
//
// - flash loan fees: charged on all flash loans, as a percentage of the amounts lent.
//
// - swap fees: a percentage of the fees charged by Pools when performing swaps. For a number of reasons, including
// swap gas costs and interface simplicity, protocol swap fees are not charged on each individual swap. Rather,
// Pools are expected to keep track of how much they have charged in swap fees, and pay any outstanding debts to the
// Vault when they are joined or exited. This prevents users from joining a Pool with unpaid debt, as well as
// exiting a Pool in debt without first paying their share.
/**
* @dev Returns the current protocol fee module.
*/
function getProtocolFeesCollector() external view returns (IProtocolFeesCollector);
/**
* @dev Safety mechanism to pause most Vault operations in the event of an emergency - typically detection of an
* error in some part of the system.
*
* The Vault can only be paused during an initial time period, after which pausing is forever disabled.
*
* While the contract is paused, the following features are disabled:
* - depositing and transferring internal balance
* - transferring external balance (using the Vault's allowance)
* - swaps
* - joining Pools
* - Asset Manager interactions
*
* Internal Balance can still be withdrawn, and Pools exited.
*/
function setPaused(bool paused) external;
/**
* @dev Returns the Vault's WETH instance.
*/
function WETH() external view returns (IWETH);
// solhint-disable-previous-line func-name-mixedcase
}
@balancer-labs/v2-solidity-utils/contracts/helpers/InputHelpers.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.7.0;
import "@balancer-labs/v2-interfaces/contracts/solidity-utils/openzeppelin/IERC20.sol";
import "@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/BalancerErrors.sol";
library InputHelpers {
function ensureInputLengthMatch(uint256 a, uint256 b) internal pure {
_require(a == b, Errors.INPUT_LENGTH_MISMATCH);
}
function ensureInputLengthMatch(
uint256 a,
uint256 b,
uint256 c
) internal pure {
_require(a == b && b == c, Errors.INPUT_LENGTH_MISMATCH);
}
function ensureArrayIsSorted(IERC20[] memory array) internal pure {
address[] memory addressArray;
// solhint-disable-next-line no-inline-assembly
assembly {
addressArray := array
}
ensureArrayIsSorted(addressArray);
}
function ensureArrayIsSorted(address[] memory array) internal pure {
if (array.length < 2) {
return;
}
address previous = array[0];
for (uint256 i = 1; i < array.length; ++i) {
address current = array[i];
_require(previous < current, Errors.UNSORTED_ARRAY);
previous = current;
}
}
}
@balancer-labs/v2-solidity-utils/contracts/math/Math.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/BalancerErrors.sol";
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow checks.
* Adapted from OpenZeppelin's SafeMath library.
*/
library Math {
// solhint-disable no-inline-assembly
/**
* @dev Returns the absolute value of a signed integer.
*/
function abs(int256 a) internal pure returns (uint256 result) {
// Equivalent to:
// result = a > 0 ? uint256(a) : uint256(-a)
assembly {
let s := sar(255, a)
result := sub(xor(a, s), s)
}
}
/**
* @dev Returns the addition of two unsigned integers of 256 bits, reverting on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
_require(c >= a, Errors.ADD_OVERFLOW);
return c;
}
/**
* @dev Returns the addition of two signed integers, reverting on overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
_require((b >= 0 && c >= a) || (b < 0 && c < a), Errors.ADD_OVERFLOW);
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers of 256 bits, reverting on overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
_require(b <= a, Errors.SUB_OVERFLOW);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the subtraction of two signed integers, reverting on overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
_require((b >= 0 && c <= a) || (b < 0 && c > a), Errors.SUB_OVERFLOW);
return c;
}
/**
* @dev Returns the largest of two numbers of 256 bits.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256 result) {
// Equivalent to:
// result = (a < b) ? b : a;
assembly {
result := sub(a, mul(sub(a, b), lt(a, b)))
}
}
/**
* @dev Returns the smallest of two numbers of 256 bits.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256 result) {
// Equivalent to `result = (a < b) ? a : b`
assembly {
result := sub(a, mul(sub(a, b), gt(a, b)))
}
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
_require(a == 0 || c / a == b, Errors.MUL_OVERFLOW);
return c;
}
function div(
uint256 a,
uint256 b,
bool roundUp
) internal pure returns (uint256) {
return roundUp ? divUp(a, b) : divDown(a, b);
}
function divDown(uint256 a, uint256 b) internal pure returns (uint256) {
_require(b != 0, Errors.ZERO_DIVISION);
return a / b;
}
function divUp(uint256 a, uint256 b) internal pure returns (uint256 result) {
_require(b != 0, Errors.ZERO_DIVISION);
// Equivalent to:
// result = a == 0 ? 0 : 1 + (a - 1) / b;
assembly {
result := mul(iszero(iszero(a)), add(1, div(sub(a, 1), b)))
}
}
}
@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Address.sol
// SPDX-License-Identifier: MIT
// Based on the Address library from OpenZeppelin Contracts, altered by removing the `isContract` checks on
// `functionCall` and `functionDelegateCall` in order to save gas, as the recipients are known to be contracts.
pragma solidity ^0.7.0;
import "@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/BalancerErrors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly {
size := extcodesize(account)
}
return size > 0;
}
// solhint-disable max-line-length
/**
* @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, Errors.ADDRESS_INSUFFICIENT_BALANCE);
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
_require(success, Errors.ADDRESS_CANNOT_SEND_VALUE);
}
/**
* @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:
*
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call(data);
return verifyCallResult(success, returndata);
}
// solhint-enable max-line-length
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but passing some native ETH as msg.value to the call.
*
* _Available since v3.4._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return verifyCallResult(success, returndata);
}
/**
* @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) {
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata);
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling up the
* revert reason or using the one provided.
*
* _Available since v4.3._
*/
function verifyCallResult(bool success, bytes memory returndata) 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
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
_revert(Errors.LOW_LEVEL_CALL_FAILED);
}
}
}
}
@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// Based on the ReentrancyGuard library from OpenZeppelin Contracts, altered to reduce bytecode size.
// Modifier code is inlined by the compiler, which causes its code to appear multiple times in the codebase. By using
// private functions, we achieve the same end result with slightly higher runtime gas costs, but reduced bytecode size.
pragma solidity ^0.7.0;
import "@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/BalancerErrors.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract 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 make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_enterNonReentrant();
_;
_exitNonReentrant();
}
function _enterNonReentrant() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
_require(_status != _ENTERED, Errors.REENTRANCY);
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _exitNonReentrant() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
@balancer-labs/v2-vault/contracts/authorizer/TimelockAuthorizer.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
import "@balancer-labs/v2-interfaces/contracts/liquidity-mining/IAuthorizerAdaptorEntrypoint.sol";
import "@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/BalancerErrors.sol";
import "@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/IAuthentication.sol";
import "@balancer-labs/v2-interfaces/contracts/vault/IVault.sol";
import "@balancer-labs/v2-interfaces/contracts/vault/IAuthorizer.sol";
import "@balancer-labs/v2-solidity-utils/contracts/helpers/InputHelpers.sol";
import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol";
import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Address.sol";
import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ReentrancyGuard.sol";
import "./TimelockExecutor.sol";
/**
* @title Timelock Authorizer
* @author Balancer Labs
* @dev Authorizer with timelocks (delays).
*
* Users are allowed to perform actions if they have the permission to do so.
*
* This Authorizer implementation allows defining a delay per action identifier. If a delay is set for an action, users
* are instead allowed to schedule an execution that will be run in the future by the Authorizer instead of executing it
* directly themselves.
*
* Glossary:
* - Action: Operation that can be performed to a target contract. These are identified by a unique bytes32 `actionId`
* defined by each target contract following `IAuthentication.getActionId`.
* - Scheduled execution: The Authorizer can define different delays per `actionId` in order to determine that a
* specific time window must pass before these can be executed. When a delay is set for an `actionId`, executions
* must be scheduled. These executions are identified with an unsigned integer called `scheduledExecutionId`.
* - Permission: Unique identifier to refer to a user (who) that is allowed to perform an action (what) in a specific
* target contract (where). This identifier is called `permissionId` and is computed as
* `keccak256(actionId, account, where)`.
*
* Permission granularity:
* In addition to the who/what/where of a permission, an extra notion of a "specifier" is introduced to enable more
* granular configuration. This concept is used within the Authorizer to provide clarity among four ambiguous actions:
* granting/revoking permissions, executing scheduled actions, and setting action delays. For example, in managing
* the permission to set action delays, it is desirable to delineate whether an account can set delays for all
* actions indiscriminately or only for a specific action ID. In this case, the permission's "baseActionId" is the
* action ID for scheduling a delay change, and the "specifier" is the action ID for which the delay will be changed.
* The "baseActionId" and "specifier" of a permission are combined into a single "extended" `actionId`
* by calling `getExtendedActionId(baseActionId, specifier)`.
*
* Note that the TimelockAuthorizer doesn't make use of reentrancy guards on the majority of external functions.
* The only function which makes an external non-view call (and so could initate a reentrancy attack) is `execute`
* which executes a scheduled execution and so this is the only protected function.
* In fact a number of the TimelockAuthorizer's functions may only be called through a scheduled execution so reentrancy
* is necessary in order to be able to call these.
*/
contract TimelockAuthorizer is IAuthorizer, IAuthentication, ReentrancyGuard {
using Address for address;
/**
* @notice An action specifier which grants a general permission to perform all variants of the base action.
*/
bytes32
public constant GENERAL_PERMISSION_SPECIFIER = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
// solhint-disable-previous-line max-line-length
/**
* @notice A sentinel value for `where` that will match any address.
*/
address public constant EVERYWHERE = address(-1);
// We institute a maximum delay to ensure that actions cannot be accidentally/maliciously disabled through setting
// an arbitrarily long delay.
uint256 public constant MAX_DELAY = 2 * (365 days);
// We need a minimum delay period to ensure that scheduled actions may be properly scrutinised.
uint256 public constant MIN_DELAY = 5 days;
struct ScheduledExecution {
address where;
bytes data;
bool executed;
bool cancelled;
bool protected;
uint256 executableAt;
}
// solhint-disable var-name-mixedcase
bytes32 public immutable GRANT_ACTION_ID;
bytes32 public immutable REVOKE_ACTION_ID;
bytes32 public immutable EXECUTE_ACTION_ID;
bytes32 public immutable SCHEDULE_DELAY_ACTION_ID;
// These action ids do not need to be used by external actors as the action ids above do.
// Instead they're saved just for gas savings so we can keep them private.
bytes32 private immutable _GENERAL_GRANT_ACTION_ID;
bytes32 private immutable _GENERAL_REVOKE_ACTION_ID;
TimelockExecutor private immutable _executor;
IAuthentication private immutable _vault;
IAuthorizerAdaptorEntrypoint private immutable _authorizerAdaptorEntrypoint;
IAuthorizerAdaptor private immutable _authorizerAdaptor;
uint256 private immutable _rootTransferDelay;
address private _root;
address private _pendingRoot;
ScheduledExecution[] private _scheduledExecutions;
mapping(bytes32 => bool) private _isPermissionGranted;
mapping(bytes32 => uint256) private _delaysPerActionId;
/**
* @notice Emitted when a new execution `scheduledExecutionId` is scheduled.
*/
event ExecutionScheduled(bytes32 indexed actionId, uint256 indexed scheduledExecutionId);
/**
* @notice Emitted when an execution `scheduledExecutionId` is executed.
*/
event ExecutionExecuted(uint256 indexed scheduledExecutionId);
/**
* @notice Emitted when an execution `scheduledExecutionId` is cancelled.
*/
event ExecutionCancelled(uint256 indexed scheduledExecutionId);
/**
* @notice Emitted when a new `delay` is set in order to perform action `actionId`.
*/
event ActionDelaySet(bytes32 indexed actionId, uint256 delay);
/**
* @notice Emitted when `account` is granted permission to perform action `actionId` in target `where`.
*/
event PermissionGranted(bytes32 indexed actionId, address indexed account, address indexed where);
/**
* @notice Emitted when `account`'s permission to perform action `actionId` in target `where` is revoked.
*/
event PermissionRevoked(bytes32 indexed actionId, address indexed account, address indexed where);
/**
* @notice Emitted when a new `root` is set.
*/
event RootSet(address indexed root);
/**
* @notice Emitted when a new `pendingRoot` is set. The new account must claim ownership for it to take effect.
*/
event PendingRootSet(address indexed pendingRoot);
modifier onlyExecutor() {
_require(msg.sender == address(_executor), Errors.SENDER_NOT_ALLOWED);
_;
}
constructor(
address admin,
IAuthorizerAdaptorEntrypoint authorizerAdaptorEntrypoint,
uint256 rootTransferDelay
) {
_setRoot(admin);
_vault = authorizerAdaptorEntrypoint.getVault();
_authorizerAdaptor = authorizerAdaptorEntrypoint.getAuthorizerAdaptor();
_authorizerAdaptorEntrypoint = authorizerAdaptorEntrypoint;
_executor = new TimelockExecutor();
_rootTransferDelay = rootTransferDelay;
bytes32 grantActionId = getActionId(TimelockAuthorizer.grantPermissions.selector);
bytes32 revokeActionId = getActionId(TimelockAuthorizer.revokePermissions.selector);
bytes32 generalGrantActionId = getExtendedActionId(grantActionId, GENERAL_PERMISSION_SPECIFIER);
bytes32 generalRevokeActionId = getExtendedActionId(revokeActionId, GENERAL_PERMISSION_SPECIFIER);
// These don't technically need to be granted as `admin` will be the new root, and can grant these permissions
// directly to themselves. By granting here improves ergonomics, especially in testing, as the admin is now
// ready to grant any permission.
_grantPermission(generalGrantActionId, admin, EVERYWHERE);
_grantPermission(generalRevokeActionId, admin, EVERYWHERE);
GRANT_ACTION_ID = grantActionId;
REVOKE_ACTION_ID = revokeActionId;
EXECUTE_ACTION_ID = getActionId(TimelockAuthorizer.execute.selector);
SCHEDULE_DELAY_ACTION_ID = getActionId(TimelockAuthorizer.scheduleDelayChange.selector);
_GENERAL_GRANT_ACTION_ID = generalGrantActionId;
_GENERAL_REVOKE_ACTION_ID = generalRevokeActionId;
}
/**
* @notice Returns true if `account` is the root.
*/
function isRoot(address account) public view returns (bool) {
return account == _root;
}
/**
* @notice Returns true if `account` is the pending root.
*/
function isPendingRoot(address account) public view returns (bool) {
return account == _pendingRoot;
}
/**
* @notice Returns the delay required to transfer the root address.
*/
function getRootTransferDelay() public view returns (uint256) {
return _rootTransferDelay;
}
/**
* @notice Returns the vault address.
*/
function getVault() external view returns (address) {
return address(_vault);
}
/**
* @notice Returns the executor address.
*/
function getExecutor() external view returns (address) {
return address(_executor);
}
/**
* @notice Returns the root address.
*/
function getRoot() external view returns (address) {
return _root;
}
/**
* @notice Returns the currently pending new root address.
*/
function getPendingRoot() external view returns (address) {
return _pendingRoot;
}
/**
* @notice Returns the action ID for function selector `selector`.
*/
function getActionId(bytes4 selector) public view override returns (bytes32) {
return keccak256(abi.encodePacked(bytes32(uint256(address(this))), selector));
}
/**
* @notice Returns the action ID for granting a permission for action `actionId`.
*/
function getGrantPermissionActionId(bytes32 actionId) public view returns (bytes32) {
return getExtendedActionId(GRANT_ACTION_ID, actionId);
}
/**
* @notice Returns the action ID for revoking a permission for action `actionId`.
*/
function getRevokePermissionActionId(bytes32 actionId) public view returns (bytes32) {
return getExtendedActionId(REVOKE_ACTION_ID, actionId);
}
/**
* @notice Returns the action ID for executing the scheduled action with execution ID `executionId`.
*/
function getExecuteExecutionActionId(uint256 executionId) public view returns (bytes32) {
return getExtendedActionId(EXECUTE_ACTION_ID, bytes32(executionId));
}
/**
* @notice Returns the action ID for scheduling setting a new delay for action `actionId`.
*/
function getScheduleDelayActionId(bytes32 actionId) public view returns (bytes32) {
return getExtendedActionId(SCHEDULE_DELAY_ACTION_ID, actionId);
}
/**
* @notice Returns the extended action ID for base action ID `baseActionId` with specific params `specifier`.
*/
function getExtendedActionId(bytes32 baseActionId, bytes32 specifier) public pure returns (bytes32) {
return keccak256(abi.encodePacked(baseActionId, specifier));
}
/**
* @notice Returns the execution delay for action `actionId`.
*/
function getActionIdDelay(bytes32 actionId) external view returns (uint256) {
return _delaysPerActionId[actionId];
}
/**
* @notice Returns the permission ID for action `actionId`, account `account` and target `where`.
*/
function getPermissionId(
bytes32 actionId,
address account,
address where
) public pure returns (bytes32) {
return keccak256(abi.encodePacked(actionId, account, where));
}
/**
* @notice Returns true if `account` has the permission defined by action `actionId` and target `where`.
* @dev This function is specific for the strict permission defined by the tuple `(actionId, where)`: `account` may
* instead hold the global permission for the action `actionId`, also granting them permission on `where`, but this
* function would return false regardless.
*
* For this reason, it's recommended to use `hasPermission` if checking whether `account` is allowed to perform
* a given action.
*/
function isPermissionGrantedOnTarget(
bytes32 actionId,
address account,
address where
) external view returns (bool) {
return _isPermissionGranted[getPermissionId(actionId, account, where)];
}
/**
* @notice Returns true if `account` has permission over the action `actionId` in target `where`.
*/
function hasPermission(
bytes32 actionId,
address account,
address where
) public view returns (bool) {
return
_isPermissionGranted[getPermissionId(actionId, account, where)] ||
_isPermissionGranted[getPermissionId(actionId, account, EVERYWHERE)];
}
/**
* @notice Returns true if `account` is allowed to grant permissions for action `actionId` in target `where`.
*/
function isGranter(
bytes32 actionId,
address account,
address where
) public view returns (bool) {
return _hasPermissionSpecificallyOrGenerally(GRANT_ACTION_ID, account, where, actionId);
}
/**
* @notice Returns true if `account` is allowed to revoke permissions for action `actionId` in target `where`.
*/
function isRevoker(
bytes32 actionId,
address account,
address where
) public view returns (bool) {
return _hasPermissionSpecificallyOrGenerally(REVOKE_ACTION_ID, account, where, actionId);
}
/**
* @notice Returns true if `account` can perform action `actionId` in target `where`.
* @dev All authentications that require the authorizer adaptor must originate from the authorizer adaptor
* entrypoint: requests coming directly from the authorizer adaptor will be rejected.
*/
function canPerform(
bytes32 actionId,
address account,
address where
) public view override returns (bool) {
if (msg.sender == address(_authorizerAdaptor)) {
// We special case the situation where the caller is the `AuthorizerAdaptor`, as it can be tricked into
// passing an incorrect `actionId` value, potentially resulting in escalation of privileges.
//
// To remedy this we force all calls to the `AuthorizerAdaptor` to be made through a singleton entrypoint
// contract, called the `AuthorizerAdaptorEntrypoint`. This contract correctly checks whether `account` can
// perform `actionId` on `where`, and then forwards the call onto the `AuthorizerAdaptor` to execute.
//
// The authorizer then rejects calls to the `AuthorizerAdaptor` which aren't made through the entrypoint,
// and approves all calls made through it (since the entrypoint will have already performed any necessary
// permission checks).
return account == address(_authorizerAdaptorEntrypoint);
}
return
_delaysPerActionId[actionId] > 0 ? account == address(_executor) : hasPermission(actionId, account, where);
}
/**
* @notice Returns true if `account` can grant permissions for action `actionId` in target `where`.
*/
function canGrant(
bytes32 actionId,
address account,
address where
) public view returns (bool) {
return _canPerformSpecificallyOrGenerally(GRANT_ACTION_ID, account, where, actionId);
}
/**
* @notice Returns true if `account` can revoke permissions for action `actionId` in target `where`.
*/
function canRevoke(
bytes32 actionId,
address account,
address where
) public view returns (bool) {
return _canPerformSpecificallyOrGenerally(REVOKE_ACTION_ID, account, where, actionId);
}
/**
* @notice Returns the scheduled execution `scheduledExecutionId`.
*/
function getScheduledExecution(uint256 scheduledExecutionId) external view returns (ScheduledExecution memory) {
return _scheduledExecutions[scheduledExecutionId];
}
/**
* @notice Returns true if execution `scheduledExecutionId` can be executed.
* Only true if it is not already executed or cancelled, and if the execution delay has passed.
*/
function canExecute(uint256 scheduledExecutionId) external view returns (bool) {
require(scheduledExecutionId < _scheduledExecutions.length, "ACTION_DOES_NOT_EXIST");
ScheduledExecution storage scheduledExecution = _scheduledExecutions[scheduledExecutionId];
return
!scheduledExecution.executed &&
!scheduledExecution.cancelled &&
block.timestamp >= scheduledExecution.executableAt;
// solhint-disable-previous-line not-rely-on-time
}
/**
* @notice Schedules an execution to change the root address to `newRoot`.
*/
function scheduleRootChange(address newRoot, address[] memory executors)
external
returns (uint256 scheduledExecutionId)
{
_require(isRoot(msg.sender), Errors.SENDER_NOT_ALLOWED);
bytes32 actionId = getActionId(this.setPendingRoot.selector);
bytes memory data = abi.encodeWithSelector(this.setPendingRoot.selector, newRoot);
return _scheduleWithDelay(actionId, address(this), data, getRootTransferDelay(), executors);
}
/**
* @notice Sets the pending root address to `pendingRoot`.
* @dev This function can never be called directly - it is only ever called as part of a scheduled execution by
* the TimelockExecutor after after calling `scheduleRootChange`.
*
* Once set as the pending root, `pendingRoot` may then call `claimRoot` to become the new root.
*/
function setPendingRoot(address pendingRoot) external onlyExecutor {
_setPendingRoot(pendingRoot);
}
/**
* @notice Transfers root powers from the current to the pending root address.
* @dev This function prevents accidentally transferring root to an invalid address.
* To become root, the pending root must call this function to ensure that it's able to interact with this contract.
*/
function claimRoot() external {
address currentRoot = _root;
address pendingRoot = _pendingRoot;
_require(msg.sender == pendingRoot, Errors.SENDER_NOT_ALLOWED);
// Grant powers to new root to grant or revoke any permission over any contract.
_grantPermission(_GENERAL_GRANT_ACTION_ID, pendingRoot, EVERYWHERE);
_grantPermission(_GENERAL_REVOKE_ACTION_ID, pendingRoot, EVERYWHERE);
// Revoke these powers from the outgoing root.
_revokePermission(_GENERAL_GRANT_ACTION_ID, currentRoot, EVERYWHERE);
_revokePermission(_GENERAL_REVOKE_ACTION_ID, currentRoot, EVERYWHERE);
// Complete the root transfer and reset the pending root.
_setRoot(pendingRoot);
_setPendingRoot(address(0));
}
/**
* @notice Sets a new delay `delay` for action `actionId`.
* @dev This function can never be called directly - it is only ever called as part of a scheduled execution by
* the TimelockExecutor after after calling `scheduleDelayChange`.
*/
function setDelay(bytes32 actionId, uint256 delay) external onlyExecutor {
bytes32 setAuthorizerActionId = _vault.getActionId(IVault.setAuthorizer.selector);
bool isAllowed = actionId == setAuthorizerActionId || delay <= _delaysPerActionId[setAuthorizerActionId];
require(isAllowed, "DELAY_EXCEEDS_SET_AUTHORIZER");
_delaysPerActionId[actionId] = delay;
emit ActionDelaySet(actionId, delay);
}
/**
* @notice Schedules an execution to set action `actionId`'s delay to `newDelay`.
*/
function scheduleDelayChange(
bytes32 actionId,
uint256 newDelay,
address[] memory executors
) external returns (uint256 scheduledExecutionId) {
require(newDelay <= MAX_DELAY, "DELAY_TOO_LARGE");
_require(isRoot(msg.sender), Errors.SENDER_NOT_ALLOWED);
// The delay change is scheduled so that it's never possible to execute an action in a shorter time than the
// current delay.
//
// If we're reducing the action's delay then we must first wait for the difference between the two delays.
// This means that if we immediately schedule the action for execution once the delay is reduced, then
// these two delays combined will result in the original delay.
//
// If we're increasing the delay on an action, we could execute this change immediately as it's impossible to
// perform an action sooner by increasing its delay. Requiring a potentially long delay before increasing the
// delay just adds unnecessary friction to increasing security for sensitive actions.
//
// We also enforce a minimum delay period to allow proper scrutiny of the change of the action's delay.
uint256 actionDelay = _delaysPerActionId[actionId];
uint256 executionDelay = newDelay < actionDelay ? Math.max(actionDelay - newDelay, MIN_DELAY) : MIN_DELAY;
bytes32 scheduleDelayActionId = getScheduleDelayActionId(actionId);
bytes memory data = abi.encodeWithSelector(this.setDelay.selector, actionId, newDelay);
return _scheduleWithDelay(scheduleDelayActionId, address(this), data, executionDelay, executors);
}
/**
* @notice Schedules an arbitrary execution of `data` in target `where`.
*/
function schedule(
address where,
bytes memory data,
address[] memory executors
) external returns (uint256 scheduledExecutionId) {
// Allowing scheduling arbitrary calls into the TimelockAuthorizer is dangerous.
//
// It is expected that only the `root` account can initiate a root transfer as this condition is enforced
// by the `scheduleRootChange` function which is the expected method of scheduling a call to `setPendingRoot`.
// If a call to `setPendingRoot` could be scheduled using this function as well as `scheduleRootChange` then
// accounts other than `root` could initiate a root transfer (provided they had the necessary permission).
// Similarly, `setDelay` can only be called if scheduled via `scheduleDelayChange`.
//
// For this reason we disallow this function from scheduling calls to functions on the Authorizer to ensure that
// these actions can only be scheduled through specialised functions.
require(where != address(this), "CANNOT_SCHEDULE_AUTHORIZER_ACTIONS");
// We also disallow the TimelockExecutor from attempting to call into itself. Otherwise the above protection
// could be bypassed by wrapping a call to `setPendingRoot` inside of a call causing the TimelockExecutor to
// reenter itself, essentially hiding the fact that `where == address(this)` inside `data`.
//
// Note: The TimelockExecutor only accepts calls from the TimelockAuthorizer (i.e. not from itself) so this
// scenario should be impossible but this check is cheap so we enforce it here as well anyway.
require(where != address(_executor), "ATTEMPTING_EXECUTOR_REENTRANCY");
bytes32 actionId = IAuthentication(where).getActionId(_decodeSelector(data));
_require(hasPermission(actionId, msg.sender, where), Errors.SENDER_NOT_ALLOWED);
return _schedule(actionId, where, data, executors);
}
/**
* @notice Executes a scheduled action `scheduledExecutionId`.
*/
function execute(uint256 scheduledExecutionId) external nonReentrant returns (bytes memory result) {
require(scheduledExecutionId < _scheduledExecutions.length, "ACTION_DOES_NOT_EXIST");
ScheduledExecution storage scheduledExecution = _scheduledExecutions[scheduledExecutionId];
require(!scheduledExecution.executed, "ACTION_ALREADY_EXECUTED");
require(!scheduledExecution.cancelled, "ACTION_ALREADY_CANCELLED");
// solhint-disable-next-line not-rely-on-time
require(block.timestamp >= scheduledExecution.executableAt, "ACTION_NOT_EXECUTABLE");
if (scheduledExecution.protected) {
bytes32 executeScheduledActionId = getExecuteExecutionActionId(scheduledExecutionId);
bool isAllowed = hasPermission(executeScheduledActionId, msg.sender, address(this));
_require(isAllowed, Errors.SENDER_NOT_ALLOWED);
}
scheduledExecution.executed = true;
// Note that this is the only place in the entire contract we perform a non-view call to an external contract.
result = _executor.execute(scheduledExecution.where, scheduledExecution.data);
emit ExecutionExecuted(scheduledExecutionId);
}
/**
* @notice Cancels a scheduled action `scheduledExecutionId`.
* @dev The permission to cancel a scheduled action is the same one used to schedule it.
*
* Note that in the case of cancelling a malicious granting or revocation of permissions to an address,
* we must assume that the granter/revoker status of all non-malicious addresses will be revoked as calls to
* manageGranter/manageRevoker have no delays associated with them.
*/
function cancel(uint256 scheduledExecutionId) external {
require(scheduledExecutionId < _scheduledExecutions.length, "ACTION_DOES_NOT_EXIST");
ScheduledExecution storage scheduledExecution = _scheduledExecutions[scheduledExecutionId];
require(!scheduledExecution.executed, "ACTION_ALREADY_EXECUTED");
require(!scheduledExecution.cancelled, "ACTION_ALREADY_CANCELLED");
// The permission to cancel a scheduled action is the same one used to schedule it.
// The root address may cancel any action even without this permission.
IAuthentication target = IAuthentication(scheduledExecution.where);
bytes32 actionId = target.getActionId(_decodeSelector(scheduledExecution.data));
_require(
hasPermission(actionId, msg.sender, scheduledExecution.where) || isRoot(msg.sender),
Errors.SENDER_NOT_ALLOWED
);
scheduledExecution.cancelled = true;
emit ExecutionCancelled(scheduledExecutionId);
}
/**
* @notice Sets `account`'s granter status to `allowed` for action `actionId` in target `where`.
* @dev Note that granters can revoke the granter status of other granters, even removing the root.
* However the root can always rejoin, and then remove any malicious granters.
*
* Note that there are no delays associated with adding or removing granters. This is based on the assumption that
* any action which a malicous user could exploit to damage the protocol will have a sufficiently long delay
* associated with either granting permission for or exercising that permission such that the root will be able to
* reestablish control and cancel the action before it can be executed.
*/
function manageGranter(
bytes32 actionId,
address account,
address where,
bool allowed
) external {
// Root may grant or revoke granter status from any address.
// Granters may only revoke a granter status from any address.
bool isAllowed = isRoot(msg.sender) || (!allowed && isGranter(actionId, msg.sender, where));
_require(isAllowed, Errors.SENDER_NOT_ALLOWED);
bytes32 grantPermissionsActionId = getGrantPermissionActionId(actionId);
(allowed ? _grantPermission : _revokePermission)(grantPermissionsActionId, account, where);
}
/**
* @notice Grants multiple permissions to a single `account`.
* @dev This function can only be used for actions that have no grant delay. For those that do, use
* `scheduleGrantPermission` instead.
*/
function grantPermissions(
bytes32[] memory actionIds,
address account,
address[] memory where
) external {
InputHelpers.ensureInputLengthMatch(actionIds.length, where.length);
for (uint256 i = 0; i < actionIds.length; i++) {
// For permissions that have a delay when granting, `canGrant` will return false. `scheduleGrantPermission`
// will succeed as it checks `isGranter` instead.
// Note that `canGrant` will return true for the executor if the permission has a delay.
_require(canGrant(actionIds[i], msg.sender, where[i]), Errors.SENDER_NOT_ALLOWED);
_grantPermission(actionIds[i], account, where[i]);
}
}
/**
* @notice Schedules a grant permission to `account` for action `actionId` in target `where`.
*/
function scheduleGrantPermission(
bytes32 actionId,
address account,
address where,
address[] memory executors
) external returns (uint256 scheduledExecutionId) {
_require(isGranter(actionId, msg.sender, where), Errors.SENDER_NOT_ALLOWED);
bytes memory data = abi.encodeWithSelector(this.grantPermissions.selector, _ar(actionId), account, _ar(where));
bytes32 grantPermissionId = getGrantPermissionActionId(actionId);
return _schedule(grantPermissionId, address(this), data, executors);
}
/**
* @notice Sets `account`'s revoker status to `allowed` for action `actionId` in target `where`.
* @dev Note that revokers can revoke the revoker status of other revokers, even banning the root.
* However the root can always rejoin, and then remove any malicious revokers.
*
* Note that there are no delays associated with adding or removing revokers. This is based on the assumption that
* any permissions for which revocation from key addresses would be dangerous (e.g. preventing the BalancerMinter
* from minting BAL) have sufficiently long delays associated with revoking them that the root will be able to
* reestablish control and cancel the revocation before the scheduled revocation can be executed.
*/
function manageRevoker(
bytes32 actionId,
address account,
address where,
bool allowed
) external {
// Root may grant or revoke revoker status from any address.
// Revokers may only revoke a revoker status from any address.
bool isAllowed = isRoot(msg.sender) || (!allowed && isRevoker(actionId, msg.sender, where));
_require(isAllowed, Errors.SENDER_NOT_ALLOWED);
bytes32 revokePermissionsActionId = getRevokePermissionActionId(actionId);
(allowed ? _grantPermission : _revokePermission)(revokePermissionsActionId, account, where);
}
/**
* @notice Revokes multiple permissions from a single `account`.
* @dev This function can only be used for actions that have no revoke delay. For those that do, use
* `scheduleRevokePermission` instead.
*/
function revokePermissions(
bytes32[] memory actionIds,
address account,
address[] memory where
) external {
InputHelpers.ensureInputLengthMatch(actionIds.length, where.length);
for (uint256 i = 0; i < actionIds.length; i++) {
// For permissions that have a delay when granting, `canRevoke` will return false.
// `scheduleRevokePermission` will succeed as it checks `isRevoker` instead.
// Note that `canRevoke` will return true for the executor if the permission has a delay.
_require(canRevoke(actionIds[i], msg.sender, where[i]), Errors.SENDER_NOT_ALLOWED);
_revokePermission(actionIds[i], account, where[i]);
}
}
/**
* @notice Schedules a revoke permission from `account` for action `actionId` in target `where`.
*/
function scheduleRevokePermission(
bytes32 actionId,
address account,
address where,
address[] memory executors
) external returns (uint256 scheduledExecutionId) {
_require(isRevoker(actionId, msg.sender, where), Errors.SENDER_NOT_ALLOWED);
bytes memory data = abi.encodeWithSelector(this.revokePermissions.selector, _ar(actionId), account, _ar(where));
bytes32 revokePermissionId = getRevokePermissionActionId(actionId);
return _schedule(revokePermissionId, address(this), data, executors);
}
/**
* @notice Revokes multiple permissions from the caller.
* @dev Note that the caller can always renounce permissions, even if revoking them would typically be
* subject to a delay.
*/
function renouncePermissions(bytes32[] memory actionIds, address[] memory where) external {
InputHelpers.ensureInputLengthMatch(actionIds.length, where.length);
for (uint256 i = 0; i < actionIds.length; i++) {
_revokePermission(actionIds[i], msg.sender, where[i]);
}
}
function _grantPermission(
bytes32 actionId,
address account,
address where
) private {
bytes32 permission = getPermissionId(actionId, account, where);
if (!_isPermissionGranted[permission]) {
_isPermissionGranted[permission] = true;
emit PermissionGranted(actionId, account, where);
}
}
function _revokePermission(
bytes32 actionId,
address account,
address where
) private {
bytes32 permission = getPermissionId(actionId, account, where);
if (_isPermissionGranted[permission]) {
_isPermissionGranted[permission] = false;
emit PermissionRevoked(actionId, account, where);
}
}
function _schedule(
bytes32 actionId,
address where,
bytes memory data,
address[] memory executors
) private returns (uint256 scheduledExecutionId) {
uint256 delay = _delaysPerActionId[actionId];
require(delay > 0, "CANNOT_SCHEDULE_ACTION");
return _scheduleWithDelay(actionId, where, data, delay, executors);
}
function _scheduleWithDelay(
bytes32 actionId,
address where,
bytes memory data,
uint256 delay,
address[] memory executors
) private returns (uint256 scheduledExecutionId) {
scheduledExecutionId = _scheduledExecutions.length;
emit ExecutionScheduled(actionId, scheduledExecutionId);
// solhint-disable-next-line not-rely-on-time
uint256 executableAt = block.timestamp + delay;
bool protected = executors.length > 0;
_scheduledExecutions.push(
ScheduledExecution({
where: where,
data: data,
executed: false,
cancelled: false,
protected: protected,
executableAt: executableAt
})
);
bytes32 executeActionId = getExecuteExecutionActionId(scheduledExecutionId);
for (uint256 i = 0; i < executors.length; i++) {
_grantPermission(executeActionId, executors[i], address(this));
}
}
/**
* @notice Returns if `account` has permission to perform the action `(baseActionId, specifier)` on target `where`.
* @dev This function differs from `_canPerformSpecificallyOrGenerally` as it *doesn't* take into account whether
* there is a delay for the action associated with the permission being checked.
*
* The address `account` may have the permission associated with the provided action but that doesn't necessarily
* mean that it may perform that action. If there is no delay associated with this action, `account` may perform the
* action directly. If there is a delay, then `account` is instead able to schedule that action to be performed
* at a later date.
*
* This function returns true in both cases.
*/
function _hasPermissionSpecificallyOrGenerally(
bytes32 baseActionId,
address account,
address where,
bytes32 specifier
) internal view returns (bool) {
bytes32 specificActionId = getExtendedActionId(baseActionId, specifier);
bytes32 generalActionId = getExtendedActionId(baseActionId, GENERAL_PERMISSION_SPECIFIER);
return hasPermission(specificActionId, account, where) || hasPermission(generalActionId, account, where);
}
/**
* @notice Returns if `account` can perform the action `(baseActionId, specifier)` on target `where`.
* @dev This function differs from `_hasPermissionSpecificallyOrGenerally` as it *does* take into account whether
* there is a delay for the action associated with the permission being checked.
*
* The address `account` may have the permission associated with the provided action but that doesn't necessarily
* mean that it may perform that action. If there is no delay associated with this action, `account` may perform the
* action directly. If there is a delay, then `account` is instead able to schedule that action to be performed
* at a later date.
*
* This function only returns true only in the first case (except for actions performed by the authorizer timelock).
*/
function _canPerformSpecificallyOrGenerally(
bytes32 baseActionId,
address account,
address where,
bytes32 specifier
) internal view returns (bool) {
// If there is a delay defined for the specific action ID, then the sender must be the authorizer (scheduled
// execution)
bytes32 specificActionId = getExtendedActionId(baseActionId, specifier);
if (_delaysPerActionId[specificActionId] > 0) {
return account == address(_executor);
}
// If there is no delay, we check if the account has that permission
if (hasPermission(specificActionId, account, where)) {
return true;
}
// If the account doesn't have the explicit permission, we repeat for the general permission
bytes32 generalActionId = getExtendedActionId(baseActionId, GENERAL_PERMISSION_SPECIFIER);
return canPerform(generalActionId, account, where);
}
/**
* @dev Sets the root address to `root`.
*/
function _setRoot(address root) internal {
_root = root;
emit RootSet(root);
}
/**
* @dev Sets the pending root address to `pendingRoot`.
*/
function _setPendingRoot(address pendingRoot) internal {
_pendingRoot = pendingRoot;
emit PendingRootSet(pendingRoot);
}
function _decodeSelector(bytes memory data) internal pure returns (bytes4) {
// The bytes4 type is left-aligned and padded with zeros: we make use of that property to build the selector
if (data.length < 4) return bytes4(0);
return bytes4(data[0]) | (bytes4(data[1]) >> 8) | (bytes4(data[2]) >> 16) | (bytes4(data[3]) >> 24);
}
function _ar(bytes32 item) private pure returns (bytes32[] memory result) {
result = new bytes32[](1);
result[0] = item;
}
function _ar(address item) private pure returns (address[] memory result) {
result = new address[](1);
result[0] = item;
}
}
@balancer-labs/v2-vault/contracts/authorizer/TimelockExecutor.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.7.0;
import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Address.sol";
import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ReentrancyGuard.sol";
import "./TimelockAuthorizer.sol";
contract TimelockExecutor is ReentrancyGuard {
TimelockAuthorizer public immutable authorizer;
constructor() {
authorizer = TimelockAuthorizer(msg.sender);
}
function execute(address target, bytes memory data) external nonReentrant returns (bytes memory result) {
require(msg.sender == address(authorizer), "ERR_SENDER_NOT_AUTHORIZER");
return Address.functionCall(target, data);
}
}
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"optimizer":{"runs":9999,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"constructor","inputs":[{"type":"address","name":"_root","internalType":"address"},{"type":"address","name":"_oldAuthorizer","internalType":"contract IBasicAuthorizer"},{"type":"address","name":"_authorizerAdaptorEntrypoint","internalType":"contract IAuthorizerAdaptorEntrypoint"},{"type":"tuple[]","name":"_rolesData","internalType":"struct TimelockAuthorizerMigrator.RoleData[]","components":[{"type":"address"},{"type":"bytes32"},{"type":"address"}]},{"type":"tuple[]","name":"_grantersData","internalType":"struct TimelockAuthorizerMigrator.RoleData[]","components":[{"type":"address"},{"type":"bytes32"},{"type":"address"}]},{"type":"tuple[]","name":"_revokersData","internalType":"struct TimelockAuthorizerMigrator.RoleData[]","components":[{"type":"address"},{"type":"bytes32"},{"type":"address"}]},{"type":"tuple[]","name":"_executeDelaysData","internalType":"struct TimelockAuthorizerMigrator.DelayData[]","components":[{"type":"bytes32"},{"type":"uint256"}]},{"type":"tuple[]","name":"_grantDelaysData","internalType":"struct TimelockAuthorizerMigrator.DelayData[]","components":[{"type":"bytes32"},{"type":"uint256"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"CHANGE_ROOT_DELAY","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"EVERYWHERE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"GENERAL_PERMISSION_SPECIFIER","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"executeDelays","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"finalizeMigration","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract TimelockAuthorizer"}],"name":"newAuthorizer","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IBasicAuthorizer"}],"name":"oldAuthorizer","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"root","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rootChangeExecutionId","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"startRootTransfer","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IVault"}],"name":"vault","inputs":[]}]
Contract Creation Code
0x6101006040523480156200001257600080fd5b5060405162005626380380620056268339810160408190526200003591620009c4565b600030876224ea006040516200004b906200083a565b620000599392919062000baf565b604051809103906000f08015801562000076573d6000803e3d6000fd5b506001600160601b0319606082811b821660e0528a811b821660c0528b901b1660a052604080516311b2515f60e31b815290519192506001600160a01b03891691638d928af891600480820192602092909190829003018186803b158015620000de57600080fd5b505afa158015620000f3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000119919062000b1d565b60601b6001600160601b03191660805260005b8651811015620002a9576200014062000848565b8782815181106200014d57fe5b60200260200101519050896001600160a01b0316639be2a8848260200151836000015184604001516040518463ffffffff1660e01b8152600401620001959392919062000c47565b60206040518083038186803b158015620001ae57600080fd5b505afa158015620001c3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001e9919062000adb565b620002115760405162461bcd60e51b8152600401620002089062000cb7565b60405180910390fd5b826001600160a01b0316636f8bc596620002358360200151620007a260201b60201c565b835160408501516200024790620007e4565b6040518463ffffffff1660e01b8152600401620002679392919062000bd3565b600060405180830381600087803b1580156200028257600080fd5b505af115801562000297573d6000803e3d6000fd5b5050600190930192506200012c915050565b5060005b85518110156200037557816001600160a01b03166378a08377878381518110620002d357fe5b602002602001015160200151888481518110620002ec57fe5b6020026020010151600001518985815181106200030557fe5b60200260200101516040015160016040518563ffffffff1660e01b815260040162000334949392919062000c66565b600060405180830381600087803b1580156200034f57600080fd5b505af115801562000364573d6000803e3d6000fd5b505060019092019150620002ad9050565b5060005b84518110156200044157816001600160a01b031663cf8475da8683815181106200039f57fe5b602002602001015160200151878481518110620003b857fe5b602002602001015160000151888581518110620003d157fe5b60200260200101516040015160016040518563ffffffff1660e01b815260040162000400949392919062000c66565b600060405180830381600087803b1580156200041b57600080fd5b505af115801562000430573d6000803e3d6000fd5b505060019092019150620003799050565b5060005b83518110156200055f5762278d008482815181106200046057fe5b60200260200101516020015111156200048d5760405162461bcd60e51b8152600401620002089062000ce0565b816001600160a01b031663f0845522858381518110620004a957fe5b602002602001015160000151868481518110620004c257fe5b602002602001015160200151620004df30620007e460201b60201c565b6040518463ffffffff1660e01b8152600401620004ff9392919062000c8d565b602060405180830381600087803b1580156200051a57600080fd5b505af11580156200052f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000555919062000b04565b5060010162000445565b5060005b8251811015620006fe5762278d008382815181106200057e57fe5b6020026020010151602001511115620005ab5760405162461bcd60e51b8152600401620002089062000ce0565b816001600160a01b031663f0845522836001600160a01b031663151b89d1868581518110620005d657fe5b6020026020010151600001516040518263ffffffff1660e01b815260040162000600919062000c3e565b60206040518083038186803b1580156200061957600080fd5b505afa1580156200062e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000654919062000b04565b8584815181106200066157fe5b6020026020010151602001516200067e30620007e460201b60201c565b6040518463ffffffff1660e01b81526004016200069e9392919062000c8d565b602060405180830381600087803b158015620006b957600080fd5b505af1158015620006ce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620006f4919062000b04565b5060010162000563565b506001600160a01b038116632e3ed05b8a6200071a30620007e4565b6040518363ffffffff1660e01b81526004016200073992919062000b81565b602060405180830381600087803b1580156200075457600080fd5b505af115801562000769573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200078f919062000b04565b6000555062000d77975050505050505050565b604080516001808252818301909252606091602080830190803683370190505090508181600081518110620007d357fe5b602002602001018181525050919050565b6040805160018082528183019092526060916020808301908036833701905050905081816000815181106200081557fe5b60200260200101906001600160a01b031690816001600160a01b031681525050919050565b61390e8062001d1883390190565b604080516060810182526000808252602082018190529181019190915290565b8051620008758162000d5e565b92915050565b600082601f8301126200088c578081fd5b8151620008a36200089d8262000d3e565b62000d17565b8181529150602080830190848101604080850287018301881015620008c757600080fd5b6000805b868110156200090d5782848b031215620008e3578182fd5b620008ee8362000d17565b84518152858501518682015286529484019492820192600101620008cb565b5050505050505092915050565b600082601f8301126200092b578081fd5b81516200093c6200089d8262000d3e565b81815291506020808301908481016060808502870183018810156200096057600080fd5b6000805b868110156200090d5782848b0312156200097c578182fd5b620009878362000d17565b620009938b8662000868565b815285850151868201526040620009ad8c82880162000868565b908201528652948401949282019260010162000964565b600080600080600080600080610100898b031215620009e1578384fd5b620009ed8a8a62000868565b9750620009fe8a60208b0162000868565b965062000a0f8a60408b0162000868565b60608a01519096506001600160401b038082111562000a2c578586fd5b62000a3a8c838d016200091a565b965060808b015191508082111562000a50578586fd5b62000a5e8c838d016200091a565b955060a08b015191508082111562000a74578485fd5b62000a828c838d016200091a565b945060c08b015191508082111562000a98578384fd5b62000aa68c838d016200087b565b935060e08b015191508082111562000abc578283fd5b5062000acb8b828c016200087b565b9150509295985092959890939650565b60006020828403121562000aed578081fd5b8151801515811462000afd578182fd5b9392505050565b60006020828403121562000b16578081fd5b5051919050565b60006020828403121562000b2f578081fd5b815162000afd8162000d5e565b6000815180845260208085019450808401835b8381101562000b765781516001600160a01b03168752958201959082019060010162000b4f565b509495945050505050565b6001600160a01b038316815260406020820181905260009062000ba79083018462000b3c565b949350505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b606080825284519082018190526000906020906080840190828801845b8281101562000c0e5781518452928401929084019060010162000bf0565b5050506001600160a01b03861684830152838103604085015262000c33818662000b3c565b979650505050505050565b90815260200190565b9283526001600160a01b03918216602084015216604082015260600190565b9384526001600160a01b039283166020850152911660408301521515606082015260800190565b60008482528360208301526060604083015262000cae606083018462000b3c565b95945050505050565b6020808252600f908201526e554e45585045435445445f524f4c4560881b604082015260600190565b60208082526016908201527f554e45585045435445445f4c415247455f44454c415900000000000000000000604082015260600190565b6040518181016001600160401b038111828210171562000d3657600080fd5b604052919050565b60006001600160401b0382111562000d54578081fd5b5060209081020190565b6001600160a01b038116811462000d7457600080fd5b50565b60805160601c60a05160601c60c05160601c60e05160601c610f2362000df5600039806101a552806102d152806103cb52806104b352806105b9528061069e52806107025280610a365250806108c85280610a9652508061072f5280610aba52508061081d52806109065280610a095280610ade5250610f236000f3fe608060405234801561001057600080fd5b50600436106100d45760003560e01c8063a217fddf11610081578063ebf0c7171161005b578063ebf0c71714610146578063fbfa77cf1461014e578063fc78a22814610156576100d4565b8063a217fddf1461012e578063b78b608714610136578063c6bfe9ae1461013e576100d4565b80637217d9d1116100b25780637217d9d11461010957806398f85d5c1461011e578063a0c286d814610126576100d4565b806311f13145146100d95780633c44172d146100e357806362cde1ba146100eb575b600080fd5b6100e161015e565b005b6100e1610476565b6100f361066b565b6040516101009190610d0a565b60405180910390f35b61011161068f565b6040516101009190610d2b565b610111610696565b6100f361069c565b6101116106c0565b6100e16106c5565b6100f3610a94565b6100f3610ab8565b6100f3610adc565b61011161066b565b600054158061025257506040517f6badd2ab00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690636badd2ab906101db90600090600401610d2b565b60006040518083038186803b1580156101f357600080fd5b505afa158015610207573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261024d9190810190610c31565b604001515b610291576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028890610e8f565b60405180910390fd5b6000546040517fcc63604a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169163cc63604a916103059190600401610d2b565b60206040518083038186803b15801561031d57600080fd5b505afa158015610331573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103559190610bbc565b61038b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028890610e58565b6000546040517ffe0d94c100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169163fe0d94c1916103ff9190600401610d2b565b600060405180830381600087803b15801561041957600080fd5b505af115801561042d573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526104739190810190610bf6565b50565b6040517fcc63604a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063cc63604a906104e990600090600401610d2b565b60206040518083038186803b15801561050157600080fd5b505afa158015610515573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105399190610bbc565b61056f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028890610d8d565b60005b600054811015610473576040517ffe0d94c100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fe0d94c1906105ee908490600401610d2b565b600060405180830381600087803b15801561060857600080fd5b505af115801561061c573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526106629190810190610bf6565b50600101610572565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81565b6224ea0081565b60005481565b7f000000000000000000000000000000000000000000000000000000000000000081565b600081565b6040517f557a640300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063557a640390610757907f000000000000000000000000000000000000000000000000000000000000000090600401610d0a565b60206040518083038186803b15801561076f57600080fd5b505afa158015610783573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a79190610bbc565b6107dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028890610dea565b6040517f851c1bb300000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063851c1bb390610872907f058a628f0000000000000000000000000000000000000000000000000000000090600401610d60565b60206040518083038186803b15801561088a57600080fd5b505afa15801561089e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c29190610bde565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16639be2a88483307f00000000000000000000000000000000000000000000000000000000000000006040518463ffffffff1660e01b815260040161094393929190610d34565b60206040518083038186803b15801561095b57600080fd5b505afa15801561096f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109939190610bbc565b9050806109cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028890610e21565b6040517f058a628f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063058a628f90610a5e907f000000000000000000000000000000000000000000000000000000000000000090600401610d0a565b600060405180830381600087803b158015610a7857600080fd5b505af1158015610a8c573d6000803e3d6000fd5b505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b80518015158114610b1057600080fd5b92915050565b600082601f830112610b26578081fd5b815167ffffffffffffffff811115610b3c578182fd5b6020610b6e817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f85011601610ec6565b92508183528481838601011115610b8457600080fd5b60005b82811015610ba2578481018201518482018301528101610b87565b82811115610bb35760008284860101525b50505092915050565b600060208284031215610bcd578081fd5b610bd78383610b00565b9392505050565b600060208284031215610bef578081fd5b5051919050565b600060208284031215610c07578081fd5b815167ffffffffffffffff811115610c1d578182fd5b610c2984828501610b16565b949350505050565b600060208284031215610c42578081fd5b815167ffffffffffffffff80821115610c59578283fd5b9083019060c08286031215610c6c578283fd5b610c7660c0610ec6565b825173ffffffffffffffffffffffffffffffffffffffff81168114610c99578485fd5b8152602083015182811115610cac578485fd5b610cb887828601610b16565b602083015250610ccb8660408501610b00565b6040820152610cdd8660608501610b00565b6060820152610cef8660808501610b00565b608082015260a083015160a082015280935050505092915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b90815260200190565b92835273ffffffffffffffffffffffffffffffffffffffff918216602084015216604082015260600190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b60208082526023908201527f43414e4e4f545f545249474745525f44454c4159535f4d4947524154494f4e5f60408201527f5945540000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526014908201527f524f4f545f4e4f545f434c41494d45445f594554000000000000000000000000604082015260600190565b6020808252601e908201527f4d49475241544f525f43414e4e4f545f5345545f415554484f52495a45520000604082015260600190565b6020808252601e908201527f43414e4e4f545f545249474745525f524f4f545f4348414e47455f5945540000604082015260600190565b60208082526017908201527f44454c4159535f4e4f545f4d494752415445445f594554000000000000000000604082015260600190565b60405181810167ffffffffffffffff81118282101715610ee557600080fd5b60405291905056fea2646970667358221220b446cc8050b42b9666cd8bda65a6f5b9e6bdbd36e7cac1f72a77ba1fa5bf93e764736f6c634300070100336101e06040523480156200001257600080fd5b506040516200390e3803806200390e8339810160408190526200003591620003df565b6001600055620000458362000265565b816001600160a01b0316638d928af86040518163ffffffff1660e01b815260040160206040518083038186803b1580156200007f57600080fd5b505afa15801562000094573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000ba919062000426565b6001600160a01b0316610160816001600160a01b031660601b81525050816001600160a01b031663e758d36b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200011157600080fd5b505afa15801562000126573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200014c919062000426565b6001600160601b0319606091821b81166101a0529083901b16610180526040516200017790620003d1565b604051809103906000f08015801562000194573d6000803e3d6000fd5b5060601b6001600160601b031916610140526101c08190526000620001c06337c5e2cb60e11b620002af565b90506000620001d6634c07348160e01b620002af565b90506000620001e883600019620002e4565b90506000620001fa83600019620002e4565b90506200020b828860001962000319565b6200021a818860001962000319565b608084905260a08390526200023663fe0d94c160e01b620002af565b60c0526200024b6378422a9160e11b620002af565b60e052610100919091526101205250620004b19350505050565b600180546001600160a01b0319166001600160a01b0383169081179091556040517f39510b933a9d010f906528d6019d3f4e2450a10dc33b10887503b31ed82f111190600090a250565b604051600090620002c7903090849060200162000480565b604051602081830303815290604052805190602001209050919050565b60008282604051602001620002fb92919062000472565b60405160208183030381529060405280519060200120905092915050565b60006200032884848462000399565b60008181526004602052604090205490915060ff166200039357600081815260046020526040808220805460ff19166001179055516001600160a01b03808516929086169187917fef6ee312a0062a24a46be2eba5284183a87ff848110e8d4df979bd690d9e9f6891a45b50505050565b6000838383604051602001620003b2939291906200044c565b6040516020818303038152906040528051906020012090509392505050565b6104ef806200341f83390190565b600080600060608486031215620003f4578283fd5b8351620004018162000498565b6020850151909350620004148162000498565b80925050604084015190509250925092565b60006020828403121562000438578081fd5b8151620004458162000498565b9392505050565b9283526001600160601b0319606092831b81166020850152911b16603482015260480190565b918252602082015260400190565b9182526001600160e01b031916602082015260240190565b6001600160a01b0381168114620004ae57600080fd5b50565b60805160a05160c05160e05161010051610120516101405160601c6101605160601c6101805160601c6101a05160601c6101c051612e916200058e6000398061145b52508061132d5250806113555250806112f152806117ed5250806107ff5280610946528061102252806113ce52806117845280611a9f52806121895250806106f1528061074b5250806106c4528061071e52508061066f52806115835250806109b352806115575250806110d05280611614528061163d52806119295250806107915280611160528061143252806115af5250612e916000f3fe608060405234801561001057600080fd5b50600436106103155760003560e01c80637e1c556d116101a7578063d00bef4d116100ee578063e8104ea011610097578063f1521d7611610071578063f1521d761461060e578063fc78a22814610621578063fe0d94c11461062957610315565b8063e8104ea0146105d5578063f0845522146105e8578063f0bb9406146105fb57610315565b8063df6b0d01116100c8578063df6b0d01146105a7578063e2b4146b146105ba578063e5e6e8ae146105cd57610315565b8063d00bef4d14610579578063d754bad914610581578063d7ad1dcf1461059457610315565b80639be2a88411610150578063c284b6b91161012a578063c284b6b91461054b578063cc63604a14610553578063cf8475da1461056657610315565b80639be2a8841461051d5780639f81aed714610530578063b3eb281d1461053857610315565b8063863bac6b11610181578063863bac6b146104ef57806386ff254b146105025780638d928af81461051557610315565b80637e1c556d146104c157806382938ca8146104c9578063851c1bb3146104dc57610315565b80634125ff901161026b57806362cde1ba116102145780636f8bc596116101ee5780636f8bc59614610488578063715716a21461049b57806378a08377146104ae57610315565b806362cde1ba146104585780636badd2ab146104605780636c1032af1461048057610315565b806355ed08a11161024557806355ed08a11461041d5780635b78b780146104305780635ca1e1651461044357610315565b80634125ff90146103ef5780634c073481146103f7578063557a64031461040a57610315565b80631b3c85eb116102cd5780632e3ed05b116102a75780632e3ed05b146103b65780633bf46797146103c957806340e58ee5146103dc57610315565b80631b3c85eb146103885780632362716d1461039b5780632debdd2e146103ae57610315565b806314ea35e7116102fe57806314ea35e714610358578063151b89d114610362578063169f14681461037557610315565b80630df322a61461031a57806310697a3a14610343575b600080fd5b61032d6103283660046124b0565b610649565b60405161033a9190612ac0565b60405180910390f35b61034b61066d565b60405161033a9190612acb565b610360610691565b005b61034b610370366004612678565b61078a565b61034b610383366004612518565b6107bc565b6103606103963660046124b0565b61092b565b61034b6103a93660046126a8565b61097b565b61034b6109b1565b61034b6103c43660046124cb565b6109d5565b61034b6103d7366004612678565b610aa9565b6103606103ea366004612678565b610abb565b61034b610d11565b6103606104053660046125c6565b610d19565b61032d6104183660046124b0565b610da4565b61034b61042b3660046127a1565b610dc5565b61034b61043e3660046126e5565b610df8565b61044b610ed7565b60405161033a9190612958565b61044b610ef3565b61047361046e366004612678565b610ef9565b60405161033a9190612d29565b61044b611020565b6103606104963660046125c6565b611044565b61032d6104a93660046126a8565b6110c9565b6103606104bc36600461274d565b6110f7565b61034b61115e565b6103606104d7366004612621565b611182565b61034b6104ea366004612806565b6111cb565b61034b6104fd3660046126e5565b6111fe565b61032d6105103660046126a8565b6112c2565b61044b6112ef565b61032d61052b3660046126a8565b611313565b61034b611424565b61032d6105463660046126a8565b61142b565b61034b611459565b61032d610561366004612678565b61147d565b61036061057436600461274d565b6114f6565b61044b611534565b61034b61058f366004612678565b611550565b61034b6105a2366004612678565b61157c565b61032d6105b53660046126a8565b6115a8565b61032d6105c83660046126a8565b6115d6565b61034b611612565b61034b6105e3366004612678565b611636565b61034b6105f63660046127c2565b611662565b6103606106093660046127a1565b611769565b61032d61061c3660046126a8565b611922565b61034b610ef3565b61063c610637366004612678565b611950565b60405161033a9190612b01565b60025473ffffffffffffffffffffffffffffffffffffffff8281169116145b919050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60015460025473ffffffffffffffffffffffffffffffffffffffff91821691166106bf338214610191611b67565b6106ec7f000000000000000000000000000000000000000000000000000000000000000082600019611b75565b6107197f000000000000000000000000000000000000000000000000000000000000000082600019611b75565b6107467f000000000000000000000000000000000000000000000000000000000000000083600019611bfe565b6107737f000000000000000000000000000000000000000000000000000000000000000083600019611bfe565b61077c81611c85565b6107866000611cf4565b5050565b60006107b67f000000000000000000000000000000000000000000000000000000000000000083610dc5565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff84163014156107fd5760405162461bcd60e51b81526004016107f490612b14565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156108695760405162461bcd60e51b81526004016107f490612b71565b60008473ffffffffffffffffffffffffffffffffffffffff1663851c1bb361089086611d63565b6040518263ffffffff1660e01b81526004016108ac9190612ad4565b60206040518083038186803b1580156108c457600080fd5b505afa1580156108d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fc9190612690565b905061091461090c8233886115d6565b610191611b67565b61092081868686611e6f565b9150505b9392505050565b61096f3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610191611b67565b61097881611cf4565b50565b6000838383604051602001610992939291906128dc565b6040516020818303038152906040528051906020012090509392505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006109e361090c33610da4565b6000610a0e7f1b3c85eb000000000000000000000000000000000000000000000000000000006111cb565b90506060631b3c85eb60e01b85604051602401610a2b9190612958565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091529050610aa0823083610a9a611459565b88611eb2565b95945050505050565b60009081526005602052604090205490565b6003548110610adc5760405162461bcd60e51b81526004016107f490612cbb565b600060038281548110610aeb57fe5b60009182526020909120600490910201600281015490915060ff1615610b235760405162461bcd60e51b81526004016107f490612cf2565b6002810154610100900460ff1615610b4d5760405162461bcd60e51b81526004016107f490612c84565b805460018083018054604080516020600261010096851615969096026000190190931694909404601f810183900483028501830190915280845273ffffffffffffffffffffffffffffffffffffffff90941693600093859363851c1bb393610c0b9390830182828015610c015780601f10610bd657610100808354040283529160200191610c01565b820191906000526020600020905b815481529060010190602001808311610be457829003601f168201915b5050505050611d63565b6040518263ffffffff1660e01b8152600401610c279190612ad4565b60206040518083038186803b158015610c3f57600080fd5b505afa158015610c53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c779190612690565b8354909150610cb290610ca3908390339073ffffffffffffffffffffffffffffffffffffffff166115d6565b8061090c575061090c33610da4565b6002830180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1661010017905560405184907f2a6bef66de603fc0ec07223576486bd905cd9bb6e05364286d9a5cd1be046ae690600090a250505050565b6303c2670081565b610d25835182516120a6565b60005b8351811015610d9e57610d6561090c858381518110610d4357fe5b602002602001015133858581518110610d5857fe5b60200260200101516110c9565b610d96848281518110610d7457fe5b602002602001015184848481518110610d8957fe5b6020026020010151611bfe565b600101610d28565b50505050565b60015473ffffffffffffffffffffffffffffffffffffffff90811691161490565b60008282604051602001610dda92919061291a565b60405160208183030381529060405280519060200120905092915050565b6000610e0861090c863386611922565b60607f4c07348100000000000000000000000000000000000000000000000000000000610e34876120b3565b86610e3e876120f4565b604051602401610e5093929190612a21565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290506000610ebc87611636565b9050610eca81308487611e6f565b925050505b949350505050565b60015473ffffffffffffffffffffffffffffffffffffffff1690565b60001981565b610f016122ef565b60038281548110610f0e57fe5b60009182526020918290206040805160c0810182526004909302909101805473ffffffffffffffffffffffffffffffffffffffff168352600180820180548451601f60026000199584161561010002959095019092169390930490810187900487028301870190945283825293949193858301939192909190830182828015610fd85780601f10610fad57610100808354040283529160200191610fd8565b820191906000526020600020905b815481529060010190602001808311610fbb57829003601f168201915b5050509183525050600282015460ff80821615156020840152610100820481161515604084015262010000909104161515606082015260039091015460809091015292915050565b7f000000000000000000000000000000000000000000000000000000000000000090565b611050835182516120a6565b60005b8351811015610d9e5761109061090c85838151811061106e57fe5b60200260200101513385858151811061108357fe5b60200260200101516115a8565b6110c184828151811061109f57fe5b6020026020010151848484815181106110b457fe5b6020026020010151611b75565b600101611053565b6000610ecf7f0000000000000000000000000000000000000000000000000000000000000000848487612163565b600061110233610da4565b8061111c57508115801561111c575061111c85338561142b565b905061112a81610191611b67565b60006111358661078a565b90506111568186868661114a57611bfe61114e565b611b755b63ffffffff16565b505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b61118e825182516120a6565b60005b82518110156111c6576111be8382815181106111a957fe5b602002602001015133848481518110610d8957fe5b600101611191565b505050565b6040516000906111e19030908490602001612928565b604051602081830303815290604052805190602001209050919050565b600061120e61090c86338661142b565b60607f6f8bc5960000000000000000000000000000000000000000000000000000000061123a876120b3565b86611244876120f4565b60405160240161125693929190612a21565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290506000610ebc8761078a565b6000600460006112d386868661097b565b815260208101919091526040016000205460ff16949350505050565b7f000000000000000000000000000000000000000000000000000000000000000090565b60003373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614156113a9577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16149050610924565b6000848152600560205260409020546113cc576113c78484846115d6565b610ecf565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161490509392505050565b6206978081565b6000610ecf7f0000000000000000000000000000000000000000000000000000000000000000848487612213565b7f000000000000000000000000000000000000000000000000000000000000000090565b60035460009082106114a15760405162461bcd60e51b81526004016107f490612cbb565b6000600383815481106114b057fe5b60009182526020909120600490910201600281015490915060ff161580156114e257506002810154610100900460ff16155b801561092457506003015442101592915050565b600061150133610da4565b8061151b57508115801561151b575061151b853385611922565b905061152981610191611b67565b600061113586611636565b60025473ffffffffffffffffffffffffffffffffffffffff1690565b60006107b67f000000000000000000000000000000000000000000000000000000000000000083610dc5565b60006107b67f000000000000000000000000000000000000000000000000000000000000000083610dc5565b6000610ecf7f0000000000000000000000000000000000000000000000000000000000000000848487612163565b6000600460006115e786868661097b565b815260208101919091526040016000205460ff1680610ecf5750600460006112d3868660001961097b565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006107b67f000000000000000000000000000000000000000000000000000000000000000083610dc5565b60006303c267008311156116885760405162461bcd60e51b81526004016107f490612c16565b61169461090c33610da4565b600084815260056020526040812054908185106116b457620697806116c3565b6116c38583036206978061224e565b905060006116d08761157c565b9050606063f0bb940660e01b88886040516024016116ef92919061291a565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152905061175d823083868a611eb2565b98975050505050505050565b6117ad3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610191611b67565b6040517f851c1bb300000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063851c1bb390611842907f058a628f0000000000000000000000000000000000000000000000000000000090600401612ad4565b60206040518083038186803b15801561185a57600080fd5b505afa15801561186e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118929190612690565b90506000818414806118b257506000828152600560205260409020548311155b9050806118d15760405162461bcd60e51b81526004016107f490612ba8565b600084815260056020526040908190208490555184907f0e182617f9e5f9ce5f761c791ec15ad52176d97f9706b5c2707ffda7b6bdf79090611914908690612acb565b60405180910390a250505050565b6000610ecf7f0000000000000000000000000000000000000000000000000000000000000000848487612213565b606061195a61225a565b600354821061197b5760405162461bcd60e51b81526004016107f490612cbb565b60006003838154811061198a57fe5b60009182526020909120600490910201600281015490915060ff16156119c25760405162461bcd60e51b81526004016107f490612cf2565b6002810154610100900460ff16156119ec5760405162461bcd60e51b81526004016107f490612c84565b8060030154421015611a105760405162461bcd60e51b81526004016107f490612bdf565b600281015462010000900460ff1615611a4e576000611a2e84611550565b90506000611a3d8233306115d6565b9050611a4b81610191611b67565b50505b60028101805460ff1916600190811790915581546040517f1cff79cd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000811693631cff79cd93611ada9392169190860190600401612979565b600060405180830381600087803b158015611af457600080fd5b505af1158015611b08573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b309190810190612846565b60405190925083907f4fa5548c15e2d4a0b806eee962935acea143d79644d2340af39f4edf13b335a990600090a250610668612273565b81610786576107868161227a565b6000611b8284848461097b565b60008181526004602052604090205490915060ff16610d9e57600081815260046020526040808220805460ff191660011790555173ffffffffffffffffffffffffffffffffffffffff808516929086169187917fef6ee312a0062a24a46be2eba5284183a87ff848110e8d4df979bd690d9e9f6891a450505050565b6000611c0b84848461097b565b60008181526004602052604090205490915060ff1615610d9e57600081815260046020526040808220805460ff191690555173ffffffffffffffffffffffffffffffffffffffff808516929086169187917f7b42e026d3b17cf41399915c285780d0f724b3464b269297aff73c0de0fe417f91a450505050565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517f39510b933a9d010f906528d6019d3f4e2450a10dc33b10887503b31ed82f111190600090a250565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517f566fe119ff450afc2580186c62762b6c1258245c8b1b6bb095e7276eb5a75b5590600090a250565b6000600482511015611d7757506000610668565b601882600381518110611d8657fe5b016020015183517fff0000000000000000000000000000000000000000000000000000000000000090911690911c9060109084906002908110611dc557fe5b016020015184517fff0000000000000000000000000000000000000000000000000000000000000090911690911c9060089085906001908110611e0457fe5b016020015185517fff0000000000000000000000000000000000000000000000000000000000000090911690911c908590600090611e3e57fe5b01602001517fff00000000000000000000000000000000000000000000000000000000000000161717179050919050565b60008481526005602052604081205480611e9b5760405162461bcd60e51b81526004016107f490612c4d565b611ea88686868487611eb2565b9695505050505050565b600354604051819087907f26ce5ffb7ab1ce72d9ca4a3e4f906d2b99194d6c53dd9832fd7a59d0b2fc6bed90600090a381516040805160c08101825273ffffffffffffffffffffffffffffffffffffffff888116825260208083018981526000948401859052606084018590529415156080840181905242890160a0850181905260038054600181018255965284517fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b600490970296870180547fffffffffffffffffffffffff00000000000000000000000000000000000000001691909516178455955180519195611fcc937fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85c90910192910190612325565b50604082015160028201805460608501516080860151151562010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff911515610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff95151560ff199094169390931794909416919091171691909117905560a090910151600390910155600061206584611550565b905060005b8551811015612099576120918287838151811061208357fe5b602002602001015130611b75565b60010161206a565b5050505095945050505050565b6107868183146067611b67565b6040805160018082528183019092526060916020808301908036833701905050905081816000815181106120e357fe5b602002602001018181525050919050565b60408051600180825281830190925260609160208083019080368337019050509050818160008151811061212457fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050919050565b6000806121708684610dc5565b600081815260056020526040902054909150156121de577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614915050610ecf565b6121e98186866115d6565b156121f8576001915050610ecf565b600061220687600019610dc5565b9050610eca818787611313565b6000806122208684610dc5565b9050600061223087600019610dc5565b905061223d8287876115d6565b80610eca5750610eca8187876115d6565b80820390821002900390565b61226c60026000541415610190611b67565b6002600055565b6001600055565b62461bcd60e51b600090815260206004526007602452600a808304818106603090810160081b83860601918390049283060160101b016642414c230000300160c81b604452610978917f42414c0000000000000000000000000000000000000000000000000000000000906242414c90606490fd5b6040805160c08101825260008082526060602083018190529282018190529181018290526080810182905260a081019190915290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061236657805160ff1916838001178555612393565b82800160010185558215612393579182015b82811115612393578251825591602001919060010190612378565b5061239f9291506123a3565b5090565b5b8082111561239f57600081556001016123a4565b803573ffffffffffffffffffffffffffffffffffffffff811681146107b657600080fd5b600082601f8301126123ec578081fd5b81356123ff6123fa82612dc6565b612d9f565b81815291506020808301908481018184028601820187101561242057600080fd5b60005b848110156124475761243588836123b8565b84529282019290820190600101612423565b505050505092915050565b600082601f830112612462578081fd5b81356124706123fa82612dc6565b81815291506020808301908481018184028601820187101561249157600080fd5b60005b8481101561244757813584529282019290820190600101612494565b6000602082840312156124c1578081fd5b61092483836123b8565b600080604083850312156124dd578081fd5b6124e784846123b8565b9150602083013567ffffffffffffffff811115612502578182fd5b61250e858286016123dc565b9150509250929050565b60008060006060848603121561252c578081fd5b61253685856123b8565b9250602084013567ffffffffffffffff80821115612552578283fd5b818601915086601f830112612565578283fd5b81356125736123fa82612de6565b818152886020838601011115612587578485fd5b81602085016020830137908101602001849052935060408601359150808211156125af578283fd5b506125bc868287016123dc565b9150509250925092565b6000806000606084860312156125da578283fd5b833567ffffffffffffffff808211156125f1578485fd5b6125fd87838801612452565b945061260c87602088016123b8565b935060408601359150808211156125af578283fd5b60008060408385031215612633578182fd5b823567ffffffffffffffff8082111561264a578384fd5b61265686838701612452565b9350602085013591508082111561266b578283fd5b5061250e858286016123dc565b600060208284031215612689578081fd5b5035919050565b6000602082840312156126a1578081fd5b5051919050565b6000806000606084860312156126bc578283fd5b833592506126cd85602086016123b8565b91506126dc85604086016123b8565b90509250925092565b600080600080608085870312156126fa578081fd5b8435935061270b86602087016123b8565b925061271a86604087016123b8565b9150606085013567ffffffffffffffff811115612735578182fd5b612741878288016123dc565b91505092959194509250565b60008060008060808587031215612762578384fd5b8435935061277386602087016123b8565b925061278286604087016123b8565b915060608501358015158114612796578182fd5b939692955090935050565b600080604083850312156127b3578182fd5b50508035926020909101359150565b6000806000606084860312156127d6578081fd5b8335925060208401359150604084013567ffffffffffffffff8111156127fa578182fd5b6125bc868287016123dc565b600060208284031215612817578081fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610924578182fd5b600060208284031215612857578081fd5b815167ffffffffffffffff81111561286d578182fd5b8201601f8101841361287d578182fd5b805161288b6123fa82612de6565b81815285602083850101111561289f578384fd5b610aa0826020830160208601612e2f565b600081518084526128c8816020860160208601612e2f565b601f01601f19169290920160200192915050565b9283527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606092831b81166020850152911b16603482015260480190565b918252602082015260400190565b9182527fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b60006040820173ffffffffffffffffffffffffffffffffffffffff8516835260206040818501528285546001808216600081146129bd57600181146129db57612a13565b607f6002840416865260ff1983166060890152608088019350612a13565b600283048087526129eb8a612e0a565b885b82811015612a095781548b8201606001529084019087016129ed565b8a01606001955050505b509198975050505050505050565b606080825284519082018190526000906020906080840190828801845b82811015612a5a57815184529284019290840190600101612a3e565b50505073ffffffffffffffffffffffffffffffffffffffff8616848301528381036040850152845180825285830191830190845b81811015612ab257612aa08451612e16565b83529284019291840191600101612a8e565b509098975050505050505050565b901515815260200190565b90815260200190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b60006020825261092460208301846128b0565b60208082526022908201527f43414e4e4f545f5343484544554c455f415554484f52495a45525f414354494f60408201527f4e53000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601e908201527f415454454d5054494e475f4558454355544f525f5245454e5452414e43590000604082015260600190565b6020808252601c908201527f44454c41595f455843454544535f5345545f415554484f52495a455200000000604082015260600190565b60208082526015908201527f414354494f4e5f4e4f545f45584543555441424c450000000000000000000000604082015260600190565b6020808252600f908201527f44454c41595f544f4f5f4c415247450000000000000000000000000000000000604082015260600190565b60208082526016908201527f43414e4e4f545f5343484544554c455f414354494f4e00000000000000000000604082015260600190565b60208082526018908201527f414354494f4e5f414c52454144595f43414e43454c4c45440000000000000000604082015260600190565b60208082526015908201527f414354494f4e5f444f45535f4e4f545f45584953540000000000000000000000604082015260600190565b60208082526017908201527f414354494f4e5f414c52454144595f4558454355544544000000000000000000604082015260600190565b60006020825273ffffffffffffffffffffffffffffffffffffffff8351166020830152602083015160c06040840152612d6560e08401826128b0565b90506040840151151560608401526060840151151560808401526080840151151560a084015260a084015160c08401528091505092915050565b60405181810167ffffffffffffffff81118282101715612dbe57600080fd5b604052919050565b600067ffffffffffffffff821115612ddc578081fd5b5060209081020190565b600067ffffffffffffffff821115612dfc578081fd5b50601f01601f191660200190565b60009081526020902090565b73ffffffffffffffffffffffffffffffffffffffff1690565b60005b83811015612e4a578181015183820152602001612e32565b83811115610d9e575050600091015256fea26469706673582212208733c30c130550b060faaef187150faeaeec2b84638906a342649c6d8f3865f964736f6c6343000701003360a060405234801561001057600080fd5b5060016000553360601b60805260805160601c6104b061003f600039806101c6528061026e52506104b06000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80631cff79cd1461003b578063d09edf3114610173575b600080fd5b6100fe6004803603604081101561005157600080fd5b73ffffffffffffffffffffffffffffffffffffffff823516919081019060408101602082013564010000000081111561008957600080fd5b82018360208201111561009b57600080fd5b803590602001918460018302840111640100000000831117156100bd57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506101a4945050505050565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610138578181015183820152602001610120565b50505050905090810190601f1680156101655780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017b61026c565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b60606101ae610290565b3373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161461025257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552525f53454e4445525f4e4f545f415554484f52495a455200000000000000604482015290519081900360640190fd5b61025c83836102a9565b9050610266610393565b92915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6102a26002600054141561019061039a565b6002600055565b6060600060608473ffffffffffffffffffffffffffffffffffffffff16846040518082805190602001908083835b6020831061031457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016102d7565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610376576040519150601f19603f3d011682016040523d82523d6000602084013e61037b565b606091505b509150915061038a82826103ac565b95945050505050565b6001600055565b816103a8576103a8816103d2565b5050565b606082156103bb575080610266565b8151156103cb5781518083602001fd5b6102666101ae5b6103fc817f42414c00000000000000000000000000000000000000000000000000000000006103ff565b50565b7f08c379a000000000000000000000000000000000000000000000000000000000600090815260206004526007602452600a808404818106603090810160081b958390069590950190829004918206850160101b01602363ffffff0060e086901c160160181b0190930160c81b60445260e882901c90606490fdfea26469706673582212202cab8bc2362052d26d734d8e96bf55d57652f71d5c18bad7251afeae8157d17b64736f6c63430007010033000000000000000000000000c34b35b9b1986aca2008c719500d4a58829f3c6e00000000000000000000000078d76296f1ae44f2dd9cc6c42837d15d4249b16c000000000000000000000000a685eee123b87dc3152651454f8a64ac949e69fd0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000c34b35b9b1986aca2008c719500d4a58829f3c6e7cec8c486992a4606bfb1e2d603d1750d55bf3f86720955da5ad5e7aa7e4c3a6000000000000000000000000ffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d1bbb3d44c814935f60561af6f45f4098e276a079945715aaf9b0e6f0c73fed20000000000000000000000000000000000000000000000000000000000278d00190a4cc815dd4870fb4e24edae69f6413d2a80864cb893c3810a35dbbc9b32290000000000000000000000000000000000000000000000000000000000127500000000000000000000000000000000000000000000000000000000000000000ba149cacd04b8ae4a926000bea0301f64f0be0786064ee6b3ae1da1b57eaeadbf0000000000000000000000000000000000000000000000000000000000278d00706e3e1e6289c5e790014b3ea331522f53f9a74f45cb3ecb46dd1fd4e40f6d030000000000000000000000000000000000000000000000000000000000278d0049ab6b886a8049936c526dc5be20dc19bc6293d6bc123d656f16c8a706c9e2090000000000000000000000000000000000000000000000000000000000127500273f2ddda67c8534d4497582efee72fc2a895aadf62d0002e41b33ce2ade2fde000000000000000000000000000000000000000000000000000000000012750079922681fd17c90b4f3409d605f5b059ffcbcef7b5440321ae93b87f3b5c1c780000000000000000000000000000000000000000000000000000000000093a8034f1dc41ca994152374a5c44fae714bce9db65db63b0eb0bcb5aa55a7bff62190000000000000000000000000000000000000000000000000000000000093a80bf9a8d654fde1e2f1891f07fa956278c8265e8048352ff4002b4d62892583ba40000000000000000000000000000000000000000000000000000000000093a80e2ae0774a123c4bf5321ab994df4e425499258b456a9d5ed08ef632100b7a8b00000000000000000000000000000000000000000000000000000000000093a80c768e5cafec3474b335504ab77e14d12354bb3991d92de39ec636092ff0449c90000000000000000000000000000000000000000000000000000000000093a80a8513b600d1bc757c89614a4a6537d35de96b450825b001da4873ea53028cafa0000000000000000000000000000000000000000000000000000000000093a80bdce9837efbaa5ecb8c57c3798534c48e76027c7460ffc59e8331656706c349c0000000000000000000000000000000000000000000000000000000000093a80
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100d45760003560e01c8063a217fddf11610081578063ebf0c7171161005b578063ebf0c71714610146578063fbfa77cf1461014e578063fc78a22814610156576100d4565b8063a217fddf1461012e578063b78b608714610136578063c6bfe9ae1461013e576100d4565b80637217d9d1116100b25780637217d9d11461010957806398f85d5c1461011e578063a0c286d814610126576100d4565b806311f13145146100d95780633c44172d146100e357806362cde1ba146100eb575b600080fd5b6100e161015e565b005b6100e1610476565b6100f361066b565b6040516101009190610d0a565b60405180910390f35b61011161068f565b6040516101009190610d2b565b610111610696565b6100f361069c565b6101116106c0565b6100e16106c5565b6100f3610a94565b6100f3610ab8565b6100f3610adc565b61011161066b565b600054158061025257506040517f6badd2ab00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000017d8b199e8f8765079a0e721e4d25008915ea0c01690636badd2ab906101db90600090600401610d2b565b60006040518083038186803b1580156101f357600080fd5b505afa158015610207573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261024d9190810190610c31565b604001515b610291576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028890610e8f565b60405180910390fd5b6000546040517fcc63604a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000017d8b199e8f8765079a0e721e4d25008915ea0c0169163cc63604a916103059190600401610d2b565b60206040518083038186803b15801561031d57600080fd5b505afa158015610331573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103559190610bbc565b61038b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028890610e58565b6000546040517ffe0d94c100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000017d8b199e8f8765079a0e721e4d25008915ea0c0169163fe0d94c1916103ff9190600401610d2b565b600060405180830381600087803b15801561041957600080fd5b505af115801561042d573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526104739190810190610bf6565b50565b6040517fcc63604a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000017d8b199e8f8765079a0e721e4d25008915ea0c0169063cc63604a906104e990600090600401610d2b565b60206040518083038186803b15801561050157600080fd5b505afa158015610515573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105399190610bbc565b61056f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028890610d8d565b60005b600054811015610473576040517ffe0d94c100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000017d8b199e8f8765079a0e721e4d25008915ea0c0169063fe0d94c1906105ee908490600401610d2b565b600060405180830381600087803b15801561060857600080fd5b505af115801561061c573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526106629190810190610bf6565b50600101610572565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81565b6224ea0081565b60005481565b7f00000000000000000000000017d8b199e8f8765079a0e721e4d25008915ea0c081565b600081565b6040517f557a640300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000017d8b199e8f8765079a0e721e4d25008915ea0c0169063557a640390610757907f000000000000000000000000c34b35b9b1986aca2008c719500d4a58829f3c6e90600401610d0a565b60206040518083038186803b15801561076f57600080fd5b505afa158015610783573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a79190610bbc565b6107dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028890610dea565b6040517f851c1bb300000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000089cceb9ced8c752b0d4dfb226a627223aa99907d169063851c1bb390610872907f058a628f0000000000000000000000000000000000000000000000000000000090600401610d60565b60206040518083038186803b15801561088a57600080fd5b505afa15801561089e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c29190610bde565b905060007f00000000000000000000000078d76296f1ae44f2dd9cc6c42837d15d4249b16c73ffffffffffffffffffffffffffffffffffffffff16639be2a88483307f00000000000000000000000089cceb9ced8c752b0d4dfb226a627223aa99907d6040518463ffffffff1660e01b815260040161094393929190610d34565b60206040518083038186803b15801561095b57600080fd5b505afa15801561096f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109939190610bbc565b9050806109cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161028890610e21565b6040517f058a628f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000089cceb9ced8c752b0d4dfb226a627223aa99907d169063058a628f90610a5e907f00000000000000000000000017d8b199e8f8765079a0e721e4d25008915ea0c090600401610d0a565b600060405180830381600087803b158015610a7857600080fd5b505af1158015610a8c573d6000803e3d6000fd5b505050505050565b7f00000000000000000000000078d76296f1ae44f2dd9cc6c42837d15d4249b16c81565b7f000000000000000000000000c34b35b9b1986aca2008c719500d4a58829f3c6e81565b7f00000000000000000000000089cceb9ced8c752b0d4dfb226a627223aa99907d81565b80518015158114610b1057600080fd5b92915050565b600082601f830112610b26578081fd5b815167ffffffffffffffff811115610b3c578182fd5b6020610b6e817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f85011601610ec6565b92508183528481838601011115610b8457600080fd5b60005b82811015610ba2578481018201518482018301528101610b87565b82811115610bb35760008284860101525b50505092915050565b600060208284031215610bcd578081fd5b610bd78383610b00565b9392505050565b600060208284031215610bef578081fd5b5051919050565b600060208284031215610c07578081fd5b815167ffffffffffffffff811115610c1d578182fd5b610c2984828501610b16565b949350505050565b600060208284031215610c42578081fd5b815167ffffffffffffffff80821115610c59578283fd5b9083019060c08286031215610c6c578283fd5b610c7660c0610ec6565b825173ffffffffffffffffffffffffffffffffffffffff81168114610c99578485fd5b8152602083015182811115610cac578485fd5b610cb887828601610b16565b602083015250610ccb8660408501610b00565b6040820152610cdd8660608501610b00565b6060820152610cef8660808501610b00565b608082015260a083015160a082015280935050505092915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b90815260200190565b92835273ffffffffffffffffffffffffffffffffffffffff918216602084015216604082015260600190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b60208082526023908201527f43414e4e4f545f545249474745525f44454c4159535f4d4947524154494f4e5f60408201527f5945540000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526014908201527f524f4f545f4e4f545f434c41494d45445f594554000000000000000000000000604082015260600190565b6020808252601e908201527f4d49475241544f525f43414e4e4f545f5345545f415554484f52495a45520000604082015260600190565b6020808252601e908201527f43414e4e4f545f545249474745525f524f4f545f4348414e47455f5945540000604082015260600190565b60208082526017908201527f44454c4159535f4e4f545f4d494752415445445f594554000000000000000000604082015260600190565b60405181810167ffffffffffffffff81118282101715610ee557600080fd5b60405291905056fea2646970667358221220b446cc8050b42b9666cd8bda65a6f5b9e6bdbd36e7cac1f72a77ba1fa5bf93e764736f6c63430007010033