Source Code
Overview
ETH Balance
0 ETH
Token Holdings
More Info
ContractCreator
Multichain Info
N/A
Latest 25 from a total of 237,719 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Send ERC20 | 6835260 | 55 days ago | IN | 0.124 ETH | 0.00008701 | ||||
Send ERC20 | 6576225 | 97 days ago | IN | 0.00001 ETH | 0.00031458 | ||||
Send ERC20 | 6228536 | 153 days ago | IN | 0.03866307 ETH | 0.00008698 | ||||
Send ERC20 | 5650397 | 238 days ago | IN | 0.001 ETH | 0.00030764 | ||||
Send ERC20 | 5625371 | 242 days ago | IN | 0.07314636 ETH | 0.00030766 | ||||
Send ERC20 | 5618102 | 243 days ago | IN | 0.1364 ETH | 0.00030745 | ||||
Send ERC20 | 5602492 | 245 days ago | IN | 0.26200347 ETH | 0.00032185 | ||||
Send ERC20 | 5600310 | 245 days ago | IN | 0.07502 ETH | 0.00031461 | ||||
Send ERC20 | 5592787 | 246 days ago | IN | 0.0001 ETH | 0.00033779 | ||||
Send ERC20 | 5486434 | 262 days ago | IN | 0.03000884 ETH | 0.000087 | ||||
Send ERC20 | 5486434 | 262 days ago | IN | 0.03000884 ETH | 0.00032179 | ||||
Send ERC20 | 5486434 | 262 days ago | IN | 0.03000884 ETH | 0.000087 | ||||
Send ERC20 | 5329683 | 285 days ago | IN | 0.23477308 ETH | 0.0000906 | ||||
Send ERC20 | 5329683 | 285 days ago | IN | 0.03866307 ETH | 0.00009056 | ||||
Send ERC20 | 5329683 | 285 days ago | IN | 0.03866307 ETH | 0.00031484 | ||||
Send ERC20 | 5305637 | 289 days ago | IN | 0.001 ETH | 0.00030741 | ||||
Send ERC20 | 5238567 | 298 days ago | IN | 0.01 ETH | 0.01384595 | ||||
Send ERC20 | 5194239 | 305 days ago | IN | 0.04678232 ETH | 0.00030741 | ||||
Send ERC20 | 5148180 | 312 days ago | IN | 0.003286 ETH | 0.00032179 | ||||
Send ERC20 | 5110731 | 318 days ago | IN | 0.24717308 ETH | 0.00030745 | ||||
Send ERC20 | 5105178 | 319 days ago | IN | 0.03866307 ETH | 0.00008701 | ||||
Send ERC20 | 4860304 | 357 days ago | IN | 0.0031 ETH | 0.00032179 | ||||
Send ERC20 | 4481667 | 415 days ago | IN | 0 ETH | 0.00031158 | ||||
Send ERC20 | 4451831 | 420 days ago | IN | 0.0031 ETH | 0.00009055 | ||||
Send ERC20 | 4451831 | 420 days ago | IN | 0.24717308 ETH | 0.00032206 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
6576225 | 97 days ago | 0.00001 ETH | ||||
5857470 | 208 days ago | Contract Creation | 0 ETH | |||
5855523 | 208 days ago | Contract Creation | 0 ETH | |||
5650397 | 238 days ago | 0.001 ETH | ||||
5625371 | 242 days ago | 0.07314636 ETH | ||||
5618102 | 243 days ago | 0.1364 ETH | ||||
5602492 | 245 days ago | 0.26200347 ETH | ||||
5600310 | 245 days ago | 0.07502 ETH | ||||
5592787 | 246 days ago | 0.0001 ETH | ||||
5486434 | 262 days ago | 0.03000884 ETH | ||||
5329683 | 285 days ago | 0.03866307 ETH | ||||
5305637 | 289 days ago | 0.001 ETH | ||||
5238567 | 298 days ago | 0.01 ETH | ||||
5194239 | 305 days ago | 0.04678232 ETH | ||||
5148180 | 312 days ago | 0.003286 ETH | ||||
5110731 | 318 days ago | 0.24717308 ETH | ||||
4860304 | 357 days ago | 0.0031 ETH | ||||
4451831 | 420 days ago | 0.24717308 ETH | ||||
4379440 | 431 days ago | 0.04252938 ETH | ||||
4235313 | 452 days ago | 0.01 ETH | ||||
4223125 | 454 days ago | 0 ETH | ||||
4139185 | 467 days ago | 0.0001 ETH | ||||
4136566 | 467 days ago | 0.03866307 ETH | ||||
4114947 | 471 days ago | 0.00437366 ETH | ||||
4104389 | 473 days ago | 0.04252938 ETH |
Loading...
Loading
Contract Name:
TokenVault
Compiler Version
v0.8.18+commit.87f61d96
Optimization Enabled:
Yes with 10000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // _____ _ _ _ _ // |_ _|_ _(_) |_____ | | __ _| |__ ___ // | |/ _` | | / / _ \ | |__/ _` | '_ (_-< // |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ pragma solidity ^0.8.18; // solhint-disable-next-line max-line-length import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import {ERC20Upgradeable} from "../thirdparty/ERC20Upgradeable.sol"; import { Create2Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/Create2Upgradeable.sol"; import {EssentialContract} from "../common/EssentialContract.sol"; import {TaikoToken} from "../L1/TaikoToken.sol"; import {BridgedERC20} from "./BridgedERC20.sol"; import {IBridge} from "./IBridge.sol"; /** * This vault holds all ERC20 tokens (but not Ether) that users have deposited. * It also manages the mapping between canonical ERC20 tokens and their bridged * tokens. * @dev Ether is held by Bridges on L1 and by the EtherVault on L2, * not TokenVaults. */ contract TokenVault is EssentialContract { using SafeERC20Upgradeable for ERC20Upgradeable; /********************* * Structs * *********************/ struct CanonicalERC20 { uint256 chainId; address addr; uint8 decimals; string symbol; string name; } struct MessageDeposit { address token; uint256 amount; } /********************* * State Variables * *********************/ // Tracks if a token on the current chain is a canonical or bridged token. mapping(address tokenAddress => bool isBridged) public isBridgedToken; // Mappings from bridged tokens to their canonical tokens. mapping(address bridgedAddress => CanonicalERC20 canonicalErc20) public bridgedToCanonical; // Mappings from canonical tokens to their bridged tokens. // Also storing chainId for tokens across other chains aside from Ethereum. mapping(uint256 chainId => mapping(address canonicalAddress => address bridgedAddress)) public canonicalToBridged; // Tracks the token and amount associated with a message hash. mapping(bytes32 msgHash => MessageDeposit messageDeposit) public messageDeposits; uint256[47] private __gap; /********************* * Events * *********************/ event BridgedERC20Deployed( uint256 indexed srcChainId, address indexed canonicalToken, address indexed bridgedToken, string canonicalTokenSymbol, string canonicalTokenName, uint8 canonicalTokenDecimal ); event EtherSent( bytes32 indexed msgHash, address indexed from, address indexed to, uint256 destChainId, uint256 amount ); event ERC20Sent( bytes32 indexed msgHash, address indexed from, address indexed to, uint256 destChainId, address token, uint256 amount ); event ERC20Released( bytes32 indexed msgHash, address indexed from, address token, uint256 amount ); event ERC20Received( bytes32 indexed msgHash, address indexed from, address indexed to, uint256 srcChainId, address token, uint256 amount ); /********************* * Custom Errors* *********************/ error TOKENVAULT_INVALID_TO(); error TOKENVAULT_INVALID_VALUE(); error TOKENVAULT_INVALID_CALL_VALUE(); error TOKENVAULT_INVALID_TOKEN(); error TOKENVAULT_INVALID_AMOUNT(); error TOKENVAULT_CANONICAL_TOKEN_NOT_FOUND(); error TOKENVAULT_INVALID_OWNER(); error TOKENVAULT_INVALID_SRC_CHAIN_ID(); error TOKENVAULT_MESSAGE_NOT_FAILED(); error TOKENVAULT_INVALID_SENDER(); /********************* * External Functions* *********************/ function init(address addressManager) external initializer { EssentialContract._init(addressManager); } /** * Receives Ether and constructs a Bridge message. Sends the Ether and * message along to the Bridge. * @param destChainId @custom:see IBridge.Message * @param to @custom:see IBridge.Message * @param gasLimit @custom:see IBridge.Message * @param processingFee @custom:see IBridge.Message * @param refundAddress @custom:see IBridge.Message * @param memo @custom:see IBridge.Message */ function sendEther( uint256 destChainId, address to, uint256 gasLimit, uint256 processingFee, address refundAddress, string memory memo ) external payable nonReentrant { if ( to == address(0) || to == resolve(destChainId, "token_vault", false) ) revert TOKENVAULT_INVALID_TO(); if (msg.value <= processingFee) revert TOKENVAULT_INVALID_VALUE(); IBridge.Message memory message; message.destChainId = destChainId; message.owner = msg.sender; message.to = to; message.gasLimit = gasLimit; message.processingFee = processingFee; message.depositValue = msg.value - processingFee; message.refundAddress = refundAddress; message.memo = memo; // prevent future PRs from changing the callValue when it must be zero if (message.callValue != 0) revert TOKENVAULT_INVALID_CALL_VALUE(); bytes32 msgHash = IBridge(resolve("bridge", false)).sendMessage{ value: msg.value }(message); emit EtherSent({ msgHash: msgHash, from: message.owner, to: message.to, destChainId: destChainId, amount: message.depositValue }); } /** * Transfers ERC20 tokens to this vault and sends a message to the * destination chain so the user can receive the same amount of tokens * by invoking the message call. * * @param destChainId @custom:see IBridge.Message * @param to @custom:see IBridge.Message * @param token The address of the token to be sent. * @param amount The amount of token to be transferred. * @param gasLimit @custom:see IBridge.Message * @param processingFee @custom:see IBridge.Message * @param refundAddress @custom:see IBridge.Message * @param memo @custom:see IBridge.Message */ function sendERC20( uint256 destChainId, address to, address token, uint256 amount, uint256 gasLimit, uint256 processingFee, address refundAddress, string memory memo ) external payable nonReentrant { if ( to == address(0) || to == resolve(destChainId, "token_vault", false) ) revert TOKENVAULT_INVALID_TO(); if (token == address(0)) revert TOKENVAULT_INVALID_TOKEN(); if (amount == 0) revert TOKENVAULT_INVALID_AMOUNT(); CanonicalERC20 memory canonicalToken; uint256 _amount; // is a bridged token, meaning, it does not live on this chain if (isBridgedToken[token]) { BridgedERC20(token).bridgeBurnFrom(msg.sender, amount); canonicalToken = bridgedToCanonical[token]; if (canonicalToken.addr == address(0)) revert TOKENVAULT_CANONICAL_TOKEN_NOT_FOUND(); _amount = amount; } else { // is a canonical token, meaning, it lives on this chain ERC20Upgradeable t = ERC20Upgradeable(token); canonicalToken = CanonicalERC20({ chainId: block.chainid, addr: token, decimals: t.decimals(), symbol: t.symbol(), name: t.name() }); uint256 _balance = t.balanceOf(address(this)); t.safeTransferFrom(msg.sender, address(this), amount); _amount = t.balanceOf(address(this)) - _balance; } IBridge.Message memory message; message.destChainId = destChainId; message.owner = msg.sender; message.to = resolve(destChainId, "token_vault", false); message.data = abi.encodeWithSelector( TokenVault.receiveERC20.selector, canonicalToken, message.owner, to, _amount ); message.gasLimit = gasLimit; message.processingFee = processingFee; message.depositValue = msg.value - processingFee; message.refundAddress = refundAddress; message.memo = memo; bytes32 msgHash = IBridge(resolve("bridge", false)).sendMessage{ value: msg.value }(message); // record the deposit for this message messageDeposits[msgHash] = MessageDeposit(token, _amount); emit ERC20Sent({ msgHash: msgHash, from: message.owner, to: to, destChainId: destChainId, token: token, amount: _amount }); } /** * Release deposited ERC20 back to the owner on the source TokenVault with * a proof that the message processing on the destination Bridge has failed. * * @param message The message that corresponds the ERC20 deposit on the * source chain. * @param proof The proof from the destination chain to show the message * has failed. */ function releaseERC20( IBridge.Message calldata message, bytes calldata proof ) external nonReentrant { if (message.owner == address(0)) revert TOKENVAULT_INVALID_OWNER(); if (message.srcChainId != block.chainid) revert TOKENVAULT_INVALID_SRC_CHAIN_ID(); IBridge bridge = IBridge(resolve("bridge", false)); bytes32 msgHash = bridge.hashMessage(message); address token = messageDeposits[msgHash].token; uint256 amount = messageDeposits[msgHash].amount; if (token == address(0)) revert TOKENVAULT_INVALID_TOKEN(); if (!bridge.isMessageFailed(msgHash, message.destChainId, proof)) revert TOKENVAULT_MESSAGE_NOT_FAILED(); messageDeposits[msgHash] = MessageDeposit(address(0), 0); if (amount > 0) { if (isBridgedToken[token]) { BridgedERC20(token).bridgeMintTo(message.owner, amount); } else { ERC20Upgradeable(token).safeTransfer(message.owner, amount); } } emit ERC20Released({ msgHash: msgHash, from: message.owner, token: token, amount: amount }); } /** * @dev This function can only be called by the bridge contract while * invoking a message call. See sendERC20, which sets the data to invoke * this function. * @param canonicalToken The canonical ERC20 token which may or may not * live on this chain. If not, a BridgedERC20 contract will be * deployed. * @param from The source address. * @param to The destination address. * @param amount The amount of tokens to be sent. 0 is a valid value. */ function receiveERC20( CanonicalERC20 calldata canonicalToken, address from, address to, uint256 amount ) external nonReentrant onlyFromNamed("bridge") { IBridge.Context memory ctx = IBridge(msg.sender).context(); if (ctx.sender != resolve(ctx.srcChainId, "token_vault", false)) revert TOKENVAULT_INVALID_SENDER(); address token; if (canonicalToken.chainId == block.chainid) { token = canonicalToken.addr; ERC20Upgradeable(token).safeTransfer(to, amount); } else { token = _getOrDeployBridgedToken(canonicalToken); BridgedERC20(token).bridgeMintTo(to, amount); } emit ERC20Received({ msgHash: ctx.msgHash, from: from, to: to, srcChainId: ctx.srcChainId, token: token, amount: amount }); } /********************* * Private Functions * *********************/ function _getOrDeployBridgedToken( CanonicalERC20 calldata canonicalToken ) private returns (address) { address token = canonicalToBridged[canonicalToken.chainId][ canonicalToken.addr ]; return token != address(0) ? token : _deployBridgedToken(canonicalToken); } /** * @dev Deploys a new BridgedERC20 contract and initializes it. This must be * called before the first time a bridged token is sent to this chain. */ function _deployBridgedToken( CanonicalERC20 calldata canonicalToken ) private returns (address bridgedToken) { bridgedToken = Create2Upgradeable.deploy( 0, // amount of Ether to send keccak256( abi.encodePacked(canonicalToken.chainId, canonicalToken.addr) ), type(BridgedERC20).creationCode ); BridgedERC20(payable(bridgedToken)).init({ _addressManager: address(_addressManager), _srcToken: canonicalToken.addr, _srcChainId: canonicalToken.chainId, _decimals: canonicalToken.decimals, _symbol: canonicalToken.symbol, _name: string( abi.encodePacked( canonicalToken.name, "(bridged", hex"F09F8C88", // 🌈 canonicalToken.chainId, ")" ) ) }); isBridgedToken[bridgedToken] = true; bridgedToCanonical[bridgedToken] = canonicalToken; canonicalToBridged[canonicalToken.chainId][ canonicalToken.addr ] = bridgedToken; emit BridgedERC20Deployed({ srcChainId: canonicalToken.chainId, canonicalToken: canonicalToken.addr, bridgedToken: bridgedToken, canonicalTokenSymbol: canonicalToken.symbol, canonicalTokenName: canonicalToken.name, canonicalTokenDecimal: canonicalToken.decimals }); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Internal function that returns the initialized version. Returns `_initialized` */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Internal function that returns the initialized version. Returns `_initializing` */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/draft-IERC20PermitUpgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "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"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, 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) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or 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 { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Create2.sol) pragma solidity ^0.8.0; /** * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer. * `CREATE2` can be used to compute in advance the address where a smart * contract will be deployed, which allows for interesting new mechanisms known * as 'counterfactual interactions'. * * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more * information. */ library Create2Upgradeable { /** * @dev Deploys a contract using `CREATE2`. The address where the contract * will be deployed can be known in advance via {computeAddress}. * * The bytecode for a contract can be obtained from Solidity with * `type(contractName).creationCode`. * * Requirements: * * - `bytecode` must not be empty. * - `salt` must have not been used for `bytecode` already. * - the factory must have a balance of at least `amount`. * - if `amount` is non-zero, `bytecode` must have a `payable` constructor. */ function deploy( uint256 amount, bytes32 salt, bytes memory bytecode ) internal returns (address addr) { require(address(this).balance >= amount, "Create2: insufficient balance"); require(bytecode.length != 0, "Create2: bytecode length is zero"); /// @solidity memory-safe-assembly assembly { addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt) } require(addr != address(0), "Create2: Failed on deploy"); } /** * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the * `bytecodeHash` or `salt` will result in a new destination address. */ function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) { return computeAddress(salt, bytecodeHash, address(this)); } /** * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}. */ function computeAddress( bytes32 salt, bytes32 bytecodeHash, address deployer ) internal pure returns (address addr) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) // Get free memory pointer // | | ↓ ptr ... ↓ ptr + 0x0B (start) ... ↓ ptr + 0x20 ... ↓ ptr + 0x40 ... | // |-------------------|---------------------------------------------------------------------------| // | bytecodeHash | CCCCCCCCCCCCC...CC | // | salt | BBBBBBBBBBBBB...BB | // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA | // | 0xFF | FF | // |-------------------|---------------------------------------------------------------------------| // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC | // | keccak(start, 85) | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ | mstore(add(ptr, 0x40), bytecodeHash) mstore(add(ptr, 0x20), salt) mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff mstore8(start, 0xff) addr := keccak256(start, 85) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCastUpgradeable { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @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] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // _____ _ _ _ _ // |_ _|_ _(_) |_____ | | __ _| |__ ___ // | |/ _` | | / / _ \ | |__/ _` | '_ (_-< // |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ pragma solidity ^0.8.18; import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; // solhint-disable-next-line max-line-length import { IERC20MetadataUpgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; import {EssentialContract} from "../common/EssentialContract.sol"; import {ERC20Upgradeable} from "../thirdparty/ERC20Upgradeable.sol"; import {BridgeErrors} from "./BridgeErrors.sol"; contract BridgedERC20 is EssentialContract, IERC20Upgradeable, IERC20MetadataUpgradeable, ERC20Upgradeable, BridgeErrors { address public srcToken; uint256 public srcChainId; uint256[48] private __gap; event BridgeMint(address indexed account, uint256 amount); event BridgeBurn(address indexed account, uint256 amount); /// @dev Initializer to be called after being deployed behind a proxy. // Intention is for a different BridgedERC20 Contract to be deployed // per unique _srcToken i.e. one for USDC, one for USDT etc. function init( address _addressManager, address _srcToken, uint256 _srcChainId, uint8 _decimals, string memory _symbol, string memory _name ) external initializer { if ( _srcToken == address(0) || _srcChainId == 0 || _srcChainId == block.chainid || bytes(_symbol).length == 0 || bytes(_name).length == 0 ) { revert B_INIT_PARAM_ERROR(); } EssentialContract._init(_addressManager); ERC20Upgradeable.__ERC20_init({ name_: _name, symbol_: _symbol, decimals_: _decimals }); srcToken = _srcToken; srcChainId = _srcChainId; } /// @dev only a TokenVault can call this function function bridgeMintTo( address account, uint256 amount ) public onlyFromNamed("token_vault") { _mint(account, amount); emit BridgeMint(account, amount); } /// @dev only a TokenVault can call this function function bridgeBurnFrom( address account, uint256 amount ) public onlyFromNamed("token_vault") { _burn(account, amount); emit BridgeBurn(account, amount); } /// @dev any address can call this // caller must have at least amount to call this function transfer( address to, uint256 amount ) public override(ERC20Upgradeable, IERC20Upgradeable) returns (bool) { if (to == address(this)) { revert B_ERC20_CANNOT_RECEIVE(); } return ERC20Upgradeable.transfer(to, amount); } /// @dev any address can call this // caller must have allowance of at least 'amount' // for 'from's tokens. function transferFrom( address from, address to, uint256 amount ) public override(ERC20Upgradeable, IERC20Upgradeable) returns (bool) { if (to == address(this)) { revert B_ERC20_CANNOT_RECEIVE(); } return ERC20Upgradeable.transferFrom(from, to, amount); } /// @dev returns the srcToken being bridged and the srcChainId // of the tokens being bridged function source() public view returns (address, uint256) { return (srcToken, srcChainId); } }
// SPDX-License-Identifier: MIT // _____ _ _ _ _ // |_ _|_ _(_) |_____ | | __ _| |__ ___ // | |/ _` | | / / _ \ | |__/ _` | '_ (_-< // |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ pragma solidity ^0.8.18; abstract contract BridgeErrors { error B_CANNOT_RECEIVE(); error B_DENIED(); error B_ERC20_CANNOT_RECEIVE(); error B_ETHER_RELEASED_ALREADY(); error B_EV_DO_NOT_BURN(); error B_EV_NOT_AUTHORIZED(); error B_EV_PARAM(); error B_FAILED_TRANSFER(); error B_FORBIDDEN(); error B_GAS_LIMIT(); error B_INCORRECT_VALUE(); error B_INIT_PARAM_ERROR(); error B_MSG_HASH_NULL(); error B_MSG_NON_RETRIABLE(); error B_MSG_NOT_FAILED(); error B_NULL_APP_ADDR(); error B_OWNER_IS_NULL(); error B_SIGNAL_NOT_RECEIVED(); error B_STATUS_MISMTACH(); error B_WRONG_CHAIN_ID(); error B_WRONG_TO_ADDRESS(); error B_ZERO_SIGNAL(); }
// SPDX-License-Identifier: MIT // _____ _ _ _ _ // |_ _|_ _(_) |_____ | | __ _| |__ ___ // | |/ _` | | / / _ \ | |__/ _` | '_ (_-< // |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ pragma solidity ^0.8.18; /** * Bridge interface. * @dev Ether is held by Bridges on L1 and by the EtherVault on L2, * not TokenVaults. */ interface IBridge { struct Message { // Message ID. uint256 id; // Message sender address (auto filled). address sender; // Source chain ID (auto filled). uint256 srcChainId; // Destination chain ID where the `to` address lives (auto filled). uint256 destChainId; // Owner address of the bridged asset. address owner; // Destination owner address. address to; // Alternate address to send any refund. If blank, defaults to owner. address refundAddress; // Deposited Ether minus the processingFee. uint256 depositValue; // callValue to invoke on the destination chain, for ERC20 transfers. uint256 callValue; // Processing fee for the relayer. Zero if owner will process themself. uint256 processingFee; // gasLimit to invoke on the destination chain, for ERC20 transfers. uint256 gasLimit; // callData to invoke on the destination chain, for ERC20 transfers. bytes data; // Optional memo. string memo; } struct Context { bytes32 msgHash; // messageHash address sender; uint256 srcChainId; } event SignalSent(address sender, bytes32 msgHash); event MessageSent(bytes32 indexed msgHash, Message message); event EtherReleased(bytes32 indexed msgHash, address to, uint256 amount); /// Sends a message to the destination chain and takes custody /// of Ether required in this contract. All extra Ether will be refunded. function sendMessage( Message memory message ) external payable returns (bytes32 msgHash); // Release Ether with a proof that the message processing on the destination // chain has been failed. function releaseEther( IBridge.Message calldata message, bytes calldata proof ) external; /// Checks if a msgHash has been stored on the bridge contract by the /// current address. function isMessageSent(bytes32 msgHash) external view returns (bool); /// Checks if a msgHash has been received on the destination chain and /// sent by the src chain. function isMessageReceived( bytes32 msgHash, uint256 srcChainId, bytes calldata proof ) external view returns (bool); /// Checks if a msgHash has been failed on the destination chain. function isMessageFailed( bytes32 msgHash, uint256 destChainId, bytes calldata proof ) external view returns (bool); /// Returns the bridge state context. function context() external view returns (Context memory context); function hashMessage( IBridge.Message calldata message ) external pure returns (bytes32); }
// SPDX-License-Identifier: MIT // _____ _ _ _ _ // |_ _|_ _(_) |_____ | | __ _| |__ ___ // | |/ _` | | / / _ \ | |__/ _` | '_ (_-< // |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ pragma solidity ^0.8.18; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {IAddressManager} from "./IAddressManager.sol"; /** * This abstract contract provides a name-to-address lookup. Under the hood, * it uses an AddressManager to manage the name-to-address mapping. * * @title AddressResolver */ abstract contract AddressResolver { IAddressManager internal _addressManager; uint256[49] private __gap; error RESOLVER_DENIED(); error RESOLVER_INVALID_ADDR(); modifier onlyFromNamed(string memory name) { if (msg.sender != resolve(name, false)) revert RESOLVER_DENIED(); _; } /** * Resolves a name to an address on the current chain. * * @dev This function will throw if the resolved address is `address(0)`. * @param name The name to resolve. * @param allowZeroAddress True to allow zero address to be returned. * @return The name's corresponding address. */ function resolve( string memory name, bool allowZeroAddress ) public view virtual returns (address payable) { return _resolve(block.chainid, name, allowZeroAddress); } /** * Resolves a name to an address on the specified chain. * * @dev This function will throw if the resolved address is `address(0)`. * @param chainId The chainId. * @param name The name to resolve. * @param allowZeroAddress True to allow zero address to be returned. * @return The name's corresponding address. */ function resolve( uint256 chainId, string memory name, bool allowZeroAddress ) public view virtual returns (address payable) { return _resolve(chainId, name, allowZeroAddress); } /** * Returns the AddressManager's address. * * @return The AddressManager's address. */ function addressManager() public view returns (address) { return address(_addressManager); } function _init(address addressManager_) internal virtual { if (addressManager_ == address(0)) revert RESOLVER_INVALID_ADDR(); _addressManager = IAddressManager(addressManager_); } function _resolve( uint256 chainId, string memory name, bool allowZeroAddress ) private view returns (address payable addr) { bytes memory key = abi.encodePacked( Strings.toString(chainId), ".", name ); addr = payable(_addressManager.getAddress(string(key))); if (!allowZeroAddress) { // We do not use custom error so this string-based // error message is more helpful for diagnosis. require( addr != address(0), string(abi.encodePacked("AR:zeroAddr:", key)) ); } } }
// SPDX-License-Identifier: MIT // _____ _ _ _ _ // |_ _|_ _(_) |_____ | | __ _| |__ ___ // | |/ _` | | / / _ \ | |__/ _` | '_ (_-< // |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ pragma solidity ^0.8.18; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; // solhint-disable-next-line max-line-length import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import {AddressResolver} from "./AddressResolver.sol"; /** * @dev This abstract contract serves as the base contract for many core * components in this package. */ abstract contract EssentialContract is ReentrancyGuardUpgradeable, OwnableUpgradeable, AddressResolver { function _init(address _addressManager) internal virtual override { ReentrancyGuardUpgradeable.__ReentrancyGuard_init(); OwnableUpgradeable.__Ownable_init(); AddressResolver._init(_addressManager); } }
// SPDX-License-Identifier: MIT // _____ _ _ _ _ // |_ _|_ _(_) |_____ | | __ _| |__ ___ // | |/ _` | | / / _ \ | |__/ _` | '_ (_-< // |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ pragma solidity ^0.8.18; /** * @notice Interface to set and get an address for a name. */ interface IAddressManager { /** * @notice Associate an address to a name. * @dev The original address associated with the name, if exists, will be * replaced. * @param name The name which an address will be associated with. * @param addr The address to be associated with the given name. */ function setAddress(string memory name, address addr) external; /** * @notice Returns the address associated with the given name. * @param name The name for which an address will be returned. * @return The address associated with the given name. If no address is * found, `address(0)` will be returned. */ function getAddress(string memory name) external view returns (address); }
// SPDX-License-Identifier: MIT // _____ _ _ _ _ // |_ _|_ _(_) |_____ | | __ _| |__ ___ // | |/ _` | | / / _ \ | |__/ _` | '_ (_-< // |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ pragma solidity ^0.8.18; import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; interface IMintableERC20 is IERC20Upgradeable { function mint(address account, uint256 amount) external; function burn(address account, uint256 amount) external; }
// SPDX-License-Identifier: MIT // _____ _ _ _ _ // |_ _|_ _(_) |_____ | | __ _| |__ ___ // | |/ _` | | / / _ \ | |__/ _` | '_ (_-< // |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ pragma solidity ^0.8.18; import { SafeCastUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol"; import {EssentialContract} from "../common/EssentialContract.sol"; import {IMintableERC20} from "../common/IMintableERC20.sol"; import {LibMath} from "../libs/LibMath.sol"; import { ERC20Upgradeable, IERC20Upgradeable } from "../thirdparty/ERC20Upgradeable.sol"; /// @dev This is Taiko's governance and fee token. contract TaikoToken is EssentialContract, ERC20Upgradeable, IMintableERC20 { using LibMath for uint256; using SafeCastUpgradeable for uint256; /********************* * State Variables * *********************/ uint256[50] private __gap; /********************* * Events and Errors * *********************/ event Mint(address account, uint256 amount); event Burn(address account, uint256 amount); error TKO_INVALID_ADDR(); /********************* * External Functions* *********************/ /// @dev Initializer to be called after being deployed behind a proxy. /// Based on our simulation in simulate/tokenomics/index.js, both /// amountMintToDAO and amountMintToDev shall be set to ~150,000,000. function init( string memory _name, string memory _symbol, address _addressManager ) external initializer { EssentialContract._init(_addressManager); ERC20Upgradeable.__ERC20_init({ name_: _name, symbol_: _symbol, decimals_: 18 }); } /********************* * Public Functions * *********************/ function transfer( address to, uint256 amount ) public override(ERC20Upgradeable, IERC20Upgradeable) returns (bool) { if (to == address(this)) revert TKO_INVALID_ADDR(); return ERC20Upgradeable.transfer(to, amount); } function transferFrom( address from, address to, uint256 amount ) public override(ERC20Upgradeable, IERC20Upgradeable) returns (bool) { if (to == address(this)) revert TKO_INVALID_ADDR(); return ERC20Upgradeable.transferFrom(from, to, amount); } /** * @dev Mints tokens to the given address's balance. This will increase * the circulating supply. * @param account The address to receive the tokens. * @param amount The amount of tokens to mint. */ function mint( address account, uint256 amount ) public onlyFromNamed("proto_broker") { if (account == address(0)) revert TKO_INVALID_ADDR(); _mint(account, amount); emit Mint(account, amount); } /** * @dev Burn tokens from the given address's balance. This will decrease * the circulating supply. * @param account The address to burn the tokens from. * @param amount The amount of tokens to burn. */ function burn( address account, uint256 amount ) public onlyFromNamed("proto_broker") { if (account == address(0)) revert TKO_INVALID_ADDR(); _burn(account, amount); emit Burn(account, amount); } }
// SPDX-License-Identifier: MIT // _____ _ _ _ _ // |_ _|_ _(_) |_____ | | __ _| |__ ___ // | |/ _` | | / / _ \ | |__/ _` | '_ (_-< // |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ pragma solidity ^0.8.18; /** * @notice This library offers additional math functions for uint256. */ library LibMath { /** * @notice Returns the smaller value between the two given values. * @param a One of the two values. * @param b The other one of the two values. * @return The smaller value. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? b : a; } /** * @notice Returns the larger value between the two given values. * @param a One of the two values. * @param b The other one of the two values. * @return The larger value. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @notice Returns the ceil value. * @param a The numerator. * @param b The denominator. * @return c The ceil value of (a/b). */ function divceil(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a / b; if (c * b < a) { c += 1; } } /** * @notice Returns the square root of a given uint256. * This method is taken from: * https://github.com/Uniswap/v2-core/blob/v1.0.1/contracts/libraries/Math.sol. * It is based on the Babylonian method: * https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method). * @param y The given number. * @return z The square root of y. */ function sqrt(uint256 y) internal pure returns (uint256 z) { if (y > 3) { z = y; uint256 x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol) // This file is copied from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol" // with the following modifications: // - decimals can be customized // - `Transfer` events are not emitted from _mint and _burn. // The MIT License (MIT) // // Copyright (c) 2016-2022 zOS Global Limited and contributors // Copyright (c) 2022-2023 Taiko Labs // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address owner => uint256 balance) private _balances; mapping(address owner => mapping(address spender => uint256 allowance)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init( string memory name_, string memory symbol_, uint8 decimals_ ) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_, decimals_); } function __ERC20_init_unchained( string memory name_, string memory symbol_, uint8 decimals_ ) internal onlyInitializing { _name = name_; _symbol = symbol_; _decimals = decimals_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf( address account ) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer( address to, uint256 amount ) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance( address owner, address spender ) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve( address spender, uint256 amount ) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance( address spender, uint256 addedValue ) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, _allowances[owner][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance( address spender, uint256 subtractedValue ) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = _allowances[owner][spender]; require( currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero" ); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require( fromBalance >= amount, "ERC20: transfer amount exceeds balance" ); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Spend `amount` form the allowance of `owner` toward `spender`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require( currentAllowance >= amount, "ERC20: insufficient allowance" ); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[44] private __gap; }
{ "optimizer": { "enabled": true, "runs": 10000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[],"name":"RESOLVER_DENIED","type":"error"},{"inputs":[],"name":"RESOLVER_INVALID_ADDR","type":"error"},{"inputs":[],"name":"TOKENVAULT_CANONICAL_TOKEN_NOT_FOUND","type":"error"},{"inputs":[],"name":"TOKENVAULT_INVALID_AMOUNT","type":"error"},{"inputs":[],"name":"TOKENVAULT_INVALID_CALL_VALUE","type":"error"},{"inputs":[],"name":"TOKENVAULT_INVALID_OWNER","type":"error"},{"inputs":[],"name":"TOKENVAULT_INVALID_SENDER","type":"error"},{"inputs":[],"name":"TOKENVAULT_INVALID_SRC_CHAIN_ID","type":"error"},{"inputs":[],"name":"TOKENVAULT_INVALID_TO","type":"error"},{"inputs":[],"name":"TOKENVAULT_INVALID_TOKEN","type":"error"},{"inputs":[],"name":"TOKENVAULT_INVALID_VALUE","type":"error"},{"inputs":[],"name":"TOKENVAULT_MESSAGE_NOT_FAILED","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"srcChainId","type":"uint256"},{"indexed":true,"internalType":"address","name":"canonicalToken","type":"address"},{"indexed":true,"internalType":"address","name":"bridgedToken","type":"address"},{"indexed":false,"internalType":"string","name":"canonicalTokenSymbol","type":"string"},{"indexed":false,"internalType":"string","name":"canonicalTokenName","type":"string"},{"indexed":false,"internalType":"uint8","name":"canonicalTokenDecimal","type":"uint8"}],"name":"BridgedERC20Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"msgHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"srcChainId","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Received","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"msgHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Released","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"msgHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"destChainId","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Sent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"msgHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"destChainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EtherSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"addressManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"bridgedAddress","type":"address"}],"name":"bridgedToCanonical","outputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"name","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"canonicalAddress","type":"address"}],"name":"canonicalToBridged","outputs":[{"internalType":"address","name":"bridgedAddress","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addressManager","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"isBridgedToken","outputs":[{"internalType":"bool","name":"isBridged","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"msgHash","type":"bytes32"}],"name":"messageDeposits","outputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"name","type":"string"}],"internalType":"struct TokenVault.CanonicalERC20","name":"canonicalToken","type":"tuple"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"receiveERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"uint256","name":"destChainId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"refundAddress","type":"address"},{"internalType":"uint256","name":"depositValue","type":"uint256"},{"internalType":"uint256","name":"callValue","type":"uint256"},{"internalType":"uint256","name":"processingFee","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"string","name":"memo","type":"string"}],"internalType":"struct IBridge.Message","name":"message","type":"tuple"},{"internalType":"bytes","name":"proof","type":"bytes"}],"name":"releaseERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"bool","name":"allowZeroAddress","type":"bool"}],"name":"resolve","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"string","name":"name","type":"string"},{"internalType":"bool","name":"allowZeroAddress","type":"bool"}],"name":"resolve","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"destChainId","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"processingFee","type":"uint256"},{"internalType":"address","name":"refundAddress","type":"address"},{"internalType":"string","name":"memo","type":"string"}],"name":"sendERC20","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"destChainId","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"processingFee","type":"uint256"},{"internalType":"address","name":"refundAddress","type":"address"},{"internalType":"string","name":"memo","type":"string"}],"name":"sendEther","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506158fd806100206000396000f3fe6080604052600436106100e85760003560e01c8063715018a61161008a5780639aa8605c116100595780639aa8605c146102b0578063c287e578146102e1578063ee1490b214610321578063f2fde38b1461033457600080fd5b8063715018a6146101fe578063780b64f0146102135780638da5cb5b146102725780639754149b1461029057600080fd5b80631be2bfa7116100c65780631be2bfa71461016c57806339da33ba1461018c5780633ab76e9f1461019f57806367090ccf146101bd57600080fd5b80630c6fab82146100ed5780630ca4dffd1461010f57806319ab453c1461014c575b600080fd5b3480156100f957600080fd5b5061010d6101083660046128f5565b610354565b005b34801561011b57600080fd5b5061012f61012a366004612a50565b610609565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561015857600080fd5b5061010d610167366004612aa2565b61061f565b34801561017857600080fd5b5061012f610187366004612abf565b61079e565b61010d61019a366004612b1a565b6107b5565b3480156101ab57600080fd5b506097546001600160a01b031661012f565b3480156101c957600080fd5b5061012f6101d8366004612b98565b60cb6020908152600092835260408084209091529082529020546001600160a01b031681565b34801561020a57600080fd5b5061010d610adb565b34801561021f57600080fd5b5061025361022e366004612bbd565b60cc60205260009081526040902080546001909101546001600160a01b039091169082565b604080516001600160a01b039093168352602083019190915201610143565b34801561027e57600080fd5b506065546001600160a01b031661012f565b34801561029c57600080fd5b5061010d6102ab366004612bd6565b610aef565b3480156102bc57600080fd5b506102d06102cb366004612aa2565b610f16565b604051610143959493929190612cc6565b3480156102ed57600080fd5b506103116102fc366004612aa2565b60c96020526000908152604090205460ff1681565b6040519015158152602001610143565b61010d61032f366004612d15565b611078565b34801561034057600080fd5b5061010d61034f366004612aa2565b611a29565b61035c611ab9565b6040518060400160405280600681526020017f627269646765000000000000000000000000000000000000000000000000000081525061039d816000610609565b6001600160a01b0316336001600160a01b0316146103e7576040517f1b0b999e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000336001600160a01b031663d0496d6a6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610427573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044b9190612db1565b905061049281604001516040518060400160405280600b81526020017f746f6b656e5f7661756c74000000000000000000000000000000000000000000815250600061079e565b6001600160a01b031681602001516001600160a01b0316146104e0576040517f80962e1c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600046873503610515576104fa6040880160208901612aa2565b90506105106001600160a01b0382168686611b12565b61059e565b61051e87611bbb565b6040517f42e91bb30000000000000000000000000000000000000000000000000000000081526001600160a01b03878116600483015260248201879052919250908216906342e91bb390604401600060405180830381600087803b15801561058557600080fd5b505af1158015610599573d6000803e3d6000fd5b505050505b815160408084015181519081526001600160a01b0384811660208301529181018790528188169291891691907fe5da926519fc972010fe65b35c1e3339e6dc72b35ffaec203999c2a2a2593eac9060600160405180910390a450505061060360018055565b50505050565b6000610616468484611c1a565b90505b92915050565b600054610100900460ff161580801561063f5750600054600160ff909116105b806106595750303b158015610659575060005460ff166001145b6106d05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561072e57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b61073782611d2d565b801561079a57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b60006107ab848484611c1a565b90505b9392505050565b6107bd611ab9565b6001600160a01b0385161580610824575061080f866040518060400160405280600b81526020017f746f6b656e5f7661756c74000000000000000000000000000000000000000000815250600061079e565b6001600160a01b0316856001600160a01b0316145b1561085b576040517f4694641b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b823411610894576040517fae3718b400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610923604051806101a001604052806000815260200160006001600160a01b03168152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160608152602001606081525090565b606081018790523360808201526001600160a01b03861660a0820152610140810185905261012081018490526109598434612e13565b60e08201526001600160a01b03831660c08201526101808101829052610100810151156109b2576040517f3dd99f7e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006109f46040518060400160405280600681526020017f62726964676500000000000000000000000000000000000000000000000000008152506000610609565b6001600160a01b03166396e1785234846040518363ffffffff1660e01b8152600401610a209190612e4d565b60206040518083038185885af1158015610a3e573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610a639190612f47565b90508160a001516001600160a01b031682608001516001600160a01b0316827fe2f39179c279514a7b46983846e33f95a561128e0660602a211cc1e61cddb9bd8b8660e00151604051610ac0929190918252602082015260400190565b60405180910390a45050610ad360018055565b505050505050565b610ae3611d46565b610aed6000611da0565b565b610af7611ab9565b6000610b0960a0850160808601612aa2565b6001600160a01b031603610b49576040517f72b41cdf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b46836040013514610b86576040517f48bc100500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610bc86040518060400160405280600681526020017f62726964676500000000000000000000000000000000000000000000000000008152506000610609565b90506000816001600160a01b0316635817b0c3866040518263ffffffff1660e01b8152600401610bf89190612ff6565b602060405180830381865afa158015610c15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c399190612f47565b600081815260cc6020526040902080546001909101549192506001600160a01b03169081610c93576040517f7c6addb700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fce70f39b0000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063ce70f39b90610ce290869060608c0135908b908b90600401613114565b602060405180830381865afa158015610cff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d239190613134565b610d59576040517f45d24f2800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805180820182526000808252602080830182815287835260cc909152929020905181547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0390911617815590516001909101558015610e9d576001600160a01b038216600090815260c9602052604090205460ff1615610e79576001600160a01b0382166342e91bb3610dfc60a08a0160808b01612aa2565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b158015610e5c57600080fd5b505af1158015610e70573d6000803e3d6000fd5b50505050610e9d565b610e9d610e8c60a0890160808a01612aa2565b6001600160a01b0384169083611b12565b610ead60a0880160808901612aa2565b6001600160a01b0316837fc5d9f7cd7998e24ecf12ad69eca9339764e2cb13788d5d9616f502601b219af68484604051610efc9291906001600160a01b03929092168252602082015260400190565b60405180910390a350505050610f1160018055565b505050565b60ca6020526000908152604090208054600182015460028301805492936001600160a01b038316937401000000000000000000000000000000000000000090930460ff1692909190610f6790613151565b80601f0160208091040260200160405190810160405280929190818152602001828054610f9390613151565b8015610fe05780601f10610fb557610100808354040283529160200191610fe0565b820191906000526020600020905b815481529060010190602001808311610fc357829003601f168201915b505050505090806003018054610ff590613151565b80601f016020809104026020016040519081016040528092919081815260200182805461102190613151565b801561106e5780601f106110435761010080835404028352916020019161106e565b820191906000526020600020905b81548152906001019060200180831161105157829003601f168201915b5050505050905085565b611080611ab9565b6001600160a01b03871615806110e757506110d2886040518060400160405280600b81526020017f746f6b656e5f7661756c74000000000000000000000000000000000000000000815250600061079e565b6001600160a01b0316876001600160a01b0316145b1561111e576040517f4694641b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03861661115e576040517f7c6addb700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84600003611198576040517f015f093200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160a08101825260008082526020820181905291810191909152606080820181905260808201526001600160a01b038716600090815260c9602052604081205460ff1615611432576040517f77be18a8000000000000000000000000000000000000000000000000000000008152336004820152602481018890526001600160a01b038916906377be18a890604401600060405180830381600087803b15801561124457600080fd5b505af1158015611258573d6000803e3d6000fd5b505050506001600160a01b03888116600090815260ca6020908152604091829020825160a081018452815481526001820154948516928101929092527401000000000000000000000000000000000000000090930460ff16918101919091526002820180549192916060840191906112cf90613151565b80601f01602080910402602001604051908101604052809291908181526020018280546112fb90613151565b80156113485780601f1061131d57610100808354040283529160200191611348565b820191906000526020600020905b81548152906001019060200180831161132b57829003601f168201915b5050505050815260200160038201805461136190613151565b80601f016020809104026020016040519081016040528092919081815260200182805461138d90613151565b80156113da5780601f106113af576101008083540402835291602001916113da565b820191906000526020600020905b8154815290600101906020018083116113bd57829003601f168201915b5050509190925250505060208101519092506001600160a01b031661142b576040517ff91680d400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50856116c4565b60008890506040518060a001604052804681526020018a6001600160a01b03168152602001826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611495573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b991906131b3565b60ff168152602001826001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156114ff573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261152791908101906131d0565b8152602001826001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa15801561156a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261159291908101906131d0565b90526040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529093506000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156115f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061161b9190612f47565b90506116326001600160a01b03831633308c611e0a565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015281906001600160a01b038416906370a0823190602401602060405180830381865afa158015611691573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b59190612f47565b6116bf9190612e13565b925050505b611753604051806101a001604052806000815260200160006001600160a01b03168152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160608152602001606081525090565b606081018b905233608082015260408051808201909152600b81527f746f6b656e5f7661756c7400000000000000000000000000000000000000000060208201526117a1908c90600061079e565b6001600160a01b031660a082015260808101516040517f0c6fab8200000000000000000000000000000000000000000000000000000000916117ec918691908e908790602401613247565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526101608201526101408101879052610120810186905261186b8634612e13565b60e08201526001600160a01b03851660c0820152610180810184905260408051808201909152600681527f627269646765000000000000000000000000000000000000000000000000000060208201526000906118c89082610609565b6001600160a01b03166396e1785234846040518363ffffffff1660e01b81526004016118f49190612e4d565b60206040518083038185885af1158015611912573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906119379190612f47565b905060405180604001604052808b6001600160a01b031681526020018481525060cc600083815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550602082015181600101559050508a6001600160a01b031682608001516001600160a01b0316827f325cab7553038374e17f39bb45e2a2c90f66c6a52798cb5f95c20d94c11c95e28f8e88604051611a0a939291909283526001600160a01b03919091166020830152604082015260600190565b60405180910390a450505050611a1f60018055565b5050505050505050565b611a31611d46565b6001600160a01b038116611aad5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016106c7565b611ab681611da0565b50565b600260015403611b0b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106c7565b6002600155565b6040516001600160a01b038316602482015260448101829052610f119084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611e5b565b8035600090815260cb60209081526040808320839290918391611be2918701908701612aa2565b6001600160a01b0390811682526020820192909252604001600020541690508061061957611c0f83611f40565b6107ae565b60018055565b600080611c26856121f7565b84604051602001611c389291906132fe565b60408051601f19818403018152908290526097547fbf40fac10000000000000000000000000000000000000000000000000000000083529092506001600160a01b03169063bf40fac190611c90908490600401613356565b602060405180830381865afa158015611cad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd19190613369565b915082611d25576040516001600160a01b038316151590611cf6908390602001613386565b60405160208183030381529060405290611d235760405162461bcd60e51b81526004016106c79190613356565b505b509392505050565b611d356122b5565b611d3d61233a565b611ab6816123bf565b6065546001600160a01b03163314610aed5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106c7565b606580546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6040516001600160a01b03808516602483015283166044820152606481018290526106039085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401611b57565b6000611eb0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166124399092919063ffffffff16565b805190915015610f115780806020019051810190611ece9190613134565b610f115760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016106c7565b6000611fd5818335611f586040860160208701612aa2565b604051602001611f9792919091825260601b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602082015260340190565b6040516020818303038152906040528051906020012060405180602001611fbd906128c3565b601f1982820381018352601f90910116604052612448565b6097549091506001600160a01b0380831691636c0db62b9116611ffe6040860160208701612aa2565b853561201060608801604089016133cb565b61201d60608901896133e8565b61202a60808b018b6133e8565b60405161203e9291908d359060200161344d565b6040516020818303038152906040526040518863ffffffff1660e01b815260040161206f97969594939291906134d0565b600060405180830381600087803b15801561208957600080fd5b505af115801561209d573d6000803e3d6000fd5b5050506001600160a01b038216600090815260c96020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905560ca90915290208391506120f8828261366f565b50508135600090815260cb6020908152604080832084939092909161212291908701908701612aa2565b6001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550806001600160a01b03168260200160208101906121839190612aa2565b6001600160a01b031683357f9e465b29e576a3e01584e31d607353f21b80c055e813af907c0a495f6cf4f7bc6121bc60608701876133e8565b6121c960808901896133e8565b6121d960608b0160408c016133cb565b6040516121ea95949392919061371d565b60405180910390a4919050565b606060006122048361254c565b600101905060008167ffffffffffffffff81111561222457612224612964565b6040519080825280601f01601f19166020018201604052801561224e576020820181803683370190505b5090508181016020015b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461225857509392505050565b600054610100900460ff166123325760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016106c7565b610aed61262e565b600054610100900460ff166123b75760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016106c7565b610aed6126ab565b6001600160a01b0381166123ff576040517f9a109b0a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b609780547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b60606107ab8484600085612731565b60008347101561249a5760405162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e636500000060448201526064016106c7565b81516000036124eb5760405162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f60448201526064016106c7565b8282516020840186f590506001600160a01b0381166107ae5760405162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f790000000000000060448201526064016106c7565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310612595577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef810000000083106125c1576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106125df57662386f26fc10000830492506010015b6305f5e10083106125f7576305f5e100830492506008015b612710831061260b57612710830492506004015b6064831061261d576064830492506002015b600a83106106195760010192915050565b600054610100900460ff16611c145760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016106c7565b600054610100900460ff166127285760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016106c7565b610aed33611da0565b6060824710156127a95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016106c7565b600080866001600160a01b031685876040516127c5919061375a565b60006040518083038185875af1925050503d8060008114612802576040519150601f19603f3d011682016040523d82523d6000602084013e612807565b606091505b509150915061281887838387612825565b925050505b949350505050565b6060831561289457825160000361288d576001600160a01b0385163b61288d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106c7565b508161281d565b61281d83838151156128a95781518083602001fd5b8060405162461bcd60e51b81526004016106c79190613356565b6121518061377783390190565b6001600160a01b0381168114611ab657600080fd5b80356128f0816128d0565b919050565b6000806000806080858703121561290b57600080fd5b843567ffffffffffffffff81111561292257600080fd5b850160a0818803121561293457600080fd5b93506020850135612944816128d0565b92506040850135612954816128d0565b9396929550929360600135925050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156129bc576129bc612964565b604052919050565b600067ffffffffffffffff8211156129de576129de612964565b50601f01601f191660200190565b600082601f8301126129fd57600080fd5b8135612a10612a0b826129c4565b612993565b818152846020838601011115612a2557600080fd5b816020850160208301376000918101602001919091529392505050565b8015158114611ab657600080fd5b60008060408385031215612a6357600080fd5b823567ffffffffffffffff811115612a7a57600080fd5b612a86858286016129ec565b9250506020830135612a9781612a42565b809150509250929050565b600060208284031215612ab457600080fd5b81356107ae816128d0565b600080600060608486031215612ad457600080fd5b83359250602084013567ffffffffffffffff811115612af257600080fd5b612afe868287016129ec565b9250506040840135612b0f81612a42565b809150509250925092565b60008060008060008060c08789031215612b3357600080fd5b863595506020870135612b45816128d0565b945060408701359350606087013592506080870135612b63816128d0565b915060a087013567ffffffffffffffff811115612b7f57600080fd5b612b8b89828a016129ec565b9150509295509295509295565b60008060408385031215612bab57600080fd5b823591506020830135612a97816128d0565b600060208284031215612bcf57600080fd5b5035919050565b600080600060408486031215612beb57600080fd5b833567ffffffffffffffff80821115612c0357600080fd5b908501906101a08288031215612c1857600080fd5b90935060208501359080821115612c2e57600080fd5b818601915086601f830112612c4257600080fd5b813581811115612c5157600080fd5b876020828501011115612c6357600080fd5b6020830194508093505050509250925092565b60005b83811015612c91578181015183820152602001612c79565b50506000910152565b60008151808452612cb2816020860160208601612c76565b601f01601f19169290920160200192915050565b8581526001600160a01b038516602082015260ff8416604082015260a060608201526000612cf760a0830185612c9a565b8281036080840152612d098185612c9a565b98975050505050505050565b600080600080600080600080610100898b031215612d3257600080fd5b883597506020890135612d44816128d0565b96506040890135612d54816128d0565b9550606089013594506080890135935060a0890135925060c0890135612d79816128d0565b915060e089013567ffffffffffffffff811115612d9557600080fd5b612da18b828c016129ec565b9150509295985092959890939650565b600060608284031215612dc357600080fd5b6040516060810181811067ffffffffffffffff82111715612de657612de6612964565b604052825181526020830151612dfb816128d0565b60208201526040928301519281019290925250919050565b81810381811115610619577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b602081528151602082015260006020830151612e7460408401826001600160a01b03169052565b5060408301516060830152606083015160808301526080830151612ea360a08401826001600160a01b03169052565b5060a08301516001600160a01b03811660c08401525060c08301516001600160a01b03811660e08401525060e0830151610100838101919091528301516101208084019190915283015161014080840191909152830151610160808401919091528301516101a0610180808501829052612f216101c0860184612c9a565b90860151858203601f190183870152909250612f3d8382612c9a565b9695505050505050565b600060208284031215612f5957600080fd5b5051919050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112612f9557600080fd5b830160208101925035905067ffffffffffffffff811115612fb557600080fd5b803603821315612fc457600080fd5b9250929050565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b6020815281356020820152600061300f602084016128e5565b6001600160a01b038116604084015250604083013560608301526060830135608083015261303f608084016128e5565b6001600160a01b03811660a08401525061305b60a084016128e5565b6001600160a01b03811660c08401525061307760c084016128e5565b6001600160a01b03811660e08401525061010060e0840135818401526101208185013581850152610140915080850135828501525061016081850135818501526130c381860186612f60565b925090506101a061018081818701526130e16101c087018585612fcb565b93506130ef81880188612f60565b93509050601f198685030182870152613109848483612fcb565b979650505050505050565b848152836020820152606060408201526000612f3d606083018486612fcb565b60006020828403121561314657600080fd5b81516107ae81612a42565b600181811c9082168061316557607f821691505b60208210810361319e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60ff81168114611ab657600080fd5b6000602082840312156131c557600080fd5b81516107ae816131a4565b6000602082840312156131e257600080fd5b815167ffffffffffffffff8111156131f957600080fd5b8201601f8101841361320a57600080fd5b8051613218612a0b826129c4565b81815285602083850101111561322d57600080fd5b61323e826020830160208601612c76565b95945050505050565b6080815284516080820152600060208601516001600160a01b0380821660a085015260ff60408901511660c08501526060880151915060a060e0850152613292610120850183612c9a565b915060808801517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80858403016101008601526132ce8382612c9a565b9188166020860152506001600160a01b038616604085015291506132ef9050565b82606083015295945050505050565b60008351613310818460208801612c76565b7f2e00000000000000000000000000000000000000000000000000000000000000908301908152835161334a816001840160208801612c76565b01600101949350505050565b6020815260006106166020830184612c9a565b60006020828403121561337b57600080fd5b81516107ae816128d0565b7f41523a7a65726f416464723a00000000000000000000000000000000000000008152600082516133be81600c850160208701612c76565b91909101600c0192915050565b6000602082840312156133dd57600080fd5b81356107ae816131a4565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261341d57600080fd5b83018035915067ffffffffffffffff82111561343857600080fd5b602001915036819003821315612fc457600080fd5b828482377f286272696467656400000000000000000000000000000000000000000000000092019182527ff09f8c88000000000000000000000000000000000000000000000000000000006008830152600c8201527f2900000000000000000000000000000000000000000000000000000000000000602c820152602d01919050565b60006001600160a01b03808a16835280891660208401525086604083015260ff8616606083015260c0608083015261350c60c083018587612fcb565b82810360a084015261351e8185612c9a565b9a9950505050505050505050565b601f821115610f1157600081815260208120601f850160051c810160208610156135535750805b601f850160051c820191505b81811015610ad35782815560010161355f565b67ffffffffffffffff83111561358a5761358a612964565b61359e836135988354613151565b8361352c565b6000601f8411600181146135f057600085156135ba5750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355613668565b600083815260209020601f19861690835b828110156136215786850135825560209485019460019092019101613601565b508682101561365c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b81358155600181016020830135613685816128d0565b81546040850135613695816131a4565b74ff00000000000000000000000000000000000000008160a01b166001600160a01b0384167fffffffffffffffffffffff000000000000000000000000000000000000000000841617178455505050506136f260608301836133e8565b613700818360028601613572565b505061370f60808301836133e8565b610603818360038601613572565b606081526000613731606083018789612fcb565b8281036020840152613744818688612fcb565b91505060ff831660408301529695505050505050565b6000825161376c818460208701612c76565b919091019291505056fe608060405234801561001057600080fd5b50612131806100206000396000f3fe608060405234801561001057600080fd5b506004361061018d5760003560e01c806367e828bf116100e35780638da5cb5b1161008c578063a9059cbb11610066578063a9059cbb146103b4578063dd62ed3e146103c7578063f2fde38b1461040d57600080fd5b80638da5cb5b1461037b57806395d89b4114610399578063a457c2d7146103a157600080fd5b8063715018a6116100bd578063715018a61461034057806377be18a8146103485780637cf8ed0d1461035b57600080fd5b806367e828bf146102a75780636c0db62b146102f757806370a082311461030a57600080fd5b806323b872dd116101455780633ab76e9f1161011f5780633ab76e9f1461026b57806342e91bb31461028957806349d126051461029e57600080fd5b806323b872dd14610230578063313ce56714610243578063395093511461025857600080fd5b80630ca4dffd116101765780630ca4dffd146101d357806318160ddd1461020b5780631be2bfa71461021d57600080fd5b806306fdde0314610192578063095ea7b3146101b0575b600080fd5b61019a610420565b6040516101a79190611abd565b60405180910390f35b6101c36101be366004611b30565b6104b2565b60405190151581526020016101a7565b6101e66101e1366004611c4b565b6104cc565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101a7565b60cb545b6040519081526020016101a7565b6101e661022b366004611c99565b6104e0565b6101c361023e366004611cf0565b6104f5565b60ce5460405160ff90911681526020016101a7565b6101c3610266366004611b30565b610551565b60975473ffffffffffffffffffffffffffffffffffffffff166101e6565b61029c610297366004611b30565b61059d565b005b61020f60fc5481565b6102cb60fb5460fc5473ffffffffffffffffffffffffffffffffffffffff90911691565b6040805173ffffffffffffffffffffffffffffffffffffffff90931683526020830191909152016101a7565b61029c610305366004611d31565b6106a1565b61020f610318366004611ddb565b73ffffffffffffffffffffffffffffffffffffffff16600090815260c9602052604090205490565b61029c6108eb565b61029c610356366004611b30565b6108ff565b60fb546101e69073ffffffffffffffffffffffffffffffffffffffff1681565b60655473ffffffffffffffffffffffffffffffffffffffff166101e6565b61019a6109f6565b6101c36103af366004611b30565b610a05565b6101c36103c2366004611b30565b610ac7565b61020f6103d5366004611df8565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260ca6020908152604080832093909416825291909152205490565b61029c61041b366004611ddb565b610b22565b606060cc805461042f90611e31565b80601f016020809104026020016040519081016040528092919081815260200182805461045b90611e31565b80156104a85780601f1061047d576101008083540402835291602001916104a8565b820191906000526020600020905b81548152906001019060200180831161048b57829003601f168201915b5050505050905090565b6000336104c0818585610bbf565b60019150505b92915050565b60006104d9468484610d3e565b9392505050565b60006104ed848484610d3e565b949350505050565b60003073ffffffffffffffffffffffffffffffffffffffff841603610546576040517f669bcddc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6104ed848484610e89565b33600081815260ca6020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104c09082908690610598908790611eb3565b610bbf565b6040518060400160405280600b81526020017f746f6b656e5f7661756c740000000000000000000000000000000000000000008152506105de8160006104cc565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610642576040517f1b0b999e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61064c8383610ea2565b8273ffffffffffffffffffffffffffffffffffffffff167f397b33b307fc137878ebfc75b295289ec0ee25a31bb5bf034f33256fe8ea2aa68360405161069491815260200190565b60405180910390a2505050565b600054610100900460ff16158080156106c15750600054600160ff909116105b806106db5750303b1580156106db575060005460ff166001145b6107525760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156107b057600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff861615806107d1575084155b806107db57504685145b806107e557508251155b806107ef57508151155b15610826576040517ff12d598000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61082f87610f60565b61083a828486610f79565b60fb80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff881617905560fc85905580156108e257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b6108f3611006565b6108fd600061106d565b565b6040518060400160405280600b81526020017f746f6b656e5f7661756c740000000000000000000000000000000000000000008152506109408160006104cc565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109a4576040517f1b0b999e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109ae83836110e4565b8273ffffffffffffffffffffffffffffffffffffffff167f9b5b9a05e4726d8bb959f1440e05c6b8109443f2083bc4e386237d76545265538360405161069491815260200190565b606060cd805461042f90611e31565b33600081815260ca6020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610aaf5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610749565b610abc8286868403610bbf565b506001949350505050565b60003073ffffffffffffffffffffffffffffffffffffffff841603610b18576040517f669bcddc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6104d98383611255565b610b2a611006565b73ffffffffffffffffffffffffffffffffffffffff8116610bb35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610749565b610bbc8161106d565b50565b73ffffffffffffffffffffffffffffffffffffffff8316610c475760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff8216610cd05760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff838116600081815260ca602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b600080610d4a85611263565b84604051602001610d5c929190611ec6565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290526097547fbf40fac100000000000000000000000000000000000000000000000000000000835290925073ffffffffffffffffffffffffffffffffffffffff169063bf40fac190610ddf908490600401611abd565b602060405180830381865afa158015610dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e209190611f1e565b915082610e815760405173ffffffffffffffffffffffffffffffffffffffff8316151590610e52908390602001611f3b565b60405160208183030381529060405290610e7f5760405162461bcd60e51b81526004016107499190611abd565b505b509392505050565b600033610e97858285611321565b610abc8585856113de565b73ffffffffffffffffffffffffffffffffffffffff8216610f055760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610749565b8060cb6000828254610f179190611eb3565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600090815260c9602052604081208054839290610f51908490611eb3565b90915550610f5c9050565b5050565b610f68611643565b610f706116c8565b610bbc8161174d565b600054610100900460ff16610ff65760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610749565b6110018383836117e1565b505050565b60655473ffffffffffffffffffffffffffffffffffffffff1633146108fd5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610749565b6065805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b73ffffffffffffffffffffffffffffffffffffffff821661116d5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260c96020526040902054818110156112095760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260c960205260408120838303905560cb8054849290611245908490611f80565b9091555061100190508360008483565b6000336104c08185856113de565b60606000611270836118ae565b600101905060008167ffffffffffffffff81111561129057611290611b5c565b6040519080825280601f01601f1916602001820160405280156112ba576020820181803683370190505b5090508181016020015b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a85049450846112c457509392505050565b73ffffffffffffffffffffffffffffffffffffffff838116600090815260ca60209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146113d857818110156113cb5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610749565b6113d88484848403610bbf565b50505050565b73ffffffffffffffffffffffffffffffffffffffff83166114675760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff82166114f05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260c960205260409020548181101561158c5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260c960205260408082208585039055918516815290812080548492906115d0908490611eb3565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161163691815260200190565b60405180910390a36113d8565b600054610100900460ff166116c05760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610749565b6108fd611990565b600054610100900460ff166117455760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610749565b6108fd611a13565b73ffffffffffffffffffffffffffffffffffffffff811661179a576040517f9a109b0a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b609780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600054610100900460ff1661185e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610749565b60cc61186a8482611fe1565b5060cd6118778382611fe1565b5060ce80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff929092169190911790555050565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106118f7577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310611923576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061194157662386f26fc10000830492506010015b6305f5e1008310611959576305f5e100830492506008015b612710831061196d57612710830492506004015b6064831061197f576064830492506002015b600a83106104c65760010192915050565b600054610100900460ff16611a0d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610749565b60018055565b600054610100900460ff16611a905760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610749565b6108fd3361106d565b60005b83811015611ab4578181015183820152602001611a9c565b50506000910152565b6020815260008251806020840152611adc816040850160208701611a99565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b73ffffffffffffffffffffffffffffffffffffffff81168114610bbc57600080fd5b60008060408385031215611b4357600080fd5b8235611b4e81611b0e565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f830112611b9c57600080fd5b813567ffffffffffffffff80821115611bb757611bb7611b5c565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715611bfd57611bfd611b5c565b81604052838152866020858801011115611c1657600080fd5b836020870160208301376000602085830101528094505050505092915050565b80358015158114611c4657600080fd5b919050565b60008060408385031215611c5e57600080fd5b823567ffffffffffffffff811115611c7557600080fd5b611c8185828601611b8b565b925050611c9060208401611c36565b90509250929050565b600080600060608486031215611cae57600080fd5b83359250602084013567ffffffffffffffff811115611ccc57600080fd5b611cd886828701611b8b565b925050611ce760408501611c36565b90509250925092565b600080600060608486031215611d0557600080fd5b8335611d1081611b0e565b92506020840135611d2081611b0e565b929592945050506040919091013590565b60008060008060008060c08789031215611d4a57600080fd5b8635611d5581611b0e565b95506020870135611d6581611b0e565b945060408701359350606087013560ff81168114611d8257600080fd5b9250608087013567ffffffffffffffff80821115611d9f57600080fd5b611dab8a838b01611b8b565b935060a0890135915080821115611dc157600080fd5b50611dce89828a01611b8b565b9150509295509295509295565b600060208284031215611ded57600080fd5b81356104d981611b0e565b60008060408385031215611e0b57600080fd5b8235611e1681611b0e565b91506020830135611e2681611b0e565b809150509250929050565b600181811c90821680611e4557607f821691505b602082108103611e7e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104c6576104c6611e84565b60008351611ed8818460208801611a99565b7f2e000000000000000000000000000000000000000000000000000000000000009083019081528351611f12816001840160208801611a99565b01600101949350505050565b600060208284031215611f3057600080fd5b81516104d981611b0e565b7f41523a7a65726f416464723a0000000000000000000000000000000000000000815260008251611f7381600c850160208701611a99565b91909101600c0192915050565b818103818111156104c6576104c6611e84565b601f82111561100157600081815260208120601f850160051c81016020861015611fba5750805b601f850160051c820191505b81811015611fd957828155600101611fc6565b505050505050565b815167ffffffffffffffff811115611ffb57611ffb611b5c565b61200f816120098454611e31565b84611f93565b602080601f831160018114612062576000841561202c5750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555611fd9565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b828110156120af57888601518255948401946001909101908401612090565b50858210156120eb57878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b0190555056fea26469706673582212205872d80ce6aa6a8f2ed4104f2c2457554a5aa23abcc60236fec759454288070a64736f6c63430008120033a264697066735822122038ce1c52f0ceeadf0c61bf3eaffc2947fa030252800d758cef4c81ccef66d4ca64736f6c63430008120033
Deployed Bytecode
0x6080604052600436106100e85760003560e01c8063715018a61161008a5780639aa8605c116100595780639aa8605c146102b0578063c287e578146102e1578063ee1490b214610321578063f2fde38b1461033457600080fd5b8063715018a6146101fe578063780b64f0146102135780638da5cb5b146102725780639754149b1461029057600080fd5b80631be2bfa7116100c65780631be2bfa71461016c57806339da33ba1461018c5780633ab76e9f1461019f57806367090ccf146101bd57600080fd5b80630c6fab82146100ed5780630ca4dffd1461010f57806319ab453c1461014c575b600080fd5b3480156100f957600080fd5b5061010d6101083660046128f5565b610354565b005b34801561011b57600080fd5b5061012f61012a366004612a50565b610609565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561015857600080fd5b5061010d610167366004612aa2565b61061f565b34801561017857600080fd5b5061012f610187366004612abf565b61079e565b61010d61019a366004612b1a565b6107b5565b3480156101ab57600080fd5b506097546001600160a01b031661012f565b3480156101c957600080fd5b5061012f6101d8366004612b98565b60cb6020908152600092835260408084209091529082529020546001600160a01b031681565b34801561020a57600080fd5b5061010d610adb565b34801561021f57600080fd5b5061025361022e366004612bbd565b60cc60205260009081526040902080546001909101546001600160a01b039091169082565b604080516001600160a01b039093168352602083019190915201610143565b34801561027e57600080fd5b506065546001600160a01b031661012f565b34801561029c57600080fd5b5061010d6102ab366004612bd6565b610aef565b3480156102bc57600080fd5b506102d06102cb366004612aa2565b610f16565b604051610143959493929190612cc6565b3480156102ed57600080fd5b506103116102fc366004612aa2565b60c96020526000908152604090205460ff1681565b6040519015158152602001610143565b61010d61032f366004612d15565b611078565b34801561034057600080fd5b5061010d61034f366004612aa2565b611a29565b61035c611ab9565b6040518060400160405280600681526020017f627269646765000000000000000000000000000000000000000000000000000081525061039d816000610609565b6001600160a01b0316336001600160a01b0316146103e7576040517f1b0b999e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000336001600160a01b031663d0496d6a6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610427573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044b9190612db1565b905061049281604001516040518060400160405280600b81526020017f746f6b656e5f7661756c74000000000000000000000000000000000000000000815250600061079e565b6001600160a01b031681602001516001600160a01b0316146104e0576040517f80962e1c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600046873503610515576104fa6040880160208901612aa2565b90506105106001600160a01b0382168686611b12565b61059e565b61051e87611bbb565b6040517f42e91bb30000000000000000000000000000000000000000000000000000000081526001600160a01b03878116600483015260248201879052919250908216906342e91bb390604401600060405180830381600087803b15801561058557600080fd5b505af1158015610599573d6000803e3d6000fd5b505050505b815160408084015181519081526001600160a01b0384811660208301529181018790528188169291891691907fe5da926519fc972010fe65b35c1e3339e6dc72b35ffaec203999c2a2a2593eac9060600160405180910390a450505061060360018055565b50505050565b6000610616468484611c1a565b90505b92915050565b600054610100900460ff161580801561063f5750600054600160ff909116105b806106595750303b158015610659575060005460ff166001145b6106d05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561072e57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b61073782611d2d565b801561079a57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b60006107ab848484611c1a565b90505b9392505050565b6107bd611ab9565b6001600160a01b0385161580610824575061080f866040518060400160405280600b81526020017f746f6b656e5f7661756c74000000000000000000000000000000000000000000815250600061079e565b6001600160a01b0316856001600160a01b0316145b1561085b576040517f4694641b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b823411610894576040517fae3718b400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610923604051806101a001604052806000815260200160006001600160a01b03168152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160608152602001606081525090565b606081018790523360808201526001600160a01b03861660a0820152610140810185905261012081018490526109598434612e13565b60e08201526001600160a01b03831660c08201526101808101829052610100810151156109b2576040517f3dd99f7e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006109f46040518060400160405280600681526020017f62726964676500000000000000000000000000000000000000000000000000008152506000610609565b6001600160a01b03166396e1785234846040518363ffffffff1660e01b8152600401610a209190612e4d565b60206040518083038185885af1158015610a3e573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610a639190612f47565b90508160a001516001600160a01b031682608001516001600160a01b0316827fe2f39179c279514a7b46983846e33f95a561128e0660602a211cc1e61cddb9bd8b8660e00151604051610ac0929190918252602082015260400190565b60405180910390a45050610ad360018055565b505050505050565b610ae3611d46565b610aed6000611da0565b565b610af7611ab9565b6000610b0960a0850160808601612aa2565b6001600160a01b031603610b49576040517f72b41cdf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b46836040013514610b86576040517f48bc100500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610bc86040518060400160405280600681526020017f62726964676500000000000000000000000000000000000000000000000000008152506000610609565b90506000816001600160a01b0316635817b0c3866040518263ffffffff1660e01b8152600401610bf89190612ff6565b602060405180830381865afa158015610c15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c399190612f47565b600081815260cc6020526040902080546001909101549192506001600160a01b03169081610c93576040517f7c6addb700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fce70f39b0000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063ce70f39b90610ce290869060608c0135908b908b90600401613114565b602060405180830381865afa158015610cff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d239190613134565b610d59576040517f45d24f2800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805180820182526000808252602080830182815287835260cc909152929020905181547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0390911617815590516001909101558015610e9d576001600160a01b038216600090815260c9602052604090205460ff1615610e79576001600160a01b0382166342e91bb3610dfc60a08a0160808b01612aa2565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b158015610e5c57600080fd5b505af1158015610e70573d6000803e3d6000fd5b50505050610e9d565b610e9d610e8c60a0890160808a01612aa2565b6001600160a01b0384169083611b12565b610ead60a0880160808901612aa2565b6001600160a01b0316837fc5d9f7cd7998e24ecf12ad69eca9339764e2cb13788d5d9616f502601b219af68484604051610efc9291906001600160a01b03929092168252602082015260400190565b60405180910390a350505050610f1160018055565b505050565b60ca6020526000908152604090208054600182015460028301805492936001600160a01b038316937401000000000000000000000000000000000000000090930460ff1692909190610f6790613151565b80601f0160208091040260200160405190810160405280929190818152602001828054610f9390613151565b8015610fe05780601f10610fb557610100808354040283529160200191610fe0565b820191906000526020600020905b815481529060010190602001808311610fc357829003601f168201915b505050505090806003018054610ff590613151565b80601f016020809104026020016040519081016040528092919081815260200182805461102190613151565b801561106e5780601f106110435761010080835404028352916020019161106e565b820191906000526020600020905b81548152906001019060200180831161105157829003601f168201915b5050505050905085565b611080611ab9565b6001600160a01b03871615806110e757506110d2886040518060400160405280600b81526020017f746f6b656e5f7661756c74000000000000000000000000000000000000000000815250600061079e565b6001600160a01b0316876001600160a01b0316145b1561111e576040517f4694641b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03861661115e576040517f7c6addb700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84600003611198576040517f015f093200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160a08101825260008082526020820181905291810191909152606080820181905260808201526001600160a01b038716600090815260c9602052604081205460ff1615611432576040517f77be18a8000000000000000000000000000000000000000000000000000000008152336004820152602481018890526001600160a01b038916906377be18a890604401600060405180830381600087803b15801561124457600080fd5b505af1158015611258573d6000803e3d6000fd5b505050506001600160a01b03888116600090815260ca6020908152604091829020825160a081018452815481526001820154948516928101929092527401000000000000000000000000000000000000000090930460ff16918101919091526002820180549192916060840191906112cf90613151565b80601f01602080910402602001604051908101604052809291908181526020018280546112fb90613151565b80156113485780601f1061131d57610100808354040283529160200191611348565b820191906000526020600020905b81548152906001019060200180831161132b57829003601f168201915b5050505050815260200160038201805461136190613151565b80601f016020809104026020016040519081016040528092919081815260200182805461138d90613151565b80156113da5780601f106113af576101008083540402835291602001916113da565b820191906000526020600020905b8154815290600101906020018083116113bd57829003601f168201915b5050509190925250505060208101519092506001600160a01b031661142b576040517ff91680d400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50856116c4565b60008890506040518060a001604052804681526020018a6001600160a01b03168152602001826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611495573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b991906131b3565b60ff168152602001826001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156114ff573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261152791908101906131d0565b8152602001826001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa15801561156a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261159291908101906131d0565b90526040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529093506000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156115f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061161b9190612f47565b90506116326001600160a01b03831633308c611e0a565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015281906001600160a01b038416906370a0823190602401602060405180830381865afa158015611691573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b59190612f47565b6116bf9190612e13565b925050505b611753604051806101a001604052806000815260200160006001600160a01b03168152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160608152602001606081525090565b606081018b905233608082015260408051808201909152600b81527f746f6b656e5f7661756c7400000000000000000000000000000000000000000060208201526117a1908c90600061079e565b6001600160a01b031660a082015260808101516040517f0c6fab8200000000000000000000000000000000000000000000000000000000916117ec918691908e908790602401613247565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526101608201526101408101879052610120810186905261186b8634612e13565b60e08201526001600160a01b03851660c0820152610180810184905260408051808201909152600681527f627269646765000000000000000000000000000000000000000000000000000060208201526000906118c89082610609565b6001600160a01b03166396e1785234846040518363ffffffff1660e01b81526004016118f49190612e4d565b60206040518083038185885af1158015611912573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906119379190612f47565b905060405180604001604052808b6001600160a01b031681526020018481525060cc600083815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550602082015181600101559050508a6001600160a01b031682608001516001600160a01b0316827f325cab7553038374e17f39bb45e2a2c90f66c6a52798cb5f95c20d94c11c95e28f8e88604051611a0a939291909283526001600160a01b03919091166020830152604082015260600190565b60405180910390a450505050611a1f60018055565b5050505050505050565b611a31611d46565b6001600160a01b038116611aad5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016106c7565b611ab681611da0565b50565b600260015403611b0b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106c7565b6002600155565b6040516001600160a01b038316602482015260448101829052610f119084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611e5b565b8035600090815260cb60209081526040808320839290918391611be2918701908701612aa2565b6001600160a01b0390811682526020820192909252604001600020541690508061061957611c0f83611f40565b6107ae565b60018055565b600080611c26856121f7565b84604051602001611c389291906132fe565b60408051601f19818403018152908290526097547fbf40fac10000000000000000000000000000000000000000000000000000000083529092506001600160a01b03169063bf40fac190611c90908490600401613356565b602060405180830381865afa158015611cad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd19190613369565b915082611d25576040516001600160a01b038316151590611cf6908390602001613386565b60405160208183030381529060405290611d235760405162461bcd60e51b81526004016106c79190613356565b505b509392505050565b611d356122b5565b611d3d61233a565b611ab6816123bf565b6065546001600160a01b03163314610aed5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106c7565b606580546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6040516001600160a01b03808516602483015283166044820152606481018290526106039085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401611b57565b6000611eb0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166124399092919063ffffffff16565b805190915015610f115780806020019051810190611ece9190613134565b610f115760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016106c7565b6000611fd5818335611f586040860160208701612aa2565b604051602001611f9792919091825260601b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602082015260340190565b6040516020818303038152906040528051906020012060405180602001611fbd906128c3565b601f1982820381018352601f90910116604052612448565b6097549091506001600160a01b0380831691636c0db62b9116611ffe6040860160208701612aa2565b853561201060608801604089016133cb565b61201d60608901896133e8565b61202a60808b018b6133e8565b60405161203e9291908d359060200161344d565b6040516020818303038152906040526040518863ffffffff1660e01b815260040161206f97969594939291906134d0565b600060405180830381600087803b15801561208957600080fd5b505af115801561209d573d6000803e3d6000fd5b5050506001600160a01b038216600090815260c96020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905560ca90915290208391506120f8828261366f565b50508135600090815260cb6020908152604080832084939092909161212291908701908701612aa2565b6001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550806001600160a01b03168260200160208101906121839190612aa2565b6001600160a01b031683357f9e465b29e576a3e01584e31d607353f21b80c055e813af907c0a495f6cf4f7bc6121bc60608701876133e8565b6121c960808901896133e8565b6121d960608b0160408c016133cb565b6040516121ea95949392919061371d565b60405180910390a4919050565b606060006122048361254c565b600101905060008167ffffffffffffffff81111561222457612224612964565b6040519080825280601f01601f19166020018201604052801561224e576020820181803683370190505b5090508181016020015b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461225857509392505050565b600054610100900460ff166123325760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016106c7565b610aed61262e565b600054610100900460ff166123b75760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016106c7565b610aed6126ab565b6001600160a01b0381166123ff576040517f9a109b0a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b609780547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b60606107ab8484600085612731565b60008347101561249a5760405162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e636500000060448201526064016106c7565b81516000036124eb5760405162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f60448201526064016106c7565b8282516020840186f590506001600160a01b0381166107ae5760405162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f790000000000000060448201526064016106c7565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310612595577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef810000000083106125c1576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106125df57662386f26fc10000830492506010015b6305f5e10083106125f7576305f5e100830492506008015b612710831061260b57612710830492506004015b6064831061261d576064830492506002015b600a83106106195760010192915050565b600054610100900460ff16611c145760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016106c7565b600054610100900460ff166127285760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e6700000000000000000000000000000000000000000060648201526084016106c7565b610aed33611da0565b6060824710156127a95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016106c7565b600080866001600160a01b031685876040516127c5919061375a565b60006040518083038185875af1925050503d8060008114612802576040519150601f19603f3d011682016040523d82523d6000602084013e612807565b606091505b509150915061281887838387612825565b925050505b949350505050565b6060831561289457825160000361288d576001600160a01b0385163b61288d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106c7565b508161281d565b61281d83838151156128a95781518083602001fd5b8060405162461bcd60e51b81526004016106c79190613356565b6121518061377783390190565b6001600160a01b0381168114611ab657600080fd5b80356128f0816128d0565b919050565b6000806000806080858703121561290b57600080fd5b843567ffffffffffffffff81111561292257600080fd5b850160a0818803121561293457600080fd5b93506020850135612944816128d0565b92506040850135612954816128d0565b9396929550929360600135925050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156129bc576129bc612964565b604052919050565b600067ffffffffffffffff8211156129de576129de612964565b50601f01601f191660200190565b600082601f8301126129fd57600080fd5b8135612a10612a0b826129c4565b612993565b818152846020838601011115612a2557600080fd5b816020850160208301376000918101602001919091529392505050565b8015158114611ab657600080fd5b60008060408385031215612a6357600080fd5b823567ffffffffffffffff811115612a7a57600080fd5b612a86858286016129ec565b9250506020830135612a9781612a42565b809150509250929050565b600060208284031215612ab457600080fd5b81356107ae816128d0565b600080600060608486031215612ad457600080fd5b83359250602084013567ffffffffffffffff811115612af257600080fd5b612afe868287016129ec565b9250506040840135612b0f81612a42565b809150509250925092565b60008060008060008060c08789031215612b3357600080fd5b863595506020870135612b45816128d0565b945060408701359350606087013592506080870135612b63816128d0565b915060a087013567ffffffffffffffff811115612b7f57600080fd5b612b8b89828a016129ec565b9150509295509295509295565b60008060408385031215612bab57600080fd5b823591506020830135612a97816128d0565b600060208284031215612bcf57600080fd5b5035919050565b600080600060408486031215612beb57600080fd5b833567ffffffffffffffff80821115612c0357600080fd5b908501906101a08288031215612c1857600080fd5b90935060208501359080821115612c2e57600080fd5b818601915086601f830112612c4257600080fd5b813581811115612c5157600080fd5b876020828501011115612c6357600080fd5b6020830194508093505050509250925092565b60005b83811015612c91578181015183820152602001612c79565b50506000910152565b60008151808452612cb2816020860160208601612c76565b601f01601f19169290920160200192915050565b8581526001600160a01b038516602082015260ff8416604082015260a060608201526000612cf760a0830185612c9a565b8281036080840152612d098185612c9a565b98975050505050505050565b600080600080600080600080610100898b031215612d3257600080fd5b883597506020890135612d44816128d0565b96506040890135612d54816128d0565b9550606089013594506080890135935060a0890135925060c0890135612d79816128d0565b915060e089013567ffffffffffffffff811115612d9557600080fd5b612da18b828c016129ec565b9150509295985092959890939650565b600060608284031215612dc357600080fd5b6040516060810181811067ffffffffffffffff82111715612de657612de6612964565b604052825181526020830151612dfb816128d0565b60208201526040928301519281019290925250919050565b81810381811115610619577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b602081528151602082015260006020830151612e7460408401826001600160a01b03169052565b5060408301516060830152606083015160808301526080830151612ea360a08401826001600160a01b03169052565b5060a08301516001600160a01b03811660c08401525060c08301516001600160a01b03811660e08401525060e0830151610100838101919091528301516101208084019190915283015161014080840191909152830151610160808401919091528301516101a0610180808501829052612f216101c0860184612c9a565b90860151858203601f190183870152909250612f3d8382612c9a565b9695505050505050565b600060208284031215612f5957600080fd5b5051919050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112612f9557600080fd5b830160208101925035905067ffffffffffffffff811115612fb557600080fd5b803603821315612fc457600080fd5b9250929050565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b6020815281356020820152600061300f602084016128e5565b6001600160a01b038116604084015250604083013560608301526060830135608083015261303f608084016128e5565b6001600160a01b03811660a08401525061305b60a084016128e5565b6001600160a01b03811660c08401525061307760c084016128e5565b6001600160a01b03811660e08401525061010060e0840135818401526101208185013581850152610140915080850135828501525061016081850135818501526130c381860186612f60565b925090506101a061018081818701526130e16101c087018585612fcb565b93506130ef81880188612f60565b93509050601f198685030182870152613109848483612fcb565b979650505050505050565b848152836020820152606060408201526000612f3d606083018486612fcb565b60006020828403121561314657600080fd5b81516107ae81612a42565b600181811c9082168061316557607f821691505b60208210810361319e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60ff81168114611ab657600080fd5b6000602082840312156131c557600080fd5b81516107ae816131a4565b6000602082840312156131e257600080fd5b815167ffffffffffffffff8111156131f957600080fd5b8201601f8101841361320a57600080fd5b8051613218612a0b826129c4565b81815285602083850101111561322d57600080fd5b61323e826020830160208601612c76565b95945050505050565b6080815284516080820152600060208601516001600160a01b0380821660a085015260ff60408901511660c08501526060880151915060a060e0850152613292610120850183612c9a565b915060808801517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80858403016101008601526132ce8382612c9a565b9188166020860152506001600160a01b038616604085015291506132ef9050565b82606083015295945050505050565b60008351613310818460208801612c76565b7f2e00000000000000000000000000000000000000000000000000000000000000908301908152835161334a816001840160208801612c76565b01600101949350505050565b6020815260006106166020830184612c9a565b60006020828403121561337b57600080fd5b81516107ae816128d0565b7f41523a7a65726f416464723a00000000000000000000000000000000000000008152600082516133be81600c850160208701612c76565b91909101600c0192915050565b6000602082840312156133dd57600080fd5b81356107ae816131a4565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261341d57600080fd5b83018035915067ffffffffffffffff82111561343857600080fd5b602001915036819003821315612fc457600080fd5b828482377f286272696467656400000000000000000000000000000000000000000000000092019182527ff09f8c88000000000000000000000000000000000000000000000000000000006008830152600c8201527f2900000000000000000000000000000000000000000000000000000000000000602c820152602d01919050565b60006001600160a01b03808a16835280891660208401525086604083015260ff8616606083015260c0608083015261350c60c083018587612fcb565b82810360a084015261351e8185612c9a565b9a9950505050505050505050565b601f821115610f1157600081815260208120601f850160051c810160208610156135535750805b601f850160051c820191505b81811015610ad35782815560010161355f565b67ffffffffffffffff83111561358a5761358a612964565b61359e836135988354613151565b8361352c565b6000601f8411600181146135f057600085156135ba5750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355613668565b600083815260209020601f19861690835b828110156136215786850135825560209485019460019092019101613601565b508682101561365c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b81358155600181016020830135613685816128d0565b81546040850135613695816131a4565b74ff00000000000000000000000000000000000000008160a01b166001600160a01b0384167fffffffffffffffffffffff000000000000000000000000000000000000000000841617178455505050506136f260608301836133e8565b613700818360028601613572565b505061370f60808301836133e8565b610603818360038601613572565b606081526000613731606083018789612fcb565b8281036020840152613744818688612fcb565b91505060ff831660408301529695505050505050565b6000825161376c818460208701612c76565b919091019291505056fe608060405234801561001057600080fd5b50612131806100206000396000f3fe608060405234801561001057600080fd5b506004361061018d5760003560e01c806367e828bf116100e35780638da5cb5b1161008c578063a9059cbb11610066578063a9059cbb146103b4578063dd62ed3e146103c7578063f2fde38b1461040d57600080fd5b80638da5cb5b1461037b57806395d89b4114610399578063a457c2d7146103a157600080fd5b8063715018a6116100bd578063715018a61461034057806377be18a8146103485780637cf8ed0d1461035b57600080fd5b806367e828bf146102a75780636c0db62b146102f757806370a082311461030a57600080fd5b806323b872dd116101455780633ab76e9f1161011f5780633ab76e9f1461026b57806342e91bb31461028957806349d126051461029e57600080fd5b806323b872dd14610230578063313ce56714610243578063395093511461025857600080fd5b80630ca4dffd116101765780630ca4dffd146101d357806318160ddd1461020b5780631be2bfa71461021d57600080fd5b806306fdde0314610192578063095ea7b3146101b0575b600080fd5b61019a610420565b6040516101a79190611abd565b60405180910390f35b6101c36101be366004611b30565b6104b2565b60405190151581526020016101a7565b6101e66101e1366004611c4b565b6104cc565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101a7565b60cb545b6040519081526020016101a7565b6101e661022b366004611c99565b6104e0565b6101c361023e366004611cf0565b6104f5565b60ce5460405160ff90911681526020016101a7565b6101c3610266366004611b30565b610551565b60975473ffffffffffffffffffffffffffffffffffffffff166101e6565b61029c610297366004611b30565b61059d565b005b61020f60fc5481565b6102cb60fb5460fc5473ffffffffffffffffffffffffffffffffffffffff90911691565b6040805173ffffffffffffffffffffffffffffffffffffffff90931683526020830191909152016101a7565b61029c610305366004611d31565b6106a1565b61020f610318366004611ddb565b73ffffffffffffffffffffffffffffffffffffffff16600090815260c9602052604090205490565b61029c6108eb565b61029c610356366004611b30565b6108ff565b60fb546101e69073ffffffffffffffffffffffffffffffffffffffff1681565b60655473ffffffffffffffffffffffffffffffffffffffff166101e6565b61019a6109f6565b6101c36103af366004611b30565b610a05565b6101c36103c2366004611b30565b610ac7565b61020f6103d5366004611df8565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260ca6020908152604080832093909416825291909152205490565b61029c61041b366004611ddb565b610b22565b606060cc805461042f90611e31565b80601f016020809104026020016040519081016040528092919081815260200182805461045b90611e31565b80156104a85780601f1061047d576101008083540402835291602001916104a8565b820191906000526020600020905b81548152906001019060200180831161048b57829003601f168201915b5050505050905090565b6000336104c0818585610bbf565b60019150505b92915050565b60006104d9468484610d3e565b9392505050565b60006104ed848484610d3e565b949350505050565b60003073ffffffffffffffffffffffffffffffffffffffff841603610546576040517f669bcddc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6104ed848484610e89565b33600081815260ca6020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104c09082908690610598908790611eb3565b610bbf565b6040518060400160405280600b81526020017f746f6b656e5f7661756c740000000000000000000000000000000000000000008152506105de8160006104cc565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610642576040517f1b0b999e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61064c8383610ea2565b8273ffffffffffffffffffffffffffffffffffffffff167f397b33b307fc137878ebfc75b295289ec0ee25a31bb5bf034f33256fe8ea2aa68360405161069491815260200190565b60405180910390a2505050565b600054610100900460ff16158080156106c15750600054600160ff909116105b806106db5750303b1580156106db575060005460ff166001145b6107525760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156107b057600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b73ffffffffffffffffffffffffffffffffffffffff861615806107d1575084155b806107db57504685145b806107e557508251155b806107ef57508151155b15610826576040517ff12d598000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61082f87610f60565b61083a828486610f79565b60fb80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff881617905560fc85905580156108e257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b6108f3611006565b6108fd600061106d565b565b6040518060400160405280600b81526020017f746f6b656e5f7661756c740000000000000000000000000000000000000000008152506109408160006104cc565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109a4576040517f1b0b999e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109ae83836110e4565b8273ffffffffffffffffffffffffffffffffffffffff167f9b5b9a05e4726d8bb959f1440e05c6b8109443f2083bc4e386237d76545265538360405161069491815260200190565b606060cd805461042f90611e31565b33600081815260ca6020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610aaf5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610749565b610abc8286868403610bbf565b506001949350505050565b60003073ffffffffffffffffffffffffffffffffffffffff841603610b18576040517f669bcddc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6104d98383611255565b610b2a611006565b73ffffffffffffffffffffffffffffffffffffffff8116610bb35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610749565b610bbc8161106d565b50565b73ffffffffffffffffffffffffffffffffffffffff8316610c475760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff8216610cd05760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff838116600081815260ca602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b600080610d4a85611263565b84604051602001610d5c929190611ec6565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290526097547fbf40fac100000000000000000000000000000000000000000000000000000000835290925073ffffffffffffffffffffffffffffffffffffffff169063bf40fac190610ddf908490600401611abd565b602060405180830381865afa158015610dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e209190611f1e565b915082610e815760405173ffffffffffffffffffffffffffffffffffffffff8316151590610e52908390602001611f3b565b60405160208183030381529060405290610e7f5760405162461bcd60e51b81526004016107499190611abd565b505b509392505050565b600033610e97858285611321565b610abc8585856113de565b73ffffffffffffffffffffffffffffffffffffffff8216610f055760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610749565b8060cb6000828254610f179190611eb3565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600090815260c9602052604081208054839290610f51908490611eb3565b90915550610f5c9050565b5050565b610f68611643565b610f706116c8565b610bbc8161174d565b600054610100900460ff16610ff65760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610749565b6110018383836117e1565b505050565b60655473ffffffffffffffffffffffffffffffffffffffff1633146108fd5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610749565b6065805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b73ffffffffffffffffffffffffffffffffffffffff821661116d5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260c96020526040902054818110156112095760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260c960205260408120838303905560cb8054849290611245908490611f80565b9091555061100190508360008483565b6000336104c08185856113de565b60606000611270836118ae565b600101905060008167ffffffffffffffff81111561129057611290611b5c565b6040519080825280601f01601f1916602001820160405280156112ba576020820181803683370190505b5090508181016020015b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a85049450846112c457509392505050565b73ffffffffffffffffffffffffffffffffffffffff838116600090815260ca60209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146113d857818110156113cb5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610749565b6113d88484848403610bbf565b50505050565b73ffffffffffffffffffffffffffffffffffffffff83166114675760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff82166114f05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260c960205260409020548181101561158c5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610749565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260c960205260408082208585039055918516815290812080548492906115d0908490611eb3565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161163691815260200190565b60405180910390a36113d8565b600054610100900460ff166116c05760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610749565b6108fd611990565b600054610100900460ff166117455760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610749565b6108fd611a13565b73ffffffffffffffffffffffffffffffffffffffff811661179a576040517f9a109b0a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b609780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600054610100900460ff1661185e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610749565b60cc61186a8482611fe1565b5060cd6118778382611fe1565b5060ce80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff929092169190911790555050565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106118f7577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310611923576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061194157662386f26fc10000830492506010015b6305f5e1008310611959576305f5e100830492506008015b612710831061196d57612710830492506004015b6064831061197f576064830492506002015b600a83106104c65760010192915050565b600054610100900460ff16611a0d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610749565b60018055565b600054610100900460ff16611a905760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610749565b6108fd3361106d565b60005b83811015611ab4578181015183820152602001611a9c565b50506000910152565b6020815260008251806020840152611adc816040850160208701611a99565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b73ffffffffffffffffffffffffffffffffffffffff81168114610bbc57600080fd5b60008060408385031215611b4357600080fd5b8235611b4e81611b0e565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f830112611b9c57600080fd5b813567ffffffffffffffff80821115611bb757611bb7611b5c565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715611bfd57611bfd611b5c565b81604052838152866020858801011115611c1657600080fd5b836020870160208301376000602085830101528094505050505092915050565b80358015158114611c4657600080fd5b919050565b60008060408385031215611c5e57600080fd5b823567ffffffffffffffff811115611c7557600080fd5b611c8185828601611b8b565b925050611c9060208401611c36565b90509250929050565b600080600060608486031215611cae57600080fd5b83359250602084013567ffffffffffffffff811115611ccc57600080fd5b611cd886828701611b8b565b925050611ce760408501611c36565b90509250925092565b600080600060608486031215611d0557600080fd5b8335611d1081611b0e565b92506020840135611d2081611b0e565b929592945050506040919091013590565b60008060008060008060c08789031215611d4a57600080fd5b8635611d5581611b0e565b95506020870135611d6581611b0e565b945060408701359350606087013560ff81168114611d8257600080fd5b9250608087013567ffffffffffffffff80821115611d9f57600080fd5b611dab8a838b01611b8b565b935060a0890135915080821115611dc157600080fd5b50611dce89828a01611b8b565b9150509295509295509295565b600060208284031215611ded57600080fd5b81356104d981611b0e565b60008060408385031215611e0b57600080fd5b8235611e1681611b0e565b91506020830135611e2681611b0e565b809150509250929050565b600181811c90821680611e4557607f821691505b602082108103611e7e577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104c6576104c6611e84565b60008351611ed8818460208801611a99565b7f2e000000000000000000000000000000000000000000000000000000000000009083019081528351611f12816001840160208801611a99565b01600101949350505050565b600060208284031215611f3057600080fd5b81516104d981611b0e565b7f41523a7a65726f416464723a0000000000000000000000000000000000000000815260008251611f7381600c850160208701611a99565b91909101600c0192915050565b818103818111156104c6576104c6611e84565b601f82111561100157600081815260208120601f850160051c81016020861015611fba5750805b601f850160051c820191505b81811015611fd957828155600101611fc6565b505050505050565b815167ffffffffffffffff811115611ffb57611ffb611b5c565b61200f816120098454611e31565b84611f93565b602080601f831160018114612062576000841561202c5750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555611fd9565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b828110156120af57888601518255948401946001909101908401612090565b50858210156120eb57878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b0190555056fea26469706673582212205872d80ce6aa6a8f2ed4104f2c2457554a5aa23abcc60236fec759454288070a64736f6c63430008120033a264697066735822122038ce1c52f0ceeadf0c61bf3eaffc2947fa030252800d758cef4c81ccef66d4ca64736f6c63430008120033
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.