Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
18396787 | 483 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
USDVMain
Compiler Version
v0.8.19+commit.7dd6d404
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: LZBL-1.1 // Copyright 2023 LayerZero Labs Ltd. // You may obtain a copy of the License at // https://github.com/LayerZero-Labs/license/blob/main/LICENSE-LZBL-1.1 pragma solidity 0.8.19; import "hardhat-deploy/solc_0.8/proxy/Proxied.sol"; import "./USDVBase.sol"; import "./interfaces/IUSDVMain.sol"; import {IVaultManager} from "../vault/interfaces/IVaultManager.sol"; contract USDVMain is IUSDVMain, Proxied, USDVBase { function initialize(address _owner, address _foundation) public proxied initializer { __USDVBase_init(_owner, _foundation); } /// @dev if after recolor, amount supplied is greater than float, the excess will be ignored (avoid reminting same color) function remint( uint32 _surplusColor, uint64 _surplusAmount, uint32[] calldata _deficits, uint64 _feeCap ) external whenNotPaused { (uint64 remintFee, Delta[] memory deltas) = _remint(_surplusColor, _surplusAmount, _deficits, _feeCap); address vaultManager = getRole(Role.VAULT); // charge remint fee if (remintFee > 0) { transfer(vaultManager, remintFee); } // minterOwner is VaultManager here IVaultManager(vaultManager).remint(deltas, remintFee); emit Reminted(deltas, remintFee); } /// @dev whenNotPaused checked in _sendAck function remintAck( Delta[] calldata _deltas, uint32 _feeColor, uint64 _feeAmount, uint64 _feeTheta ) external whenNotPaused onlyRole(Role.MESSAGING) { address vaultManager = getRole(Role.VAULT); // the fee is credited to the vault if (_feeAmount > 0) { _sendAck(vaultManager, _feeColor, _feeAmount, _feeTheta); } // apply the changes to the vault IVaultManager(vaultManager).remint(_deltas, _feeAmount); emit Reminted(_deltas, _feeAmount); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import {MessagingFee, MessagingReceipt} from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; // @dev unable to inherit ERC20 because the OFTAdapter needs to use this interface as well interface IOFT { struct SendParam { bytes32 to; uint amountLD; uint minAmountLD; uint32 dstEid; } error LDMinusSD(); error AmountSlippage(uint _amountLDSend, uint256 _minAmountLD); event SetInspector(address _inspector); event SendOFT(bytes32 indexed _guid, address indexed _fromAddress, uint _amountLD, bytes _composeMsg); event ReceiveOFT(bytes32 indexed _guid, address indexed _toAddress, uint _amountLD); function token() external view returns (address); function quoteSendFee( SendParam calldata _send, bytes calldata _options, bool _useLZToken, bytes calldata _composeMsg ) external view returns (uint nativeFee, uint lzTokenFee); function send( SendParam calldata _send, bytes calldata _options, MessagingFee calldata _msgFee, address payable _refundAddress, bytes calldata _composeMsg ) external payable returns (MessagingReceipt memory); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.8.0; struct PacketForQuote { address sender; uint32 dstEid; bytes message; } struct Packet { uint64 nonce; uint32 srcEid; address sender; uint32 dstEid; bytes32 receiver; bytes32 guid; bytes message; } struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.8.0; import "./IMessageLibManager.sol"; import "./IMessagingComposer.sol"; import "./IMessagingChannel.sol"; import "./IMessagingContext.sol"; import {Origin} from "../MessagingStructs.sol"; struct MessagingParams { uint32 dstEid; bytes32 receiver; bytes message; bytes options; } struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; } struct MessagingFee { uint nativeFee; uint lzTokenFee; } interface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext { event PacketSent(bytes encodedPayload, bytes options, address sendLibrary); event PacketDelivered(Origin origin, address receiver, bytes32 payloadHash); event PacketReceived(Origin origin, address receiver); event LzReceiveFailed(Origin origin, address receiver, bytes reason); event LayerZeroTokenSet(address token); function quote( address _sender, uint32 _dstEid, bytes calldata _message, bool _payInLzToken, bytes calldata _options ) external view returns (MessagingFee memory); function send( MessagingParams calldata _params, uint _lzTokenFee, address payable _refundAddress ) external payable returns (MessagingReceipt memory); function sendWithAlt( MessagingParams calldata _params, uint _lzTokenFee, uint _altTokenFee ) external returns (MessagingReceipt memory); function deliver(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external; function deliverable(Origin calldata _origin, address _receiveLib, address _receiver) external view returns (bool); function lzReceive( Origin calldata _origin, address _receiver, bytes32 _guid, bytes calldata _message, bytes calldata _extraData ) external payable returns (bool, bytes memory); // oapp can burn messages partially by calling this function with its own business logic if messages are delivered in order function clear(Origin calldata _origin, bytes32 _guid, bytes calldata _message) external; function setLayerZeroToken(address _layerZeroToken) external; function layerZeroToken() external view returns (address); function altFeeToken() external view returns (address); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.8.0; struct SetConfigParam { uint32 configType; bytes config; } interface IMessageLibManager { struct Timeout { address lib; uint expiry; } event LibraryRegistered(address newLib); event DefaultSendLibrarySet(uint32 eid, address newLib); event DefaultReceiveLibrarySet(uint32 eid, address oldLib, address newLib); event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint expiry); event SendLibrarySet(address sender, uint32 eid, address newLib); event ReceiveLibrarySet(address receiver, uint32 eid, address oldLib, address newLib); event ReceiveLibraryTimoutSet(address receiver, uint32 eid, address oldLib, uint timeout); function registerLibrary(address _lib) external; function isRegisteredLibrary(address _lib) external view returns (bool); function getRegisteredLibraries() external view returns (address[] memory); function setDefaultSendLibrary(uint32 _eid, address _newLib) external; function defaultSendLibrary(uint32 _eid) external view returns (address); function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint _timeout) external; function defaultReceiveLibrary(uint32 _eid) external view returns (address); function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint _expiry) external; function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint expiry); function defaultConfig(address _lib, uint32 _eid, uint32 _configType) external view returns (bytes memory); function isSupportedEid(uint32 _eid) external view returns (bool); /// ------------------- OApp interfaces ------------------- function setSendLibrary(uint32 _eid, address _newLib) external; function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib); function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool); function setReceiveLibrary(uint32 _eid, address _newLib, uint _gracePeriod) external; function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault); function setReceiveLibraryTimeout(uint32 _eid, address _lib, uint _gracePeriod) external; function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint expiry); function setConfig(address _lib, uint32 _eid, SetConfigParam[] calldata _params) external; function getConfig( address _oapp, address _lib, uint32 _eid, uint32 _configType ) external view returns (bytes memory config, bool isDefault); function snapshotConfig(address _lib, uint32[] calldata _eids) external; function resetConfig(address _lib, uint32[] calldata _eids) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.8.0; interface IMessagingChannel { event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce); function eid() external view returns (uint32); // this is an emergency function if a message can not be delivered for some reasons // required to provide _nextNonce to avoid race condition function skip(uint32 _srcEid, bytes32 _sender, uint64 _nonce) external; function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32); function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64); function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64); function inboundPayloadHash( address _receiver, uint32 _srcEid, bytes32 _sender, uint64 _nonce ) external view returns (bytes32); function hasPayloadHash( address _receiver, uint32 _srcEid, bytes32 _sender, uint64 _nonce ) external view returns (bool); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.8.0; interface IMessagingComposer { event ComposedMessageDelivered(address receiver, address composer, bytes32 guid, bytes message); event ComposedMessageReceived(address receiver, address composer, bytes32 guid); event LzComposeFailed(address receiver, address composer, bytes32 guid, bytes reason); function deliverComposedMessage(address _composer, bytes32 _guid, bytes calldata _message) external; function lzCompose( address _receiver, address _composer, bytes32 _guid, bytes calldata _message, bytes calldata _extraData ) external payable returns (bool, bytes memory); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.8.0; interface IMessagingContext { function isSendingMessage() external view returns (bool); function getSendContext() external view returns (uint32, address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.0; interface IERC5267Upgradeable { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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] * ```solidity * 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 Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer(address from, address to, uint256 amount) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _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; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[45] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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.9.0) (token/ERC20/extensions/ERC20Permit.sol) pragma solidity ^0.8.0; import "./IERC20PermitUpgradeable.sol"; import "../ERC20Upgradeable.sol"; import "../../../utils/cryptography/ECDSAUpgradeable.sol"; import "../../../utils/cryptography/EIP712Upgradeable.sol"; import "../../../utils/CountersUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation 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. * * _Available since v3.4._ * * @custom:storage-size 51 */ abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; mapping(address => CountersUpgradeable.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private constant _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`. * However, to ensure consistency with the upgradeable transpiler, we will continue * to reserve a slot. * @custom:oz-renamed-from _PERMIT_TYPEHASH */ // solhint-disable-next-line var-name-mixedcase bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT; /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ function __ERC20Permit_init(string memory name) internal onlyInitializing { __EIP712_init_unchained(name, "1"); } function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSAUpgradeable.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { CountersUpgradeable.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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 * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [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://consensys.net/diligence/blog/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.8.0/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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(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 v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library CountersUpgradeable { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; import "./math/SignedMathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { 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 = MathUpgradeable.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 `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.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); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../StringsUpgradeable.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSAUpgradeable { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) { // 32 is the length in bytes of hash, // enforced by the type signature above /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") mstore(0x1c, hash) message := keccak256(0x00, 0x3c) } } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, "\x19\x01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) data := keccak256(ptr, 0x42) } } /** * @dev Returns an Ethereum Signed Data with intended validator, created from a * `validator` and `data` according to the version 0 of EIP-191. * * See {recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x00", validator, data)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.8; import "./ECDSAUpgradeable.sol"; import "../../interfaces/IERC5267Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * _Available since v3.4._ * * @custom:storage-size 52 */ abstract contract EIP712Upgradeable is Initializable, IERC5267Upgradeable { bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); /// @custom:oz-renamed-from _HASHED_NAME bytes32 private _hashedName; /// @custom:oz-renamed-from _HASHED_VERSION bytes32 private _hashedVersion; string private _name; string private _version; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ function __EIP712_init(string memory name, string memory version) internal onlyInitializing { __EIP712_init_unchained(name, version); } function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing { _name = name; _version = version; // Reset prior values in storage if upgrading _hashedName = 0; _hashedVersion = 0; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { return _buildDomainSeparator(); } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {EIP-5267}. * * _Available since v4.9._ */ function eip712Domain() public view virtual override returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { // If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized // and the EIP712 domain is not reliable, as it will be missing name and version. require(_hashedName == 0 && _hashedVersion == 0, "EIP712: Uninitialized"); return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712Name() internal virtual view returns (string memory) { return _name; } /** * @dev The version parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712Version() internal virtual view returns (string memory) { return _version; } /** * @dev The hash of the name parameter for the EIP712 domain. * * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead. */ function _EIP712NameHash() internal view returns (bytes32) { string memory name = _EIP712Name(); if (bytes(name).length > 0) { return keccak256(bytes(name)); } else { // If the name is empty, the contract may have been upgraded without initializing the new storage. // We return the name hash in storage if non-zero, otherwise we assume the name is empty by design. bytes32 hashedName = _hashedName; if (hashedName != 0) { return hashedName; } else { return keccak256(""); } } } /** * @dev The hash of the version parameter for the EIP712 domain. * * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead. */ function _EIP712VersionHash() internal view returns (bytes32) { string memory version = _EIP712Version(); if (bytes(version).length > 0) { return keccak256(bytes(version)); } else { // If the version is empty, the contract may have been upgraded without initializing the new storage. // We return the version hash in storage if non-zero, otherwise we assume the version is empty by design. bytes32 hashedVersion = _hashedVersion; if (hashedVersion != 0) { return hashedVersion; } else { return keccak256(""); } } } /** * @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[48] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 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 256, 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 << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMathUpgradeable { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/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 IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit 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(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation 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). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // 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 cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [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://consensys.net/diligence/blog/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.8.0/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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(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 (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 SafeCast { /** * @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: LZBL-1.1 // Copyright 2023 LayerZero Labs Ltd. // You may obtain a copy of the License at // https://github.com/LayerZero-Labs/license/blob/main/LICENSE-LZBL-1.1 pragma solidity ^0.8.0; import "@layerzerolabs/lz-evm-oapp-v2/contracts/standards/oft/interfaces/IOFT.sol"; import {MessagingFee, MessagingParams, MessagingReceipt} from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; import {Delta} from "../../usdv/interfaces/IUSDV.sol"; interface IMessaging { error NotUSDV(address sender); error NotImplemented(); error NotMainChain(); event SetPerColorExtraGas(uint32 dstEid, uint8 msgType, uint extraGas); struct SendParam { uint32 dstEid; bytes32 to; uint32 color; uint64 amount; uint64 theta; } function send( SendParam calldata _pram, bytes calldata _extraOptions, MessagingFee calldata _msgFee, address payable _refundAddress, bytes calldata _composeMsg ) external payable returns (MessagingReceipt memory msgReceipt); function syncDelta( uint32 _dstEid, Delta[] calldata _deltas, bytes calldata _extraOptions, MessagingFee calldata _msgFee, address payable _refundAddress ) external payable returns (MessagingReceipt memory msgReceipt); function quoteSendFee( uint32 _dstEid, bytes calldata _extraOptions, bool _useLZToken, bytes calldata _composeMsg ) external view returns (uint nativeFee, uint lzTokenFee); function quoteSyncDeltaFee( uint32 _dstEid, Delta[] calldata _deltas, bytes calldata _extraOptions, bool _useLZToken ) external view returns (uint nativeFee, uint lzTokenFee); function remint( Delta[] calldata _deltas, uint32 _feeColor, uint64 _feeAmount, uint64 _feeTheta, bytes calldata _extraOptions, MessagingFee calldata _msgFee, address payable _refundAddress ) external payable returns (MessagingReceipt memory msgReceipt); function quoteRemintFee( Delta[] calldata _deltas, bytes calldata _extraOptions, bool _useLZToken ) external view returns (uint nativeFee, uint lzTokenFee); }
// SPDX-License-Identifier: LZBL-1.1 // Copyright 2023 LayerZero Labs Ltd. // You may obtain a copy of the License at // https://github.com/LayerZero-Labs/license/blob/main/LICENSE-LZBL-1.1 pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol"; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; import "../messaging/interfaces/IMessaging.sol"; import "./interfaces/IUSDV.sol"; import "./interfaces/IOperator.sol"; import "./libs/Colors.sol"; abstract contract USDVBase is IUSDV, ERC20PermitUpgradeable { using Colors for Colors.Info; using SafeCast for uint256; uint64 internal totalSupply_; // governance bool public paused; mapping(Role => address) internal roles; Colors.Info internal colorInfo; mapping(address user => State) public userStates; mapping(address user => address colorer) public colorers; function __USDVBase_init(address _owner, address _foundation) internal onlyInitializing { __ERC20_init_unchained("USDV", "USDV"); __EIP712_init_unchained("USDV", "1"); __ERC20Permit_init_unchained("USDV"); __USDVBase_init_unchained(_owner, _foundation); } function __USDVBase_init_unchained(address _owner, address _foundation) internal onlyInitializing { roles[Role.FOUNDATION] = _foundation; roles[Role.OWNER] = _owner; } // ======================== Modifiers ======================== modifier notBlacklisted(address _user) { if (userStates[_user].blacklisted) revert Blacklisted(); _; } modifier onlyRole(Role _role) { if (msg.sender != getRole(_role)) revert Unauthorized(); _; } modifier whenNotPaused() { if (paused) revert Paused(); _; } // ======================== Only Role / Owner ======================== /// @dev owner / role can set role function setRole(Role _role, address _addr) external { if (msg.sender != getRole(_role) && msg.sender != getRole(Role.OWNER)) revert Unauthorized(); roles[_role] = _addr; emit SetRole(_role, _addr); } // ======================== OnlyFoundation ======================== function blacklist(address _user, bool _isBlacklisted) external onlyRole(Role.FOUNDATION) { userStates[_user].blacklisted = _isBlacklisted; emit SetBlacklist(_user, _isBlacklisted); } // ======================== OnlyOperator ======================== function setPause(bool _paused) external onlyRole(Role.OPERATOR) { paused = _paused; emit SetPause(_paused); } // ======================== OnlyVault ======================== /// @dev on main chain, VAULT is the VaultManager /// @dev on side chain, this can be used to fix the book in emergency e.g. hardfork /// action is allowed whenPaused() to fix invalid state function mint(address _receiver, uint64 _amount, uint32 _color) external whenNotPaused onlyRole(Role.VAULT) { // update the color space colorInfo.mint(_color, _amount, 0); // update the token space _mintBalance(_receiver, _amount, _color); } /// @dev on main chain, VAULT is the VaultManager /// @dev on side chain, this can be used to fix the book in emergency e.g. hardfork /// @dev this function might have race condition. /// @param _deficits proposed deltas to match surplus (if any) /// @return minted used for color, and deltas for deficits. if burn 0 then Delta.amount = 0; function burn( address _from, uint64 _amount, uint32[] calldata _deficits ) external whenNotPaused onlyRole(Role.VAULT) returns (Delta[] memory) { uint32 burntColor = _burnBalance(_from, _amount); //update the color space return colorInfo.burn(_deficits, _amount, burntColor); } // ======================== OnlyColorer ======================== /// @dev property: if defaultColor != nil, then color always equals defaultColor /// @dev can also assign to NIL_COLOR to clear the default color /// @dev operator can set default color for any account function setDefaultColor(address _user, uint32 _defaultColor) external { if (msg.sender != _getColorer(_user) && msg.sender != getRole(Role.OPERATOR)) revert Unauthorized(); // assert colorer State memory state = userStates[_user]; // setting to Nil color is also allowed state.defaultColor = _defaultColor; if (_defaultColor != Colors.NIL) { if (_defaultColor > colorInfo.maxKnownColor) revert Colors.InvalidColor(_defaultColor); // if the new color is not the same as the old color, update color if (state.color != _defaultColor) { colorInfo.recolor(state.color, _defaultColor, state.balance); // change config state.color = _defaultColor; } } userStates[_user] = state; emit SetDefaultColor(msg.sender, _user, _defaultColor); } // ======================== User Configuration ======================== /// @dev user and operator can set colorer function setColorer(address _user, address _colorer) external override { if (msg.sender != _user && msg.sender != getRole(Role.OPERATOR)) revert Unauthorized(); colorers[_user] = _colorer; emit SetColorer(msg.sender, _user, _colorer); } // ======================== overriding ERC20 internal functions ======================== /// @dev blacklisted not allowed. checked in the internal function function _transfer(address _from, address _to, uint _amount) internal override whenNotPaused { uint64 amountU64 = _amount.toUint64(); uint32 fromColor = _debit(_from, amountU64); _credit(_to, fromColor, amountU64); emit Transfer(_from, _to, _amount); } /// @dev blacklisted not allowed function _spendAllowance( address _owner, address _spender, uint256 _amount ) internal override notBlacklisted(_spender) { super._spendAllowance(_owner, _spender, _amount); } // ======================== basic coloring operations ======================== /// @dev debit will only update storage balance and returns user color /// @dev blacklisted not allowed function _debit(address _from, uint64 _amount) internal notBlacklisted(_from) returns (uint32 color) { if (_from == address(0)) revert InvalidUser(); uint64 balance = userStates[_from].balance; if (balance < _amount) revert InsufficientBalance(); userStates[_from].balance = balance - _amount; return userStates[_from].color; } /// @dev credit will update user state color and credit balance /// @dev blacklisted not allowed function _credit(address _to, uint32 _inboundColor, uint64 _amount) internal notBlacklisted(_to) { // following OZ's ERC20 if (_to == address(0)) revert InvalidUser(); if (_amount == 0) return; // transfer 0 is allowed State memory state = userStates[_to]; if (state.color != _inboundColor) { // ONLY if (1) user has not default color && (2) credit amount is greater than balance bool changeColor = state.defaultColor == Colors.NIL && _amount > state.balance; if (changeColor) { // recolor the current to inbound color colorInfo.recolor(state.color, _inboundColor, state.balance); // change color state.color = _inboundColor; } else { // recolor the inbound color to current color colorInfo.recolor(_inboundColor, state.color, _amount); } } // else, same color, in-kind merge // increment the balance state.balance += _amount; userStates[_to] = state; } function _mintBalance(address _receiver, uint64 _amount, uint32 _color) internal { _credit(_receiver, _color, _amount); totalSupply_ += _amount; emit Transfer(address(0), _receiver, _amount); } function _burnBalance(address _from, uint64 _targetAmount) internal returns (uint32 color) { // change balance color = _debit(_from, _targetAmount); totalSupply_ -= _targetAmount; emit Transfer(_from, address(0), _targetAmount); } // ======================== Cross-chain features ======================== /// all cross chain functions have 3 parts: /// (1) quote at source /// (2) send at source /// (3) ack at destination // ======================== SEND ======================== function quoteSendFee( SendParam calldata _param, bytes calldata _extraOptions, bool _useLZToken, bytes calldata _composeMsg ) external view returns (uint nativeFee, uint lzTokenFee) { return IMessaging(roles[Role.MESSAGING]).quoteSendFee(_param.dstEid, _extraOptions, _useLZToken, _composeMsg); } function _send(uint64 _amount) internal returns (uint32 color, uint64 theta) { if (_amount == 0) revert Colors.InvalidAmount(); IOperator(getRole(Role.OPERATOR)).tryConsume(msg.sender, _amount); color = _burnBalance(msg.sender, _amount); // theta == surplus theta = colorInfo.send(color, _amount); } function send( SendParam calldata _param, bytes calldata _extraOptions, MessagingFee calldata _msgFee, address payable _refundAddress, bytes calldata _composeMsg ) external payable whenNotPaused returns (MessagingReceipt memory msgReceipt) { // revert if address is 0x0 as it is checked on sendAck if (_param.to == bytes32(0)) revert InvalidArgument(); uint64 amount = _param.amountLD.toUint64(); (uint32 color, uint64 theta) = _send(amount); IMessaging.SendParam memory sendParam = IMessaging.SendParam(_param.dstEid, _param.to, color, amount, theta); msgReceipt = IMessaging(getRole(Role.MESSAGING)).send{value: msg.value}( sendParam, _extraOptions, _msgFee, _refundAddress, _composeMsg ); emit SendOFT(msgReceipt.guid, msg.sender, amount, _composeMsg); } /// @dev whenNotPaused checked in _sendAck /// @dev receive side interface function sendAck( bytes32 _guid, address _receiver, uint32 _color, uint64 _amount, uint64 _theta ) external whenNotPaused onlyRole(Role.MESSAGING) { _sendAck(_receiver, _color, _amount, _theta); emit ReceiveOFT(_guid, _receiver, _amount); } /// @dev symmetrical operation to the _send() function _sendAck(address _receiver, uint32 _color, uint64 _amount, uint64 _theta) internal { IOperator(getRole(Role.OPERATOR)).refill(msg.sender, _amount); // update the color space // must mint out the colors first or the _credit() may fail colorInfo.mint(_color, _amount - _theta, _theta); // update the token space _mintBalance(_receiver, _amount, _color); } // ================== Synchronization (Sync + Remint) ======================== /// @dev this function might have race condition. /// @param _theta length must be 1 and the color must be THETA /// @param _deficits in ascending order function syncDelta( uint32 _eid, uint64 _theta, uint32[] calldata _deficits, uint64 _feeCap, bytes calldata _extraOptions, MessagingFee calldata _msgFee, address payable _refundAddress ) external payable whenNotPaused returns (MessagingReceipt memory msgReceipt) { (uint64 surplus, Delta[] memory deltas) = colorInfo.extractDelta(Colors.THETA, _theta, _deficits); if (surplus == 0) revert Colors.InvalidAmount(); address operator = getRole(Role.OPERATOR); uint64 fee = IOperator(operator).getSyncFees(msg.sender, deltas, surplus); if (fee > 0) { if (fee > _feeCap) revert FeeTooHigh(); _transfer(msg.sender, operator, fee); } uint32 eid = _eid; msgReceipt = IMessaging(getRole(Role.MESSAGING)).syncDelta{value: msg.value}( eid, deltas, _extraOptions, _msgFee, _refundAddress ); emit Synced(msgReceipt.guid, deltas); } function syncDeltaAck(Delta[] calldata _deltas) external whenNotPaused onlyRole(Role.MESSAGING) { colorInfo.syncDeltaAck(_deltas); } // @dev race condition may create a longer payload. so should quote with the buffer function quoteSyncDeltaFee( uint32 _dstEid, uint32 _numDeficits, bytes calldata _extraOptions, bool _useLzToken ) external view returns (uint nativeFee, uint lzTokenFee) { Delta[] memory deltas = new Delta[](_numDeficits + 1); return IMessaging(getRole(Role.MESSAGING)).quoteSyncDeltaFee(_dstEid, deltas, _extraOptions, _useLzToken); } /// @dev this function might have race condition. function _remint( uint32 _surplusColor, uint64 _surplusAmount, uint32[] calldata _deficits, uint64 _feeCap ) internal returns (uint64 minterRemintFee, Delta[] memory deltas) { if (_surplusColor == Colors.THETA) revert Colors.InvalidColor(Colors.THETA); uint64 totalSurplus; (totalSurplus, deltas) = colorInfo.extractDelta(_surplusColor, _surplusAmount, _deficits); if (totalSurplus == 0) revert Colors.InvalidAmount(); address operator = getRole(Role.OPERATOR); uint64 operatorRemintFee; (minterRemintFee, operatorRemintFee) = IOperator(operator).getRemintFees( msg.sender, _surplusColor, deltas, totalSurplus ); if (minterRemintFee + operatorRemintFee > _feeCap) revert FeeTooHigh(); // pay operator remint fee if (operatorRemintFee > 0) { _transfer(msg.sender, operator, operatorRemintFee); } } /// @dev return the configured color if set by the operator or address function _getColorer(address _user) internal view returns (address) { address colorer = colorers[_user]; if (colorer != address(0x0)) return colorer; return _user; } // ======================== Views Functions ======================== function colorStateOf(uint32 _color) public view returns (Colors.ColorState memory) { return colorInfo.colorStates[_color]; } function getRole(Role _role) public view returns (address) { return roles[_role]; } function getDeltas(uint32 _startColor, uint32 _endColor) external view returns (Delta[] memory) { return colorInfo.getDeltas(_startColor, _endColor); } function getDeltas(uint32[] calldata _colors) external view returns (Delta[] memory) { return colorInfo.getDeltas(_colors); } function maxKnownColor() external view returns (uint32) { return colorInfo.maxKnownColor; } // ======================== ERC20 Views Functions ======================== function token() external view returns (address) { return address(this); } function totalSupply() public view override(ERC20Upgradeable, IERC20Upgradeable) returns (uint) { return totalSupply_; } function decimals() public view virtual override returns (uint8) { return 6; } function balanceOf(address _user) public view override(ERC20Upgradeable, IERC20Upgradeable) returns (uint) { return userStates[_user].balance; } /** * @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: LZBL-1.1 // Copyright 2023 LayerZero Labs Ltd. // You may obtain a copy of the License at // https://github.com/LayerZero-Labs/license/blob/main/LICENSE-LZBL-1.1 pragma solidity ^0.8.0; import {Delta} from "./IUSDV.sol"; interface IOperator { function tryConsume(address _caller, uint64 _amount) external returns (uint64); function refill(address _caller, uint64 _extraTokens) external; function getSyncFees( address _caller, Delta[] calldata _deltas, uint64 _usdvAmount ) external returns (uint64 syncFee); function getRemintFees( address _caller, uint32 _toColor, Delta[] calldata _deltas, uint64 _usdvAmount ) external returns (uint64 minterRemintFee, uint64 operatorRemintFee); }
// SPDX-License-Identifier: LZBL-1.1 // Copyright 2023 LayerZero Labs Ltd. // You may obtain a copy of the License at // https://github.com/LayerZero-Labs/license/blob/main/LICENSE-LZBL-1.1 pragma solidity ^0.8.0; import "@layerzerolabs/lz-evm-oapp-v2/contracts/standards/oft/interfaces/IOFT.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; struct Delta { uint32 color; int64 amount; } struct State { uint32 color; uint64 balance; // config bool blacklisted; uint32 defaultColor; } enum Role { OWNER, OPERATOR, VAULT, MESSAGING, FOUNDATION } interface IUSDV is IOFT, IERC20Upgradeable { error Unauthorized(); error InvalidUser(); error InvalidArgument(); error NotImplemented(); error InsufficientBalance(); error Paused(); error Blacklisted(); error FeeTooHigh(); // role assigment event SetRole(Role role, address addr); event SetColorer(address indexed caller, address indexed user, address colorer); event SetDefaultColor(address indexed caller, address indexed user, uint32 defaultColor); // governance state event SetBlacklist(address indexed user, bool isBlacklisted); event SetPause(bool paused); // cross-chain events event Synced(bytes32 guid, Delta[] deltas); function mint(address _receiver, uint64 _amount, uint32 _color) external; function burn(address _from, uint64 _amount, uint32[] calldata _delta) external returns (Delta[] memory deltas); /// -------- coloring interfaces -------- function setColorer(address _user, address _colorer) external; function setDefaultColor(address _user, uint32 _defaultColor) external; /// -------- governance interfaces -------- function setPause(bool _pause) external; function setRole(Role _role, address _addr) external; /// -------- cross-chain interfaces (non-OFT) -------- function sendAck(bytes32 _guid, address _receiver, uint32 _color, uint64 _amount, uint64 _theta) external; function syncDelta( uint32 _dstEid, uint64 _theta, uint32[] calldata _deficits, uint64 _feeCap, bytes calldata _extraOptions, MessagingFee calldata _msgFee, address payable _refundAddress ) external payable returns (MessagingReceipt memory msgReceipt); function syncDeltaAck(Delta[] calldata _deltas) external; function quoteSyncDeltaFee( uint32 _dstEid, uint32 _numDeficits, bytes calldata _extraOptions, bool _useLzToken ) external view returns (uint nativeFee, uint lzTokenFee); function userStates( address _user ) external view returns (uint32 color, uint64 balance, bool blacklisted, uint32 defaultColor); }
// SPDX-License-Identifier: LZBL-1.1 // Copyright 2023 LayerZero Labs Ltd. // You may obtain a copy of the License at // https://github.com/LayerZero-Labs/license/blob/main/LICENSE-LZBL-1.1 pragma solidity ^0.8.0; import "./IUSDV.sol"; interface IUSDVMain is IUSDV { event Reminted(Delta[] deltas, uint64 remintFee); function remint(uint32 _surplusColor, uint64 _surplusAmount, uint32[] calldata _deficits, uint64 _feeCap) external; function remintAck(Delta[] calldata _deltas, uint32 _feeColor, uint64 _feeAmount, uint64 _feeTheta) external; }
// SPDX-License-Identifier: LZBL-1.1 // Copyright 2023 LayerZero Labs Ltd. // You may obtain a copy of the License at // https://github.com/LayerZero-Labs/license/blob/main/LICENSE-LZBL-1.1 pragma solidity ^0.8.0; import {Delta} from "../interfaces/IUSDV.sol"; library Colors { struct Info { uint32 maxKnownColor; // theta is not a known color mapping(uint32 color => ColorState) colorStates; } struct ColorState { uint64 colored; // restrict the overall token balance to be 1/2 * uint64.max int64 delta; int64 lastDelta; // delta checkpoint to prevent flashloan attack uint32 lastBlockNumber; // block number of the last checkpoint bool known; } error InvalidColor(uint32 color); error InvalidAmount(); error NotDeltaZero(); error Overflow(); event ColorMinted(uint32 indexed color, uint64 amount); event ColorBurnt(uint32 indexed color, uint64 amount); event ColorAdded(uint32 indexed color); event Recolored(uint32 indexed fromColor, uint32 indexed toColor, uint64 amount); uint32 internal constant NIL = 0; uint32 internal constant THETA = type(uint32).max; uint64 internal constant INT64_MAX = uint64(type(int64).max); function addColor(Info storage _self, uint32 _color) internal { if (_color >= THETA || _color == NIL) revert InvalidColor(_color); // new color, that is used on side chains mainly to check if the color is known and valid if (!_self.colorStates[_color].known) { _self.colorStates[_color].known = true; if (_color > _self.maxKnownColor) { _self.maxKnownColor = _color; } emit ColorAdded(_color); } } // ----- ALL FOLLOWING FUNCTIONS SHOULD BE DELTA-ZERO IF USED EXTERNALLY----- /// @dev recoloring is swapping the delta between the fromColor and toColor function recolor(Info storage _self, uint32 _fromColor, uint32 _toColor, uint64 _amount) internal { if (_amount == 0) return; if (_amount > INT64_MAX) revert Overflow(); int64 amountInt64 = int64(_amount); // handle from state ColorState memory fromState = _self.colorStates[_fromColor]; _decrDelta(fromState, amountInt64); if (_fromColor != THETA) fromState.colored -= _amount; _self.colorStates[_fromColor] = fromState; // handle to state ColorState memory toState = _self.colorStates[_toColor]; _decrDelta(toState, -amountInt64); if (_toColor != THETA) toState.colored += _amount; _self.colorStates[_toColor] = toState; emit Recolored(_fromColor, _toColor, _amount); } /// @dev used in both genesis mint() and cross-chain mint() /// @param _color to mint /// @param _amount to mint, can be zero (if only minting theta) /// @param _theta to recolor to color function mint(Info storage _self, uint32 _color, uint64 _amount, uint64 _theta) internal { if (_amount > INT64_MAX) revert Overflow(); addColor(_self, _color); _self.colorStates[_color].colored += _amount; // in cross-chain send() minting, need to recolor from theta to color to compensate the difference recolor(_self, THETA, _color, _theta); emit ColorMinted(_color, _amount); } /// @dev used only in cross-chain send() function send(Info storage _self, uint32 _color, uint64 _amount) internal returns (uint64 theta) { if (_amount == 0) revert InvalidAmount(); if (_amount > INT64_MAX) revert Overflow(); ColorState memory state = _self.colorStates[_color]; if (state.delta > 0) { // if delta is positive, burn from delta first // theta = min(delta, amount) uint64 delta = uint64(state.delta); // this casting is checked theta = delta >= _amount ? _amount : delta; } // only need to burn the amount - theta at the source chain uint64 minted = _amount - theta; if (minted > 0) { _burn(_self, _color, minted); } // recoloring color to theta recolor(_self, _color, THETA, theta); // recolor burntSurplus to theta } /// @dev deltas can include some surplus to mitigate the race condition /// @return used values all negative function burn( Info storage _self, uint32[] calldata _deficits, uint64 _amount, uint32 _color ) internal returns (Delta[] memory used) { if (_amount == 0) revert InvalidAmount(); if (_amount > INT64_MAX) revert Overflow(); _burn(_self, _color, _amount); uint64 burntSurplus; (burntSurplus, used) = extractDelta(_self, _color, _amount, _deficits); if (burntSurplus == 0) { used = new Delta[](1); // if not redeeming any surplus, then the list includes only the redeemed color and the amount used[0] = Delta(_color, -int64(_amount)); } else { // the first delta in the delta list is the surplus (+delta) of the redeemed color // we need to return negative minted to indicate how much was burnt // burnt amount = [amount - surplus], negating it becomes [surplus - amount] used[0].amount -= int64(_amount); } } /// @notice decrement and extract deltas given amount and deficit colors /// @dev used in sync()/remint()/redeem() /// @param _color with or without surplus /// @param _amount with or without surplus, if includes surplus, surplus will be extracted and used as target to find deficits /// @param _deficits colors sorted in ascending order, used greedily to find deltas summing to surplus /// @return totalSurplus totalSurplus extracted from _amount /// @return used first element positive surplus, following elements negative deficits function extractDelta( Info storage _self, uint32 _color, uint64 _amount, uint32[] calldata _deficits ) internal returns (uint64 totalSurplus, Delta[] memory used) { if (_amount > INT64_MAX) revert Overflow(); // 1. extract surplus from _amount int64 surplus = _clampDelta(_self, _color, int64(_amount)); if (surplus == 0) return (0, used); // redeem could have 0 surplus totalSurplus = uint64(surplus); // return the clamped value // insert the surplus into the head of the delta list used = new Delta[](_deficits.length + 1); used[0] = Delta(_color, surplus); uint idx = 1; // next index to insert used // 2. extract deficits based on hint from _deficits param, with -surplus as target sum int64 remainingDeficit = -surplus; // negate it for the use of _clampDelta() as the cap uint32 lastColor = 0; for (uint i = 0; i < _deficits.length; i++) { uint32 deficitColor = _deficits[i]; if ( deficitColor <= lastColor || // no duplicate deficitColor == THETA || // no theta deficitColor == _color // cant overlap with _color. in theory it wont but safer to check ) revert InvalidColor(deficitColor); // use the remainingDeficit as the target, maximally uses deficitColor int64 deficit = _clampDelta(_self, deficitColor, remainingDeficit); if (deficit < 0) { used[idx++] = Delta(deficitColor, deficit); remainingDeficit -= deficit; if (remainingDeficit == 0) { // change the length of the delta list to 'idx' assembly { mstore(used, idx) } return (totalSurplus, used); } } // update the color cursor lastColor = deficitColor; } revert NotDeltaZero(); } /// @notice strictly delta-zero. no surplus delta /// @dev used ONLY in syncDeltaAck(() at the destination chain /// @dev this function does not change the colored circulation function syncDeltaAck(Info storage _self, Delta[] calldata _deltas) internal { int64 totalDelta = 0; for (uint i = 0; i < _deltas.length; i++) { Delta calldata delta = _deltas[i]; if (delta.color != THETA) { addColor(_self, delta.color); } ColorState memory state = _self.colorStates[delta.color]; _decrDelta(state, -delta.amount); _self.colorStates[delta.color] = state; totalDelta += delta.amount; } // delta-zero invariant if (totalDelta != 0) revert NotDeltaZero(); } /// @dev compare two int64 and return the one with smaller absolute value /// @dev if the sign of the two int64 are different, return 0 function absMinOrZero(int64 _a, int64 _b) internal pure returns (int64) { if (_a == 0 || _b == 0) return 0; int64 sign = _a ^ _b; if (sign < 0) return 0; if (_a > 0) { return _a < _b ? _a : _b; } else { return _a > _b ? _a : _b; } } // ==================== View ==================== /// @dev returns deltas of known colors in range [_startColor, _endColor) and theta // @dev if endIdx == 0, set endIdx = maxKnownColor function getDeltas( Info storage _self, uint32 _startColor, uint32 _endColor ) internal view returns (Delta[] memory deltas) { _endColor = _endColor == 0 ? _self.maxKnownColor + 1 : _endColor; uint32 index = 0; deltas = new Delta[](_endColor - _startColor + 1); // +1 for theta for (uint32 i = _startColor; i < _endColor; i++) { if (_self.colorStates[i].known) { deltas[index++] = Delta(i, _self.colorStates[i].delta); } } deltas[index++] = Delta(THETA, _self.colorStates[THETA].delta); assembly { mstore(deltas, index) } } /// @param _colors in ascending order function getDeltas(Info storage _self, uint32[] calldata _colors) internal view returns (Delta[] memory deltas) { deltas = new Delta[](_colors.length); uint32 lastColor = 0; uint32 index = 0; for (uint i = 0; i < _colors.length; i++) { uint32 color = _colors[i]; if (color <= lastColor) revert InvalidColor(color); if (color == THETA) { deltas[index++] = Delta(THETA, _self.colorStates[THETA].delta); } else if (_self.colorStates[color].known) { deltas[index++] = Delta(color, _self.colorStates[color].delta); } lastColor = color; } assembly { mstore(deltas, index) } } // ==================== Non-Delta Zero ==================== /// @notice clamp delta by delta budget /// @dev _target and color delta should be of the same sign, function returns 0 if they are not /// @dev used by sync and remint /// @param _color of delta to update /// @param _deltaTarget in surplus or deficit /// @return delta of surplus/deficit deducted function _clampDelta(Info storage _self, uint32 _color, int64 _deltaTarget) internal returns (int64 delta) { ColorState memory state = _self.colorStates[_color]; // don't need to check known here, as state will have no delta if it is unknown // 1. clamp by min(state.delta, state.lastDelta) // prevent flash loan. int64 deltaBudget = state.delta; // also skip if the delta == last delta if (state.lastBlockNumber == block.number && deltaBudget != state.lastDelta) { deltaBudget = absMinOrZero(deltaBudget, state.lastDelta); if (deltaBudget == 0) return 0; } delta = absMinOrZero(deltaBudget, _deltaTarget); if (delta == 0) return 0; _decrDelta(state, delta); _self.colorStates[_color] = state; } /// @dev update lastBlockNumber and lastDelta before changing delta function _decrDelta(ColorState memory state, int64 _loss) private view { if (block.number != state.lastBlockNumber) { state.lastBlockNumber = uint32(block.number); state.lastDelta = state.delta; } state.delta -= _loss; } function _burn(Info storage _self, uint32 _color, uint64 _amount) private { _self.colorStates[_color].colored -= _amount; emit ColorBurnt(_color, _amount); } }
// SPDX-License-Identifier: LZBL-1.1 // Copyright 2023 LayerZero Labs Ltd. // You may obtain a copy of the License at // https://github.com/LayerZero-Labs/license/blob/main/LICENSE-LZBL-1.1 pragma solidity ^0.8.0; import {Delta} from "../../usdv/interfaces/IUSDV.sol"; import "../libs/Asset.sol"; enum Role { OWNER, OPERATOR, FOUNDATION, LIQUIDITY_PROVIDER, DONOR } interface IVaultManager { error InvalidAmount(); error NotDeltaZero(); error WrongSign(); error InvalidArgument(); error InvalidColor(uint32 color); error ColorPaused(); error Unauthorized(); event DistributedReward(address[] token, uint[] amounts); event Minted(address indexed receiver, uint32 indexed color, uint64 amount, bytes32 memo); event Redeemed(address indexed redeemer, uint64 amount); event PendingRemint(Delta[] deltas); event WithdrewReward(address caller, address receiver, uint32 color, uint64 rewards); event WithdrewFees(address caller, address receiver, uint64 fees); event RegisteredAsset(address asset); event EnabledAsset(bool enabled); event SetRole(Role role, address addr); event SetFeeBpsCap(Role role, uint16 cap); event SetFeeBps(Role role, uint16 bps); event SetRateLimiter(address limiter); event PausedColor(uint32 color, bool paused); event SetMinter(address minter, uint32 color); function assetInfoOf( address _token ) external view returns (bool enabled, uint usdvToTokenRate, uint collateralized); function mint(address _token, address _receiver, uint64 _amount, uint32 _color, bytes32 _memo) external; function remint(Delta[] calldata _deltas, uint64 _remintFee) external; function redeem( address _token, address _receiver, uint64 _amount, uint64 _minAmount, uint32[] calldata _deficits ) external returns (uint amountAfterFee); function redeemOut(address _token, uint64 _amount) external view returns (uint); }
// SPDX-License-Identifier: LZBL-1.1 // Copyright 2023 LayerZero Labs Ltd. // You may obtain a copy of the License at // https://github.com/LayerZero-Labs/license/blob/main/LICENSE-LZBL-1.1 pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Governance} from "./Governance.sol"; library Asset { using SafeERC20 for IERC20; using Governance for Governance.Info; struct Info { IERC20 token; bool registered; bool enabled; // to allow minting uint usdvToTokenRate; // all the following values are in token amount uint collateralized; } error TokenDecimalInvalid(uint provided, uint min); error Disabled(); error AlreadyRegistered(); error SlippageTooHigh(); error NotRegistered(); modifier onlyRegistered(Info storage _self) { if (!_self.registered) revert NotRegistered(); _; } function initialize(Info storage _self, address _token, uint8 _shareDecimals) internal { if (_self.registered) revert AlreadyRegistered(); // set token _self.token = IERC20(_token); _self.enabled = true; _self.registered = true; // set conversion rate uint8 tokenDecimals = IERC20Metadata(_token).decimals(); if (_shareDecimals > tokenDecimals) { revert TokenDecimalInvalid(tokenDecimals, _shareDecimals); } _self.usdvToTokenRate = 10 ** (tokenDecimals - _shareDecimals); } // @dev if _newFund is true, _from must approve the token transfer // @dev if internal mint such as turning yield into collateral, _newFund should be false function credit(Info storage _self, address _from, uint64 _usdvAmount, bool _newFund) internal { // assert the asset is enabled if (!_self.enabled) revert Disabled(); uint tokenAmount = _usdv2Token(_self, _usdvAmount); _self.collateralized += tokenAmount; if (_newFund) { _self.token.safeTransferFrom(_from, address(this), tokenAmount); } } function redeem( Info storage _self, Governance.Info storage _govInfo, address _receiver, uint64 _usdvAmount, uint64 _minUsdvAmount ) internal onlyRegistered(_self) returns (uint amountAfterFee) { uint tokenAmount = _usdv2Token(_self, _usdvAmount); _self.collateralized -= tokenAmount; // pay redemption fee amountAfterFee = _govInfo.payRedemptionFee(_self.token, tokenAmount); if (amountAfterFee < _usdv2Token(_self, _minUsdvAmount)) revert SlippageTooHigh(); // transfer collateral to receiver _self.token.safeTransfer(_receiver, amountAfterFee); } function setEnabled(Info storage _self, bool _enabled) internal onlyRegistered(_self) { _self.enabled = _enabled; } // ========================= View ========================= /// @return reward in usdv function distributable(Info storage _self) internal view returns (uint) { uint rebasedFunds = _self.token.balanceOf(address(this)) - _self.collateralized; return rebasedFunds / _self.usdvToTokenRate; } function redeemOutput( Info storage _self, Governance.Info storage _govInfo, uint64 _shares ) internal view returns (uint) { uint tokenAmount = _usdv2Token(_self, _shares); return tokenAmount - _govInfo.getRedemptionFee(tokenAmount); } // ========================= Internal ========================= function _usdv2Token(Info storage _self, uint64 _shares) private view returns (uint) { return _shares * _self.usdvToTokenRate; } }
// SPDX-License-Identifier: LZBL-1.1 // Copyright 2023 LayerZero Labs Ltd. // You may obtain a copy of the License at // https://github.com/LayerZero-Labs/license/blob/main/LICENSE-LZBL-1.1 pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Role} from "../interfaces/IVaultManager.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; library Governance { using SafeERC20 for IERC20; uint16 internal constant ONE_HUNDRED_PERCENT = 10000; // 100% uint16 internal constant RESERVE_FEE_BPS_CAP = 300; // 3% // A % fee is applicable on yield distribution for the vault service. uint16 internal constant REDEMPTION_FEE_BPS_CAP_MIN = 10; //0.1% struct Fee { uint16 bps; uint16 cap; } struct Info { mapping(Role => Fee) fees; mapping(Role => address) roles; uint operatorLastPing; // timestamp } event PaidRedemptionFee(address indexed to, uint amount); // ========================= Operator ========================= function ping(Info storage _self) internal { _self.operatorLastPing = block.timestamp; } // ========================= Fees ========================= function getRedemptionFee(Info storage _self, uint _amount) internal view returns (uint fee) { return (_amount * _self.fees[Role.FOUNDATION].bps) / ONE_HUNDRED_PERCENT; } function payRedemptionFee(Info storage _self, IERC20 _token, uint _amount) internal returns (uint) { uint fee = getRedemptionFee(_self, _amount); // pay redemption fee to operator address _to = _self.roles[Role.OPERATOR]; _token.safeTransfer(_to, fee); emit PaidRedemptionFee(_to, fee); return _amount - fee; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; abstract contract Proxied { /// @notice to be used by initialisation / postUpgrade function so that only the proxy's admin can execute them /// It also allows these functions to be called inside a contructor /// even if the contract is meant to be used without proxy modifier proxied() { address proxyAdminAddress = _proxyAdmin(); // With hardhat-deploy proxies // the proxyAdminAddress is zero only for the implementation contract // if the implementation contract want to be used as a standalone/immutable contract // it simply has to execute the `proxied` function // This ensure the proxyAdminAddress is never zero post deployment // And allow you to keep the same code for both proxied contract and immutable contract if (proxyAdminAddress == address(0)) { // ensure can not be called twice when used outside of proxy : no admin // solhint-disable-next-line security/no-inline-assembly assembly { sstore( 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ) } } else { require(msg.sender == proxyAdminAddress); } _; } modifier onlyProxyAdmin() { require(msg.sender == _proxyAdmin(), "NOT_AUTHORIZED"); _; } function _proxyAdmin() internal view returns (address ownerAddress) { // solhint-disable-next-line security/no-inline-assembly assembly { ownerAddress := sload(0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103) } } }
{ "evmVersion": "paris", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 5000 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"uint256","name":"_amountLDSend","type":"uint256"},{"internalType":"uint256","name":"_minAmountLD","type":"uint256"}],"name":"AmountSlippage","type":"error"},{"inputs":[],"name":"Blacklisted","type":"error"},{"inputs":[],"name":"FeeTooHigh","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidArgument","type":"error"},{"inputs":[{"internalType":"uint32","name":"color","type":"uint32"}],"name":"InvalidColor","type":"error"},{"inputs":[],"name":"InvalidUser","type":"error"},{"inputs":[],"name":"LDMinusSD","type":"error"},{"inputs":[],"name":"NotDeltaZero","type":"error"},{"inputs":[],"name":"NotImplemented","type":"error"},{"inputs":[],"name":"Overflow","type":"error"},{"inputs":[],"name":"Paused","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_guid","type":"bytes32"},{"indexed":true,"internalType":"address","name":"_toAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amountLD","type":"uint256"}],"name":"ReceiveOFT","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint32","name":"color","type":"uint32"},{"internalType":"int64","name":"amount","type":"int64"}],"indexed":false,"internalType":"struct Delta[]","name":"deltas","type":"tuple[]"},{"indexed":false,"internalType":"uint64","name":"remintFee","type":"uint64"}],"name":"Reminted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_guid","type":"bytes32"},{"indexed":true,"internalType":"address","name":"_fromAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amountLD","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"_composeMsg","type":"bytes"}],"name":"SendOFT","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"bool","name":"isBlacklisted","type":"bool"}],"name":"SetBlacklist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"colorer","type":"address"}],"name":"SetColorer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint32","name":"defaultColor","type":"uint32"}],"name":"SetDefaultColor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_inspector","type":"address"}],"name":"SetInspector","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"paused","type":"bool"}],"name":"SetPause","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"enum Role","name":"role","type":"uint8"},{"indexed":false,"internalType":"address","name":"addr","type":"address"}],"name":"SetRole","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"guid","type":"bytes32"},{"components":[{"internalType":"uint32","name":"color","type":"uint32"},{"internalType":"int64","name":"amount","type":"int64"}],"indexed":false,"internalType":"struct Delta[]","name":"deltas","type":"tuple[]"}],"name":"Synced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"bool","name":"_isBlacklisted","type":"bool"}],"name":"blacklist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint64","name":"_amount","type":"uint64"},{"internalType":"uint32[]","name":"_deficits","type":"uint32[]"}],"name":"burn","outputs":[{"components":[{"internalType":"uint32","name":"color","type":"uint32"},{"internalType":"int64","name":"amount","type":"int64"}],"internalType":"struct Delta[]","name":"","type":"tuple[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_color","type":"uint32"}],"name":"colorStateOf","outputs":[{"components":[{"internalType":"uint64","name":"colored","type":"uint64"},{"internalType":"int64","name":"delta","type":"int64"},{"internalType":"int64","name":"lastDelta","type":"int64"},{"internalType":"uint32","name":"lastBlockNumber","type":"uint32"},{"internalType":"bool","name":"known","type":"bool"}],"internalType":"struct Colors.ColorState","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"colorers","outputs":[{"internalType":"address","name":"colorer","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_startColor","type":"uint32"},{"internalType":"uint32","name":"_endColor","type":"uint32"}],"name":"getDeltas","outputs":[{"components":[{"internalType":"uint32","name":"color","type":"uint32"},{"internalType":"int64","name":"amount","type":"int64"}],"internalType":"struct Delta[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32[]","name":"_colors","type":"uint32[]"}],"name":"getDeltas","outputs":[{"components":[{"internalType":"uint32","name":"color","type":"uint32"},{"internalType":"int64","name":"amount","type":"int64"}],"internalType":"struct Delta[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum Role","name":"_role","type":"uint8"}],"name":"getRole","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_foundation","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxKnownColor","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint64","name":"_amount","type":"uint64"},{"internalType":"uint32","name":"_color","type":"uint32"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"to","type":"bytes32"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"uint256","name":"minAmountLD","type":"uint256"},{"internalType":"uint32","name":"dstEid","type":"uint32"}],"internalType":"struct IOFT.SendParam","name":"_param","type":"tuple"},{"internalType":"bytes","name":"_extraOptions","type":"bytes"},{"internalType":"bool","name":"_useLZToken","type":"bool"},{"internalType":"bytes","name":"_composeMsg","type":"bytes"}],"name":"quoteSendFee","outputs":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"internalType":"uint32","name":"_numDeficits","type":"uint32"},{"internalType":"bytes","name":"_extraOptions","type":"bytes"},{"internalType":"bool","name":"_useLzToken","type":"bool"}],"name":"quoteSyncDeltaFee","outputs":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_surplusColor","type":"uint32"},{"internalType":"uint64","name":"_surplusAmount","type":"uint64"},{"internalType":"uint32[]","name":"_deficits","type":"uint32[]"},{"internalType":"uint64","name":"_feeCap","type":"uint64"}],"name":"remint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"color","type":"uint32"},{"internalType":"int64","name":"amount","type":"int64"}],"internalType":"struct Delta[]","name":"_deltas","type":"tuple[]"},{"internalType":"uint32","name":"_feeColor","type":"uint32"},{"internalType":"uint64","name":"_feeAmount","type":"uint64"},{"internalType":"uint64","name":"_feeTheta","type":"uint64"}],"name":"remintAck","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"to","type":"bytes32"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"uint256","name":"minAmountLD","type":"uint256"},{"internalType":"uint32","name":"dstEid","type":"uint32"}],"internalType":"struct IOFT.SendParam","name":"_param","type":"tuple"},{"internalType":"bytes","name":"_extraOptions","type":"bytes"},{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"_msgFee","type":"tuple"},{"internalType":"address payable","name":"_refundAddress","type":"address"},{"internalType":"bytes","name":"_composeMsg","type":"bytes"}],"name":"send","outputs":[{"components":[{"internalType":"bytes32","name":"guid","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"fee","type":"tuple"}],"internalType":"struct MessagingReceipt","name":"msgReceipt","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_guid","type":"bytes32"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint32","name":"_color","type":"uint32"},{"internalType":"uint64","name":"_amount","type":"uint64"},{"internalType":"uint64","name":"_theta","type":"uint64"}],"name":"sendAck","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_colorer","type":"address"}],"name":"setColorer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32","name":"_defaultColor","type":"uint32"}],"name":"setDefaultColor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum Role","name":"_role","type":"uint8"},{"internalType":"address","name":"_addr","type":"address"}],"name":"setRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"uint64","name":"_theta","type":"uint64"},{"internalType":"uint32[]","name":"_deficits","type":"uint32[]"},{"internalType":"uint64","name":"_feeCap","type":"uint64"},{"internalType":"bytes","name":"_extraOptions","type":"bytes"},{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"_msgFee","type":"tuple"},{"internalType":"address payable","name":"_refundAddress","type":"address"}],"name":"syncDelta","outputs":[{"components":[{"internalType":"bytes32","name":"guid","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"fee","type":"tuple"}],"internalType":"struct MessagingReceipt","name":"msgReceipt","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"color","type":"uint32"},{"internalType":"int64","name":"amount","type":"int64"}],"internalType":"struct Delta[]","name":"_deltas","type":"tuple[]"}],"name":"syncDeltaAck","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"userStates","outputs":[{"internalType":"uint32","name":"color","type":"uint32"},{"internalType":"uint64","name":"balance","type":"uint64"},{"internalType":"bool","name":"blacklisted","type":"bool"},{"internalType":"uint32","name":"defaultColor","type":"uint32"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50615f7080620000216000396000f3fe6080604052600436106102bb5760003560e01c80636288a66c1161016e578063a9059cbb116100cb578063dd62ed3e1161007f578063e7e46ab811610064578063e7e46ab8146109d1578063f2e12a39146109f1578063fc0c546a14610a1157600080fd5b8063dd62ed3e1461096b578063e71b81e3146109b157600080fd5b8063c07f7c44116100b0578063c07f7c441461090b578063cd2a04fd1461092b578063d505accf1461094b57600080fd5b8063a9059cbb146108cb578063bedb86fb146108eb57600080fd5b80637ecebe001161012257806395d89b411161010757806395d89b411461076a5780639a7609291461077f578063a457c2d7146108ab57600080fd5b80637ecebe001461072257806384b0196e1461074257600080fd5b8063698b933e11610153578063698b933e1461069a57806370a08231146106ba57806375c2f5751461070257600080fd5b80636288a66c1461065557806368c5cad61461067557600080fd5b80633644e5151161021c5780634f3e1c55116101d05780635ae0d1af116101b55780635ae0d1af146105ef5780635c975abb1461060f5780635e8282c61461063557600080fd5b80634f3e1c55146105bc578063543ab3c7146105dc57600080fd5b80633950935111610201578063395093511461055a578063404e51291461057a578063485cc9551461059c57600080fd5b80633644e515146105255780633708da431461053a57600080fd5b806318160ddd1161027357806323b872dd1161025857806323b872dd1461049b5780632aa854c5146104bb578063313ce5671461050957600080fd5b806318160ddd1461043d57806318cda9181461046657600080fd5b8063095ea7b3116102a4578063095ea7b3146103375780630ecc535f146103675780631746d3011461041057600080fd5b806306fdde03146102c057806307abceb7146102eb575b600080fd5b3480156102cc57600080fd5b506102d5610a24565b6040516102e29190614d1d565b60405180910390f35b6102fe6102f9366004614db2565b610ab6565b604080518251815260208084015167ffffffffffffffff16818301529282015180519282019290925291015160608201526080016102e2565b34801561034357600080fd5b50610357610352366004614e5f565b610c71565b60405190151581526020016102e2565b34801561037357600080fd5b506103d6610382366004614e8b565b60d06020526000908152604090205463ffffffff8082169167ffffffffffffffff6401000000008204169160ff6c01000000000000000000000000830416916d010000000000000000000000000090041684565b6040805163ffffffff958616815267ffffffffffffffff9094166020850152911515918301919091529190911660608201526080016102e2565b34801561041c57600080fd5b5061043061042b366004614ec1565b610c8b565b6040516102e29190614f43565b34801561044957600080fd5b5060cc5467ffffffffffffffff165b6040519081526020016102e2565b34801561047257600080fd5b50610486610481366004614f66565b610ca0565b604080519283526020830191909152016102e2565b3480156104a757600080fd5b506103576104b6366004614fdc565b610da2565b3480156104c757600080fd5b506104f16104d6366004614e8b565b60d1602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016102e2565b34801561051557600080fd5b50604051600681526020016102e2565b34801561053157600080fd5b50610458610dc6565b34801561054657600080fd5b50610430610555366004615078565b610dd5565b34801561056657600080fd5b50610357610575366004614e5f565b610e6a565b34801561058657600080fd5b5061059a6105953660046150dd565b610ea9565b005b3480156105a857600080fd5b5061059a6105b7366004615109565b610f78565b3480156105c857600080fd5b5061059a6105d7366004615142565b611178565b6102fe6105ea366004615160565b6113ff565b3480156105fb57600080fd5b5061059a61060a366004615273565b611663565b34801561061b57600080fd5b5060cc546103579068010000000000000000900460ff1681565b34801561064157600080fd5b5061059a610650366004615109565b6116df565b34801561066157600080fd5b506104f16106703660046152c4565b6117b1565b34801561068157600080fd5b5060ce5460405163ffffffff90911681526020016102e2565b3480156106a657600080fd5b5061059a6106b53660046152df565b6117fa565b3480156106c657600080fd5b506104586106d5366004614e8b565b6001600160a01b0316600090815260d06020526040902054640100000000900467ffffffffffffffff1690565b34801561070e57600080fd5b5061059a61071d36600461535b565b61194e565b34801561072e57600080fd5b5061045861073d366004614e8b565b611a17565b34801561074e57600080fd5b50610757611a35565b6040516102e297969594939291906153b3565b34801561077657600080fd5b506102d5611af7565b34801561078b57600080fd5b5061085161079a366004615465565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101919091525063ffffffff908116600090815260cf6020908152604091829020825160a081018452905467ffffffffffffffff81168252680100000000000000008104600790810b93830193909352700100000000000000000000000000000000810490920b92810192909252600160c01b81049092166060820152600160e01b90910460ff161515608082015290565b6040516102e29190600060a08201905067ffffffffffffffff8351168252602083015160070b6020830152604083015160070b604083015263ffffffff606084015116606083015260808301511515608083015292915050565b3480156108b757600080fd5b506103576108c6366004614e5f565b611b06565b3480156108d757600080fd5b506103576108e6366004614e5f565b611bb0565b3480156108f757600080fd5b5061059a610906366004615480565b611bbe565b34801561091757600080fd5b5061048661092636600461549b565b611c72565b34801561093757600080fd5b5061059a610946366004615530565b611d35565b34801561095757600080fd5b5061059a61096636600461559d565b611e69565b34801561097757600080fd5b50610458610986366004615109565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b3480156109bd57600080fd5b506104306109cc366004615614565b611fcd565b3480156109dd57600080fd5b5061059a6109ec36600461564a565b611fdb565b3480156109fd57600080fd5b5061059a610a0c366004615691565b61205f565b348015610a1d57600080fd5b50306104f1565b606060368054610a33906156ad565b80601f0160208091040260200160405190810160405280929190818152602001828054610a5f906156ad565b8015610aac5780601f10610a8157610100808354040283529160200191610aac565b820191906000526020600020905b815481529060010190602001808311610a8f57829003601f168201915b5050505050905090565b610abe614c8f565b60cc5468010000000000000000900460ff1615610aee576040516313d0ff5960e31b815260040160405180910390fd5b8735610b26576040517fa9cb9e0d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610b35896020013561214c565b9050600080610b43836121d0565b9150915060006040518060a001604052808d6060016020810190610b679190615465565b63ffffffff90811682528e3560208301528516604082015267ffffffffffffffff808716606083015284166080909101529050610ba460036117b1565b6001600160a01b03166318d6b43a34838e8e8e8e8e8e6040518963ffffffff1660e01b8152600401610bdc9796959493929190615725565b60806040518083038185885af1158015610bfa573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610c1f91906157f7565b805160405191965033917f9ae5a085fcdd3a841fd4b8e8f114073db75391319202e87af5e7fe2fd6889cd890610c5a9088908c908c906158b4565b60405180910390a350505050979650505050505050565b600033610c7f8185856122d6565b60019150505b92915050565b6060610c9960ce8484612426565b9392505050565b60008080610caf876001615910565b63ffffffff1667ffffffffffffffff811115610ccd57610ccd6157c8565b604051908082528060200260200182016040528015610d1257816020015b6040805180820190915260008082526020820152815260200190600190039081610ceb5790505b509050610d1f60036117b1565b6001600160a01b03166344d9c50789838989896040518663ffffffff1660e01b8152600401610d5295949392919061592d565b6040805180830381865afa158015610d6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d929190615974565b92509250505b9550959350505050565b600033610db08582856125f6565b610dbb858585612666565b506001949350505050565b6000610dd0612710565b905090565b60cc5460609068010000000000000000900460ff1615610e08576040516313d0ff5960e31b815260040160405180910390fd5b6002610e13816117b1565b6001600160a01b0316336001600160a01b031614610e43576040516282b42960e81b815260040160405180910390fd5b6000610e4f878761271a565b9050610e5f60ce868689856127cf565b979650505050505050565b3360008181526034602090815260408083206001600160a01b0387168452909152812054909190610c7f9082908690610ea4908790615998565b6122d6565b6004610eb4816117b1565b6001600160a01b0316336001600160a01b031614610ee4576040516282b42960e81b815260040160405180910390fd5b6001600160a01b038316600081815260d060205260409081902080548515156c01000000000000000000000000027fffffffffffffffffffffffffffffffffffffff00ffffffffffffffffffffffff909116179055517ffed07c88bd5d31bfd0ce77ed7ffdc74a163a61cfc5edcec801e3a7954e33d6e790610f6b90851515815260200190565b60405180910390a2505050565b6000610fa27fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b90506001600160a01b038116610fe1576001600160a01b037fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355610ff6565b336001600160a01b03821614610ff657600080fd5b600054610100900460ff16158080156110165750600054600160ff909116105b806110305750303b158015611030575060005460ff166001145b6110a75760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561110557600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b61110f8484612956565b801561117257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b61118182612b07565b6001600160a01b0316336001600160a01b0316141580156111bd57506111a760016117b1565b6001600160a01b0316336001600160a01b031614155b156111da576040516282b42960e81b815260040160405180910390fd5b6001600160a01b038216600090815260d060209081526040918290208251608081018452905463ffffffff8082168352640100000000820467ffffffffffffffff16938301939093526c01000000000000000000000000900460ff16151592810192909252821660608201819052156112d15760ce5463ffffffff908116908316111561129b576040517fe310af2200000000000000000000000000000000000000000000000000000000815263ffffffff8316600482015260240161109e565b8163ffffffff16816000015163ffffffff16146112d157805160208201516112c79160ce918590612b37565b63ffffffff821681525b6001600160a01b038316600081815260d06020908152604091829020845181549286015184870151606088015163ffffffff9081166d0100000000000000000000000000027fffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffffff9215156c0100000000000000000000000002929092167fffffffffffffffffffffffffffffff0000000000ffffffffffffffffffffffff67ffffffffffffffff909416640100000000027fffffffffffffffffffffffffffffffffffffffff00000000000000000000000090971691909416179490941716179190911790555133907fe4aecbadc43072e0b1df5edd735f0359b389b0138fde0f0e7703924cd8aacf43906113f290869063ffffffff91909116815260200190565b60405180910390a3505050565b611407614c8f565b60cc5468010000000000000000900460ff1615611437576040516313d0ff5960e31b815260040160405180910390fd5b60008061144e60ce63ffffffff8d8d8d612f4c8416565b915091508167ffffffffffffffff16600003611496576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006114a260016117b1565b90506000816001600160a01b03166389e5cfdc3385876040518463ffffffff1660e01b81526004016114d6939291906159ab565b6020604051808303816000875af11580156114f5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151991906159e7565b905067ffffffffffffffff81161561158e578967ffffffffffffffff168167ffffffffffffffff161115611579576040517fcd4e616700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61158e33838367ffffffffffffffff16612666565b8d61159960036117b1565b6001600160a01b031663564991453483878e8e8e8e6040518863ffffffff1660e01b81526004016115cf96959493929190615a04565b60806040518083038185885af11580156115ed573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061161291906157f7565b95507f0592f6297549007244c93f321fd1e211a37a640783e4fc2a9960e30758b2ae4e866000015185604051611649929190615a6a565b60405180910390a150505050509998505050505050505050565b60cc5468010000000000000000900460ff1615611693576040516313d0ff5960e31b815260040160405180910390fd5b600361169e816117b1565b6001600160a01b0316336001600160a01b0316146116ce576040516282b42960e81b815260040160405180910390fd5b6116da60ce84846131f5565b505050565b336001600160a01b0383161480159061171357506116fd60016117b1565b6001600160a01b0316336001600160a01b031614155b15611730576040516282b42960e81b815260040160405180910390fd5b6001600160a01b03828116600081815260d1602090815260409182902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001694861694851790559051928352909133917ffde4ca3ca044bff553b751429dbfacecaab2484c2408dcc9a000be9abefb9a69910160405180910390a35050565b600060cd60008360048111156117c9576117c9615a8b565b60048111156117da576117da615a8b565b81526020810191909152604001600020546001600160a01b031692915050565b60cc5468010000000000000000900460ff161561182a576040516313d0ff5960e31b815260040160405180910390fd5b6003611835816117b1565b6001600160a01b0316336001600160a01b031614611865576040516282b42960e81b815260040160405180910390fd5b600061187160026117b1565b905067ffffffffffffffff84161561188f5761188f8186868661349c565b6040517f1dd2a73b0000000000000000000000000000000000000000000000000000000081526001600160a01b03821690631dd2a73b906118d8908a908a908990600401615acc565b600060405180830381600087803b1580156118f257600080fd5b505af1158015611906573d6000803e3d6000fd5b505050507f05da80fdd93a61677cae6bc9b9d749bd763c539ab2055ba2310b25a5b625561687878660405161193d93929190615acc565b60405180910390a150505050505050565b60cc5468010000000000000000900460ff161561197e576040516313d0ff5960e31b815260040160405180910390fd5b6003611989816117b1565b6001600160a01b0316336001600160a01b0316146119b9576040516282b42960e81b815260040160405180910390fd5b6119c58585858561349c565b60405167ffffffffffffffff841681526001600160a01b0386169087907ffc1b5feb636aa495ed28914895ca443adffbd4e2da951d5694baa392b4ebd1589060200160405180910390a3505050505050565b6001600160a01b038116600090815260996020526040812054610c85565b6000606080600080600060606065546000801b148015611a555750606654155b611aa15760405162461bcd60e51b815260206004820152601560248201527f4549503731323a20556e696e697469616c697a65640000000000000000000000604482015260640161109e565b611aa961354f565b611ab161355e565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b606060378054610a33906156ad565b3360008181526034602090815260408083206001600160a01b038716845290915281205490919083811015611ba35760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f000000000000000000000000000000000000000000000000000000606482015260840161109e565b610dbb82868684036122d6565b600033610c7f818585612666565b6001611bc9816117b1565b6001600160a01b0316336001600160a01b031614611bf9576040516282b42960e81b815260040160405180910390fd5b60cc805483151568010000000000000000027fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff9091161790556040517f140eb9f8b591138e129e4caf389c92df4f0545b902523eee9e63153ecdb2026e90611c6690841515815260200190565b60405180910390a15050565b6003600090815260cd6020527f310c72720b1a4f557c4a5c3b412492f965bebddd685b67587bd0620a2d756da25481906001600160a01b031663314dfef5611cc060808b0160608c01615465565b89898989896040518763ffffffff1660e01b8152600401611ce696959493929190615b3d565b6040805180830381865afa158015611d02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d269190615974565b91509150965096945050505050565b60cc5468010000000000000000900460ff1615611d65576040516313d0ff5960e31b815260040160405180910390fd5b600080611d75878787878761356d565b915091506000611d8560026117b1565b905067ffffffffffffffff831615611dad57611dab818467ffffffffffffffff16611bb0565b505b6040517f1dd2a73b0000000000000000000000000000000000000000000000000000000081526001600160a01b03821690631dd2a73b90611df49085908790600401615b85565b600060405180830381600087803b158015611e0e57600080fd5b505af1158015611e22573d6000803e3d6000fd5b505050507f05da80fdd93a61677cae6bc9b9d749bd763c539ab2055ba2310b25a5b62556168284604051611e57929190615b85565b60405180910390a15050505050505050565b83421115611eb95760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e65000000604482015260640161109e565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888611ee88c613740565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000611f4382613768565b90506000611f53828787876137b0565b9050896001600160a01b0316816001600160a01b031614611fb65760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604482015260640161109e565b611fc18a8a8a6122d6565b50505050505050505050565b6060610c9960ce84846137ce565b60cc5468010000000000000000900460ff161561200b576040516313d0ff5960e31b815260040160405180910390fd5b6002612016816117b1565b6001600160a01b0316336001600160a01b031614612046576040516282b42960e81b815260040160405180910390fd5b61205460ce83856000613a00565b611172848484613b08565b612068826117b1565b6001600160a01b0316336001600160a01b0316141580156120a4575061208e60006117b1565b6001600160a01b0316336001600160a01b031614155b156120c1576040516282b42960e81b815260040160405180910390fd5b8060cd60008460048111156120d8576120d8615a8b565b60048111156120e9576120e9615a8b565b815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b031602179055507f5c22095cd1123887402a709a9698bc2961c12cb22eeb16e5d76480931f63ede08282604051611c66929190615bb1565b600067ffffffffffffffff8211156121cc5760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201527f3420626974730000000000000000000000000000000000000000000000000000606482015260840161109e565b5090565b6000808267ffffffffffffffff16600003612217576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61222160016117b1565b6040517f376829ab00000000000000000000000000000000000000000000000000000000815233600482015267ffffffffffffffff851660248201526001600160a01b03919091169063376829ab906044016020604051808303816000875af1158015612292573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122b691906159e7565b506122c1338461271a565b91506122cf60ce8385613bac565b9050915091565b6001600160a01b0383166123515760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840161109e565b6001600160a01b0382166123cd5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840161109e565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591016113f2565b606063ffffffff82161561243a578161244d565b835461244d9063ffffffff166001615910565b9150600061245b8484615c04565b612466906001615910565b63ffffffff1667ffffffffffffffff811115612484576124846157c8565b6040519080825280602002602001820160405280156124c957816020015b60408051808201909152600080825260208201528152602001906001900390816124a25790505b509150835b8363ffffffff168163ffffffff1610156125855763ffffffff81166000908152600187016020526040902054600160e01b900460ff16156125735760408051808201825263ffffffff831680825260009081526001890160209081529290205468010000000000000000900460070b91810191909152838361254f81615c21565b945063ffffffff168151811061256757612567615c44565b60200260200101819052505b8061257d81615c21565b9150506124ce565b5060408051808201825263ffffffff80825260009081526001880160209081529290205468010000000000000000900460070b9181019190915282826125ca81615c21565b935063ffffffff16815181106125e2576125e2615c44565b602090810291909101015281529392505050565b6001600160a01b038216600090815260d0602052604090205482906c01000000000000000000000000900460ff161561265b576040517f09550c7700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611172848484613d32565b60cc5468010000000000000000900460ff1615612696576040516313d0ff5960e31b815260040160405180910390fd5b60006126a18261214c565b905060006126af8583613dbe565b90506126bc848284613f42565b836001600160a01b0316856001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161270191815260200190565b60405180910390a35050505050565b6000610dd06141f8565b60006127268383613dbe565b60cc8054919250839160009061274790849067ffffffffffffffff16615c73565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060006001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516127c1919067ffffffffffffffff91909116815260200190565b60405180910390a392915050565b60608267ffffffffffffffff16600003612815576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b677fffffffffffffff67ffffffffffffffff84161115612861576040517f35278d1200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61286c86838561426c565b600061287b8784868989612f4c565b9250905067ffffffffffffffff81166000036129195760408051600180825281830190925290816020015b60408051808201909152600080825260208201528152602001906001900390816128a657905050915060405180604001604052808463ffffffff168152602001856128f090615c94565b60070b8152508260008151811061290957612909615c44565b602002602001018190525061294c565b838260008151811061292d5761292d615c44565b60200260200101516020018181516129459190615cd2565b60070b9052505b5095945050505050565b600054610100900460ff166129d35760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161109e565b612a476040518060400160405280600481526020017f55534456000000000000000000000000000000000000000000000000000000008152506040518060400160405280600481526020017f5553445600000000000000000000000000000000000000000000000000000000815250614309565b612abb6040518060400160405280600481526020017f55534456000000000000000000000000000000000000000000000000000000008152506040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525061439f565b612af96040518060400160405280600481526020017f5553445600000000000000000000000000000000000000000000000000000000815250614444565b612b0382826144c4565b5050565b6001600160a01b03808216600090815260d160205260408120549091168015612b305792915050565b5090919050565b67ffffffffffffffff81161561117257677fffffffffffffff67ffffffffffffffff82161115612b93576040517f35278d1200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63ffffffff8381166000908152600186016020908152604091829020825160a081018452905467ffffffffffffffff81168252680100000000000000008104600790810b93830193909352700100000000000000000000000000000000810490920b92810192909252600160c01b81049092166060820152600160e01b90910460ff16151560808201528190612c2981836145d1565b63ffffffff85811614612c56578281600001818151612c489190615c73565b67ffffffffffffffff169052505b63ffffffff858116600090815260018801602090815260408083208551815487850151888501516060808b01516080808d015167ffffffffffffffff9788167fffffffffffffffffffffffffffffffff0000000000000000000000000000000090971696909617680100000000000000009588168602177fffffffff000000000000000000000000ffffffffffffffffffffffffffffffff1670010000000000000000000000000000000094881685027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff1617600160c01b928d168302177fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b9615158702179097558e8b168a5298879020875160a08101895290549586168152928504600790810b9884019890985290840490960b948101949094529481049095169282019290925260ff9290930491909116151590820152612dc781612dc285615c94565b6145d1565b63ffffffff85811614612df4578381600001818151612de69190615d18565b67ffffffffffffffff169052505b63ffffffff858116600081815260018a01602090815260409182902085518154878401518886015160608a015160808b015167ffffffffffffffff9586167fffffffffffffffffffffffffffffffff00000000000000000000000000000000909516949094176801000000000000000093861693909302929092177fffffffff000000000000000000000000ffffffffffffffffffffffffffffffff16700100000000000000000000000000000000918516919091027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff1617600160c01b91891691909102177fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b91151591909102179091559151918816825291928916917ff7a8a1aaba5fdf151f99b4845a353a64b739bdf6b5eed27d53943121397b6f6a910160405180910390a350505050505050565b60006060677fffffffffffffff67ffffffffffffffff86161115612f9c576040517f35278d1200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612fa9888888614618565b90508060070b600003612fc0576000925050610d98565b915081612fce846001615998565b67ffffffffffffffff811115612fe657612fe66157c8565b60405190808252806020026020018201604052801561302b57816020015b60408051808201909152600080825260208201528152602001906001900390816130045790505b50915060405180604001604052808863ffffffff1681526020018260070b8152508260008151811061305f5761305f615c44565b60209081029190910101526001600061307783615c94565b90506000805b878110156131c257600089898381811061309957613099615c44565b90506020020160208101906130ae9190615465565b90508263ffffffff168163ffffffff161115806130d0575063ffffffff818116145b806130e657508b63ffffffff168163ffffffff16145b15613125576040517fe310af2200000000000000000000000000000000000000000000000000000000815263ffffffff8216600482015260240161109e565b60006131328e8387614618565b905060008160070b12156131ad5760405180604001604052808363ffffffff1681526020018260070b81525088878061316a90615d39565b98508151811061317c5761317c615c44565b60209081029190910101526131918186615cd2565b94508460070b6000036131ad5785885250505050505050610d98565b509150806131ba81615d39565b91505061307d565b506040517ffb71cfdc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805b8281101561345e573684848381811061321457613214615c44565b60400291909101915063ffffffff90506132316020830183615465565b63ffffffff1614613252576132528661324d6020840184615465565b614831565b600060018701816132666020850185615465565b63ffffffff90811682526020808301939093526040918201600020825160a081018452905467ffffffffffffffff81168252680100000000000000008104600790810b838701527001000000000000000000000000000000008204900b82850152600160c01b81049092166060820152600160e01b90910460ff161515608082015292506133089183916132ff91908601908601615d53565b612dc290615c94565b8060018801600061331c6020860186615465565b63ffffffff9081168252602080830193909352604091820160002084518154868601518786015160608901516080909901511515600160e01b027fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff99909616600160c01b027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff67ffffffffffffffff92831670010000000000000000000000000000000002167fffffffff000000000000000000000000ffffffffffffffffffffffffffffffff93831668010000000000000000027fffffffffffffffffffffffffffffffff00000000000000000000000000000000909516929095169190911792909217169190911717949094161790925561343d918401908401615d53565b6134479085615d6e565b93505050808061345690615d39565b9150506131f9565b508060070b600014611172576040517ffb71cfdc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6134a660016117b1565b6040517f31b99cf800000000000000000000000000000000000000000000000000000000815233600482015267ffffffffffffffff841660248201526001600160a01b0391909116906331b99cf890604401600060405180830381600087803b15801561351257600080fd5b505af1158015613526573d6000803e3d6000fd5b5050505061354483828461353a9190615c73565b60ce919084613a00565b611172848385613b08565b606060678054610a33906156ad565b606060688054610a33906156ad565b600060607fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000163ffffffff8816016135d6576040517fe310af2200000000000000000000000000000000000000000000000000000000815263ffffffff600482015260240161109e565b60006135e660ce89898989612f4c565b9250905067ffffffffffffffff811660000361362e576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061363a60016117b1565b90506000816001600160a01b0316632a29c222338c87876040518563ffffffff1660e01b81526004016136709493929190615db4565b60408051808303816000875af115801561368e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136b29190615dfd565b909550905067ffffffffffffffff86166136cc8287615d18565b67ffffffffffffffff16111561370e576040517fcd4e616700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff8116156137335761373333838367ffffffffffffffff16612666565b5050509550959350505050565b6001600160a01b03811660009081526099602052604090208054600181018255905b50919050565b6000610c85613775612710565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b60008060006137c187878787614962565b9150915061294c81614a26565b60608167ffffffffffffffff8111156137e9576137e96157c8565b60405190808252806020026020018201604052801561382e57816020015b60408051808201909152600080825260208201528152602001906001900390816138075790505b50905060008060005b848110156139f557600086868381811061385357613853615c44565b90506020020160208101906138689190615465565b90508363ffffffff168163ffffffff16116138b7576040517fe310af2200000000000000000000000000000000000000000000000000000000815263ffffffff8216600482015260240161109e565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000163ffffffff8216016139505760408051808201825263ffffffff808252600090815260018b0160209081529290205468010000000000000000900460070b91810191909152858461392881615c21565b955063ffffffff168151811061394057613940615c44565b60200260200101819052506139e1565b63ffffffff81166000908152600189016020526040902054600160e01b900460ff16156139e15760408051808201825263ffffffff8316808252600090815260018b0160209081529290205468010000000000000000900460070b9181019190915285846139bd81615c21565b955063ffffffff16815181106139d5576139d5615c44565b60200260200101819052505b9250806139ed81615d39565b915050613837565b508252509392505050565b677fffffffffffffff67ffffffffffffffff83161115613a4c576040517f35278d1200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613a568484614831565b63ffffffff8316600090815260018501602052604081208054849290613a8790849067ffffffffffffffff16615d18565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550613abd8463ffffffff8584612b37565b60405167ffffffffffffffff8316815263ffffffff8416907f8deb13badd22d3eef6ddd202585d140ee59c89dfc214751d4db8a50ef7ca775f9060200160405180910390a250505050565b613b13838284613f42565b60cc8054839190600090613b3290849067ffffffffffffffff16615d18565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550826001600160a01b031660006001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516113f2919067ffffffffffffffff91909116815260200190565b60008167ffffffffffffffff16600003613bf2576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b677fffffffffffffff67ffffffffffffffff83161115613c3e576040517f35278d1200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63ffffffff83811660009081526001860160209081526040808320815160a081018352905467ffffffffffffffff81168252680100000000000000008104600790810b9483018590527001000000000000000000000000000000008204900b92820192909252600160c01b82049094166060850152600160e01b900460ff16151560808401521315613cf057602081015167ffffffffffffffff8085169082161015613cea5780613cec565b835b9250505b6000613cfc8385615c73565b905067ffffffffffffffff811615613d1957613d1986868361426c565b613d29868663ffffffff86612b37565b50509392505050565b6001600160a01b0383811660009081526034602090815260408083209386168352929052205460001981146111725781811015613db15760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161109e565b61117284848484036122d6565b6001600160a01b038216600090815260d0602052604081205483906c01000000000000000000000000900460ff1615613e23576040517f09550c7700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038416613e63576040517ffd684c3b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038416600090815260d0602052604090205467ffffffffffffffff6401000000009091048116908416811015613ecc576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613ed68482615c73565b6001600160a01b038616600090815260d060205260409020805467ffffffffffffffff92909216640100000000027fffffffffffffffffffffffffffffffffffffffff0000000000000000ffffffff8316811790915563ffffffff9081169116179250505b5092915050565b6001600160a01b038316600090815260d0602052604090205483906c01000000000000000000000000900460ff1615613fa7576040517f09550c7700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038416613fe7576040517ffd684c3b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff821615611172576001600160a01b038416600090815260d060209081526040918290208251608081018452905463ffffffff80821680845267ffffffffffffffff6401000000008404169484019490945260ff6c010000000000000000000000008304161515948301949094526d0100000000000000000000000000900483166060820152918516146140ed57606081015160009063ffffffff161580156140af5750816020015167ffffffffffffffff168467ffffffffffffffff16115b905080156140da57815160208301516140cc9160ce918890612b37565b63ffffffff851682526140eb565b81516140eb9060ce90879087612b37565b505b82816020018181516140ff9190615d18565b67ffffffffffffffff9081169091526001600160a01b038716600090815260d0602090815260409182902085518154928701519387015160609097015163ffffffff9081166d0100000000000000000000000000027fffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffffff9815156c0100000000000000000000000002989098167fffffffffffffffffffffffffffffff0000000000ffffffffffffffffffffffff95909616640100000000027fffffffffffffffffffffffffffffffffffffffff000000000000000000000000909416911617919091179190911691909117929092179091555050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f614223614b8b565b61422b614be4565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b63ffffffff821660009081526001840160205260408120805483929061429d90849067ffffffffffffffff16615c73565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055508163ffffffff167f75945fa1de0a0428b95184192b3c8819207e55f2485d2f05af0f55d39d3c57d182604051610f6b919067ffffffffffffffff91909116815260200190565b600054610100900460ff166143865760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161109e565b60366143928382615e7a565b5060376116da8282615e7a565b600054610100900460ff1661441c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161109e565b60676144288382615e7a565b5060686144358282615e7a565b50506000606581905560665550565b600054610100900460ff166144c15760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161109e565b50565b600054610100900460ff166145415760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161109e565b60cd6020527ff21edf1b278093a327d2897733f77e05e09f26bebbea4dc9d85ae85d03ca4e8580546001600160a01b039283167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617909155600080527fcd565b10a72538d86f6d352f37ebc5dff31587960b12c0afe00fd03947a6932a8054939092169216919091179055565b816060015163ffffffff1643146145fc5763ffffffff43166060830152602082015160070b60408301525b808260200181815161460e9190615cd2565b60070b9052505050565b63ffffffff82811660009081526001850160209081526040808320815160a081018352905467ffffffffffffffff81168252680100000000000000008104600790810b9483018590527001000000000000000000000000000000008204900b92820192909252600160c01b820490941660608501819052600160e01b90910460ff1615156080850152919291431480156146bc5750816040015160070b8160070b14155b156146e7576146cf818360400151614c15565b90508060070b6000036146e757600092505050610c99565b6146f18185614c15565b92508260070b60000361470957600092505050610c99565b61471382846145d1565b5063ffffffff808516600090815260018701602090815260409182902084518154928601519386015160608701516080909701511515600160e01b027fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff97909616600160c01b027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff67ffffffffffffffff92831670010000000000000000000000000000000002167fffffffff000000000000000000000000ffffffffffffffffffffffffffffffff96831668010000000000000000027fffffffffffffffffffffffffffffffff00000000000000000000000000000000909616929093169190911793909317939093169290921717929092161790559392505050565b63ffffffff81811610158061484a575063ffffffff8116155b15614889576040517fe310af2200000000000000000000000000000000000000000000000000000000815263ffffffff8216600482015260240161109e565b63ffffffff81166000908152600183016020526040902054600160e01b900460ff16612b035763ffffffff8082166000818152600185016020526040902080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b1790558354909116101561492d5781547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001663ffffffff82161782555b60405163ffffffff8216907f5e6a67179496481d824a7314b1b05d10e27f204cb598b1a74f6ba235e86b738d90600090a25050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156149995750600090506003614a1d565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156149ed573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116614a1657600060019250925050614a1d565b9150600090505b94509492505050565b6000816004811115614a3a57614a3a615a8b565b03614a425750565b6001816004811115614a5657614a56615a8b565b03614aa35760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161109e565b6002816004811115614ab757614ab7615a8b565b03614b045760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161109e565b6003816004811115614b1857614b18615a8b565b036144c15760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f7565000000000000000000000000000000000000000000000000000000000000606482015260840161109e565b600080614b9661354f565b805190915015614bad578051602090910120919050565b6065548015614bbc5792915050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4709250505090565b600080614bef61355e565b805190915015614c06578051602090910120919050565b6066548015614bbc5792915050565b60008260070b60001480614c2c57508160070b6000145b15614c3957506000610c85565b8282186000600782900b1215614c53576000915050610c85565b60008460070b1315614c7c578260070b8460070b12614c725782614c74565b835b915050610c85565b8260070b8460070b13614c725782614c74565b604051806060016040528060008019168152602001600067ffffffffffffffff168152602001614cd2604051806040016040528060008152602001600081525090565b905290565b6000815180845260005b81811015614cfd57602081850181015186830182015201614ce1565b506000602082860101526020601f19601f83011685010191505092915050565b602081526000610c996020830184614cd7565b60006080828403121561376257600080fd5b60008083601f840112614d5457600080fd5b50813567ffffffffffffffff811115614d6c57600080fd5b602083019150836020828501011115614d8457600080fd5b9250929050565b60006040828403121561376257600080fd5b6001600160a01b03811681146144c157600080fd5b6000806000806000806000610120888a031215614dce57600080fd5b614dd88989614d30565b9650608088013567ffffffffffffffff80821115614df557600080fd5b614e018b838c01614d42565b9098509650869150614e168b60a08c01614d8b565b955060e08a01359150614e2882614d9d565b9093506101008901359080821115614e3f57600080fd5b50614e4c8a828b01614d42565b989b979a50959850939692959293505050565b60008060408385031215614e7257600080fd5b8235614e7d81614d9d565b946020939093013593505050565b600060208284031215614e9d57600080fd5b8135610c9981614d9d565b803563ffffffff81168114614ebc57600080fd5b919050565b60008060408385031215614ed457600080fd5b614edd83614ea8565b9150614eeb60208401614ea8565b90509250929050565b600081518084526020808501945080840160005b83811015614f38578151805163ffffffff16885283015160070b8388015260409096019590820190600101614f08565b509495945050505050565b602081526000610c996020830184614ef4565b80358015158114614ebc57600080fd5b600080600080600060808688031215614f7e57600080fd5b614f8786614ea8565b9450614f9560208701614ea8565b9350604086013567ffffffffffffffff811115614fb157600080fd5b614fbd88828901614d42565b9094509250614fd0905060608701614f56565b90509295509295909350565b600080600060608486031215614ff157600080fd5b8335614ffc81614d9d565b9250602084013561500c81614d9d565b929592945050506040919091013590565b67ffffffffffffffff811681146144c157600080fd5b60008083601f84011261504557600080fd5b50813567ffffffffffffffff81111561505d57600080fd5b6020830191508360208260051b8501011115614d8457600080fd5b6000806000806060858703121561508e57600080fd5b843561509981614d9d565b935060208501356150a98161501d565b9250604085013567ffffffffffffffff8111156150c557600080fd5b6150d187828801615033565b95989497509550505050565b600080604083850312156150f057600080fd5b82356150fb81614d9d565b9150614eeb60208401614f56565b6000806040838503121561511c57600080fd5b823561512781614d9d565b9150602083013561513781614d9d565b809150509250929050565b6000806040838503121561515557600080fd5b8235614edd81614d9d565b60008060008060008060008060006101008a8c03121561517f57600080fd5b6151888a614ea8565b985060208a01356151988161501d565b975060408a013567ffffffffffffffff808211156151b557600080fd5b6151c18d838e01615033565b909950975060608c013591506151d68261501d565b90955060808b013590808211156151ec57600080fd5b506151f98c828d01614d42565b909550935061520d90508b60a08c01614d8b565b915060e08a013561521d81614d9d565b809150509295985092959850929598565b60008083601f84011261524057600080fd5b50813567ffffffffffffffff81111561525857600080fd5b6020830191508360208260061b8501011115614d8457600080fd5b6000806020838503121561528657600080fd5b823567ffffffffffffffff81111561529d57600080fd5b6152a98582860161522e565b90969095509350505050565b803560058110614ebc57600080fd5b6000602082840312156152d657600080fd5b610c99826152b5565b6000806000806000608086880312156152f757600080fd5b853567ffffffffffffffff81111561530e57600080fd5b61531a8882890161522e565b909650945061532d905060208701614ea8565b9250604086013561533d8161501d565b9150606086013561534d8161501d565b809150509295509295909350565b600080600080600060a0868803121561537357600080fd5b85359450602086013561538581614d9d565b935061539360408701614ea8565b925060608601356153a38161501d565b9150608086013561534d8161501d565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e0818401526153ef60e084018a614cd7565b8381036040850152615401818a614cd7565b606085018990526001600160a01b038816608086015260a0850187905284810360c0860152855180825283870192509083019060005b8181101561545357835183529284019291840191600101615437565b50909c9b505050505050505050505050565b60006020828403121561547757600080fd5b610c9982614ea8565b60006020828403121561549257600080fd5b610c9982614f56565b60008060008060008060e087890312156154b457600080fd5b6154be8888614d30565b9550608087013567ffffffffffffffff808211156154db57600080fd5b6154e78a838b01614d42565b90975095508591506154fb60a08a01614f56565b945060c089013591508082111561551157600080fd5b5061551e89828a01614d42565b979a9699509497509295939492505050565b60008060008060006080868803121561554857600080fd5b61555186614ea8565b945060208601356155618161501d565b9350604086013567ffffffffffffffff81111561557d57600080fd5b61558988828901615033565b909450925050606086013561534d8161501d565b600080600080600080600060e0888a0312156155b857600080fd5b87356155c381614d9d565b965060208801356155d381614d9d565b95506040880135945060608801359350608088013560ff811681146155f757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806020838503121561562757600080fd5b823567ffffffffffffffff81111561563e57600080fd5b6152a985828601615033565b60008060006060848603121561565f57600080fd5b833561566a81614d9d565b9250602084013561567a8161501d565b915061568860408501614ea8565b90509250925092565b600080604083850312156156a457600080fd5b615127836152b5565b600181811c908216806156c157607f821691505b602082108103613762577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b600061014063ffffffff808b5116845260208b015160208501528060408c01511660408501525060608a015167ffffffffffffffff80821660608601528060808d015116608086015250508060a0840152615783818401898b6156fa565b873560c0850152602088013560e085015290506001600160a01b0386166101008401528281036101208401526157ba8185876156fa565b9a9950505050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000818303608081121561580a57600080fd5b604080516060810167ffffffffffffffff828210818311171561582f5761582f6157c8565b908352855182526020860151906158458261501d565b816020840152837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08601121561587a57600080fd5b8351945083850191508482108183111715615897576158976157c8565b508252848201518352606090940151602083015283015250919050565b67ffffffffffffffff841681526040602082015260006158d86040830184866156fa565b95945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b63ffffffff818116838216019080821115613f3b57613f3b6158e1565b63ffffffff8616815260806020820152600061594c6080830187614ef4565b828103604084015261595f8186886156fa565b91505082151560608301529695505050505050565b6000806040838503121561598757600080fd5b505080516020909101519092909150565b80820180821115610c8557610c856158e1565b6001600160a01b03841681526060602082015260006159cd6060830185614ef4565b905067ffffffffffffffff83166040830152949350505050565b6000602082840312156159f957600080fd5b8151610c998161501d565b63ffffffff8716815260c060208201526000615a2360c0830188614ef4565b8281036040840152615a368187896156fa565b85356060850152602086013560808501529150615a509050565b6001600160a01b03831660a0830152979650505050505050565b828152604060208201526000615a836040830184614ef4565b949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8035600781900b8114614ebc57600080fd5b60408082528181018490526000908560608401835b87811015615b1e5763ffffffff615af784614ea8565b1682526020615b07818501615aba565b60070b908301529183019190830190600101615ae1565b5080935050505067ffffffffffffffff83166020830152949350505050565b63ffffffff87168152608060208201526000615b5d6080830187896156fa565b85151560408401528281036060840152615b788185876156fa565b9998505050505050505050565b604081526000615b986040830185614ef4565b905067ffffffffffffffff831660208301529392505050565b6040810160058410615bec577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b9281526001600160a01b039190911660209091015290565b63ffffffff828116828216039080821115613f3b57613f3b6158e1565b600063ffffffff808316818103615c3a57615c3a6158e1565b6001019392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b67ffffffffffffffff828116828216039080821115613f3b57613f3b6158e1565b60008160070b7fffffffffffffffffffffffffffffffffffffffffffffffff80000000000000008103615cc957615cc96158e1565b60000392915050565b600782810b9082900b037fffffffffffffffffffffffffffffffffffffffffffffffff80000000000000008112677fffffffffffffff82131715610c8557610c856158e1565b67ffffffffffffffff818116838216019080821115613f3b57613f3b6158e1565b60006000198203615d4c57615d4c6158e1565b5060010190565b600060208284031215615d6557600080fd5b610c9982615aba565b600781810b9083900b01677fffffffffffffff81137fffffffffffffffffffffffffffffffffffffffffffffffff800000000000000082121715610c8557610c856158e1565b6001600160a01b038516815263ffffffff84166020820152608060408201526000615de26080830185614ef4565b905067ffffffffffffffff8316606083015295945050505050565b60008060408385031215615e1057600080fd5b8251615e1b8161501d565b60208401519092506151378161501d565b601f8211156116da57600081815260208120601f850160051c81016020861015615e535750805b601f850160051c820191505b81811015615e7257828155600101615e5f565b505050505050565b815167ffffffffffffffff811115615e9457615e946157c8565b615ea881615ea284546156ad565b84615e2c565b602080601f831160018114615edd5760008415615ec55750858301515b600019600386901b1c1916600185901b178555615e72565b600085815260208120601f198616915b82811015615f0c57888601518255948401946001909101908401615eed565b5085821015615f2a5787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fea26469706673582212202e862fa54ddcf7c8c76b92495c01f7e259ab5a0b471331d93951f4a6cd2b6f4164736f6c63430008130033
Deployed Bytecode
0x6080604052600436106102bb5760003560e01c80636288a66c1161016e578063a9059cbb116100cb578063dd62ed3e1161007f578063e7e46ab811610064578063e7e46ab8146109d1578063f2e12a39146109f1578063fc0c546a14610a1157600080fd5b8063dd62ed3e1461096b578063e71b81e3146109b157600080fd5b8063c07f7c44116100b0578063c07f7c441461090b578063cd2a04fd1461092b578063d505accf1461094b57600080fd5b8063a9059cbb146108cb578063bedb86fb146108eb57600080fd5b80637ecebe001161012257806395d89b411161010757806395d89b411461076a5780639a7609291461077f578063a457c2d7146108ab57600080fd5b80637ecebe001461072257806384b0196e1461074257600080fd5b8063698b933e11610153578063698b933e1461069a57806370a08231146106ba57806375c2f5751461070257600080fd5b80636288a66c1461065557806368c5cad61461067557600080fd5b80633644e5151161021c5780634f3e1c55116101d05780635ae0d1af116101b55780635ae0d1af146105ef5780635c975abb1461060f5780635e8282c61461063557600080fd5b80634f3e1c55146105bc578063543ab3c7146105dc57600080fd5b80633950935111610201578063395093511461055a578063404e51291461057a578063485cc9551461059c57600080fd5b80633644e515146105255780633708da431461053a57600080fd5b806318160ddd1161027357806323b872dd1161025857806323b872dd1461049b5780632aa854c5146104bb578063313ce5671461050957600080fd5b806318160ddd1461043d57806318cda9181461046657600080fd5b8063095ea7b3116102a4578063095ea7b3146103375780630ecc535f146103675780631746d3011461041057600080fd5b806306fdde03146102c057806307abceb7146102eb575b600080fd5b3480156102cc57600080fd5b506102d5610a24565b6040516102e29190614d1d565b60405180910390f35b6102fe6102f9366004614db2565b610ab6565b604080518251815260208084015167ffffffffffffffff16818301529282015180519282019290925291015160608201526080016102e2565b34801561034357600080fd5b50610357610352366004614e5f565b610c71565b60405190151581526020016102e2565b34801561037357600080fd5b506103d6610382366004614e8b565b60d06020526000908152604090205463ffffffff8082169167ffffffffffffffff6401000000008204169160ff6c01000000000000000000000000830416916d010000000000000000000000000090041684565b6040805163ffffffff958616815267ffffffffffffffff9094166020850152911515918301919091529190911660608201526080016102e2565b34801561041c57600080fd5b5061043061042b366004614ec1565b610c8b565b6040516102e29190614f43565b34801561044957600080fd5b5060cc5467ffffffffffffffff165b6040519081526020016102e2565b34801561047257600080fd5b50610486610481366004614f66565b610ca0565b604080519283526020830191909152016102e2565b3480156104a757600080fd5b506103576104b6366004614fdc565b610da2565b3480156104c757600080fd5b506104f16104d6366004614e8b565b60d1602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016102e2565b34801561051557600080fd5b50604051600681526020016102e2565b34801561053157600080fd5b50610458610dc6565b34801561054657600080fd5b50610430610555366004615078565b610dd5565b34801561056657600080fd5b50610357610575366004614e5f565b610e6a565b34801561058657600080fd5b5061059a6105953660046150dd565b610ea9565b005b3480156105a857600080fd5b5061059a6105b7366004615109565b610f78565b3480156105c857600080fd5b5061059a6105d7366004615142565b611178565b6102fe6105ea366004615160565b6113ff565b3480156105fb57600080fd5b5061059a61060a366004615273565b611663565b34801561061b57600080fd5b5060cc546103579068010000000000000000900460ff1681565b34801561064157600080fd5b5061059a610650366004615109565b6116df565b34801561066157600080fd5b506104f16106703660046152c4565b6117b1565b34801561068157600080fd5b5060ce5460405163ffffffff90911681526020016102e2565b3480156106a657600080fd5b5061059a6106b53660046152df565b6117fa565b3480156106c657600080fd5b506104586106d5366004614e8b565b6001600160a01b0316600090815260d06020526040902054640100000000900467ffffffffffffffff1690565b34801561070e57600080fd5b5061059a61071d36600461535b565b61194e565b34801561072e57600080fd5b5061045861073d366004614e8b565b611a17565b34801561074e57600080fd5b50610757611a35565b6040516102e297969594939291906153b3565b34801561077657600080fd5b506102d5611af7565b34801561078b57600080fd5b5061085161079a366004615465565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101919091525063ffffffff908116600090815260cf6020908152604091829020825160a081018452905467ffffffffffffffff81168252680100000000000000008104600790810b93830193909352700100000000000000000000000000000000810490920b92810192909252600160c01b81049092166060820152600160e01b90910460ff161515608082015290565b6040516102e29190600060a08201905067ffffffffffffffff8351168252602083015160070b6020830152604083015160070b604083015263ffffffff606084015116606083015260808301511515608083015292915050565b3480156108b757600080fd5b506103576108c6366004614e5f565b611b06565b3480156108d757600080fd5b506103576108e6366004614e5f565b611bb0565b3480156108f757600080fd5b5061059a610906366004615480565b611bbe565b34801561091757600080fd5b5061048661092636600461549b565b611c72565b34801561093757600080fd5b5061059a610946366004615530565b611d35565b34801561095757600080fd5b5061059a61096636600461559d565b611e69565b34801561097757600080fd5b50610458610986366004615109565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b3480156109bd57600080fd5b506104306109cc366004615614565b611fcd565b3480156109dd57600080fd5b5061059a6109ec36600461564a565b611fdb565b3480156109fd57600080fd5b5061059a610a0c366004615691565b61205f565b348015610a1d57600080fd5b50306104f1565b606060368054610a33906156ad565b80601f0160208091040260200160405190810160405280929190818152602001828054610a5f906156ad565b8015610aac5780601f10610a8157610100808354040283529160200191610aac565b820191906000526020600020905b815481529060010190602001808311610a8f57829003601f168201915b5050505050905090565b610abe614c8f565b60cc5468010000000000000000900460ff1615610aee576040516313d0ff5960e31b815260040160405180910390fd5b8735610b26576040517fa9cb9e0d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610b35896020013561214c565b9050600080610b43836121d0565b9150915060006040518060a001604052808d6060016020810190610b679190615465565b63ffffffff90811682528e3560208301528516604082015267ffffffffffffffff808716606083015284166080909101529050610ba460036117b1565b6001600160a01b03166318d6b43a34838e8e8e8e8e8e6040518963ffffffff1660e01b8152600401610bdc9796959493929190615725565b60806040518083038185885af1158015610bfa573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610c1f91906157f7565b805160405191965033917f9ae5a085fcdd3a841fd4b8e8f114073db75391319202e87af5e7fe2fd6889cd890610c5a9088908c908c906158b4565b60405180910390a350505050979650505050505050565b600033610c7f8185856122d6565b60019150505b92915050565b6060610c9960ce8484612426565b9392505050565b60008080610caf876001615910565b63ffffffff1667ffffffffffffffff811115610ccd57610ccd6157c8565b604051908082528060200260200182016040528015610d1257816020015b6040805180820190915260008082526020820152815260200190600190039081610ceb5790505b509050610d1f60036117b1565b6001600160a01b03166344d9c50789838989896040518663ffffffff1660e01b8152600401610d5295949392919061592d565b6040805180830381865afa158015610d6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d929190615974565b92509250505b9550959350505050565b600033610db08582856125f6565b610dbb858585612666565b506001949350505050565b6000610dd0612710565b905090565b60cc5460609068010000000000000000900460ff1615610e08576040516313d0ff5960e31b815260040160405180910390fd5b6002610e13816117b1565b6001600160a01b0316336001600160a01b031614610e43576040516282b42960e81b815260040160405180910390fd5b6000610e4f878761271a565b9050610e5f60ce868689856127cf565b979650505050505050565b3360008181526034602090815260408083206001600160a01b0387168452909152812054909190610c7f9082908690610ea4908790615998565b6122d6565b6004610eb4816117b1565b6001600160a01b0316336001600160a01b031614610ee4576040516282b42960e81b815260040160405180910390fd5b6001600160a01b038316600081815260d060205260409081902080548515156c01000000000000000000000000027fffffffffffffffffffffffffffffffffffffff00ffffffffffffffffffffffff909116179055517ffed07c88bd5d31bfd0ce77ed7ffdc74a163a61cfc5edcec801e3a7954e33d6e790610f6b90851515815260200190565b60405180910390a2505050565b6000610fa27fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b90506001600160a01b038116610fe1576001600160a01b037fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355610ff6565b336001600160a01b03821614610ff657600080fd5b600054610100900460ff16158080156110165750600054600160ff909116105b806110305750303b158015611030575060005460ff166001145b6110a75760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561110557600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b61110f8484612956565b801561117257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b61118182612b07565b6001600160a01b0316336001600160a01b0316141580156111bd57506111a760016117b1565b6001600160a01b0316336001600160a01b031614155b156111da576040516282b42960e81b815260040160405180910390fd5b6001600160a01b038216600090815260d060209081526040918290208251608081018452905463ffffffff8082168352640100000000820467ffffffffffffffff16938301939093526c01000000000000000000000000900460ff16151592810192909252821660608201819052156112d15760ce5463ffffffff908116908316111561129b576040517fe310af2200000000000000000000000000000000000000000000000000000000815263ffffffff8316600482015260240161109e565b8163ffffffff16816000015163ffffffff16146112d157805160208201516112c79160ce918590612b37565b63ffffffff821681525b6001600160a01b038316600081815260d06020908152604091829020845181549286015184870151606088015163ffffffff9081166d0100000000000000000000000000027fffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffffff9215156c0100000000000000000000000002929092167fffffffffffffffffffffffffffffff0000000000ffffffffffffffffffffffff67ffffffffffffffff909416640100000000027fffffffffffffffffffffffffffffffffffffffff00000000000000000000000090971691909416179490941716179190911790555133907fe4aecbadc43072e0b1df5edd735f0359b389b0138fde0f0e7703924cd8aacf43906113f290869063ffffffff91909116815260200190565b60405180910390a3505050565b611407614c8f565b60cc5468010000000000000000900460ff1615611437576040516313d0ff5960e31b815260040160405180910390fd5b60008061144e60ce63ffffffff8d8d8d612f4c8416565b915091508167ffffffffffffffff16600003611496576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006114a260016117b1565b90506000816001600160a01b03166389e5cfdc3385876040518463ffffffff1660e01b81526004016114d6939291906159ab565b6020604051808303816000875af11580156114f5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151991906159e7565b905067ffffffffffffffff81161561158e578967ffffffffffffffff168167ffffffffffffffff161115611579576040517fcd4e616700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61158e33838367ffffffffffffffff16612666565b8d61159960036117b1565b6001600160a01b031663564991453483878e8e8e8e6040518863ffffffff1660e01b81526004016115cf96959493929190615a04565b60806040518083038185885af11580156115ed573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061161291906157f7565b95507f0592f6297549007244c93f321fd1e211a37a640783e4fc2a9960e30758b2ae4e866000015185604051611649929190615a6a565b60405180910390a150505050509998505050505050505050565b60cc5468010000000000000000900460ff1615611693576040516313d0ff5960e31b815260040160405180910390fd5b600361169e816117b1565b6001600160a01b0316336001600160a01b0316146116ce576040516282b42960e81b815260040160405180910390fd5b6116da60ce84846131f5565b505050565b336001600160a01b0383161480159061171357506116fd60016117b1565b6001600160a01b0316336001600160a01b031614155b15611730576040516282b42960e81b815260040160405180910390fd5b6001600160a01b03828116600081815260d1602090815260409182902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001694861694851790559051928352909133917ffde4ca3ca044bff553b751429dbfacecaab2484c2408dcc9a000be9abefb9a69910160405180910390a35050565b600060cd60008360048111156117c9576117c9615a8b565b60048111156117da576117da615a8b565b81526020810191909152604001600020546001600160a01b031692915050565b60cc5468010000000000000000900460ff161561182a576040516313d0ff5960e31b815260040160405180910390fd5b6003611835816117b1565b6001600160a01b0316336001600160a01b031614611865576040516282b42960e81b815260040160405180910390fd5b600061187160026117b1565b905067ffffffffffffffff84161561188f5761188f8186868661349c565b6040517f1dd2a73b0000000000000000000000000000000000000000000000000000000081526001600160a01b03821690631dd2a73b906118d8908a908a908990600401615acc565b600060405180830381600087803b1580156118f257600080fd5b505af1158015611906573d6000803e3d6000fd5b505050507f05da80fdd93a61677cae6bc9b9d749bd763c539ab2055ba2310b25a5b625561687878660405161193d93929190615acc565b60405180910390a150505050505050565b60cc5468010000000000000000900460ff161561197e576040516313d0ff5960e31b815260040160405180910390fd5b6003611989816117b1565b6001600160a01b0316336001600160a01b0316146119b9576040516282b42960e81b815260040160405180910390fd5b6119c58585858561349c565b60405167ffffffffffffffff841681526001600160a01b0386169087907ffc1b5feb636aa495ed28914895ca443adffbd4e2da951d5694baa392b4ebd1589060200160405180910390a3505050505050565b6001600160a01b038116600090815260996020526040812054610c85565b6000606080600080600060606065546000801b148015611a555750606654155b611aa15760405162461bcd60e51b815260206004820152601560248201527f4549503731323a20556e696e697469616c697a65640000000000000000000000604482015260640161109e565b611aa961354f565b611ab161355e565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b606060378054610a33906156ad565b3360008181526034602090815260408083206001600160a01b038716845290915281205490919083811015611ba35760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f000000000000000000000000000000000000000000000000000000606482015260840161109e565b610dbb82868684036122d6565b600033610c7f818585612666565b6001611bc9816117b1565b6001600160a01b0316336001600160a01b031614611bf9576040516282b42960e81b815260040160405180910390fd5b60cc805483151568010000000000000000027fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff9091161790556040517f140eb9f8b591138e129e4caf389c92df4f0545b902523eee9e63153ecdb2026e90611c6690841515815260200190565b60405180910390a15050565b6003600090815260cd6020527f310c72720b1a4f557c4a5c3b412492f965bebddd685b67587bd0620a2d756da25481906001600160a01b031663314dfef5611cc060808b0160608c01615465565b89898989896040518763ffffffff1660e01b8152600401611ce696959493929190615b3d565b6040805180830381865afa158015611d02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d269190615974565b91509150965096945050505050565b60cc5468010000000000000000900460ff1615611d65576040516313d0ff5960e31b815260040160405180910390fd5b600080611d75878787878761356d565b915091506000611d8560026117b1565b905067ffffffffffffffff831615611dad57611dab818467ffffffffffffffff16611bb0565b505b6040517f1dd2a73b0000000000000000000000000000000000000000000000000000000081526001600160a01b03821690631dd2a73b90611df49085908790600401615b85565b600060405180830381600087803b158015611e0e57600080fd5b505af1158015611e22573d6000803e3d6000fd5b505050507f05da80fdd93a61677cae6bc9b9d749bd763c539ab2055ba2310b25a5b62556168284604051611e57929190615b85565b60405180910390a15050505050505050565b83421115611eb95760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e65000000604482015260640161109e565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888611ee88c613740565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000611f4382613768565b90506000611f53828787876137b0565b9050896001600160a01b0316816001600160a01b031614611fb65760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604482015260640161109e565b611fc18a8a8a6122d6565b50505050505050505050565b6060610c9960ce84846137ce565b60cc5468010000000000000000900460ff161561200b576040516313d0ff5960e31b815260040160405180910390fd5b6002612016816117b1565b6001600160a01b0316336001600160a01b031614612046576040516282b42960e81b815260040160405180910390fd5b61205460ce83856000613a00565b611172848484613b08565b612068826117b1565b6001600160a01b0316336001600160a01b0316141580156120a4575061208e60006117b1565b6001600160a01b0316336001600160a01b031614155b156120c1576040516282b42960e81b815260040160405180910390fd5b8060cd60008460048111156120d8576120d8615a8b565b60048111156120e9576120e9615a8b565b815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b031602179055507f5c22095cd1123887402a709a9698bc2961c12cb22eeb16e5d76480931f63ede08282604051611c66929190615bb1565b600067ffffffffffffffff8211156121cc5760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201527f3420626974730000000000000000000000000000000000000000000000000000606482015260840161109e565b5090565b6000808267ffffffffffffffff16600003612217576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61222160016117b1565b6040517f376829ab00000000000000000000000000000000000000000000000000000000815233600482015267ffffffffffffffff851660248201526001600160a01b03919091169063376829ab906044016020604051808303816000875af1158015612292573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122b691906159e7565b506122c1338461271a565b91506122cf60ce8385613bac565b9050915091565b6001600160a01b0383166123515760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840161109e565b6001600160a01b0382166123cd5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840161109e565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591016113f2565b606063ffffffff82161561243a578161244d565b835461244d9063ffffffff166001615910565b9150600061245b8484615c04565b612466906001615910565b63ffffffff1667ffffffffffffffff811115612484576124846157c8565b6040519080825280602002602001820160405280156124c957816020015b60408051808201909152600080825260208201528152602001906001900390816124a25790505b509150835b8363ffffffff168163ffffffff1610156125855763ffffffff81166000908152600187016020526040902054600160e01b900460ff16156125735760408051808201825263ffffffff831680825260009081526001890160209081529290205468010000000000000000900460070b91810191909152838361254f81615c21565b945063ffffffff168151811061256757612567615c44565b60200260200101819052505b8061257d81615c21565b9150506124ce565b5060408051808201825263ffffffff80825260009081526001880160209081529290205468010000000000000000900460070b9181019190915282826125ca81615c21565b935063ffffffff16815181106125e2576125e2615c44565b602090810291909101015281529392505050565b6001600160a01b038216600090815260d0602052604090205482906c01000000000000000000000000900460ff161561265b576040517f09550c7700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611172848484613d32565b60cc5468010000000000000000900460ff1615612696576040516313d0ff5960e31b815260040160405180910390fd5b60006126a18261214c565b905060006126af8583613dbe565b90506126bc848284613f42565b836001600160a01b0316856001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161270191815260200190565b60405180910390a35050505050565b6000610dd06141f8565b60006127268383613dbe565b60cc8054919250839160009061274790849067ffffffffffffffff16615c73565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060006001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516127c1919067ffffffffffffffff91909116815260200190565b60405180910390a392915050565b60608267ffffffffffffffff16600003612815576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b677fffffffffffffff67ffffffffffffffff84161115612861576040517f35278d1200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61286c86838561426c565b600061287b8784868989612f4c565b9250905067ffffffffffffffff81166000036129195760408051600180825281830190925290816020015b60408051808201909152600080825260208201528152602001906001900390816128a657905050915060405180604001604052808463ffffffff168152602001856128f090615c94565b60070b8152508260008151811061290957612909615c44565b602002602001018190525061294c565b838260008151811061292d5761292d615c44565b60200260200101516020018181516129459190615cd2565b60070b9052505b5095945050505050565b600054610100900460ff166129d35760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161109e565b612a476040518060400160405280600481526020017f55534456000000000000000000000000000000000000000000000000000000008152506040518060400160405280600481526020017f5553445600000000000000000000000000000000000000000000000000000000815250614309565b612abb6040518060400160405280600481526020017f55534456000000000000000000000000000000000000000000000000000000008152506040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525061439f565b612af96040518060400160405280600481526020017f5553445600000000000000000000000000000000000000000000000000000000815250614444565b612b0382826144c4565b5050565b6001600160a01b03808216600090815260d160205260408120549091168015612b305792915050565b5090919050565b67ffffffffffffffff81161561117257677fffffffffffffff67ffffffffffffffff82161115612b93576040517f35278d1200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63ffffffff8381166000908152600186016020908152604091829020825160a081018452905467ffffffffffffffff81168252680100000000000000008104600790810b93830193909352700100000000000000000000000000000000810490920b92810192909252600160c01b81049092166060820152600160e01b90910460ff16151560808201528190612c2981836145d1565b63ffffffff85811614612c56578281600001818151612c489190615c73565b67ffffffffffffffff169052505b63ffffffff858116600090815260018801602090815260408083208551815487850151888501516060808b01516080808d015167ffffffffffffffff9788167fffffffffffffffffffffffffffffffff0000000000000000000000000000000090971696909617680100000000000000009588168602177fffffffff000000000000000000000000ffffffffffffffffffffffffffffffff1670010000000000000000000000000000000094881685027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff1617600160c01b928d168302177fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b9615158702179097558e8b168a5298879020875160a08101895290549586168152928504600790810b9884019890985290840490960b948101949094529481049095169282019290925260ff9290930491909116151590820152612dc781612dc285615c94565b6145d1565b63ffffffff85811614612df4578381600001818151612de69190615d18565b67ffffffffffffffff169052505b63ffffffff858116600081815260018a01602090815260409182902085518154878401518886015160608a015160808b015167ffffffffffffffff9586167fffffffffffffffffffffffffffffffff00000000000000000000000000000000909516949094176801000000000000000093861693909302929092177fffffffff000000000000000000000000ffffffffffffffffffffffffffffffff16700100000000000000000000000000000000918516919091027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff1617600160c01b91891691909102177fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b91151591909102179091559151918816825291928916917ff7a8a1aaba5fdf151f99b4845a353a64b739bdf6b5eed27d53943121397b6f6a910160405180910390a350505050505050565b60006060677fffffffffffffff67ffffffffffffffff86161115612f9c576040517f35278d1200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612fa9888888614618565b90508060070b600003612fc0576000925050610d98565b915081612fce846001615998565b67ffffffffffffffff811115612fe657612fe66157c8565b60405190808252806020026020018201604052801561302b57816020015b60408051808201909152600080825260208201528152602001906001900390816130045790505b50915060405180604001604052808863ffffffff1681526020018260070b8152508260008151811061305f5761305f615c44565b60209081029190910101526001600061307783615c94565b90506000805b878110156131c257600089898381811061309957613099615c44565b90506020020160208101906130ae9190615465565b90508263ffffffff168163ffffffff161115806130d0575063ffffffff818116145b806130e657508b63ffffffff168163ffffffff16145b15613125576040517fe310af2200000000000000000000000000000000000000000000000000000000815263ffffffff8216600482015260240161109e565b60006131328e8387614618565b905060008160070b12156131ad5760405180604001604052808363ffffffff1681526020018260070b81525088878061316a90615d39565b98508151811061317c5761317c615c44565b60209081029190910101526131918186615cd2565b94508460070b6000036131ad5785885250505050505050610d98565b509150806131ba81615d39565b91505061307d565b506040517ffb71cfdc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805b8281101561345e573684848381811061321457613214615c44565b60400291909101915063ffffffff90506132316020830183615465565b63ffffffff1614613252576132528661324d6020840184615465565b614831565b600060018701816132666020850185615465565b63ffffffff90811682526020808301939093526040918201600020825160a081018452905467ffffffffffffffff81168252680100000000000000008104600790810b838701527001000000000000000000000000000000008204900b82850152600160c01b81049092166060820152600160e01b90910460ff161515608082015292506133089183916132ff91908601908601615d53565b612dc290615c94565b8060018801600061331c6020860186615465565b63ffffffff9081168252602080830193909352604091820160002084518154868601518786015160608901516080909901511515600160e01b027fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff99909616600160c01b027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff67ffffffffffffffff92831670010000000000000000000000000000000002167fffffffff000000000000000000000000ffffffffffffffffffffffffffffffff93831668010000000000000000027fffffffffffffffffffffffffffffffff00000000000000000000000000000000909516929095169190911792909217169190911717949094161790925561343d918401908401615d53565b6134479085615d6e565b93505050808061345690615d39565b9150506131f9565b508060070b600014611172576040517ffb71cfdc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6134a660016117b1565b6040517f31b99cf800000000000000000000000000000000000000000000000000000000815233600482015267ffffffffffffffff841660248201526001600160a01b0391909116906331b99cf890604401600060405180830381600087803b15801561351257600080fd5b505af1158015613526573d6000803e3d6000fd5b5050505061354483828461353a9190615c73565b60ce919084613a00565b611172848385613b08565b606060678054610a33906156ad565b606060688054610a33906156ad565b600060607fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000163ffffffff8816016135d6576040517fe310af2200000000000000000000000000000000000000000000000000000000815263ffffffff600482015260240161109e565b60006135e660ce89898989612f4c565b9250905067ffffffffffffffff811660000361362e576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061363a60016117b1565b90506000816001600160a01b0316632a29c222338c87876040518563ffffffff1660e01b81526004016136709493929190615db4565b60408051808303816000875af115801561368e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136b29190615dfd565b909550905067ffffffffffffffff86166136cc8287615d18565b67ffffffffffffffff16111561370e576040517fcd4e616700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff8116156137335761373333838367ffffffffffffffff16612666565b5050509550959350505050565b6001600160a01b03811660009081526099602052604090208054600181018255905b50919050565b6000610c85613775612710565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b60008060006137c187878787614962565b9150915061294c81614a26565b60608167ffffffffffffffff8111156137e9576137e96157c8565b60405190808252806020026020018201604052801561382e57816020015b60408051808201909152600080825260208201528152602001906001900390816138075790505b50905060008060005b848110156139f557600086868381811061385357613853615c44565b90506020020160208101906138689190615465565b90508363ffffffff168163ffffffff16116138b7576040517fe310af2200000000000000000000000000000000000000000000000000000000815263ffffffff8216600482015260240161109e565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000163ffffffff8216016139505760408051808201825263ffffffff808252600090815260018b0160209081529290205468010000000000000000900460070b91810191909152858461392881615c21565b955063ffffffff168151811061394057613940615c44565b60200260200101819052506139e1565b63ffffffff81166000908152600189016020526040902054600160e01b900460ff16156139e15760408051808201825263ffffffff8316808252600090815260018b0160209081529290205468010000000000000000900460070b9181019190915285846139bd81615c21565b955063ffffffff16815181106139d5576139d5615c44565b60200260200101819052505b9250806139ed81615d39565b915050613837565b508252509392505050565b677fffffffffffffff67ffffffffffffffff83161115613a4c576040517f35278d1200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613a568484614831565b63ffffffff8316600090815260018501602052604081208054849290613a8790849067ffffffffffffffff16615d18565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550613abd8463ffffffff8584612b37565b60405167ffffffffffffffff8316815263ffffffff8416907f8deb13badd22d3eef6ddd202585d140ee59c89dfc214751d4db8a50ef7ca775f9060200160405180910390a250505050565b613b13838284613f42565b60cc8054839190600090613b3290849067ffffffffffffffff16615d18565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550826001600160a01b031660006001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516113f2919067ffffffffffffffff91909116815260200190565b60008167ffffffffffffffff16600003613bf2576040517f2c5211c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b677fffffffffffffff67ffffffffffffffff83161115613c3e576040517f35278d1200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63ffffffff83811660009081526001860160209081526040808320815160a081018352905467ffffffffffffffff81168252680100000000000000008104600790810b9483018590527001000000000000000000000000000000008204900b92820192909252600160c01b82049094166060850152600160e01b900460ff16151560808401521315613cf057602081015167ffffffffffffffff8085169082161015613cea5780613cec565b835b9250505b6000613cfc8385615c73565b905067ffffffffffffffff811615613d1957613d1986868361426c565b613d29868663ffffffff86612b37565b50509392505050565b6001600160a01b0383811660009081526034602090815260408083209386168352929052205460001981146111725781811015613db15760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161109e565b61117284848484036122d6565b6001600160a01b038216600090815260d0602052604081205483906c01000000000000000000000000900460ff1615613e23576040517f09550c7700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038416613e63576040517ffd684c3b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038416600090815260d0602052604090205467ffffffffffffffff6401000000009091048116908416811015613ecc576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b613ed68482615c73565b6001600160a01b038616600090815260d060205260409020805467ffffffffffffffff92909216640100000000027fffffffffffffffffffffffffffffffffffffffff0000000000000000ffffffff8316811790915563ffffffff9081169116179250505b5092915050565b6001600160a01b038316600090815260d0602052604090205483906c01000000000000000000000000900460ff1615613fa7576040517f09550c7700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038416613fe7576040517ffd684c3b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff821615611172576001600160a01b038416600090815260d060209081526040918290208251608081018452905463ffffffff80821680845267ffffffffffffffff6401000000008404169484019490945260ff6c010000000000000000000000008304161515948301949094526d0100000000000000000000000000900483166060820152918516146140ed57606081015160009063ffffffff161580156140af5750816020015167ffffffffffffffff168467ffffffffffffffff16115b905080156140da57815160208301516140cc9160ce918890612b37565b63ffffffff851682526140eb565b81516140eb9060ce90879087612b37565b505b82816020018181516140ff9190615d18565b67ffffffffffffffff9081169091526001600160a01b038716600090815260d0602090815260409182902085518154928701519387015160609097015163ffffffff9081166d0100000000000000000000000000027fffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffffff9815156c0100000000000000000000000002989098167fffffffffffffffffffffffffffffff0000000000ffffffffffffffffffffffff95909616640100000000027fffffffffffffffffffffffffffffffffffffffff000000000000000000000000909416911617919091179190911691909117929092179091555050505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f614223614b8b565b61422b614be4565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b63ffffffff821660009081526001840160205260408120805483929061429d90849067ffffffffffffffff16615c73565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055508163ffffffff167f75945fa1de0a0428b95184192b3c8819207e55f2485d2f05af0f55d39d3c57d182604051610f6b919067ffffffffffffffff91909116815260200190565b600054610100900460ff166143865760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161109e565b60366143928382615e7a565b5060376116da8282615e7a565b600054610100900460ff1661441c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161109e565b60676144288382615e7a565b5060686144358282615e7a565b50506000606581905560665550565b600054610100900460ff166144c15760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161109e565b50565b600054610100900460ff166145415760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161109e565b60cd6020527ff21edf1b278093a327d2897733f77e05e09f26bebbea4dc9d85ae85d03ca4e8580546001600160a01b039283167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617909155600080527fcd565b10a72538d86f6d352f37ebc5dff31587960b12c0afe00fd03947a6932a8054939092169216919091179055565b816060015163ffffffff1643146145fc5763ffffffff43166060830152602082015160070b60408301525b808260200181815161460e9190615cd2565b60070b9052505050565b63ffffffff82811660009081526001850160209081526040808320815160a081018352905467ffffffffffffffff81168252680100000000000000008104600790810b9483018590527001000000000000000000000000000000008204900b92820192909252600160c01b820490941660608501819052600160e01b90910460ff1615156080850152919291431480156146bc5750816040015160070b8160070b14155b156146e7576146cf818360400151614c15565b90508060070b6000036146e757600092505050610c99565b6146f18185614c15565b92508260070b60000361470957600092505050610c99565b61471382846145d1565b5063ffffffff808516600090815260018701602090815260409182902084518154928601519386015160608701516080909701511515600160e01b027fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff97909616600160c01b027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff67ffffffffffffffff92831670010000000000000000000000000000000002167fffffffff000000000000000000000000ffffffffffffffffffffffffffffffff96831668010000000000000000027fffffffffffffffffffffffffffffffff00000000000000000000000000000000909616929093169190911793909317939093169290921717929092161790559392505050565b63ffffffff81811610158061484a575063ffffffff8116155b15614889576040517fe310af2200000000000000000000000000000000000000000000000000000000815263ffffffff8216600482015260240161109e565b63ffffffff81166000908152600183016020526040902054600160e01b900460ff16612b035763ffffffff8082166000818152600185016020526040902080547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b1790558354909116101561492d5781547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001663ffffffff82161782555b60405163ffffffff8216907f5e6a67179496481d824a7314b1b05d10e27f204cb598b1a74f6ba235e86b738d90600090a25050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156149995750600090506003614a1d565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156149ed573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116614a1657600060019250925050614a1d565b9150600090505b94509492505050565b6000816004811115614a3a57614a3a615a8b565b03614a425750565b6001816004811115614a5657614a56615a8b565b03614aa35760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161109e565b6002816004811115614ab757614ab7615a8b565b03614b045760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161109e565b6003816004811115614b1857614b18615a8b565b036144c15760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f7565000000000000000000000000000000000000000000000000000000000000606482015260840161109e565b600080614b9661354f565b805190915015614bad578051602090910120919050565b6065548015614bbc5792915050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4709250505090565b600080614bef61355e565b805190915015614c06578051602090910120919050565b6066548015614bbc5792915050565b60008260070b60001480614c2c57508160070b6000145b15614c3957506000610c85565b8282186000600782900b1215614c53576000915050610c85565b60008460070b1315614c7c578260070b8460070b12614c725782614c74565b835b915050610c85565b8260070b8460070b13614c725782614c74565b604051806060016040528060008019168152602001600067ffffffffffffffff168152602001614cd2604051806040016040528060008152602001600081525090565b905290565b6000815180845260005b81811015614cfd57602081850181015186830182015201614ce1565b506000602082860101526020601f19601f83011685010191505092915050565b602081526000610c996020830184614cd7565b60006080828403121561376257600080fd5b60008083601f840112614d5457600080fd5b50813567ffffffffffffffff811115614d6c57600080fd5b602083019150836020828501011115614d8457600080fd5b9250929050565b60006040828403121561376257600080fd5b6001600160a01b03811681146144c157600080fd5b6000806000806000806000610120888a031215614dce57600080fd5b614dd88989614d30565b9650608088013567ffffffffffffffff80821115614df557600080fd5b614e018b838c01614d42565b9098509650869150614e168b60a08c01614d8b565b955060e08a01359150614e2882614d9d565b9093506101008901359080821115614e3f57600080fd5b50614e4c8a828b01614d42565b989b979a50959850939692959293505050565b60008060408385031215614e7257600080fd5b8235614e7d81614d9d565b946020939093013593505050565b600060208284031215614e9d57600080fd5b8135610c9981614d9d565b803563ffffffff81168114614ebc57600080fd5b919050565b60008060408385031215614ed457600080fd5b614edd83614ea8565b9150614eeb60208401614ea8565b90509250929050565b600081518084526020808501945080840160005b83811015614f38578151805163ffffffff16885283015160070b8388015260409096019590820190600101614f08565b509495945050505050565b602081526000610c996020830184614ef4565b80358015158114614ebc57600080fd5b600080600080600060808688031215614f7e57600080fd5b614f8786614ea8565b9450614f9560208701614ea8565b9350604086013567ffffffffffffffff811115614fb157600080fd5b614fbd88828901614d42565b9094509250614fd0905060608701614f56565b90509295509295909350565b600080600060608486031215614ff157600080fd5b8335614ffc81614d9d565b9250602084013561500c81614d9d565b929592945050506040919091013590565b67ffffffffffffffff811681146144c157600080fd5b60008083601f84011261504557600080fd5b50813567ffffffffffffffff81111561505d57600080fd5b6020830191508360208260051b8501011115614d8457600080fd5b6000806000806060858703121561508e57600080fd5b843561509981614d9d565b935060208501356150a98161501d565b9250604085013567ffffffffffffffff8111156150c557600080fd5b6150d187828801615033565b95989497509550505050565b600080604083850312156150f057600080fd5b82356150fb81614d9d565b9150614eeb60208401614f56565b6000806040838503121561511c57600080fd5b823561512781614d9d565b9150602083013561513781614d9d565b809150509250929050565b6000806040838503121561515557600080fd5b8235614edd81614d9d565b60008060008060008060008060006101008a8c03121561517f57600080fd5b6151888a614ea8565b985060208a01356151988161501d565b975060408a013567ffffffffffffffff808211156151b557600080fd5b6151c18d838e01615033565b909950975060608c013591506151d68261501d565b90955060808b013590808211156151ec57600080fd5b506151f98c828d01614d42565b909550935061520d90508b60a08c01614d8b565b915060e08a013561521d81614d9d565b809150509295985092959850929598565b60008083601f84011261524057600080fd5b50813567ffffffffffffffff81111561525857600080fd5b6020830191508360208260061b8501011115614d8457600080fd5b6000806020838503121561528657600080fd5b823567ffffffffffffffff81111561529d57600080fd5b6152a98582860161522e565b90969095509350505050565b803560058110614ebc57600080fd5b6000602082840312156152d657600080fd5b610c99826152b5565b6000806000806000608086880312156152f757600080fd5b853567ffffffffffffffff81111561530e57600080fd5b61531a8882890161522e565b909650945061532d905060208701614ea8565b9250604086013561533d8161501d565b9150606086013561534d8161501d565b809150509295509295909350565b600080600080600060a0868803121561537357600080fd5b85359450602086013561538581614d9d565b935061539360408701614ea8565b925060608601356153a38161501d565b9150608086013561534d8161501d565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e0818401526153ef60e084018a614cd7565b8381036040850152615401818a614cd7565b606085018990526001600160a01b038816608086015260a0850187905284810360c0860152855180825283870192509083019060005b8181101561545357835183529284019291840191600101615437565b50909c9b505050505050505050505050565b60006020828403121561547757600080fd5b610c9982614ea8565b60006020828403121561549257600080fd5b610c9982614f56565b60008060008060008060e087890312156154b457600080fd5b6154be8888614d30565b9550608087013567ffffffffffffffff808211156154db57600080fd5b6154e78a838b01614d42565b90975095508591506154fb60a08a01614f56565b945060c089013591508082111561551157600080fd5b5061551e89828a01614d42565b979a9699509497509295939492505050565b60008060008060006080868803121561554857600080fd5b61555186614ea8565b945060208601356155618161501d565b9350604086013567ffffffffffffffff81111561557d57600080fd5b61558988828901615033565b909450925050606086013561534d8161501d565b600080600080600080600060e0888a0312156155b857600080fd5b87356155c381614d9d565b965060208801356155d381614d9d565b95506040880135945060608801359350608088013560ff811681146155f757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806020838503121561562757600080fd5b823567ffffffffffffffff81111561563e57600080fd5b6152a985828601615033565b60008060006060848603121561565f57600080fd5b833561566a81614d9d565b9250602084013561567a8161501d565b915061568860408501614ea8565b90509250925092565b600080604083850312156156a457600080fd5b615127836152b5565b600181811c908216806156c157607f821691505b602082108103613762577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b600061014063ffffffff808b5116845260208b015160208501528060408c01511660408501525060608a015167ffffffffffffffff80821660608601528060808d015116608086015250508060a0840152615783818401898b6156fa565b873560c0850152602088013560e085015290506001600160a01b0386166101008401528281036101208401526157ba8185876156fa565b9a9950505050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000818303608081121561580a57600080fd5b604080516060810167ffffffffffffffff828210818311171561582f5761582f6157c8565b908352855182526020860151906158458261501d565b816020840152837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08601121561587a57600080fd5b8351945083850191508482108183111715615897576158976157c8565b508252848201518352606090940151602083015283015250919050565b67ffffffffffffffff841681526040602082015260006158d86040830184866156fa565b95945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b63ffffffff818116838216019080821115613f3b57613f3b6158e1565b63ffffffff8616815260806020820152600061594c6080830187614ef4565b828103604084015261595f8186886156fa565b91505082151560608301529695505050505050565b6000806040838503121561598757600080fd5b505080516020909101519092909150565b80820180821115610c8557610c856158e1565b6001600160a01b03841681526060602082015260006159cd6060830185614ef4565b905067ffffffffffffffff83166040830152949350505050565b6000602082840312156159f957600080fd5b8151610c998161501d565b63ffffffff8716815260c060208201526000615a2360c0830188614ef4565b8281036040840152615a368187896156fa565b85356060850152602086013560808501529150615a509050565b6001600160a01b03831660a0830152979650505050505050565b828152604060208201526000615a836040830184614ef4565b949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8035600781900b8114614ebc57600080fd5b60408082528181018490526000908560608401835b87811015615b1e5763ffffffff615af784614ea8565b1682526020615b07818501615aba565b60070b908301529183019190830190600101615ae1565b5080935050505067ffffffffffffffff83166020830152949350505050565b63ffffffff87168152608060208201526000615b5d6080830187896156fa565b85151560408401528281036060840152615b788185876156fa565b9998505050505050505050565b604081526000615b986040830185614ef4565b905067ffffffffffffffff831660208301529392505050565b6040810160058410615bec577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b9281526001600160a01b039190911660209091015290565b63ffffffff828116828216039080821115613f3b57613f3b6158e1565b600063ffffffff808316818103615c3a57615c3a6158e1565b6001019392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b67ffffffffffffffff828116828216039080821115613f3b57613f3b6158e1565b60008160070b7fffffffffffffffffffffffffffffffffffffffffffffffff80000000000000008103615cc957615cc96158e1565b60000392915050565b600782810b9082900b037fffffffffffffffffffffffffffffffffffffffffffffffff80000000000000008112677fffffffffffffff82131715610c8557610c856158e1565b67ffffffffffffffff818116838216019080821115613f3b57613f3b6158e1565b60006000198203615d4c57615d4c6158e1565b5060010190565b600060208284031215615d6557600080fd5b610c9982615aba565b600781810b9083900b01677fffffffffffffff81137fffffffffffffffffffffffffffffffffffffffffffffffff800000000000000082121715610c8557610c856158e1565b6001600160a01b038516815263ffffffff84166020820152608060408201526000615de26080830185614ef4565b905067ffffffffffffffff8316606083015295945050505050565b60008060408385031215615e1057600080fd5b8251615e1b8161501d565b60208401519092506151378161501d565b601f8211156116da57600081815260208120601f850160051c81016020861015615e535750805b601f850160051c820191505b81811015615e7257828155600101615e5f565b505050505050565b815167ffffffffffffffff811115615e9457615e946157c8565b615ea881615ea284546156ad565b84615e2c565b602080601f831160018114615edd5760008415615ec55750858301515b600019600386901b1c1916600185901b178555615e72565b600085815260208120601f198616915b82811015615f0c57888601518255948401946001909101908401615eed565b5085821015615f2a5787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fea26469706673582212202e862fa54ddcf7c8c76b92495c01f7e259ab5a0b471331d93951f4a6cd2b6f4164736f6c63430008130033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ 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.