Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
L2ERC20ExtendedTokensBridge
Compiler Version
v0.8.10+commit.fc410830
Optimization Enabled:
Yes with 100000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {IL1ERC20Bridge} from "./interfaces/IL1ERC20Bridge.sol"; import {IL2ERC20Bridge} from "./interfaces/IL2ERC20Bridge.sol"; import {IERC20Bridged} from "../token/ERC20Bridged.sol"; import {ITokenRateUpdatable} from "../optimism/interfaces/ITokenRateUpdatable.sol"; import {ERC20RebasableBridged} from "../token/ERC20RebasableBridged.sol"; import {BridgingManager} from "../BridgingManager.sol"; import {RebasableAndNonRebasableTokens} from "./RebasableAndNonRebasableTokens.sol"; import {CrossDomainEnabled} from "./CrossDomainEnabled.sol"; import {DepositDataCodec} from "../lib/DepositDataCodec.sol"; import {Versioned} from "../utils/Versioned.sol"; /// @author psirex, kovalgek /// @notice The L2 token bridge works with the L1 token bridge to enable ERC20 token bridging /// between L1 and L2. It acts as a minter for new tokens when it hears about /// deposits into the L1 token bridge. It also acts as a burner of the tokens /// intended for withdrawal, informing the L1 bridge to release L1 funds. Additionally, adds /// the methods for bridging management: enabling and disabling withdrawals/deposits contract L2ERC20ExtendedTokensBridge is IL2ERC20Bridge, BridgingManager, RebasableAndNonRebasableTokens, CrossDomainEnabled, Versioned { using SafeERC20 for IERC20; address private immutable L1_TOKEN_BRIDGE; /// @param messenger_ L2 messenger address being used for cross-chain communications /// @param l1TokenBridge_ Address of the corresponding L1 bridge /// @param l1TokenNonRebasable_ Address of the bridged token in the L1 chain /// @param l1TokenRebasable_ Address of the bridged token in the L1 chain /// @param l2TokenNonRebasable_ Address of the token minted on the L2 chain when token bridged /// @param l2TokenRebasable_ Address of the token minted on the L2 chain when token bridged constructor( address messenger_, address l1TokenBridge_, address l1TokenNonRebasable_, address l1TokenRebasable_, address l2TokenNonRebasable_, address l2TokenRebasable_ ) CrossDomainEnabled(messenger_) RebasableAndNonRebasableTokens ( l1TokenNonRebasable_, l1TokenRebasable_, l2TokenNonRebasable_, l2TokenRebasable_ ) { if (l1TokenBridge_ == address(0)) { revert ErrorZeroAddressL1Bridge(); } L1_TOKEN_BRIDGE = l1TokenBridge_; } /// @notice Initializes the contract from scratch. /// @param admin_ Address of the account to grant the DEFAULT_ADMIN_ROLE function initialize(address admin_) external { _initializeExtendedTokensBridge(); _initializeBridgingManager(admin_); } /// @notice A function to finalize upgrade to v2 (from v1). function finalizeUpgrade_v2() external { if (!_isBridgingManagerInitialized()) { revert ErrorBridgingManagerIsNotInitialized(); } _initializeExtendedTokensBridge(); } /// @inheritdoc IL2ERC20Bridge function l1TokenBridge() external view returns (address) { return L1_TOKEN_BRIDGE; } /// @inheritdoc IL2ERC20Bridge function withdraw( address l2Token_, uint256 amount_, uint32 l1Gas_, bytes calldata data_ ) external whenWithdrawalsEnabled onlySupportedL2Token(l2Token_) { if (Address.isContract(msg.sender)) { revert ErrorSenderNotEOA(); } _withdrawTo(l2Token_, msg.sender, msg.sender, amount_, l1Gas_, data_); emit WithdrawalInitiated(_getL1Token(l2Token_), l2Token_, msg.sender, msg.sender, amount_, data_); } /// @inheritdoc IL2ERC20Bridge function withdrawTo( address l2Token_, address to_, uint256 amount_, uint32 l1Gas_, bytes calldata data_ ) external whenWithdrawalsEnabled onlyNonZeroAccount(to_) onlySupportedL2Token(l2Token_) { _withdrawTo(l2Token_, msg.sender, to_, amount_, l1Gas_, data_); emit WithdrawalInitiated(_getL1Token(l2Token_), l2Token_, msg.sender, to_, amount_, data_); } /// @inheritdoc IL2ERC20Bridge function finalizeDeposit( address l1Token_, address l2Token_, address from_, address to_, uint256 amount_, bytes calldata data_ ) external whenDepositsEnabled onlyFromCrossDomainAccount(L1_TOKEN_BRIDGE) onlySupportedL1L2TokensPair(l1Token_, l2Token_) { DepositDataCodec.DepositData memory depositData = DepositDataCodec.decodeDepositData(data_); ITokenRateUpdatable tokenRateOracle = ERC20RebasableBridged(L2_TOKEN_REBASABLE).TOKEN_RATE_ORACLE(); tokenRateOracle.updateRate(depositData.rate, depositData.timestamp); uint256 depositedL2TokenAmount = _mintTokens(l2Token_, to_, amount_); emit DepositFinalized(l1Token_, l2Token_, from_, to_, depositedL2TokenAmount, depositData.data); } function _initializeExtendedTokensBridge() internal { _initializeContractVersionTo(2); // used for `bridgeWrap` call to succeed in the `_mintTokens` method IERC20(L2_TOKEN_NON_REBASABLE).safeIncreaseAllowance(L2_TOKEN_REBASABLE, type(uint256).max); } /// @notice Performs the logic for withdrawals by burning the token and informing /// the L1 token Gateway of the withdrawal. This function does not allow sending to token addresses. /// L1_TOKEN_REBASABLE does not allow transfers to itself. Additionally, sending funds to /// L1_TOKEN_NON_REBASABLE would lock these funds permanently, as it is non-upgradeable. /// @param l2Token_ Address of L2 token where withdrawal was initiated. /// @param from_ Account to pull the withdrawal from on L2 /// @param to_ Account to give the withdrawal to on L1. /// @param amount_ Amount of the token to withdraw /// @param l1Gas_ Minimum gas limit to use for the transaction. /// @param data_ Optional data to forward to L1. This data is provided /// solely as a convenience for external contracts. Aside from enforcing a maximum /// length, these contracts provide no guarantees about its content function _withdrawTo( address l2Token_, address from_, address to_, uint256 amount_, uint32 l1Gas_, bytes calldata data_ ) internal { if (to_ == L1_TOKEN_REBASABLE || to_ == L1_TOKEN_NON_REBASABLE) { revert ErrorTransferToL1TokenContract(); } uint256 nonRebasableAmountToWithdraw = _burnTokens(l2Token_, from_, amount_); bytes memory message = abi.encodeWithSelector( IL1ERC20Bridge.finalizeERC20Withdrawal.selector, _getL1Token(l2Token_), l2Token_, from_, to_, nonRebasableAmountToWithdraw, data_ ); sendCrossDomainMessage(L1_TOKEN_BRIDGE, l1Gas_, message); } /// @notice Mints tokens, wraps if needed and returns amount of minted tokens. /// @param l2Token_ Address of L2 token for which deposit is finalizing. /// @param to_ Account that token mints for. /// @param nonRebasableTokenAmount_ Amount of non-rebasable token. /// @return returns amount of minted tokens. function _mintTokens( address l2Token_, address to_, uint256 nonRebasableTokenAmount_ ) internal returns (uint256) { if (nonRebasableTokenAmount_ == 0) { return 0; } if (l2Token_ == L2_TOKEN_REBASABLE) { IERC20Bridged(L2_TOKEN_NON_REBASABLE).bridgeMint(address(this), nonRebasableTokenAmount_); return ERC20RebasableBridged(l2Token_).bridgeWrap(to_, nonRebasableTokenAmount_); } IERC20Bridged(l2Token_).bridgeMint(to_, nonRebasableTokenAmount_); return nonRebasableTokenAmount_; } /// @notice Unwraps if needed, burns tokens and returns amount of non-rebasable token to withdraw. /// @param l2Token_ Address of L2 token where withdrawal was initiated. /// @param from_ Account which tokens are burns. /// @param amount_ Amount of token to burn. /// @return returns amount of non-rebasable token to withdraw. function _burnTokens( address l2Token_, address from_, uint256 amount_ ) internal returns (uint256) { if (amount_ == 0) { return 0; } uint256 nonRebasableTokenAmount = amount_; if (l2Token_ == L2_TOKEN_REBASABLE) { nonRebasableTokenAmount = ERC20RebasableBridged(L2_TOKEN_REBASABLE).getSharesByTokens(amount_); if (nonRebasableTokenAmount != 0) { ERC20RebasableBridged(L2_TOKEN_REBASABLE).bridgeUnwrap(from_, amount_); IERC20Bridged(L2_TOKEN_NON_REBASABLE).bridgeBurn(from_, nonRebasableTokenAmount); } return nonRebasableTokenAmount; } IERC20Bridged(L2_TOKEN_NON_REBASABLE).bridgeBurn(from_, nonRebasableTokenAmount); return nonRebasableTokenAmount; } error ErrorSenderNotEOA(); error ErrorZeroAddressL1Bridge(); error ErrorTransferToL1TokenContract(); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; /// @author psirex, kovalgek /// @notice Contains administrative methods to retrieve and control the state of the bridging contract BridgingManager is AccessControl { /// @dev Stores the state of the bridging /// @param isInitialized Shows whether the contract is initialized or not /// @param isDepositsEnabled Stores the state of the deposits /// @param isWithdrawalsEnabled Stores the state of the withdrawals struct State { /// @dev This variable is used to determine whether the contract has been initialized or not. /// At the same time, bridges have their own code for initialization and storage versioning. /// Therefore, it is recommended to base upgrade logic on new mechanisms since v2. bool isInitialized; bool isDepositsEnabled; bool isWithdrawalsEnabled; } bytes32 public constant DEPOSITS_ENABLER_ROLE = keccak256("BridgingManager.DEPOSITS_ENABLER_ROLE"); bytes32 public constant DEPOSITS_DISABLER_ROLE = keccak256("BridgingManager.DEPOSITS_DISABLER_ROLE"); bytes32 public constant WITHDRAWALS_ENABLER_ROLE = keccak256("BridgingManager.WITHDRAWALS_ENABLER_ROLE"); bytes32 public constant WITHDRAWALS_DISABLER_ROLE = keccak256("BridgingManager.WITHDRAWALS_DISABLER_ROLE"); /// @dev The location of the slot with State bytes32 private constant STATE_SLOT = keccak256("BridgingManager.bridgingState"); /// @notice Initializes the contract to grant DEFAULT_ADMIN_ROLE to the admin_ address /// @dev This method might be called only once /// @param admin_ Address of the account to grant the DEFAULT_ADMIN_ROLE function _initializeBridgingManager(address admin_) internal { if (admin_ == address(0)) { revert ErrorZeroAddressAdmin(); } State storage s = _loadState(); if (s.isInitialized) { revert ErrorAlreadyInitialized(); } _grantRole(DEFAULT_ADMIN_ROLE, admin_); s.isInitialized = true; emit Initialized(admin_); } /// @notice Returns whether the contract is initialized or not function isInitialized() public view returns (bool) { return _loadState().isInitialized; } /// @notice Returns whether the deposits are enabled or not function isDepositsEnabled() public view returns (bool) { return _loadState().isDepositsEnabled; } /// @notice Returns whether the withdrawals are enabled or not function isWithdrawalsEnabled() public view returns (bool) { return _loadState().isWithdrawalsEnabled; } /// @notice Enables the deposits if they are disabled function enableDeposits() external onlyRole(DEPOSITS_ENABLER_ROLE) { if (isDepositsEnabled()) { revert ErrorDepositsEnabled(); } _loadState().isDepositsEnabled = true; emit DepositsEnabled(msg.sender); } /// @notice Disables the deposits if they aren't disabled yet function disableDeposits() external whenDepositsEnabled onlyRole(DEPOSITS_DISABLER_ROLE) { _loadState().isDepositsEnabled = false; emit DepositsDisabled(msg.sender); } /// @notice Enables the withdrawals if they are disabled function enableWithdrawals() external onlyRole(WITHDRAWALS_ENABLER_ROLE) { if (isWithdrawalsEnabled()) { revert ErrorWithdrawalsEnabled(); } _loadState().isWithdrawalsEnabled = true; emit WithdrawalsEnabled(msg.sender); } /// @notice Disables the withdrawals if they aren't disabled yet function disableWithdrawals() external whenWithdrawalsEnabled onlyRole(WITHDRAWALS_DISABLER_ROLE) { _loadState().isWithdrawalsEnabled = false; emit WithdrawalsDisabled(msg.sender); } function _isBridgingManagerInitialized() internal view returns (bool) { State storage s = _loadState(); return s.isInitialized; } /// @dev Returns the reference to the slot with State struct function _loadState() private pure returns (State storage r) { bytes32 slot = STATE_SLOT; assembly { r.slot := slot } } /// @dev Validates that deposits are enabled modifier whenDepositsEnabled() { if (!isDepositsEnabled()) { revert ErrorDepositsDisabled(); } _; } /// @dev Validates that withdrawals are enabled modifier whenWithdrawalsEnabled() { if (!isWithdrawalsEnabled()) { revert ErrorWithdrawalsDisabled(); } _; } event DepositsEnabled(address indexed enabler); event DepositsDisabled(address indexed disabler); event WithdrawalsEnabled(address indexed enabler); event WithdrawalsDisabled(address indexed disabler); event Initialized(address indexed admin); error ErrorZeroAddressAdmin(); error ErrorDepositsEnabled(); error ErrorDepositsDisabled(); error ErrorWithdrawalsEnabled(); error ErrorWithdrawalsDisabled(); error ErrorAlreadyInitialized(); error ErrorBridgingManagerIsNotInitialized(); }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /// @author kovalgek /// @notice encodes and decodes DepositData for crosschain transfering. library DepositDataCodec { uint8 internal constant RATE_FIELD_SIZE = 16; uint8 internal constant TIMESTAMP_FIELD_SIZE = 5; struct DepositData { uint128 rate; uint40 timestamp; bytes data; } function encodeDepositData(DepositData memory depositData) internal pure returns (bytes memory) { bytes memory data = bytes.concat( abi.encodePacked(depositData.rate), abi.encodePacked(depositData.timestamp), abi.encodePacked(depositData.data) ); return data; } function decodeDepositData(bytes calldata buffer) internal pure returns (DepositData memory) { if (buffer.length < RATE_FIELD_SIZE + TIMESTAMP_FIELD_SIZE) { revert ErrorDepositDataLength(); } DepositData memory depositData = DepositData({ rate: uint128(bytes16(buffer[0:RATE_FIELD_SIZE])), timestamp: uint40(bytes5(buffer[RATE_FIELD_SIZE:RATE_FIELD_SIZE + TIMESTAMP_FIELD_SIZE])), data: buffer[RATE_FIELD_SIZE + TIMESTAMP_FIELD_SIZE:] }); return depositData; } error ErrorDepositDataLength(); }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /// @dev A copy of UnstructuredRefStorage.sol library from Lido on Ethereum protocol. /// https://github.com/lidofinance/lido-dao/blob/master/contracts/0.8.9/lib/UnstructuredRefStorage.sol library UnstructuredRefStorage { function storageMapAddressMapAddressUint256(bytes32 _position) internal pure returns ( mapping(address => mapping(address => uint256)) storage result ) { assembly { result.slot := _position } } function storageMapAddressAddressUint256(bytes32 _position) internal pure returns ( mapping(address => uint256) storage result ) { assembly { result.slot := _position } } }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /// @dev A copy of UnstructuredStorage.sol library from Lido on Ethereum protocol. /// https://github.com/lidofinance/lido-dao/blob/master/contracts/0.8.9/lib/UnstructuredStorage.sol library UnstructuredStorage { function getStorageBool(bytes32 position) internal view returns (bool data) { assembly { data := sload(position) } } function getStorageUint256(bytes32 position) internal view returns (uint256 data) { assembly { data := sload(position) } } function setStorageBool(bytes32 position, bool data) internal { assembly { sstore(position, data) } } function setStorageUint256(bytes32 position, uint256 data) internal { assembly { sstore(position, data) } } }
// SPDX-FileCopyrightText: 2022 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; import {ICrossDomainMessenger} from "./interfaces/ICrossDomainMessenger.sol"; /// @dev Helper contract for contracts performing cross-domain communications contract CrossDomainEnabled { /// @notice Messenger contract used to send and receive messages from the other domain ICrossDomainMessenger public immutable MESSENGER; /// @param messenger_ Address of the CrossDomainMessenger on the current layer constructor(address messenger_) { if (messenger_ == address(0)) { revert ErrorZeroAddressMessenger(); } MESSENGER = ICrossDomainMessenger(messenger_); } /// @dev Sends a message to an account on another domain /// @param crossDomainTarget_ Intended recipient on the destination domain /// @param message_ Data to send to the target (usually calldata to a function with /// `onlyFromCrossDomainAccount()`) /// @param gasLimit_ gasLimit for the receipt of the message on the target domain. function sendCrossDomainMessage( address crossDomainTarget_, uint32 gasLimit_, bytes memory message_ ) internal { MESSENGER.sendMessage(crossDomainTarget_, message_, gasLimit_); } /// @dev Enforces that the modified function is only callable by a specific cross-domain account /// @param sourceDomainAccount_ The only account on the originating domain which is /// authenticated to call this function modifier onlyFromCrossDomainAccount(address sourceDomainAccount_) { if (msg.sender != address(MESSENGER)) { revert ErrorUnauthorizedMessenger(); } if (MESSENGER.xDomainMessageSender() != sourceDomainAccount_) { revert ErrorWrongCrossDomainSender(); } _; } error ErrorZeroAddressMessenger(); error ErrorUnauthorizedMessenger(); error ErrorWrongCrossDomainSender(); }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /// @author kovalgek /// @notice A subset of chainlink data feed interface for token rate oracle. interface IChainlinkAggregatorInterface { /// @notice get the latest token rate data. /// @return roundId_ is a unique id for each answer. The value is based on timestamp. /// @return answer_ is wstETH/stETH token rate. It is a chainlink convention to return int256. /// @return startedAt_ is time when rate was pushed on L1 side. /// @return updatedAt_ is the same as startedAt_. /// @return answeredInRound_ is the same as roundId_. function latestRoundData() external view returns ( uint80 roundId_, int256 answer_, uint256 startedAt_, uint256 updatedAt_, uint80 answeredInRound_ ); /// @notice get the lastest token rate. /// @return wstETH/stETH token rate. It is a chainlink convention to return int256. function latestAnswer() external view returns (int256); /// @notice represents the number of decimals the oracle responses represent. /// @return decimals of the oracle response. function decimals() external view returns (uint8); }
// SPDX-FileCopyrightText: 2022 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; interface ICrossDomainMessenger { function xDomainMessageSender() external view returns (address); /// Sends a cross domain message to the target messenger. /// @param _target Target contract address. /// @param _message Message to send to the target. /// @param _gasLimit Gas limit for the provided message. function sendMessage( address _target, bytes calldata _message, uint32 _gasLimit ) external; }
// SPDX-FileCopyrightText: 2022 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /// @notice The L1 Standard bridge locks bridged tokens on the L1 side, sends deposit messages /// on the L2 side, and finalizes token withdrawals from L2. interface IL1ERC20Bridge { event ERC20DepositInitiated( address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256 _amount, bytes _data ); event ERC20WithdrawalFinalized( address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256 _amount, bytes _data ); /// @notice get the address of the corresponding L2 bridge contract. /// @return Address of the corresponding L2 bridge contract. function l2TokenBridge() external returns (address); /// @notice deposit an amount of the ERC20 to the caller's balance on L2. /// @param l1Token_ Address of the L1 ERC20 we are depositing /// @param l2Token_ Address of the L1 respective L2 ERC20 /// @param amount_ Amount of the ERC20 to deposit /// @param l2Gas_ Gas limit required to complete the deposit on L2. /// @param data_ Optional data to forward to L2. This data is provided /// solely as a convenience for external contracts. Aside from enforcing a maximum /// length, these contracts provide no guarantees about its content. function depositERC20( address l1Token_, address l2Token_, uint256 amount_, uint32 l2Gas_, bytes calldata data_ ) external; /// @notice deposit an amount of ERC20 to a recipient's balance on L2. /// @param l1Token_ Address of the L1 ERC20 we are depositing /// @param l2Token_ Address of the L1 respective L2 ERC20 /// @param to_ L2 address to credit the withdrawal to. /// @param amount_ Amount of the ERC20 to deposit. /// @param l2Gas_ Gas limit required to complete the deposit on L2. /// @param data_ Optional data to forward to L2. This data is provided /// solely as a convenience for external contracts. Aside from enforcing a maximum /// length, these contracts provide no guarantees about its content. function depositERC20To( address l1Token_, address l2Token_, address to_, uint256 amount_, uint32 l2Gas_, bytes calldata data_ ) external; /// @notice Complete a withdrawal from L2 to L1, and credit funds to the recipient's balance of the /// L1 ERC20 token. /// @dev This call will fail if the initialized withdrawal from L2 has not been finalized. /// @param l1Token_ Address of L1 token to finalizeWithdrawal for. /// @param l2Token_ Address of L2 token where withdrawal was initiated. /// @param from_ L2 address initiating the transfer. /// @param to_ L1 address to credit the withdrawal to. /// @param amount_ Amount of the ERC20 to deposit. /// @param data_ Data provided by the sender on L2. This data is provided /// solely as a convenience for external contracts. Aside from enforcing a maximum /// length, these contracts provide no guarantees about its content. function finalizeERC20Withdrawal( address l1Token_, address l2Token_, address from_, address to_, uint256 amount_, bytes calldata data_ ) external; }
// SPDX-FileCopyrightText: 2022 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /// @notice The L2 token bridge works with the L1 token bridge to enable ERC20 token bridging /// between L1 and L2. It acts as a minter for new tokens when it hears about /// deposits into the L1 token bridge. It also acts as a burner of the tokens /// intended for withdrawal, informing the L1 bridge to release L1 funds. interface IL2ERC20Bridge { event WithdrawalInitiated( address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256 _amount, bytes _data ); event DepositFinalized( address indexed _l1Token, address indexed _l2Token, address indexed _from, address _to, uint256 _amount, bytes _data ); /// @notice Returns the address of the corresponding L1 bridge contract function l1TokenBridge() external returns (address); /// @notice Initiates a withdraw of some tokens to the caller's account on L1 /// @param l2Token_ Address of L2 token where withdrawal was initiated. /// @param amount_ Amount of the token to withdraw. /// @param l1Gas_ Minimum gas limit to use for the transaction. /// @param data_ Optional data to forward to L1. This data is provided /// solely as a convenience for external contracts. Aside from enforcing a maximum /// length, these contracts provide no guarantees about its content. function withdraw( address l2Token_, uint256 amount_, uint32 l1Gas_, bytes calldata data_ ) external; /// @notice Initiates a withdraw of some token to a recipient's account on L1. /// @param l2Token_ Address of L2 token where withdrawal is initiated. /// @param to_ L1 adress to credit the withdrawal to. /// @param amount_ Amount of the token to withdraw. /// @param l1Gas_ Minimum gas limit to use for the transaction. /// @param data_ Optional data to forward to L1. This data is provided /// solely as a convenience for external contracts. Aside from enforcing a maximum /// length, these contracts provide no guarantees about its content. function withdrawTo( address l2Token_, address to_, uint256 amount_, uint32 l1Gas_, bytes calldata data_ ) external; /// @notice Completes a deposit from L1 to L2, and credits funds to the recipient's balance of /// this L2 token. This call will fail if it did not originate from a corresponding deposit /// in L1StandardTokenBridge. /// @param l1Token_ Address for the l1 token this is called with /// @param l2Token_ Address for the l2 token this is called with /// @param from_ Account to pull the deposit from on L2. /// @param to_ Address to receive the withdrawal at /// @param amount_ Amount of the token to withdraw /// @param data_ Data provider by the sender on L1. This data is provided /// solely as a convenience for external contracts. Aside from enforcing a maximum /// length, these contracts provide no guarantees about its content. function finalizeDeposit( address l1Token_, address l2Token_, address from_, address to_, uint256 amount_, bytes calldata data_ ) external; }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /// @author kovalgek /// @notice An interface for updating token rate of token rate oracle. interface ITokenRateUpdatable { /// @notice Updates token rate. /// @param tokenRate_ wstETH/stETH token rate. /// @param rateUpdatedL1Timestamp_ L1 time when rate was updated on L1 side. function updateRate(uint256 tokenRate_, uint256 rateUpdatedL1Timestamp_) external; }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /// @author psirex, kovalgek /// @notice Contains the logic for validation of tokens used in the bridging process contract RebasableAndNonRebasableTokens { /// @notice Address of the bridged non rebasable token in the L1 chain address public immutable L1_TOKEN_NON_REBASABLE; /// @notice Address of the bridged rebasable token in the L1 chain address public immutable L1_TOKEN_REBASABLE; /// @notice Address of the non rebasable token minted on the L2 chain when token bridged address public immutable L2_TOKEN_NON_REBASABLE; /// @notice Address of the rebasable token minted on the L2 chain when token bridged address public immutable L2_TOKEN_REBASABLE; /// @param l1TokenNonRebasable_ Address of the bridged non rebasable token in the L1 chain /// @param l1TokenRebasable_ Address of the bridged rebasable token in the L1 chain /// @param l2TokenNonRebasable_ Address of the non rebasable token minted on the L2 chain when token bridged /// @param l2TokenRebasable_ Address of the rebasable token minted on the L2 chain when token bridged constructor( address l1TokenNonRebasable_, address l1TokenRebasable_, address l2TokenNonRebasable_, address l2TokenRebasable_ ) { if (l1TokenNonRebasable_ == address(0)) { revert ErrorZeroAddressL1TokenNonRebasable(); } if (l1TokenRebasable_ == address(0)) { revert ErrorZeroAddressL1TokenRebasable(); } if (l2TokenNonRebasable_ == address(0)) { revert ErrorZeroAddressL2TokenNonRebasable(); } if (l2TokenRebasable_ == address(0)) { revert ErrorZeroAddressL2TokenRebasable(); } L1_TOKEN_NON_REBASABLE = l1TokenNonRebasable_; L1_TOKEN_REBASABLE = l1TokenRebasable_; L2_TOKEN_NON_REBASABLE = l2TokenNonRebasable_; L2_TOKEN_REBASABLE = l2TokenRebasable_; } function _isSupportedL1L2TokensPair(address l1Token_, address l2Token_) internal view returns (bool) { bool isNonRebasablePair = l1Token_ == L1_TOKEN_NON_REBASABLE && l2Token_ == L2_TOKEN_NON_REBASABLE; bool isRebasablePair = l1Token_ == L1_TOKEN_REBASABLE && l2Token_ == L2_TOKEN_REBASABLE; return isNonRebasablePair || isRebasablePair; } function _getL1Token(address l2Token_) internal view returns (address) { if (l2Token_ == L2_TOKEN_NON_REBASABLE) { return L1_TOKEN_NON_REBASABLE; } if (l2Token_ == L2_TOKEN_REBASABLE) { return L1_TOKEN_REBASABLE; } revert ErrorUnsupportedL2Token(l2Token_); } /// @dev Validates that passed l1Token_ and l2Token_ tokens pair is supported by the bridge. modifier onlySupportedL1L2TokensPair(address l1Token_, address l2Token_) { if (!_isSupportedL1L2TokensPair(l1Token_, l2Token_)) { revert ErrorUnsupportedL1L2TokensPair(l1Token_, l2Token_); } _; } /// @dev Validates that passed l2Token_ is supported by the bridge modifier onlySupportedL2Token(address l2Token_) { if (l2Token_ != L2_TOKEN_NON_REBASABLE && l2Token_ != L2_TOKEN_REBASABLE) { revert ErrorUnsupportedL2Token(l2Token_); } _; } /// @dev validates that account_ is not zero address modifier onlyNonZeroAccount(address account_) { if (account_ == address(0)) { revert ErrorAccountIsZeroAddress(); } _; } error ErrorZeroAddressL1TokenNonRebasable(); error ErrorZeroAddressL1TokenRebasable(); error ErrorZeroAddressL2TokenNonRebasable(); error ErrorZeroAddressL2TokenRebasable(); error ErrorUnsupportedL2Token(address l2Token); error ErrorUnsupportedL1L2TokensPair(address l1Token, address l2Token); error ErrorAccountIsZeroAddress(); }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; import {ITokenRateUpdatable} from "./interfaces/ITokenRateUpdatable.sol"; import {IChainlinkAggregatorInterface} from "./interfaces/IChainlinkAggregatorInterface.sol"; import {CrossDomainEnabled} from "./CrossDomainEnabled.sol"; import {Versioned} from "../utils/Versioned.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {UnstructuredStorage} from "../lib/UnstructuredStorage.sol"; interface ITokenRateOracle is ITokenRateUpdatable, IChainlinkAggregatorInterface {} /// @author kovalgek /// @notice Oracle for storing and providing token rate. /// NB: Cross-chain apps and CEXes should fetch the token rate specific to the chain for deposits/withdrawals /// and compare against the token rate on L1 being an ultimate source of truth; /// If the L1 rate differs, it can be pushed permissionlessly via OpStackTokenRatePusher. /// @dev Token rate updates can be delivered from two sources: L1 token rate pusher and L2 bridge. contract TokenRateOracle is ITokenRateOracle, CrossDomainEnabled, AccessControl, Versioned { using UnstructuredStorage for bytes32; /// @dev Used to store historical data of rate and times. struct TokenRateData { /// @notice wstETH/stETH token rate. uint128 tokenRate; /// @notice last time when token rate was updated on L1. uint64 rateUpdatedL1Timestamp; /// @notice last time when token rate was received on L2. uint64 rateReceivedL2Timestamp; } // occupies a single slot /// @notice A bridge which can update oracle. address public immutable L2_ERC20_TOKEN_BRIDGE; /// @notice An address of account on L1 that can update token rate. address public immutable L1_TOKEN_RATE_PUSHER; /// @notice A time period when token rate can be considered outdated. uint256 public immutable TOKEN_RATE_OUTDATED_DELAY; /// @notice A time difference between received l1Timestamp and L2 block.timestamp /// when token rate can be considered outdated. uint256 public immutable MAX_ALLOWED_L2_TO_L1_CLOCK_LAG; /// @notice Allowed token rate deviation per day in basic points. uint256 public immutable MAX_ALLOWED_TOKEN_RATE_DEVIATION_PER_DAY_BP; /// @notice The maximum allowed time difference between the current time and the last received /// token rate update that can be set during a pause. This is required to limit the pause role /// and mitigate potential economic attacks. /// See the 'pauseTokenRateUpdates()' method uint256 public immutable OLDEST_RATE_ALLOWED_IN_PAUSE_TIME_SPAN; /// @notice The minimum delta time between two L1 timestamps of token rate updates. uint256 public immutable MIN_TIME_BETWEEN_TOKEN_RATE_UPDATES; /// @notice Decimals of the oracle response. uint8 public constant DECIMALS = 27; /// @notice Max sane token rate value. uint256 public constant MAX_SANE_TOKEN_RATE = 10 ** (DECIMALS + 2); /// @notice Min sane token rate value. uint256 public constant MIN_SANE_TOKEN_RATE = 10 ** (DECIMALS - 2); /// @dev Role granting the permission to pause updating rate. bytes32 public constant RATE_UPDATE_DISABLER_ROLE = keccak256("TokenRateOracle.RATE_UPDATE_DISABLER_ROLE"); /// @dev Role granting the permission to resume updating rate. bytes32 public constant RATE_UPDATE_ENABLER_ROLE = keccak256("TokenRafteOracle.RATE_UPDATE_ENABLER_ROLE"); /// @notice Basic point scale. uint256 private constant BASIS_POINT_SCALE = 1e4; /// @notice Number of seconds in one day. uint256 private constant ONE_DAY_SECONDS = 86400; /// @notice Flag to pause token rate updates slot position. bytes32 private constant PAUSE_TOKEN_RATE_UPDATES_SLOT = keccak256("TokenRateOracle.PAUSE_TOKEN_RATE_UPDATES_SLOT"); /// @notice Token rates array slot position. bytes32 private constant TOKEN_RATES_DATA_SLOT = keccak256("TokenRateOracle.TOKEN_RATES_DATA_SLOT"); /// @param messenger_ L2 messenger address being used for cross-chain communications /// @param l2ERC20TokenBridge_ the bridge address that has a right to updates oracle. /// @param l1TokenRatePusher_ An address of account on L1 that can update token rate. /// @param tokenRateOutdatedDelay_ time period when token rate can be considered outdated. /// @param maxAllowedL2ToL1ClockLag_ A time difference between received l1Timestamp and L2 block.timestamp /// when token rate can be considered outdated. /// @param maxAllowedTokenRateDeviationPerDayBp_ Allowed token rate deviation per day in basic points. /// Can't be bigger than BASIS_POINT_SCALE. /// @param oldestRateAllowedInPauseTimeSpan_ Maximum allowed time difference between the current time /// and the last received token rate update that can be set during a pause. /// @param minTimeBetweenTokenRateUpdates_ Minimum delta time between two /// L1 timestamps of token rate updates. constructor( address messenger_, address l2ERC20TokenBridge_, address l1TokenRatePusher_, uint256 tokenRateOutdatedDelay_, uint256 maxAllowedL2ToL1ClockLag_, uint256 maxAllowedTokenRateDeviationPerDayBp_, uint256 oldestRateAllowedInPauseTimeSpan_, uint256 minTimeBetweenTokenRateUpdates_ ) CrossDomainEnabled(messenger_) { if (l2ERC20TokenBridge_ == address(0)) { revert ErrorZeroAddressL2ERC20TokenBridge(); } if (l1TokenRatePusher_ == address(0)) { revert ErrorZeroAddressL1TokenRatePusher(); } if (maxAllowedTokenRateDeviationPerDayBp_ == 0 || maxAllowedTokenRateDeviationPerDayBp_ > BASIS_POINT_SCALE) { revert ErrorMaxTokenRateDeviationIsOutOfRange(); } L2_ERC20_TOKEN_BRIDGE = l2ERC20TokenBridge_; L1_TOKEN_RATE_PUSHER = l1TokenRatePusher_; TOKEN_RATE_OUTDATED_DELAY = tokenRateOutdatedDelay_; MAX_ALLOWED_L2_TO_L1_CLOCK_LAG = maxAllowedL2ToL1ClockLag_; MAX_ALLOWED_TOKEN_RATE_DEVIATION_PER_DAY_BP = maxAllowedTokenRateDeviationPerDayBp_; OLDEST_RATE_ALLOWED_IN_PAUSE_TIME_SPAN = oldestRateAllowedInPauseTimeSpan_; MIN_TIME_BETWEEN_TOKEN_RATE_UPDATES = minTimeBetweenTokenRateUpdates_; } /// @notice Initializes the contract from scratch. /// @param admin_ Address of the account to grant the DEFAULT_ADMIN_ROLE /// @param tokenRate_ wstETH/stETH token rate, uses 10**DECIMALS precision. /// @param rateUpdatedL1Timestamp_ L1 time when rate was updated on L1 side. function initialize(address admin_, uint256 tokenRate_, uint256 rateUpdatedL1Timestamp_) external { _initializeContractVersionTo(1); if (admin_ == address(0)) { revert ErrorZeroAddressAdmin(); } if (tokenRate_ < MIN_SANE_TOKEN_RATE || tokenRate_ > MAX_SANE_TOKEN_RATE) { revert ErrorTokenRateIsOutOfSaneRange(tokenRate_); } if (rateUpdatedL1Timestamp_ > block.timestamp + MAX_ALLOWED_L2_TO_L1_CLOCK_LAG) { revert ErrorL1TimestampExceededMaxAllowedClockLag(rateUpdatedL1Timestamp_); } _grantRole(DEFAULT_ADMIN_ROLE, admin_); _addTokenRate(tokenRate_, rateUpdatedL1Timestamp_, block.timestamp); } /// @notice Pauses token rate updates and sets the old rate provided by tokenRateIndex_. /// Should be called by DAO or emergency brakes only. /// @param tokenRateIndex_ The index of the token rate that applies after the pause. /// Token Rate can't be received older then OLDEST_RATE_ALLOWED_IN_PAUSE_TIME_SPAN /// except only if the passed index is the latest one. function pauseTokenRateUpdates(uint256 tokenRateIndex_) external onlyRole(RATE_UPDATE_DISABLER_ROLE) { if (_isPaused()) { revert ErrorAlreadyPaused(); } TokenRateData memory tokenRateData = _getTokenRateByIndex(tokenRateIndex_); if (tokenRateIndex_ != _getStorageTokenRates().length - 1 && tokenRateData.rateReceivedL2Timestamp < block.timestamp - OLDEST_RATE_ALLOWED_IN_PAUSE_TIME_SPAN) { revert ErrorTokenRateUpdateTooOld(); } _removeElementsAfterIndex(tokenRateIndex_); _setPause(true); emit TokenRateUpdatesPaused(tokenRateData.tokenRate, tokenRateData.rateUpdatedL1Timestamp); emit RateUpdated(tokenRateData.tokenRate, tokenRateData.rateUpdatedL1Timestamp); } /// @notice Resume token rate updates applying provided token rate. /// @param tokenRate_ a new token rate that applies after resuming. /// @param rateUpdatedL1Timestamp_ L1 time when rate was updated on L1 side. function resumeTokenRateUpdates( uint256 tokenRate_, uint256 rateUpdatedL1Timestamp_ ) external onlyRole(RATE_UPDATE_ENABLER_ROLE) { if (!_isPaused()) { revert ErrorAlreadyResumed(); } if (tokenRate_ < MIN_SANE_TOKEN_RATE || tokenRate_ > MAX_SANE_TOKEN_RATE) { revert ErrorTokenRateIsOutOfSaneRange(tokenRate_); } if (rateUpdatedL1Timestamp_ > block.timestamp + MAX_ALLOWED_L2_TO_L1_CLOCK_LAG) { revert ErrorL1TimestampExceededMaxAllowedClockLag(rateUpdatedL1Timestamp_); } if (rateUpdatedL1Timestamp_ < _getLastTokenRate().rateUpdatedL1Timestamp) { revert ErrorL1TimestampOlderThanPrevious(rateUpdatedL1Timestamp_); } _addTokenRate(tokenRate_, rateUpdatedL1Timestamp_, block.timestamp); _setPause(false); emit TokenRateUpdatesResumed(tokenRate_, rateUpdatedL1Timestamp_); emit RateUpdated(tokenRate_, rateUpdatedL1Timestamp_); } /// @notice Shows that token rate updates are paused or not. function isTokenRateUpdatesPaused() external view returns (bool) { return _isPaused(); } /// @notice Returns token rate data by index. /// @param tokenRateIndex_ an index of token rate data. function getTokenRateByIndex(uint256 tokenRateIndex_) external view returns (TokenRateData memory) { return _getTokenRateByIndex(tokenRateIndex_); } /// @notice Returns token rates data length. function getTokenRatesLength() external view returns (uint256) { return _getStorageTokenRates().length; } /// @inheritdoc IChainlinkAggregatorInterface function latestRoundData() external view returns ( uint80 roundId_, int256 answer_, uint256 startedAt_, uint256 updatedAt_, uint80 answeredInRound_ ) { TokenRateData memory tokenRateData = _getLastTokenRate(); return ( uint80(tokenRateData.rateUpdatedL1Timestamp), int256(uint256(tokenRateData.tokenRate)), tokenRateData.rateUpdatedL1Timestamp, tokenRateData.rateReceivedL2Timestamp, uint80(tokenRateData.rateUpdatedL1Timestamp) ); } /// @inheritdoc IChainlinkAggregatorInterface function latestAnswer() external view returns (int256) { TokenRateData memory tokenRateData = _getLastTokenRate(); return int256(uint256(tokenRateData.tokenRate)); } /// @inheritdoc IChainlinkAggregatorInterface function decimals() external pure returns (uint8) { return DECIMALS; } /// @inheritdoc ITokenRateUpdatable function updateRate( uint256 tokenRate_, uint256 rateUpdatedL1Timestamp_ ) external onlyBridgeOrTokenRatePusher { if (_isPaused()) { emit TokenRateUpdateAttemptDuringPause(); return; } TokenRateData storage tokenRateData = _getLastTokenRate(); /// @dev checks if the clock lag (i.e, time difference) between L1 and L2 exceeds the configurable threshold if (rateUpdatedL1Timestamp_ > block.timestamp + MAX_ALLOWED_L2_TO_L1_CLOCK_LAG) { revert ErrorL1TimestampExceededAllowedClockLag(tokenRate_, rateUpdatedL1Timestamp_); } /// @dev Use only the most up-to-date token rate. Reverting should be avoided as it may occur occasionally. if (rateUpdatedL1Timestamp_ < tokenRateData.rateUpdatedL1Timestamp) { emit DormantTokenRateUpdateIgnored(rateUpdatedL1Timestamp_, tokenRateData.rateUpdatedL1Timestamp); return; } /// @dev Bump L2 receipt time, don't touch the rate othwerwise /// NB: Here we assume that the rate can only be changed together with the token rebase induced /// by the AccountingOracle report if (rateUpdatedL1Timestamp_ == tokenRateData.rateUpdatedL1Timestamp) { tokenRateData.rateReceivedL2Timestamp = uint64(block.timestamp); emit RateReceivedTimestampUpdated(block.timestamp); return; } /// @dev This condition was made under the assumption that the L1 timestamps can be manipulated. if (rateUpdatedL1Timestamp_ < tokenRateData.rateUpdatedL1Timestamp + MIN_TIME_BETWEEN_TOKEN_RATE_UPDATES) { emit UpdateRateIsTooOften(rateUpdatedL1Timestamp_, tokenRateData.rateUpdatedL1Timestamp); return; } /// @dev allow token rate to be within some configurable range that depens on time it wasn't updated. if (!_isTokenRateWithinAllowedRange( tokenRateData.tokenRate, tokenRate_, tokenRateData.rateUpdatedL1Timestamp, rateUpdatedL1Timestamp_) ) { revert ErrorTokenRateIsOutOfRange(tokenRate_, rateUpdatedL1Timestamp_); } /// @dev notify that there is a differnce L1 and L2 time. if (rateUpdatedL1Timestamp_ > block.timestamp) { emit TokenRateL1TimestampIsInFuture(tokenRate_, rateUpdatedL1Timestamp_); } _addTokenRate(tokenRate_, rateUpdatedL1Timestamp_, block.timestamp); emit RateUpdated(tokenRate_, rateUpdatedL1Timestamp_); } /// @notice Returns flag that shows that token rate can be considered outdated. function isLikelyOutdated() external view returns (bool) { return (block.timestamp > _getLastTokenRate().rateReceivedL2Timestamp + TOKEN_RATE_OUTDATED_DELAY) || _isPaused(); } /// @notice Allow tokenRate deviation from the previous value to be /// ±`MAX_ALLOWED_TOKEN_RATE_DEVIATION_PER_DAY` BP per day. function _isTokenRateWithinAllowedRange( uint256 currentTokenRate_, uint256 newTokenRate_, uint256 currentRateL1Timestamp_, uint256 newRateL1Timestamp_ ) internal view returns (bool) { uint256 allowedTokenRateDeviation = _allowedTokenRateDeviation(newRateL1Timestamp_, currentRateL1Timestamp_); return newTokenRate_ <= _maxTokenRateLimit(currentTokenRate_, allowedTokenRateDeviation) && newTokenRate_ >= _minTokenRateLimit(currentTokenRate_, allowedTokenRateDeviation); } /// @dev Returns the allowed token deviation depending on the number of days passed since the last update. function _allowedTokenRateDeviation( uint256 newRateL1Timestamp_, uint256 currentRateL1Timestamp_ ) internal view returns (uint256) { uint256 rateL1TimestampDiff = newRateL1Timestamp_ - currentRateL1Timestamp_; uint256 roundedUpNumberOfDays = (rateL1TimestampDiff + ONE_DAY_SECONDS - 1) / ONE_DAY_SECONDS; return roundedUpNumberOfDays * MAX_ALLOWED_TOKEN_RATE_DEVIATION_PER_DAY_BP; } /// @dev Returns the maximum allowable value for the token rate. function _maxTokenRateLimit( uint256 currentTokenRate, uint256 allowedTokenRateDeviation ) internal pure returns (uint256) { uint256 maxTokenRateLimit = currentTokenRate * (BASIS_POINT_SCALE + allowedTokenRateDeviation) / BASIS_POINT_SCALE; return Math.min(maxTokenRateLimit, MAX_SANE_TOKEN_RATE); } /// @dev Returns the minimum allowable value for the token rate. function _minTokenRateLimit( uint256 currentTokenRate, uint256 allowedTokenRateDeviation ) internal pure returns (uint256) { uint256 minTokenRateLimit = MIN_SANE_TOKEN_RATE; if (allowedTokenRateDeviation <= BASIS_POINT_SCALE) { minTokenRateLimit = (currentTokenRate * (BASIS_POINT_SCALE - allowedTokenRateDeviation) / BASIS_POINT_SCALE); } return Math.max(minTokenRateLimit, MIN_SANE_TOKEN_RATE); } function _isCallerBridgeOrMessengerWithTokenRatePusher(address caller_) internal view returns (bool) { if (caller_ == L2_ERC20_TOKEN_BRIDGE) { return true; } if (caller_ == address(MESSENGER) && MESSENGER.xDomainMessageSender() == L1_TOKEN_RATE_PUSHER) { return true; } return false; } function _addTokenRate( uint256 tokenRate_, uint256 rateUpdatedL1Timestamp_, uint256 rateReceivedL2Timestamp_ ) internal { _getStorageTokenRates().push(TokenRateData({ tokenRate: uint128(tokenRate_), rateUpdatedL1Timestamp: uint64(rateUpdatedL1Timestamp_), rateReceivedL2Timestamp: uint64(rateReceivedL2Timestamp_) })); } function _getLastTokenRate() internal view returns (TokenRateData storage) { return _getTokenRateByIndex(_getStorageTokenRates().length - 1); } function _getTokenRateByIndex(uint256 tokenRateIndex_) internal view returns (TokenRateData storage) { if (tokenRateIndex_ >= _getStorageTokenRates().length) { revert ErrorWrongTokenRateIndex(); } return _getStorageTokenRates()[tokenRateIndex_]; } function _getStorageTokenRates() internal pure returns (TokenRateData [] storage result) { bytes32 position = TOKEN_RATES_DATA_SLOT; assembly { result.slot := position } } /// @dev tokenRateIndex_ is limited by time in the past and the number of elements also has restrictions. /// Therefore, this loop can't consume a lot of gas. function _removeElementsAfterIndex(uint256 tokenRateIndex_) internal { uint256 tokenRatesLength = _getStorageTokenRates().length; if (tokenRateIndex_ >= tokenRatesLength) { return; } uint256 numberOfElementsToRemove = tokenRatesLength - tokenRateIndex_ - 1; for (uint256 i = 0; i < numberOfElementsToRemove; i++) { _getStorageTokenRates().pop(); } } function _setPause(bool pause) internal { PAUSE_TOKEN_RATE_UPDATES_SLOT.setStorageBool(pause); } function _isPaused() internal view returns (bool) { return PAUSE_TOKEN_RATE_UPDATES_SLOT.getStorageBool(); } modifier onlyBridgeOrTokenRatePusher() { if (!_isCallerBridgeOrMessengerWithTokenRatePusher(msg.sender)) { revert ErrorNotBridgeOrTokenRatePusher(); } _; } event RateUpdated(uint256 tokenRate_, uint256 indexed rateL1Timestamp_); event RateReceivedTimestampUpdated(uint256 indexed rateReceivedL2Timestamp); event DormantTokenRateUpdateIgnored(uint256 indexed newRateL1Timestamp_, uint256 indexed currentRateL1Timestamp_); event TokenRateL1TimestampIsInFuture(uint256 tokenRate_, uint256 indexed rateL1Timestamp_); event TokenRateUpdatesPaused(uint256 tokenRate_, uint256 indexed rateL1Timestamp_); event TokenRateUpdatesResumed(uint256 tokenRate_, uint256 indexed rateL1Timestamp_); event TokenRateUpdateAttemptDuringPause(); event UpdateRateIsTooOften(uint256 indexed newRateL1Timestamp_, uint256 indexed currentRateL1Timestamp_); error ErrorZeroAddressAdmin(); error ErrorWrongTokenRateIndex(); error ErrorTokenRateUpdateTooOld(); error ErrorAlreadyPaused(); error ErrorAlreadyResumed(); error ErrorZeroAddressL2ERC20TokenBridge(); error ErrorZeroAddressL1TokenRatePusher(); error ErrorNotBridgeOrTokenRatePusher(); error ErrorL1TimestampExceededAllowedClockLag(uint256 tokenRate_, uint256 rateL1Timestamp_); error ErrorTokenRateIsOutOfRange(uint256 tokenRate_, uint256 rateL1Timestamp_); error ErrorMaxTokenRateDeviationIsOutOfRange(); error ErrorTokenRateIsOutOfSaneRange(uint256 tokenRate_); error ErrorL1TimestampExceededMaxAllowedClockLag(uint256 rateL1Timestamp_); error ErrorL1TimestampOlderThanPrevious(uint256 rateL1Timestamp_); }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {ERC20Core} from "./ERC20Core.sol"; import {ERC20Metadata} from "./ERC20Metadata.sol"; /// @author psirex, kovalgek /// @notice Extends the ERC20 functionality that allows the bridge to mint/burn tokens interface IERC20Bridged is IERC20 { /// @notice Returns bridge which can mint and burn tokens on L2 function bridge() external view returns (address); /// @notice Creates `amount_` tokens and assigns them to `account_`, increasing the total supply /// @param account_ An address of the account to mint tokens /// @param amount_ An amount of tokens to mint function bridgeMint(address account_, uint256 amount_) external; /// @notice Destroys `amount_` tokens from `account_`, reducing the total supply /// @param account_ An address of the account to burn tokens /// @param amount_ An amount of tokens to burn function bridgeBurn(address account_, uint256 amount_) external; } /// @author psirex, kovalgek /// @notice Extends the ERC20 functionality that allows the bridge to mint/burn tokens contract ERC20Bridged is IERC20Bridged, ERC20Core, ERC20Metadata { /// @inheritdoc IERC20Bridged address public immutable bridge; /// @param name_ The name of the token /// @param symbol_ The symbol of the token /// @param decimals_ The decimals places of the token /// @param bridge_ The bridge address which allows to mint/burn tokens constructor( string memory name_, string memory symbol_, uint8 decimals_, address bridge_ ) ERC20Metadata(name_, symbol_, decimals_) { if (bridge_ == address(0)) { revert ErrorZeroAddressBridge(); } bridge = bridge_; } /// @inheritdoc IERC20Bridged function bridgeMint(address account_, uint256 amount_) external onlyBridge { _mint(account_, amount_); } /// @inheritdoc IERC20Bridged function bridgeBurn(address account_, uint256 amount_) external onlyBridge { _burn(account_, amount_); } /// @notice Sets the name and the symbol of the tokens if they both are empty /// @param name_ The name of the token /// @param symbol_ The symbol of the token function _initializeERC20Metadata(string memory name_, string memory symbol_) internal { _setERC20MetadataName(name_); _setERC20MetadataSymbol(symbol_); } /// @dev Validates that sender of the transaction is the bridge modifier onlyBridge() { if (msg.sender != bridge) { revert ErrorNotBridge(); } _; } error ErrorZeroAddressBridge(); error ErrorNotBridge(); }
// SPDX-FileCopyrightText: 2022 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /// @author psirex /// @notice Contains the required logic of the ERC20 standard as defined in the EIP. Additionally /// provides methods for direct allowance increasing/decreasing. contract ERC20Core is IERC20 { /// @inheritdoc IERC20 uint256 public totalSupply; /// @inheritdoc IERC20 mapping(address => uint256) public balanceOf; /// @inheritdoc IERC20 mapping(address => mapping(address => uint256)) public allowance; /// @inheritdoc IERC20 function approve(address spender_, uint256 amount_) external returns (bool) { _approve(msg.sender, spender_, amount_); return true; } /// @inheritdoc IERC20 function transfer(address to_, uint256 amount_) external returns (bool) { _transfer(msg.sender, to_, amount_); return true; } /// @inheritdoc IERC20 function transferFrom( address from_, address to_, uint256 amount_ ) external returns (bool) { _spendAllowance(from_, msg.sender, amount_); _transfer(from_, to_, amount_); return true; } /// @dev Moves amount_ of tokens from sender_ to recipient_ /// @param from_ An address of the sender of the tokens /// @param to_ An address of the recipient of the tokens /// @param amount_ An amount of tokens to transfer function _transfer( address from_, address to_, uint256 amount_ ) internal onlyNonZeroAccount(from_) onlyNonZeroAccount(to_) { _decreaseBalance(from_, amount_); balanceOf[to_] += amount_; emit Transfer(from_, to_, amount_); } /// @dev Updates owner_'s allowance for spender_ based on spent amount_. Does not update /// the allowance amount in case of infinite allowance /// @param owner_ An address of the account to spend allowance /// @param spender_ An address of the spender of the tokens /// @param amount_ An amount of allowance spend function _spendAllowance( address owner_, address spender_, uint256 amount_ ) internal { uint256 currentAllowance = allowance[owner_][spender_]; if (currentAllowance == type(uint256).max) { return; } if (amount_ > currentAllowance) { revert ErrorNotEnoughAllowance(); } unchecked { _approve(owner_, spender_, currentAllowance - amount_); } } /// @dev Sets amount_ as the allowance of spender_ over the owner_'s tokens /// @param owner_ An address of the account to set allowance /// @param spender_ An address of the tokens spender /// @param amount_ An amount of tokens to allow to spend function _approve( address owner_, address spender_, uint256 amount_ ) internal virtual onlyNonZeroAccount(owner_) onlyNonZeroAccount(spender_) { allowance[owner_][spender_] = amount_; emit Approval(owner_, spender_, amount_); } /// @dev Creates amount_ tokens and assigns them to account_, increasing the total supply /// @param account_ An address of the account to mint tokens /// @param amount_ An amount of tokens to mint function _mint(address account_, uint256 amount_) internal onlyNonZeroAccount(account_) { totalSupply += amount_; balanceOf[account_] += amount_; emit Transfer(address(0), account_, amount_); } /// @dev Destroys amount_ tokens from account_, reducing the total supply. /// @param account_ An address of the account to mint tokens /// @param amount_ An amount of tokens to mint function _burn(address account_, uint256 amount_) internal onlyNonZeroAccount(account_) { _decreaseBalance(account_, amount_); totalSupply -= amount_; emit Transfer(account_, address(0), amount_); } /// @dev Decreases the balance of the account_ /// @param account_ An address of the account to decrease balance /// @param amount_ An amount of balance decrease function _decreaseBalance(address account_, uint256 amount_) internal { uint256 balance = balanceOf[account_]; if (amount_ > balance) { revert ErrorNotEnoughBalance(); } unchecked { balanceOf[account_] = balance - amount_; } } /// @dev validates that account_ is not zero address modifier onlyNonZeroAccount(address account_) { if (account_ == address(0)) { revert ErrorAccountIsZeroAddress(); } _; } error ErrorNotEnoughBalance(); error ErrorNotEnoughAllowance(); error ErrorAccountIsZeroAddress(); }
// SPDX-FileCopyrightText: 2022 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /// @author psirex /// @notice Interface for the optional metadata functions from the ERC20 standard. interface IERC20Metadata { /// @dev Returns the name of the token. function name() external view returns (string memory); /// @dev Returns the symbol of the token. function symbol() external view returns (string memory); /// @dev Returns the decimals places of the token. function decimals() external view returns (uint8); } /// @author psirex /// @notice Contains the optional metadata functions from the ERC20 standard /// @dev Uses the UnstructuredStorage pattern to store dynamic name and symbol data. Might be used /// with the upgradable proxies contract ERC20Metadata is IERC20Metadata { /// @dev Stores the dynamic metadata of the ERC20 token. Allows safely use of this /// contract with upgradable proxies struct DynamicMetadata { string name; string symbol; } /// @dev Location of the slot with DynamicMetdata /// The slot's index string has a misspelling, but the contract storage will be broken without it. bytes32 private constant DYNAMIC_METADATA_SLOT = keccak256("ERC20Metdata.dynamicMetadata"); /// @inheritdoc IERC20Metadata uint8 public immutable decimals; /// @param name_ Name of the token /// @param symbol_ Symbol of the token /// @param decimals_ Decimals places of the token constructor( string memory name_, string memory symbol_, uint8 decimals_ ) { if (decimals_ == 0) { revert ErrorZeroDecimals(); } decimals = decimals_; _setERC20MetadataName(name_); _setERC20MetadataSymbol(symbol_); } /// @inheritdoc IERC20Metadata function name() public view returns (string memory) { return _loadDynamicMetadata().name; } /// @inheritdoc IERC20Metadata function symbol() public view returns (string memory) { return _loadDynamicMetadata().symbol; } /// @dev Sets the name of the token. function _setERC20MetadataName(string memory name_) internal { if (bytes(name_).length == 0) { revert ErrorNameIsEmpty(); } _loadDynamicMetadata().name = name_; } /// @dev Sets the symbol of the token. function _setERC20MetadataSymbol(string memory symbol_) internal { if (bytes(symbol_).length == 0) { revert ErrorSymbolIsEmpty(); } _loadDynamicMetadata().symbol = symbol_; } function _isMetadataInitialized() internal view returns (bool) { return bytes(name()).length != 0 && bytes(symbol()).length != 0; } /// @dev Returns the reference to the slot with DynamicMetadata struct function _loadDynamicMetadata() private pure returns (DynamicMetadata storage r) { bytes32 slot = DYNAMIC_METADATA_SLOT; assembly { r.slot := slot } } error ErrorZeroDecimals(); error ErrorNameIsEmpty(); error ErrorSymbolIsEmpty(); }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {IERC20Wrapper} from "./interfaces/IERC20Wrapper.sol"; import {ITokenRateOracle} from "../optimism/TokenRateOracle.sol"; import {ERC20Metadata} from "./ERC20Metadata.sol"; import {UnstructuredRefStorage} from "../lib/UnstructuredRefStorage.sol"; import {UnstructuredStorage} from "../lib/UnstructuredStorage.sol"; /// @author kovalgek /// @notice Extends the ERC20 functionality that allows the bridge to wrap/unwrap token. interface IBridgeWrapper { /// @notice Returns bridge which can wrap/unwrap token on L2. function L2_ERC20_TOKEN_BRIDGE() external view returns (address); /// @notice Exchanges non-rebasable token (shares) to rebasable token. Can be called by bridge only. /// @param account_ an address of the account to exchange shares for. /// @param sharesAmount_ amount of non-rebasable token (shares). /// @return Amount of rebasable token. function bridgeWrap(address account_, uint256 sharesAmount_) external returns (uint256); /// @notice Exchanges rebasable token to non-rebasable (shares). Can be called by bridge only. /// @param account_ an address of the account to exchange token for. /// @param tokenAmount_ amount of rebasable token to uwrap in exchange for non-rebasable token (shares). /// @return Amount of non-rebasable token (shares) user receives after unwrap. function bridgeUnwrap(address account_, uint256 tokenAmount_) external returns (uint256); } /// @author kovalgek /// @notice Rebasable token that wraps/unwraps non-rebasable token and allow to mint/burn tokens by bridge. contract ERC20RebasableBridged is IERC20, IERC20Wrapper, IBridgeWrapper, ERC20Metadata { using SafeERC20 for IERC20; using UnstructuredRefStorage for bytes32; using UnstructuredStorage for bytes32; /// @inheritdoc IBridgeWrapper address public immutable L2_ERC20_TOKEN_BRIDGE; /// @notice Contract of non-rebasable token to wrap from. IERC20 public immutable TOKEN_TO_WRAP_FROM; /// @notice Oracle contract used to get token rate for wrapping/unwrapping tokens. ITokenRateOracle public immutable TOKEN_RATE_ORACLE; /// @notice Decimals of the oracle response. uint8 public immutable TOKEN_RATE_ORACLE_DECIMALS; /// @dev token allowance slot position. bytes32 internal constant TOKEN_ALLOWANCE_POSITION = keccak256("ERC20RebasableBridged.TOKEN_ALLOWANCE_POSITION"); /// @dev user shares slot position. bytes32 internal constant SHARES_POSITION = keccak256("ERC20RebasableBridged.SHARES_POSITION"); /// @dev token shares slot position. bytes32 internal constant TOTAL_SHARES_POSITION = keccak256("ERC20RebasableBridged.TOTAL_SHARES_POSITION"); /// @param name_ The name of the token /// @param symbol_ The symbol of the token /// @param decimals_ The decimals places of the token /// @param tokenToWrapFrom_ address of the ERC20 token to wrap /// @param tokenRateOracle_ address of oracle that returns tokens rate /// @param l2ERC20TokenBridge_ The bridge address which allows to mint/burn tokens constructor( string memory name_, string memory symbol_, uint8 decimals_, address tokenToWrapFrom_, address tokenRateOracle_, address l2ERC20TokenBridge_ ) ERC20Metadata(name_, symbol_, decimals_) { if (tokenToWrapFrom_ == address(0)) { revert ErrorZeroAddressTokenToWrapFrom(); } if (tokenRateOracle_ == address(0)) { revert ErrorZeroAddressTokenRateOracle(); } if (l2ERC20TokenBridge_ == address(0)) { revert ErrorZeroAddressL2ERC20TokenBridge(); } TOKEN_TO_WRAP_FROM = IERC20(tokenToWrapFrom_); TOKEN_RATE_ORACLE = ITokenRateOracle(tokenRateOracle_); TOKEN_RATE_ORACLE_DECIMALS = TOKEN_RATE_ORACLE.decimals(); L2_ERC20_TOKEN_BRIDGE = l2ERC20TokenBridge_; } /// @inheritdoc IERC20Wrapper function wrap(uint256 sharesAmount_) external returns (uint256) { return _wrap(msg.sender, msg.sender, sharesAmount_); } /// @inheritdoc IERC20Wrapper function unwrap(uint256 tokenAmount_) external returns (uint256) { return _unwrap(msg.sender, tokenAmount_); } /// @notice Exchanges rebasable token to non-rebasable by providing rebasable token shares. /// @param sharesAmount_ amount of rebasable token shares to unwrap. /// @return amount of non-rebasable token user receives after unwrap. function unwrapShares(uint256 sharesAmount_) external returns (uint256) { uint256 tokenAmount = _getTokensByShares(sharesAmount_); return _unwrapShares(msg.sender, sharesAmount_, tokenAmount); } /// @inheritdoc IBridgeWrapper function bridgeWrap(address account_, uint256 sharesAmount_) external onlyBridge returns (uint256) { return _wrap(L2_ERC20_TOKEN_BRIDGE, account_, sharesAmount_); } /// @inheritdoc IBridgeWrapper function bridgeUnwrap(address account_, uint256 tokenAmount_) external onlyBridge returns (uint256) { return _unwrap(account_, tokenAmount_); } /// @inheritdoc IERC20 function allowance(address owner, address spender) external view returns (uint256) { return _getTokenAllowance()[owner][spender]; } /// @inheritdoc IERC20 function totalSupply() external view returns (uint256) { return _getTokensByShares(_getTotalShares()); } /// @inheritdoc IERC20 function balanceOf(address account_) external view returns (uint256) { return _getTokensByShares(_sharesOf(account_)); } /// @notice Get shares amount of the provided account. /// @param account_ provided account address. /// @return amount of shares owned by `_account`. function sharesOf(address account_) external view returns (uint256) { return _sharesOf(account_); } /// @return total amount of shares. function getTotalShares() external view returns (uint256) { return _getTotalShares(); } /// @notice Get amount of tokens for a given amount of shares. /// @param sharesAmount_ amount of shares. /// @return amount of tokens for a given shares amount. function getTokensByShares(uint256 sharesAmount_) external view returns (uint256) { return _getTokensByShares(sharesAmount_); } /// @notice Get amount of shares for a given amount of tokens. /// @param tokenAmount_ provided tokens amount. /// @return amount of shares for a given tokens amount. function getSharesByTokens(uint256 tokenAmount_) external view returns (uint256) { return _getSharesByTokens(tokenAmount_); } /// @inheritdoc IERC20 function approve(address spender_, uint256 amount_) external returns (bool) { _approve(msg.sender, spender_, amount_); return true; } /// @inheritdoc IERC20 function transfer(address to_, uint256 amount_) external returns (bool) { _transfer(msg.sender, to_, amount_); return true; } /// @inheritdoc IERC20 function transferFrom(address from_, address to_, uint256 amount_) external returns (bool) { _spendAllowance(from_, msg.sender, amount_); _transfer(from_, to_, amount_); return true; } /// @notice Moves `sharesAmount_` token shares from the caller's account to the `recipient_` account. /// /// @return amount of transferred tokens. /// Emits a `TransferShares` event. /// Emits a `Transfer` event. /// /// Requirements: /// /// - `recipient_` cannot be the zero address. /// - the caller must have at least `sharesAmount_` shares. /// /// @dev The `sharesAmount_` argument is the amount of shares, not tokens. /// function transferShares(address recipient_, uint256 sharesAmount_) external returns (uint256) { _transferShares(msg.sender, recipient_, sharesAmount_); uint256 tokensAmount = _getTokensByShares(sharesAmount_); _emitTransferEvents(msg.sender, recipient_, tokensAmount, sharesAmount_); return tokensAmount; } /// @notice Moves `sharesAmount_` token shares from the `sender_` account to the `_recipient` account. /// /// @return amount of transferred tokens. /// Emits a `TransferShares` event. /// Emits a `Transfer` event. /// /// Requirements: /// /// - `sender_` and `_recipient` cannot be the zero addresses. /// - `sender_` must have at least `sharesAmount_` shares. /// - the caller must have allowance for `sender_`'s tokens of at least `_getTokensByShares(sharesAmount_)`. /// /// @dev The `_sharesAmount` argument is the amount of shares, not tokens. /// function transferSharesFrom( address sender_, address recipient_, uint256 sharesAmount_ ) external returns (uint256) { uint256 tokensAmount = _getTokensByShares(sharesAmount_); _spendAllowance(sender_, msg.sender, tokensAmount); _transferShares(sender_, recipient_, sharesAmount_); _emitTransferEvents(sender_, recipient_, tokensAmount, sharesAmount_); return tokensAmount; } function _getTokenAllowance() internal pure returns (mapping(address => mapping(address => uint256)) storage) { return TOKEN_ALLOWANCE_POSITION.storageMapAddressMapAddressUint256(); } /// @notice Amount of shares (locked wstETH amount) owned by the holder. function _getShares() internal pure returns (mapping(address => uint256) storage) { return SHARES_POSITION.storageMapAddressAddressUint256(); } /// @notice The total amount of shares in existence. function _getTotalShares() internal view returns (uint256) { return TOTAL_SHARES_POSITION.getStorageUint256(); } /// @notice Set total amount of shares. function _setTotalShares(uint256 _newTotalShares) internal { TOTAL_SHARES_POSITION.setStorageUint256(_newTotalShares); } /// @dev Moves amount_ of tokens from sender_ to recipient_ /// @param from_ An address of the sender of the tokens /// @param to_ An address of the recipient of the tokens /// @param amount_ An amount of tokens to transfer function _transfer( address from_, address to_, uint256 amount_ ) internal onlyNonZeroAccount(from_) onlyNonZeroAccount(to_) { uint256 sharesToTransfer = _getSharesByTokens(amount_); _transferShares(from_, to_, sharesToTransfer); _emitTransferEvents(from_, to_, amount_, sharesToTransfer); } /// @dev Updates owner_'s allowance for spender_ based on spent amount_. Does not update /// the allowance amount in case of infinite allowance /// @param owner_ An address of the account to spend allowance /// @param spender_ An address of the spender of the tokens /// @param amount_ An amount of allowance spend function _spendAllowance( address owner_, address spender_, uint256 amount_ ) internal { uint256 currentAllowance = _getTokenAllowance()[owner_][spender_]; if (currentAllowance == type(uint256).max) { return; } if (amount_ > currentAllowance) { revert ErrorNotEnoughAllowance(); } unchecked { _approve(owner_, spender_, currentAllowance - amount_); } } /// @dev Sets amount_ as the allowance of spender_ over the owner_'s tokens /// @param owner_ An address of the account to set allowance /// @param spender_ An address of the tokens spender /// @param amount_ An amount of tokens to allow to spend function _approve( address owner_, address spender_, uint256 amount_ ) internal virtual onlyNonZeroAccount(owner_) onlyNonZeroAccount(spender_) { _getTokenAllowance()[owner_][spender_] = amount_; emit Approval(owner_, spender_, amount_); } function _sharesOf(address account_) internal view returns (uint256) { return _getShares()[account_]; } function _getTokensByShares(uint256 sharesAmount_) internal view returns (uint256) { return (sharesAmount_ * _getTokenRate()) / (10 ** TOKEN_RATE_ORACLE_DECIMALS); } function _getSharesByTokens(uint256 tokenAmount_) internal view returns (uint256) { return (tokenAmount_ * (10 ** TOKEN_RATE_ORACLE_DECIMALS)) / _getTokenRate(); } function _getTokenRate() internal view returns (uint256) { return uint256(TOKEN_RATE_ORACLE.latestAnswer()); } /// @dev Creates `amount_` shares and assigns them to `account_`, increasing the total shares supply /// @param recipient_ An address of the account to mint shares /// @param amount_ An amount of shares to mint function _mintShares( address recipient_, uint256 amount_ ) internal onlyNonZeroAccount(recipient_) { _setTotalShares(_getTotalShares() + amount_); _getShares()[recipient_] = _getShares()[recipient_] + amount_; } /// @dev Destroys `amount_` shares from `account_`, reducing the total shares supply. /// @param account_ An address of the account to mint shares /// @param amount_ An amount of shares to mint function _burnShares( address account_, uint256 amount_ ) internal onlyNonZeroAccount(account_) { uint256 accountShares = _getShares()[account_]; if (accountShares < amount_) revert ErrorNotEnoughBalance(); _setTotalShares(_getTotalShares() - amount_); _getShares()[account_] = accountShares - amount_; } /// @dev Moves `sharesAmount_` shares from `sender_` to `recipient_`. /// @param sender_ An address of the account to take shares /// @param recipient_ An address of the account to transfer shares /// @param sharesAmount_ An amount of shares to transfer function _transferShares( address sender_, address recipient_, uint256 sharesAmount_ ) internal onlyNonZeroAccount(sender_) onlyNonZeroAccount(recipient_) { if (recipient_ == address(this)) revert ErrorTransferToRebasableContract(); uint256 currentSenderShares = _getShares()[sender_]; if (sharesAmount_ > currentSenderShares) revert ErrorNotEnoughBalance(); _getShares()[sender_] = currentSenderShares - sharesAmount_; _getShares()[recipient_] = _getShares()[recipient_] + sharesAmount_; } /// @dev Emits `Transfer` and `TransferShares` events function _emitTransferEvents( address _from, address _to, uint256 _tokenAmount, uint256 _sharesAmount ) internal { emit Transfer(_from, _to, _tokenAmount); emit TransferShares(_from, _to, _sharesAmount); } /// @notice Sets the name and the symbol of the tokens if they both are empty /// @param name_ The name of the token /// @param symbol_ The symbol of the token function _initializeERC20Metadata(string memory name_, string memory symbol_) internal { _setERC20MetadataName(name_); _setERC20MetadataSymbol(symbol_); } function _wrap(address from_, address to_, uint256 sharesAmount_) internal returns (uint256) { if (sharesAmount_ == 0) revert ErrorZeroSharesWrap(); TOKEN_TO_WRAP_FROM.safeTransferFrom(from_, address(this), sharesAmount_); _mintShares(to_, sharesAmount_); uint256 tokensAmount = _getTokensByShares(sharesAmount_); _emitTransferEvents(address(0), to_, tokensAmount, sharesAmount_); return tokensAmount; } function _unwrap(address account_, uint256 tokenAmount_) internal returns (uint256) { if (tokenAmount_ == 0) revert ErrorZeroTokensUnwrap(); uint256 sharesAmount = _getSharesByTokens(tokenAmount_); return _unwrapShares(account_, sharesAmount, tokenAmount_); } function _unwrapShares(address account_, uint256 sharesAmount_, uint256 tokenAmount_) internal returns (uint256) { if (sharesAmount_ == 0) revert ErrorZeroSharesUnwrap(); _burnShares(account_, sharesAmount_); _emitTransferEvents(account_, address(0), tokenAmount_, sharesAmount_); TOKEN_TO_WRAP_FROM.safeTransfer(account_, sharesAmount_); return sharesAmount_; } /// @dev validates that account_ is not zero address modifier onlyNonZeroAccount(address account_) { if (account_ == address(0)) { revert ErrorAccountIsZeroAddress(); } _; } /// @dev Validates that sender of the transaction is the bridge modifier onlyBridge() { if (msg.sender != L2_ERC20_TOKEN_BRIDGE) { revert ErrorNotBridge(); } _; } /// @notice An executed shares transfer from `sender` to `recipient`. /// @dev emitted in pair with an ERC20-defined `Transfer` event. event TransferShares( address indexed from, address indexed to, uint256 sharesValue ); error ErrorZeroAddressTokenToWrapFrom(); error ErrorZeroAddressTokenRateOracle(); error ErrorZeroAddressL2ERC20TokenBridge(); error ErrorZeroSharesWrap(); error ErrorZeroTokensUnwrap(); error ErrorZeroSharesUnwrap(); error ErrorTransferToRebasableContract(); error ErrorNotEnoughBalance(); error ErrorNotEnoughAllowance(); error ErrorAccountIsZeroAddress(); error ErrorNotBridge(); }
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; /// @author kovalgek /// @notice Extends the ERC20 functionality that allows to wrap/unwrap token. interface IERC20Wrapper { /// @notice Exchanges wrappable token to wrapper one. /// @param wrappableTokenAmount_ amount of wrappable token to wrap. /// @return Amount of wrapper token user receives after wrap. function wrap(uint256 wrappableTokenAmount_) external returns (uint256); /// @notice Exchanges wrapper token to wrappable one. /// @param wrapperTokenAmount_ amount of wrapper token to uwrap in exchange for wrappable. /// @return Amount of wrappable token user receives after unwrap. function unwrap(uint256 wrapperTokenAmount_) external returns (uint256); }
// SPDX-FileCopyrightText: 2022 Lido <[email protected]> // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.10; import {UnstructuredStorage} from "../lib/UnstructuredStorage.sol"; /// @dev A copy of Versioned.sol contract from Lido on Ethereum protocol /// https://github.com/lidofinance/lido-dao/blob/master/contracts/0.8.9/utils/Versioned.sol contract Versioned { using UnstructuredStorage for bytes32; event ContractVersionSet(uint256 version); error NonZeroContractVersionOnInit(); error InvalidContractVersionIncrement(); error UnexpectedContractVersion(uint256 expected, uint256 received); /// @dev Storage slot: uint256 version /// Version of the initialized contract storage. /// The version stored in CONTRACT_VERSION_POSITION equals to: /// - 0 right after the deployment, before an initializer is invoked (and only at that moment); /// - N after calling initialize(), where N is the initially deployed contract version; /// - N after upgrading contract by calling finalizeUpgrade_vN(). bytes32 internal constant CONTRACT_VERSION_POSITION = keccak256("lido.Versioned.contractVersion"); uint256 internal constant PETRIFIED_VERSION_MARK = type(uint256).max; constructor() { // lock version in the implementation's storage to prevent initialization CONTRACT_VERSION_POSITION.setStorageUint256(PETRIFIED_VERSION_MARK); } /// @notice Returns the current contract version. function getContractVersion() public view returns (uint256) { return CONTRACT_VERSION_POSITION.getStorageUint256(); } function _checkContractVersion(uint256 version) internal view { uint256 expectedVersion = getContractVersion(); if (version != expectedVersion) { revert UnexpectedContractVersion(expectedVersion, version); } } /// @dev Sets the contract version to N. Should be called from the initialize() function. function _initializeContractVersionTo(uint256 version) internal { if (getContractVersion() != 0) revert NonZeroContractVersionOnInit(); _setContractVersion(version); } /// @dev Updates the contract version. Should be called from a finalizeUpgrade_vN() function. function _updateContractVersion(uint256 newVersion) internal { if (newVersion != getContractVersion() + 1) revert InvalidContractVersionIncrement(); _setContractVersion(newVersion); } function _setContractVersion(uint256 version) private { CONTRACT_VERSION_POSITION.setStorageUint256(version); emit ContractVersionSet(version); } }
{ "optimizer": { "enabled": true, "runs": 100000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"messenger_","type":"address"},{"internalType":"address","name":"l1TokenBridge_","type":"address"},{"internalType":"address","name":"l1TokenNonRebasable_","type":"address"},{"internalType":"address","name":"l1TokenRebasable_","type":"address"},{"internalType":"address","name":"l2TokenNonRebasable_","type":"address"},{"internalType":"address","name":"l2TokenRebasable_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ErrorAccountIsZeroAddress","type":"error"},{"inputs":[],"name":"ErrorAlreadyInitialized","type":"error"},{"inputs":[],"name":"ErrorBridgingManagerIsNotInitialized","type":"error"},{"inputs":[],"name":"ErrorDepositDataLength","type":"error"},{"inputs":[],"name":"ErrorDepositsDisabled","type":"error"},{"inputs":[],"name":"ErrorDepositsEnabled","type":"error"},{"inputs":[],"name":"ErrorSenderNotEOA","type":"error"},{"inputs":[],"name":"ErrorTransferToL1TokenContract","type":"error"},{"inputs":[],"name":"ErrorUnauthorizedMessenger","type":"error"},{"inputs":[{"internalType":"address","name":"l1Token","type":"address"},{"internalType":"address","name":"l2Token","type":"address"}],"name":"ErrorUnsupportedL1L2TokensPair","type":"error"},{"inputs":[{"internalType":"address","name":"l2Token","type":"address"}],"name":"ErrorUnsupportedL2Token","type":"error"},{"inputs":[],"name":"ErrorWithdrawalsDisabled","type":"error"},{"inputs":[],"name":"ErrorWithdrawalsEnabled","type":"error"},{"inputs":[],"name":"ErrorWrongCrossDomainSender","type":"error"},{"inputs":[],"name":"ErrorZeroAddressAdmin","type":"error"},{"inputs":[],"name":"ErrorZeroAddressL1Bridge","type":"error"},{"inputs":[],"name":"ErrorZeroAddressL1TokenNonRebasable","type":"error"},{"inputs":[],"name":"ErrorZeroAddressL1TokenRebasable","type":"error"},{"inputs":[],"name":"ErrorZeroAddressL2TokenNonRebasable","type":"error"},{"inputs":[],"name":"ErrorZeroAddressL2TokenRebasable","type":"error"},{"inputs":[],"name":"ErrorZeroAddressMessenger","type":"error"},{"inputs":[],"name":"InvalidContractVersionIncrement","type":"error"},{"inputs":[],"name":"NonZeroContractVersionOnInit","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"received","type":"uint256"}],"name":"UnexpectedContractVersion","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"version","type":"uint256"}],"name":"ContractVersionSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_l1Token","type":"address"},{"indexed":true,"internalType":"address","name":"_l2Token","type":"address"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":false,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"_data","type":"bytes"}],"name":"DepositFinalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"disabler","type":"address"}],"name":"DepositsDisabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"enabler","type":"address"}],"name":"DepositsEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"admin","type":"address"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_l1Token","type":"address"},{"indexed":true,"internalType":"address","name":"_l2Token","type":"address"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":false,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"_data","type":"bytes"}],"name":"WithdrawalInitiated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"disabler","type":"address"}],"name":"WithdrawalsDisabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"enabler","type":"address"}],"name":"WithdrawalsEnabled","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPOSITS_DISABLER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPOSITS_ENABLER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"L1_TOKEN_NON_REBASABLE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"L1_TOKEN_REBASABLE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"L2_TOKEN_NON_REBASABLE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"L2_TOKEN_REBASABLE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MESSENGER","outputs":[{"internalType":"contract ICrossDomainMessenger","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAWALS_DISABLER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAWALS_ENABLER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disableDeposits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disableWithdrawals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableDeposits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableWithdrawals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"l1Token_","type":"address"},{"internalType":"address","name":"l2Token_","type":"address"},{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"finalizeDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"finalizeUpgrade_v2","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getContractVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isDepositsEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isWithdrawalsEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"l1TokenBridge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"l2Token_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"uint32","name":"l1Gas_","type":"uint32"},{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"l2Token_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"uint32","name":"l1Gas_","type":"uint32"},{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"withdrawTo","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6101406040523480156200001257600080fd5b5060405162003690380380620036908339810160408190526200003591620001c0565b85848484846001600160a01b038416620000625760405163635c10c560e01b815260040160405180910390fd5b6001600160a01b0383166200008a57604051636a83f30760e01b815260040160405180910390fd5b6001600160a01b038216620000b257604051630f52c48160e01b815260040160405180910390fd5b6001600160a01b038116620000da57604051636cdc4fe760e11b815260040160405180910390fd5b6001600160a01b0393841660805291831660a052821660c052811660e05281166200011857604051635d4339db60e01b815260040160405180910390fd5b6001600160a01b0316610100526200015f7f4dd0f6662ba1d6b081f08b350f5e9a6a7b15cf586926ba66f753594928fa64a66000196200019f602090811b6200143e17901c565b6001600160a01b038516620001875760405163094531c560e31b815260040160405180910390fd5b505050506001600160a01b0316610120525062000241565b9055565b80516001600160a01b0381168114620001bb57600080fd5b919050565b60008060008060008060c08789031215620001da57600080fd5b620001e587620001a3565b9550620001f560208801620001a3565b94506200020560408801620001a3565b93506200021560608801620001a3565b92506200022560808801620001a3565b91506200023560a08801620001a3565b90509295509295509295565b60805160a05160c05160e05161010051610120516133346200035c600039600081816102c101528181610a6c01526116f301526000818161044f01528181610aa301528181610b1301526123d301526000818161020c015281816106ec01528181610c6101528181610f70015281816117a301528181611a2201528181611bb401528181611e2501528181612073015281816120f401526121c80152600081816105250152818161069501528181610f19015281816117280152818161197801528181611c3b01528181611e030152818161228201526123310152600081816103140152818161153e015281816117f801526119cc0152600081816104bc015281816115930152818161177d015261192201526133346000f3fe608060405234801561001057600080fd5b50600436106101da5760003560e01c80638d7601c011610104578063b210de8b116100a2578063e3b523e311610071578063e3b523e3146104f1578063e8bac93b14610518578063f73abda914610520578063fadcc54a1461054757600080fd5b8063b210de8b1461049c578063c4d66de8146104a4578063c83dbcee146104b7578063d547741f146104de57600080fd5b8063a217fddf116100de578063a217fddf14610471578063a3a7954814610479578063ac67e1af1461048c578063ad960ce11461049457600080fd5b80638d7601c0146103df57806391d1485414610406578063927ede2d1461044a57600080fd5b8063392e53cd1161017c5780635ed2c2201161014b5780635ed2c2201461036d578063662a633a1461039d5780636f18bd22146103b05780638aa10435146103d757600080fd5b8063392e53cd146102e55780633d9131a41461030f5780635777bf50146103365780635e4c57a41461036557600080fd5b80632f2ff15d116101b85780632f2ff15d1461028457806332b7006d1461029957806336568abe146102ac57806336c717c1146102bf57600080fd5b806301ffc9a7146101df57806320f748c414610207578063248a9ca314610253575b600080fd5b6101f26101ed366004612b74565b61056e565b60405190151581526020015b60405180910390f35b61022e7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101fe565b610276610261366004612bb6565b60009081526020819052604090206001015490565b6040519081526020016101fe565b610297610292366004612bf1565b610607565b005b6102976102a7366004612c83565b610631565b6102976102ba366004612bf1565b610853565b7f000000000000000000000000000000000000000000000000000000000000000061022e565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5460ff166101f2565b61022e7f000000000000000000000000000000000000000000000000000000000000000081565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba54610100900460ff166101f2565b610297610906565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5462010000900460ff166101f2565b6102976103ab366004612cf4565b610a0a565b6102767f63f736f21cb2943826cd50b191eb054ebbea670e4e962d0527611f830cd399d681565b610276610e38565b6102767f94a954c0bc99227eddbc0715a62a7e1056ed8784cd719c2303b685683908857c81565b6101f2610414366004612bf1565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61022e7f000000000000000000000000000000000000000000000000000000000000000081565b610276600081565b610297610487366004612d8c565b610e67565b61029761109b565b61029761119a565b61029761129a565b6102976104b2366004612e0f565b6112ff565b61022e7f000000000000000000000000000000000000000000000000000000000000000081565b6102976104ec366004612bf1565b611313565b6102767f9ab8816a3dc0b3849ec1ac00483f6ec815b07eee2fd766a353311c823ad59d0d81565b610297611338565b61022e7f000000000000000000000000000000000000000000000000000000000000000081565b6102767f4b43b36766bde12c5e9cbbc37d15f8d1f769f08f54720ab370faeb4ce893753a81565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061060157507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60008281526020819052604090206001015461062281611442565b61062c838361144c565b505050565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5462010000900460ff16610692576040517f77d195b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b847f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561073b57507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b1561078f576040517f39394bc700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024015b60405180910390fd5b333b156107c8576040517fdf6691fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6107d78633338888888861153c565b3373ffffffffffffffffffffffffffffffffffffffff87166107f888611724565b73ffffffffffffffffffffffffffffffffffffffff167f73d170910aba9e6d50b102db522b1dbcd796216f5128b445aa2135272886497e338988886040516108439493929190612e75565b60405180910390a4505050505050565b73ffffffffffffffffffffffffffffffffffffffff811633146108f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610786565b6109028282611866565b5050565b7f4b43b36766bde12c5e9cbbc37d15f8d1f769f08f54720ab370faeb4ce893753a61093081611442565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba54610100900460ff1615610991576040517f4f2c8be200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1661010017905560405133907fc36a428b063177e3f28b3b5d340c08f77827847b2ee30114ccf0c40e519c420a90600090a250565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba54610100900460ff16610a6a576040517fa185a6b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000003373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610afa576040517ff95a18f800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16636e296e456040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba09190612eb5565b73ffffffffffffffffffffffffffffffffffffffff1614610bed576040517fe36e2eb200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8787610bf9828261191d565b610c4f576040517f759b5b3000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808416600483015282166024820152604401610786565b6000610c5b8686611a84565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166345a8306f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cee9190612eb5565b825160208401516040517f405abb410000000000000000000000000000000000000000000000000000000081526fffffffffffffffffffffffffffffffff909216600483015264ffffffffff16602482015290915073ffffffffffffffffffffffffffffffffffffffff82169063405abb4190604401600060405180830381600087803b158015610d7e57600080fd5b505af1158015610d92573d6000803e3d6000fd5b505050506000610da38c8b8b611ba3565b90508a73ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff168e73ffffffffffffffffffffffffffffffffffffffff167fb0444523268717a02698be47d0803aa7468c00acbed2f8bd93a0459cde61dd898d858860400151604051610e2193929190612f48565b60405180910390a450505050505050505050505050565b6000610e627f4dd0f6662ba1d6b081f08b350f5e9a6a7b15cf586926ba66f753594928fa64a65490565b905090565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5462010000900460ff16610ec8576040517f77d195b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff8116610f16576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b867f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015610fbf57507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b1561100e576040517f39394bc700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610786565b61101d8833898989898961153c565b3373ffffffffffffffffffffffffffffffffffffffff891661103e8a611724565b73ffffffffffffffffffffffffffffffffffffffff167f73d170910aba9e6d50b102db522b1dbcd796216f5128b445aa2135272886497e8a8a89896040516110899493929190612e75565b60405180910390a45050505050505050565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba54610100900460ff166110fb576040517fa185a6b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f63f736f21cb2943826cd50b191eb054ebbea670e4e962d0527611f830cd399d661112581611442565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905560405133907f9ca4d309bbfd23c65db3dc38c1712862f5812c7139937e2655de86e803f73bb990600090a250565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5462010000900460ff166111fb576040517f77d195b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f94a954c0bc99227eddbc0715a62a7e1056ed8784cd719c2303b685683908857c61122581611442565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff16905560405133907f644eeba8ede48fefc32ada09fb240c5f6c0f06507ab1d296d5af41f1521d9fcb90600090a250565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5460ff166112f5576040517f1ac3cb3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6112fd611ddf565b565b611307611ddf565b61131081611e6a565b50565b60008281526020819052604090206001015461132e81611442565b61062c8383611866565b7f9ab8816a3dc0b3849ec1ac00483f6ec815b07eee2fd766a353311c823ad59d0d61136281611442565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5462010000900460ff16156113c4576040517ff74ad25400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff166201000017905560405133907fb2ed3603bd9051f0182ebfb75f12a21059b4d31b578a2a05c8d0245e9e2d320490600090a250565b9055565b6113108133611f8d565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109025760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556114de3390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614806115e157507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b15611618576040517f78b53a0700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061162588888761205d565b905060007fa9f9e675000000000000000000000000000000000000000000000000000000006116538a611724565b8a8a8a86898960405160240161166f9796959493929190612f7d565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290506117197f00000000000000000000000000000000000000000000000000000000000000008683612396565b505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156117a157507f0000000000000000000000000000000000000000000000000000000000000000919050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561181c57507f0000000000000000000000000000000000000000000000000000000000000000919050565b6040517f39394bc700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152602401610786565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109025760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480156119c657507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148015611a7057507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b90508180611a7b5750805b95945050505050565b60408051606080820183526000808352602083015291810191909152611aac60056010613009565b60ff16821015611ae8576040517f35363af400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516060810190915260009080611b04601084878961302e565b611b0d91613058565b60801c815260200185601086611b24600583613009565b60ff1692611b349392919061302e565b611b3d916130a0565b60d81c81526020018585611b5360056010613009565b60ff16908092611b659392919061302e565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050915250949350505050565b600081611bb257506000611dd8565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611d4c576040517f8c2a993e000000000000000000000000000000000000000000000000000000008152306004820152602481018390527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690638c2a993e90604401600060405180830381600087803b158015611c9457600080fd5b505af1158015611ca8573d6000803e3d6000fd5b50506040517f2ed2493100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301526024820186905287169250632ed2493191506044016020604051808303816000875af1158015611d21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d4591906130e6565b9050611dd8565b6040517f8c2a993e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015260248201849052851690638c2a993e90604401600060405180830381600087803b158015611dbc57600080fd5b505af1158015611dd0573d6000803e3d6000fd5b505050508190505b9392505050565b611de96002612443565b6112fd73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000167f00000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61248b565b73ffffffffffffffffffffffffffffffffffffffff8116611eb7576040517fc6ab211700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba805460ff1615611f14576040517f66a02dea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f1f60008361144c565b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117815560405173ffffffffffffffffffffffffffffffffffffffff8316907f908408e307fc569b417f6cbec5d5a06f44a0a505ac0479b47d421a4b2fd6a1e690600090a25050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1661090257611fe38173ffffffffffffffffffffffffffffffffffffffff1660146125c6565b611fee8360206125c6565b604051602001611fff9291906130ff565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a000000000000000000000000000000000000000000000000000000000825261078691600401613180565b60008161206c57506000611dd8565b60008290507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156122e5576040517f7749c54f000000000000000000000000000000000000000000000000000000008152600481018490527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690637749c54f90602401602060405180830381865afa158015612150573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061217491906130e6565b90508015611d45576040517fe53d44df00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018590527f0000000000000000000000000000000000000000000000000000000000000000169063e53d44df906044016020604051808303816000875af1158015612211573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223591906130e6565b506040517f74f4f54700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906374f4f54790604401600060405180830381600087803b1580156122c657600080fd5b505af11580156122da573d6000803e3d6000fd5b505050509050611dd8565b6040517f74f4f54700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906374f4f54790604401600060405180830381600087803b15801561237557600080fd5b505af1158015612389573d6000803e3d6000fd5b5092979650505050505050565b6040517f3dbb202b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690633dbb202b9061240c90869085908790600401613193565b600060405180830381600087803b15801561242657600080fd5b505af115801561243a573d6000803e3d6000fd5b50505050505050565b61244b610e38565b15612482576040517f61394a8400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61131081612809565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015612502573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061252691906130e6565b61253091906131d8565b6040805173ffffffffffffffffffffffffffffffffffffffff8616602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b3000000000000000000000000000000000000000000000000000000001790529091506125c0908590612868565b50505050565b606060006125d58360026131f0565b6125e09060026131d8565b67ffffffffffffffff8111156125f8576125f861322d565b6040519080825280601f01601f191660200182016040528015612622576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106126595761265961325c565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106126bc576126bc61325c565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060006126f88460026131f0565b6127039060016131d8565b90505b60018111156127a0577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106127445761274461325c565b1a60f81b82828151811061275a5761275a61325c565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c936127998161328b565b9050612706565b508315611dd8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610786565b6128327f4dd0f6662ba1d6b081f08b350f5e9a6a7b15cf586926ba66f753594928fa64a6829055565b6040518181527ffddcded6b4f4730c226821172046b48372d3cd963c159701ae1b7c3bcac541bb9060200160405180910390a150565b60006128ca826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166129749092919063ffffffff16565b80519091501561062c57808060200190518101906128e891906132c0565b61062c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610786565b6060612983848460008561298b565b949350505050565b606082471015612a1d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610786565b73ffffffffffffffffffffffffffffffffffffffff85163b612a9b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610786565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051612ac491906132e2565b60006040518083038185875af1925050503d8060008114612b01576040519150601f19603f3d011682016040523d82523d6000602084013e612b06565b606091505b5091509150612b16828286612b21565b979650505050505050565b60608315612b30575081611dd8565b825115612b405782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107869190613180565b600060208284031215612b8657600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114611dd857600080fd5b600060208284031215612bc857600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811461131057600080fd5b60008060408385031215612c0457600080fd5b823591506020830135612c1681612bcf565b809150509250929050565b803563ffffffff81168114612c3557600080fd5b919050565b60008083601f840112612c4c57600080fd5b50813567ffffffffffffffff811115612c6457600080fd5b602083019150836020828501011115612c7c57600080fd5b9250929050565b600080600080600060808688031215612c9b57600080fd5b8535612ca681612bcf565b945060208601359350612cbb60408701612c21565b9250606086013567ffffffffffffffff811115612cd757600080fd5b612ce388828901612c3a565b969995985093965092949392505050565b600080600080600080600060c0888a031215612d0f57600080fd5b8735612d1a81612bcf565b96506020880135612d2a81612bcf565b95506040880135612d3a81612bcf565b94506060880135612d4a81612bcf565b93506080880135925060a088013567ffffffffffffffff811115612d6d57600080fd5b612d798a828b01612c3a565b989b979a50959850939692959293505050565b60008060008060008060a08789031215612da557600080fd5b8635612db081612bcf565b95506020870135612dc081612bcf565b945060408701359350612dd560608801612c21565b9250608087013567ffffffffffffffff811115612df157600080fd5b612dfd89828a01612c3a565b979a9699509497509295939492505050565b600060208284031215612e2157600080fd5b8135611dd881612bcf565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff85168152836020820152606060408201526000612eab606083018486612e2c565b9695505050505050565b600060208284031215612ec757600080fd5b8151611dd881612bcf565b60005b83811015612eed578181015183820152602001612ed5565b838111156125c05750506000910152565b60008151808452612f16816020860160208601612ed2565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b73ffffffffffffffffffffffffffffffffffffffff84168152826020820152606060408201526000611a7b6060830184612efe565b600073ffffffffffffffffffffffffffffffffffffffff808a1683528089166020840152808816604084015280871660608401525084608083015260c060a0830152612fcd60c083018486612e2c565b9998505050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600060ff821660ff84168060ff0382111561302657613026612fda565b019392505050565b6000808585111561303e57600080fd5b8386111561304b57600080fd5b5050820193919092039150565b7fffffffffffffffffffffffffffffffff0000000000000000000000000000000081358181169160108510156130985780818660100360031b1b83161692505b505092915050565b7fffffffffff00000000000000000000000000000000000000000000000000000081358181169160058510156130985760059490940360031b84901b1690921692915050565b6000602082840312156130f857600080fd5b5051919050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613137816017850160208801612ed2565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613174816028840160208801612ed2565b01602801949350505050565b602081526000611dd86020830184612efe565b73ffffffffffffffffffffffffffffffffffffffff841681526060602082015260006131c26060830185612efe565b905063ffffffff83166040830152949350505050565b600082198211156131eb576131eb612fda565b500190565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561322857613228612fda565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008161329a5761329a612fda565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b6000602082840312156132d257600080fd5b81518015158114611dd857600080fd5b600082516132f4818460208701612ed2565b919091019291505056fea26469706673582212207ba9a85c702b75acdd091db135d80f68e1c7696b2c11133c99509c7d0ab5290464736f6c634300080a00330000000000000000000000004200000000000000000000000000000000000007000000000000000000000000755610f5be536ad7afbaa7c10f3e938ea3aa18770000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe84000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a9200100000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c80638d7601c011610104578063b210de8b116100a2578063e3b523e311610071578063e3b523e3146104f1578063e8bac93b14610518578063f73abda914610520578063fadcc54a1461054757600080fd5b8063b210de8b1461049c578063c4d66de8146104a4578063c83dbcee146104b7578063d547741f146104de57600080fd5b8063a217fddf116100de578063a217fddf14610471578063a3a7954814610479578063ac67e1af1461048c578063ad960ce11461049457600080fd5b80638d7601c0146103df57806391d1485414610406578063927ede2d1461044a57600080fd5b8063392e53cd1161017c5780635ed2c2201161014b5780635ed2c2201461036d578063662a633a1461039d5780636f18bd22146103b05780638aa10435146103d757600080fd5b8063392e53cd146102e55780633d9131a41461030f5780635777bf50146103365780635e4c57a41461036557600080fd5b80632f2ff15d116101b85780632f2ff15d1461028457806332b7006d1461029957806336568abe146102ac57806336c717c1146102bf57600080fd5b806301ffc9a7146101df57806320f748c414610207578063248a9ca314610253575b600080fd5b6101f26101ed366004612b74565b61056e565b60405190151581526020015b60405180910390f35b61022e7f00000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f81565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101fe565b610276610261366004612bb6565b60009081526020819052604090206001015490565b6040519081526020016101fe565b610297610292366004612bf1565b610607565b005b6102976102a7366004612c83565b610631565b6102976102ba366004612bf1565b610853565b7f000000000000000000000000755610f5be536ad7afbaa7c10f3e938ea3aa187761022e565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5460ff166101f2565b61022e7f000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe8481565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba54610100900460ff166101f2565b610297610906565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5462010000900460ff166101f2565b6102976103ab366004612cf4565b610a0a565b6102767f63f736f21cb2943826cd50b191eb054ebbea670e4e962d0527611f830cd399d681565b610276610e38565b6102767f94a954c0bc99227eddbc0715a62a7e1056ed8784cd719c2303b685683908857c81565b6101f2610414366004612bf1565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61022e7f000000000000000000000000420000000000000000000000000000000000000781565b610276600081565b610297610487366004612d8c565b610e67565b61029761109b565b61029761119a565b61029761129a565b6102976104b2366004612e0f565b6112ff565b61022e7f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca081565b6102976104ec366004612bf1565b611313565b6102767f9ab8816a3dc0b3849ec1ac00483f6ec815b07eee2fd766a353311c823ad59d0d81565b610297611338565b61022e7f000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a9200181565b6102767f4b43b36766bde12c5e9cbbc37d15f8d1f769f08f54720ab370faeb4ce893753a81565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061060157507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60008281526020819052604090206001015461062281611442565b61062c838361144c565b505050565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5462010000900460ff16610692576040517f77d195b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b847f000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a9200173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561073b57507f00000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b1561078f576040517f39394bc700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024015b60405180910390fd5b333b156107c8576040517fdf6691fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6107d78633338888888861153c565b3373ffffffffffffffffffffffffffffffffffffffff87166107f888611724565b73ffffffffffffffffffffffffffffffffffffffff167f73d170910aba9e6d50b102db522b1dbcd796216f5128b445aa2135272886497e338988886040516108439493929190612e75565b60405180910390a4505050505050565b73ffffffffffffffffffffffffffffffffffffffff811633146108f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610786565b6109028282611866565b5050565b7f4b43b36766bde12c5e9cbbc37d15f8d1f769f08f54720ab370faeb4ce893753a61093081611442565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba54610100900460ff1615610991576040517f4f2c8be200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1661010017905560405133907fc36a428b063177e3f28b3b5d340c08f77827847b2ee30114ccf0c40e519c420a90600090a250565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba54610100900460ff16610a6a576040517fa185a6b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000755610f5be536ad7afbaa7c10f3e938ea3aa18773373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000042000000000000000000000000000000000000071614610afa576040517ff95a18f800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000420000000000000000000000000000000000000773ffffffffffffffffffffffffffffffffffffffff16636e296e456040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba09190612eb5565b73ffffffffffffffffffffffffffffffffffffffff1614610bed576040517fe36e2eb200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8787610bf9828261191d565b610c4f576040517f759b5b3000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808416600483015282166024820152604401610786565b6000610c5b8686611a84565b905060007f00000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f73ffffffffffffffffffffffffffffffffffffffff166345a8306f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cee9190612eb5565b825160208401516040517f405abb410000000000000000000000000000000000000000000000000000000081526fffffffffffffffffffffffffffffffff909216600483015264ffffffffff16602482015290915073ffffffffffffffffffffffffffffffffffffffff82169063405abb4190604401600060405180830381600087803b158015610d7e57600080fd5b505af1158015610d92573d6000803e3d6000fd5b505050506000610da38c8b8b611ba3565b90508a73ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff168e73ffffffffffffffffffffffffffffffffffffffff167fb0444523268717a02698be47d0803aa7468c00acbed2f8bd93a0459cde61dd898d858860400151604051610e2193929190612f48565b60405180910390a450505050505050505050505050565b6000610e627f4dd0f6662ba1d6b081f08b350f5e9a6a7b15cf586926ba66f753594928fa64a65490565b905090565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5462010000900460ff16610ec8576040517f77d195b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff8116610f16576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b867f000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a9200173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015610fbf57507f00000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b1561100e576040517f39394bc700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610786565b61101d8833898989898961153c565b3373ffffffffffffffffffffffffffffffffffffffff891661103e8a611724565b73ffffffffffffffffffffffffffffffffffffffff167f73d170910aba9e6d50b102db522b1dbcd796216f5128b445aa2135272886497e8a8a89896040516110899493929190612e75565b60405180910390a45050505050505050565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba54610100900460ff166110fb576040517fa185a6b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f63f736f21cb2943826cd50b191eb054ebbea670e4e962d0527611f830cd399d661112581611442565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905560405133907f9ca4d309bbfd23c65db3dc38c1712862f5812c7139937e2655de86e803f73bb990600090a250565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5462010000900460ff166111fb576040517f77d195b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f94a954c0bc99227eddbc0715a62a7e1056ed8784cd719c2303b685683908857c61122581611442565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff16905560405133907f644eeba8ede48fefc32ada09fb240c5f6c0f06507ab1d296d5af41f1521d9fcb90600090a250565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5460ff166112f5576040517f1ac3cb3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6112fd611ddf565b565b611307611ddf565b61131081611e6a565b50565b60008281526020819052604090206001015461132e81611442565b61062c8383611866565b7f9ab8816a3dc0b3849ec1ac00483f6ec815b07eee2fd766a353311c823ad59d0d61136281611442565b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba5462010000900460ff16156113c4576040517ff74ad25400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff166201000017905560405133907fb2ed3603bd9051f0182ebfb75f12a21059b4d31b578a2a05c8d0245e9e2d320490600090a250565b9055565b6113108133611f8d565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109025760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556114de3390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b7f000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe8473ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614806115e157507f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b15611618576040517f78b53a0700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061162588888761205d565b905060007fa9f9e675000000000000000000000000000000000000000000000000000000006116538a611724565b8a8a8a86898960405160240161166f9796959493929190612f7d565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290506117197f000000000000000000000000755610f5be536ad7afbaa7c10f3e938ea3aa18778683612396565b505050505050505050565b60007f000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a9200173ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156117a157507f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0919050565b7f00000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561181c57507f000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe84919050565b6040517f39394bc700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152602401610786565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109025760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000807f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480156119c657507f000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a9200173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b905060007f000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe8473ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148015611a7057507f00000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b90508180611a7b5750805b95945050505050565b60408051606080820183526000808352602083015291810191909152611aac60056010613009565b60ff16821015611ae8576040517f35363af400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516060810190915260009080611b04601084878961302e565b611b0d91613058565b60801c815260200185601086611b24600583613009565b60ff1692611b349392919061302e565b611b3d916130a0565b60d81c81526020018585611b5360056010613009565b60ff16908092611b659392919061302e565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050915250949350505050565b600081611bb257506000611dd8565b7f00000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611d4c576040517f8c2a993e000000000000000000000000000000000000000000000000000000008152306004820152602481018390527f000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a9200173ffffffffffffffffffffffffffffffffffffffff1690638c2a993e90604401600060405180830381600087803b158015611c9457600080fd5b505af1158015611ca8573d6000803e3d6000fd5b50506040517f2ed2493100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301526024820186905287169250632ed2493191506044016020604051808303816000875af1158015611d21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d4591906130e6565b9050611dd8565b6040517f8c2a993e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015260248201849052851690638c2a993e90604401600060405180830381600087803b158015611dbc57600080fd5b505af1158015611dd0573d6000803e3d6000fd5b505050508190505b9392505050565b611de96002612443565b6112fd73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a92001167f00000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61248b565b73ffffffffffffffffffffffffffffffffffffffff8116611eb7576040517fc6ab211700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f013e929b381f2fbbac854bd18fb8231dc73c4a2eab0d4cbb4db9436b6ff9b2ba805460ff1615611f14576040517f66a02dea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611f1f60008361144c565b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117815560405173ffffffffffffffffffffffffffffffffffffffff8316907f908408e307fc569b417f6cbec5d5a06f44a0a505ac0479b47d421a4b2fd6a1e690600090a25050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1661090257611fe38173ffffffffffffffffffffffffffffffffffffffff1660146125c6565b611fee8360206125c6565b604051602001611fff9291906130ff565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a000000000000000000000000000000000000000000000000000000000825261078691600401613180565b60008161206c57506000611dd8565b60008290507f00000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156122e5576040517f7749c54f000000000000000000000000000000000000000000000000000000008152600481018490527f00000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f73ffffffffffffffffffffffffffffffffffffffff1690637749c54f90602401602060405180830381865afa158015612150573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061217491906130e6565b90508015611d45576040517fe53d44df00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018590527f00000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f169063e53d44df906044016020604051808303816000875af1158015612211573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223591906130e6565b506040517f74f4f54700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018390527f000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a9200116906374f4f54790604401600060405180830381600087803b1580156122c657600080fd5b505af11580156122da573d6000803e3d6000fd5b505050509050611dd8565b6040517f74f4f54700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018390527f000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a9200116906374f4f54790604401600060405180830381600087803b15801561237557600080fd5b505af1158015612389573d6000803e3d6000fd5b5092979650505050505050565b6040517f3dbb202b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000042000000000000000000000000000000000000071690633dbb202b9061240c90869085908790600401613193565b600060405180830381600087803b15801561242657600080fd5b505af115801561243a573d6000803e3d6000fd5b50505050505050565b61244b610e38565b15612482576040517f61394a8400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61131081612809565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015612502573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061252691906130e6565b61253091906131d8565b6040805173ffffffffffffffffffffffffffffffffffffffff8616602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b3000000000000000000000000000000000000000000000000000000001790529091506125c0908590612868565b50505050565b606060006125d58360026131f0565b6125e09060026131d8565b67ffffffffffffffff8111156125f8576125f861322d565b6040519080825280601f01601f191660200182016040528015612622576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106126595761265961325c565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106126bc576126bc61325c565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060006126f88460026131f0565b6127039060016131d8565b90505b60018111156127a0577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106127445761274461325c565b1a60f81b82828151811061275a5761275a61325c565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c936127998161328b565b9050612706565b508315611dd8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610786565b6128327f4dd0f6662ba1d6b081f08b350f5e9a6a7b15cf586926ba66f753594928fa64a6829055565b6040518181527ffddcded6b4f4730c226821172046b48372d3cd963c159701ae1b7c3bcac541bb9060200160405180910390a150565b60006128ca826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166129749092919063ffffffff16565b80519091501561062c57808060200190518101906128e891906132c0565b61062c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610786565b6060612983848460008561298b565b949350505050565b606082471015612a1d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610786565b73ffffffffffffffffffffffffffffffffffffffff85163b612a9b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610786565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051612ac491906132e2565b60006040518083038185875af1925050503d8060008114612b01576040519150601f19603f3d011682016040523d82523d6000602084013e612b06565b606091505b5091509150612b16828286612b21565b979650505050505050565b60608315612b30575081611dd8565b825115612b405782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107869190613180565b600060208284031215612b8657600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114611dd857600080fd5b600060208284031215612bc857600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811461131057600080fd5b60008060408385031215612c0457600080fd5b823591506020830135612c1681612bcf565b809150509250929050565b803563ffffffff81168114612c3557600080fd5b919050565b60008083601f840112612c4c57600080fd5b50813567ffffffffffffffff811115612c6457600080fd5b602083019150836020828501011115612c7c57600080fd5b9250929050565b600080600080600060808688031215612c9b57600080fd5b8535612ca681612bcf565b945060208601359350612cbb60408701612c21565b9250606086013567ffffffffffffffff811115612cd757600080fd5b612ce388828901612c3a565b969995985093965092949392505050565b600080600080600080600060c0888a031215612d0f57600080fd5b8735612d1a81612bcf565b96506020880135612d2a81612bcf565b95506040880135612d3a81612bcf565b94506060880135612d4a81612bcf565b93506080880135925060a088013567ffffffffffffffff811115612d6d57600080fd5b612d798a828b01612c3a565b989b979a50959850939692959293505050565b60008060008060008060a08789031215612da557600080fd5b8635612db081612bcf565b95506020870135612dc081612bcf565b945060408701359350612dd560608801612c21565b9250608087013567ffffffffffffffff811115612df157600080fd5b612dfd89828a01612c3a565b979a9699509497509295939492505050565b600060208284031215612e2157600080fd5b8135611dd881612bcf565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff85168152836020820152606060408201526000612eab606083018486612e2c565b9695505050505050565b600060208284031215612ec757600080fd5b8151611dd881612bcf565b60005b83811015612eed578181015183820152602001612ed5565b838111156125c05750506000910152565b60008151808452612f16816020860160208601612ed2565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b73ffffffffffffffffffffffffffffffffffffffff84168152826020820152606060408201526000611a7b6060830184612efe565b600073ffffffffffffffffffffffffffffffffffffffff808a1683528089166020840152808816604084015280871660608401525084608083015260c060a0830152612fcd60c083018486612e2c565b9998505050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600060ff821660ff84168060ff0382111561302657613026612fda565b019392505050565b6000808585111561303e57600080fd5b8386111561304b57600080fd5b5050820193919092039150565b7fffffffffffffffffffffffffffffffff0000000000000000000000000000000081358181169160108510156130985780818660100360031b1b83161692505b505092915050565b7fffffffffff00000000000000000000000000000000000000000000000000000081358181169160058510156130985760059490940360031b84901b1690921692915050565b6000602082840312156130f857600080fd5b5051919050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613137816017850160208801612ed2565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613174816028840160208801612ed2565b01602801949350505050565b602081526000611dd86020830184612efe565b73ffffffffffffffffffffffffffffffffffffffff841681526060602082015260006131c26060830185612efe565b905063ffffffff83166040830152949350505050565b600082198211156131eb576131eb612fda565b500190565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561322857613228612fda565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008161329a5761329a612fda565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b6000602082840312156132d257600080fd5b81518015158114611dd857600080fd5b600082516132f4818460208701612ed2565b919091019291505056fea26469706673582212207ba9a85c702b75acdd091db135d80f68e1c7696b2c11133c99509c7d0ab5290464736f6c634300080a0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000004200000000000000000000000000000000000007000000000000000000000000755610f5be536ad7afbaa7c10f3e938ea3aa18770000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe84000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a9200100000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f
-----Decoded View---------------
Arg [0] : messenger_ (address): 0x4200000000000000000000000000000000000007
Arg [1] : l1TokenBridge_ (address): 0x755610f5Be536Ad7afBAa7c10F3E938Ea3aa1877
Arg [2] : l1TokenNonRebasable_ (address): 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0
Arg [3] : l1TokenRebasable_ (address): 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84
Arg [4] : l2TokenNonRebasable_ (address): 0xc02fE7317D4eb8753a02c35fe019786854A92001
Arg [5] : l2TokenRebasable_ (address): 0x81f2508AAC59757EF7425DDc9717AB5c2AA0A84F
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000004200000000000000000000000000000000000007
Arg [1] : 000000000000000000000000755610f5be536ad7afbaa7c10f3e938ea3aa1877
Arg [2] : 0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0
Arg [3] : 000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe84
Arg [4] : 000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a92001
Arg [5] : 00000000000000000000000081f2508aac59757ef7425ddc9717ab5c2aa0a84f
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 35 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.