Polygon Sponsored slots available. Book your slot here!
Overview
POL Balance
POL Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
USDR
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 10001 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity ^0.8.9; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@layerzerolabs/solidity-examples/contracts/contracts-upgradable/token/oft/OFTUpgradeable.sol"; import "./WadRayMath.sol"; import "../AddressAccessor.sol"; import "../constants/addresses.sol"; import "../constants/constants.sol"; import "../constants/roles.sol"; import "../interfaces/IExchange.sol"; import "../interfaces/IUSDR.sol"; import "./WUSDR.sol"; contract USDR is AddressAccessorUpgradable, PausableUpgradeable, OFTUpgradeable, IUSDR { using WadRayMath for uint256; using SafeERC20 for IERC20; event Rebase( uint256 indexed blockNumber, uint256 indexed day, uint256 supply, uint256 supplyDelta, uint256 index ); event SyncToChain(uint16 dstChainId, uint256 liquidityIndex); event SyncFromChain(uint16 srcChainId, uint256 liquidityIndex); address public constant MULTICHAIN_VAULT = 0x52b9D0F46451bd2c610Ae6Ab1F5312a35A6159E3; address public constant PREVIOUS_WUSDR = 0xAF0D9D65fC54de245cdA37af3d18cbEc860A4D4b; uint16 public constant PT_SYNC = 1; bool public isMain; bool private _preMinted; address public previousImplementation; uint256 private _totalSupply; uint256 private _totalSupplyScale; uint256 public liquidityIndex; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowedValue; function initialize( address _owner, address _previousImplementation, address _lzEndpoint, bool _isMainChain ) public initializer { __AccessControl_init(); __Pausable_init(); __OFTUpgradeable_init("Real USD", "USDR", _lzEndpoint); _transferOwnership(_owner); _grantRole(DEFAULT_ADMIN_ROLE, _owner); isMain = _isMainChain; previousImplementation = _previousImplementation; if (_previousImplementation != address(0)) { liquidityIndex = USDR(_previousImplementation).liquidityIndex(); } else { liquidityIndex = 1e27; } } function reinitialize() external reinitializer(5) { if (!isMain) { _revokeRole(DEFAULT_ADMIN_ROLE, msg.sender); _grantRole(DEFAULT_ADMIN_ROLE, owner()); } } function resetInitialLiquidityIndex() external onlyOwner { require(isMain, "USDR: not main chain"); address usdrImpl = addressProvider.getAddress(USDR_ADDRESS); require(usdrImpl != address(this)); liquidityIndex = USDR(usdrImpl).liquidityIndex(); } function supportsInterface(bytes4 interfaceId) public view override(AccessControlUpgradeable, OFTUpgradeable) returns (bool) { return AccessControlUpgradeable.supportsInterface(interfaceId) || OFTUpgradeable.supportsInterface(interfaceId); } function burn(address account, uint256 amount) external whenNotPaused { require(account != address(0), "burn from zero address"); if (msg.sender != account) { _spendAllowance(account, msg.sender, amount); } uint256 accountBalance = balanceOf(account); require(accountBalance >= amount, "burn amount exceeds balance"); if (accountBalance == amount) { _totalSupply -= _balances[account]; delete _balances[account]; } else { uint256 amount_ = amount.wadToRay().rayDiv(liquidityIndex); if (amount_ > _balances[account]) { amount_ = _balances[account]; } _totalSupply -= amount_; _balances[account] -= amount_; } emit Transfer(account, address(0), amount); } function mint(address account, uint256 amount) external onlyRole(MINTER_ROLE) whenNotPaused { require(account != address(0), "mint to zero address"); uint256 amount_ = amount.wadToRay().rayDiv(liquidityIndex); require(amount_ <= MAX_UINT128 - totalSupply(), "max supply exceeded"); _totalSupply += amount_; _balances[account] += amount_; emit Transfer(address(0), account, amount); } function rebase(uint256 supplyDelta) external onlyRole(CONTROLLER_ROLE) whenNotPaused { uint256 ts = totalSupply(); (address treasury, address exchange) = abi.decode( addressProvider.getAddresses( abi.encode(TREASURY_ADDRESS, USDR_EXCHANGE_ADDRESS) ), (address, address) ); require(msg.sender == treasury, "caller is not treasury"); if (supplyDelta > 0) { supplyDelta = IExchange(exchange).scaleFromUnderlying(supplyDelta); uint256 maxSupplyDelta = MAX_UINT128 - ts; if (supplyDelta > maxSupplyDelta) { supplyDelta = maxSupplyDelta; } if (supplyDelta > 0) { liquidityIndex = (liquidityIndex * (ts + supplyDelta)) / ts; int128[7] memory delta; delta[6] = int128(uint128(totalSupply() - ts)); IExchange(exchange).updateMintingStats(delta); } } emit Rebase( block.number, block.timestamp / 1 days, ts, supplyDelta, liquidityIndex ); } function sync( uint16 _dstChainId, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) public payable whenNotPaused { require(isMain, "USDR: can only sync from main chain"); _sync( _dstChainId, liquidityIndex, _refundAddress, _zroPaymentAddress, _adapterParams ); } function allowance(address owner_, address spender) public view override(ERC20Upgradeable, IERC20Upgradeable) returns (uint256) { return _allowedValue[owner_][spender]; } function approve(address spender, uint256 value) public override(ERC20Upgradeable, IERC20Upgradeable) returns (bool) { _allowedValue[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function balanceOf(address account) public view override(ERC20Upgradeable, IERC20Upgradeable) returns (uint256) { return _balances[account].rayMul(liquidityIndex).rayToWad(); } function decimals() public pure override returns (uint8) { return 9; } function decreaseAllowance(address spender, uint256 subtractedValue) public override returns (bool) { uint256 oldValue = _allowedValue[msg.sender][spender]; if (subtractedValue >= oldValue) { delete _allowedValue[msg.sender][spender]; } else { _allowedValue[msg.sender][spender] = oldValue - subtractedValue; } emit Approval(msg.sender, spender, _allowedValue[msg.sender][spender]); return true; } function increaseAllowance(address spender, uint256 addedValue) public override returns (bool) { _allowedValue[msg.sender][spender] += addedValue; emit Approval(msg.sender, spender, _allowedValue[msg.sender][spender]); return true; } function totalSupply() public view override(ERC20Upgradeable, IERC20Upgradeable) returns (uint256) { uint256 _previous; if (previousImplementation != address(0)) { _previous = USDR(previousImplementation).totalSupply() - ERC4626(PREVIOUS_WUSDR).convertToAssets( IERC20(PREVIOUS_WUSDR).balanceOf(MULTICHAIN_VAULT) ); } return _totalSupply.rayMul(liquidityIndex).rayToWad() + _previous; } function transfer(address to, uint256 amount) public override(ERC20Upgradeable, IERC20Upgradeable) whenNotPaused returns (bool) { uint256 amount_ = _transferableAmount(amount, msg.sender); _balances[msg.sender] -= amount_; _balances[to] += amount_; emit Transfer(msg.sender, to, amount); return true; } function transferAll(address to) public whenNotPaused returns (bool) { uint256 amount = balanceOf(msg.sender); uint256 amount_ = _balances[msg.sender]; delete _balances[msg.sender]; _balances[to] += amount_; emit Transfer(msg.sender, to, amount); return true; } function transferAllFrom(address from, address to) public whenNotPaused returns (bool) { uint256 amount = balanceOf(from); uint256 amount_ = _balances[from]; _spendAllowance(from, msg.sender, amount); delete _balances[from]; _balances[to] += amount_; emit Transfer(from, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public override(ERC20Upgradeable, IERC20Upgradeable) whenNotPaused returns (bool) { _spendAllowance(from, msg.sender, amount); uint256 amount_ = _transferableAmount(amount, from); _balances[from] -= amount_; _balances[to] += amount_; emit Transfer(from, to, amount); return true; } function _transferableAmount(uint256 amount, address sender) internal view returns (uint256) { uint256 balance = balanceOf(sender); require(amount <= balance, "USDR: amount exceeds balance"); if (amount == balanceOf(sender)) { return _balances[sender]; } return amount.wadToRay().rayDiv(liquidityIndex); } function _approve( address owner, address spender, uint256 value ) internal virtual override { _allowedValue[owner][spender] = value; emit Approval(owner, spender, value); } /// /// LayerZero overrides /// function sendFrom( address _from, uint16 _dstChainId, bytes calldata _toAddress, uint256 _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) public payable override whenNotPaused { _send( _from, _dstChainId, _toAddress, _amount, _refundAddress, _zroPaymentAddress, _adapterParams ); } function _debitFrom( address _from, uint16, bytes memory, uint256 _amount ) internal override returns (uint256) { uint256 transferAmount = _transferableAmount(_amount, _from); if (isMain) { _balances[_from] -= transferAmount; _balances[address(this)] += transferAmount; emit Transfer(_from, address(this), _amount); } else { _totalSupply -= transferAmount; _balances[_from] -= transferAmount; emit Transfer(_from, address(0), _amount); } return transferAmount; } function _creditTo( uint16, address _toAddress, uint256 _amount ) internal override returns (uint256) { uint256 receivedAmount = _amount.rayMul(liquidityIndex).rayToWad(); if (isMain) { _balances[address(this)] -= _amount; _balances[_toAddress] += _amount; emit Transfer(address(this), _toAddress, receivedAmount); } else { _totalSupply += _amount; _balances[_toAddress] += _amount; emit Transfer(address(0), _toAddress, receivedAmount); } return _amount; } function _sync( uint16 _dstChainId, uint256 _liquidityIndex, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) internal { _checkAdapterParams(_dstChainId, PT_SYNC, _adapterParams, NO_EXTRA_GAS); bytes memory lzPayload = abi.encode(PT_SYNC, _liquidityIndex); _lzSend( _dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value ); emit SyncToChain(_dstChainId, _liquidityIndex); } function _syncAck(uint16 _srcChainId, bytes memory _payload) internal { (, uint256 _liquidityIndex) = abi.decode(_payload, (uint16, uint256)); require( liquidityIndex <= _liquidityIndex, "USDR: liquidity index too low" ); liquidityIndex = _liquidityIndex; emit SyncFromChain(_srcChainId, _liquidityIndex); } function _nonblockingLzReceive( uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload ) internal override { uint16 packetType; assembly { packetType := mload(add(_payload, 32)) } if (packetType == PT_SEND) { _sendAck(_srcChainId, _srcAddress, _nonce, _payload); } else if (packetType == PT_SYNC) { _syncAck(_srcChainId, _payload); } else { revert("USDR: unknown packet type"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-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; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } 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"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/extensions/ERC4626.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../utils/SafeERC20.sol"; import "../../../interfaces/IERC4626.sol"; import "../../../utils/math/Math.sol"; /** * @dev Implementation of the ERC4626 "Tokenized Vault Standard" as defined in * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626]. * * This extension allows the minting and burning of "shares" (represented using the ERC20 inheritance) in exchange for * underlying "assets" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends * the ERC20 standard. Any additional extensions included along it would affect the "shares" token represented by this * contract and not the "assets" token which is an independent contract. * * CAUTION: Deposits and withdrawals may incur unexpected slippage. Users should verify that the amount received of * shares or assets is as expected. EOAs should operate through a wrapper that performs these checks such as * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router]. * * _Available since v4.7._ */ abstract contract ERC4626 is ERC20, IERC4626 { using Math for uint256; IERC20Metadata private immutable _asset; /** * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777). */ constructor(IERC20Metadata asset_) { _asset = asset_; } /** @dev See {IERC4262-asset}. */ function asset() public view virtual override returns (address) { return address(_asset); } /** @dev See {IERC4262-totalAssets}. */ function totalAssets() public view virtual override returns (uint256) { return _asset.balanceOf(address(this)); } /** @dev See {IERC4262-convertToShares}. */ function convertToShares(uint256 assets) public view virtual override returns (uint256 shares) { return _convertToShares(assets, Math.Rounding.Down); } /** @dev See {IERC4262-convertToAssets}. */ function convertToAssets(uint256 shares) public view virtual override returns (uint256 assets) { return _convertToAssets(shares, Math.Rounding.Down); } /** @dev See {IERC4262-maxDeposit}. */ function maxDeposit(address) public view virtual override returns (uint256) { return _isVaultCollateralized() ? type(uint256).max : 0; } /** @dev See {IERC4262-maxMint}. */ function maxMint(address) public view virtual override returns (uint256) { return type(uint256).max; } /** @dev See {IERC4262-maxWithdraw}. */ function maxWithdraw(address owner) public view virtual override returns (uint256) { return _convertToAssets(balanceOf(owner), Math.Rounding.Down); } /** @dev See {IERC4262-maxRedeem}. */ function maxRedeem(address owner) public view virtual override returns (uint256) { return balanceOf(owner); } /** @dev See {IERC4262-previewDeposit}. */ function previewDeposit(uint256 assets) public view virtual override returns (uint256) { return _convertToShares(assets, Math.Rounding.Down); } /** @dev See {IERC4262-previewMint}. */ function previewMint(uint256 shares) public view virtual override returns (uint256) { return _convertToAssets(shares, Math.Rounding.Up); } /** @dev See {IERC4262-previewWithdraw}. */ function previewWithdraw(uint256 assets) public view virtual override returns (uint256) { return _convertToShares(assets, Math.Rounding.Up); } /** @dev See {IERC4262-previewRedeem}. */ function previewRedeem(uint256 shares) public view virtual override returns (uint256) { return _convertToAssets(shares, Math.Rounding.Down); } /** @dev See {IERC4262-deposit}. */ function deposit(uint256 assets, address receiver) public virtual override returns (uint256) { require(assets <= maxDeposit(receiver), "ERC4626: deposit more than max"); uint256 shares = previewDeposit(assets); _deposit(_msgSender(), receiver, assets, shares); return shares; } /** @dev See {IERC4262-mint}. */ function mint(uint256 shares, address receiver) public virtual override returns (uint256) { require(shares <= maxMint(receiver), "ERC4626: mint more than max"); uint256 assets = previewMint(shares); _deposit(_msgSender(), receiver, assets, shares); return assets; } /** @dev See {IERC4262-withdraw}. */ function withdraw( uint256 assets, address receiver, address owner ) public virtual override returns (uint256) { require(assets <= maxWithdraw(owner), "ERC4626: withdraw more than max"); uint256 shares = previewWithdraw(assets); _withdraw(_msgSender(), receiver, owner, assets, shares); return shares; } /** @dev See {IERC4262-redeem}. */ function redeem( uint256 shares, address receiver, address owner ) public virtual override returns (uint256) { require(shares <= maxRedeem(owner), "ERC4626: redeem more than max"); uint256 assets = previewRedeem(shares); _withdraw(_msgSender(), receiver, owner, assets, shares); return assets; } /** * @dev Internal conversion function (from assets to shares) with support for rounding direction. * * Will revert if assets > 0, totalSupply > 0 and totalAssets = 0. That corresponds to a case where any asset * would represent an infinite amout of shares. */ function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256 shares) { uint256 supply = totalSupply(); return (assets == 0 || supply == 0) ? assets.mulDiv(10**decimals(), 10**_asset.decimals(), rounding) : assets.mulDiv(supply, totalAssets(), rounding); } /** * @dev Internal conversion function (from shares to assets) with support for rounding direction. */ function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256 assets) { uint256 supply = totalSupply(); return (supply == 0) ? shares.mulDiv(10**_asset.decimals(), 10**decimals(), rounding) : shares.mulDiv(totalAssets(), supply, rounding); } /** * @dev Deposit/mint common workflow. */ function _deposit( address caller, address receiver, uint256 assets, uint256 shares ) internal virtual { // If _asset is ERC777, `transferFrom` can trigger a reenterancy BEFORE the transfer happens through the // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer, // calls the vault, which is assumed not malicious. // // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the // assets are transfered and before the shares are minted, which is a valid state. // slither-disable-next-line reentrancy-no-eth SafeERC20.safeTransferFrom(_asset, caller, address(this), assets); _mint(receiver, shares); emit Deposit(caller, receiver, assets, shares); } /** * @dev Withdraw/redeem common workflow. */ function _withdraw( address caller, address receiver, address owner, uint256 assets, uint256 shares ) internal virtual { if (caller != owner) { _spendAllowance(owner, caller, shares); } // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer, // calls the vault, which is assumed not malicious. // // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the // shares are burned and after the assets are transfered, which is a valid state. _burn(owner, shares); SafeERC20.safeTransfer(_asset, receiver, assets); emit Withdraw(caller, receiver, owner, assets, shares); } function _isVaultCollateralized() private view returns (bool) { return totalAssets() > 0 || totalSupply() == 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @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 pragma solidity ^0.8.2; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol"; import "./IOFTUpgradeable.sol"; import "./OFTCoreUpgradeable.sol"; // override decimal() function is needed contract OFTUpgradeable is Initializable, OFTCoreUpgradeable, ERC20Upgradeable, IOFTUpgradeable { function __OFTUpgradeable_init(string memory _name, string memory _symbol, address _lzEndpoint) internal onlyInitializing { __ERC20_init_unchained(_name, _symbol); __Ownable_init_unchained(); __LzAppUpgradeable_init_unchained(_lzEndpoint); } function __OFTUpgradeable_init_unchained(string memory _name, string memory _symbol, address _lzEndpoint) internal onlyInitializing {} function supportsInterface(bytes4 interfaceId) public view virtual override(OFTCoreUpgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IOFTUpgradeable).interfaceId || interfaceId == type(IERC20Upgradeable).interfaceId || super.supportsInterface(interfaceId); } function token() public view virtual override returns (address) { return address(this); } function circulatingSupply() public view virtual override returns (uint) { return totalSupply(); } function _debitFrom(address _from, uint16, bytes memory, uint _amount) internal virtual override returns(uint) { address spender = _msgSender(); if (_from != spender) _spendAllowance(_from, spender, _amount); _burn(_from, _amount); return _amount; } function _creditTo(uint16, address _toAddress, uint _amount) internal virtual override returns(uint) { _mint(_toAddress, _amount); return _amount; } /** * @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 */ uint[50] private __gap; }
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity ^0.8.9; library WadRayMath { uint256 internal constant HALF_RAY = 5e26; uint256 internal constant RAY = 1e27; uint256 internal constant WAD = 1e18; uint256 internal constant WAD_RAY_RATIO = 1e9; function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) { return (b / 2 + a * RAY) / b; } function rayMul(uint256 a, uint256 b) internal pure returns (uint256) { return (HALF_RAY + a * b) / RAY; } function rayToWad(uint256 a) internal pure returns (uint256) { return (WAD_RAY_RATIO / 2 + a) / WAD_RAY_RATIO; } function wadToRay(uint256 a) internal pure returns (uint256) { return a * WAD_RAY_RATIO; } }
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity ^0.8.9; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "./AddressProvider.sol"; abstract contract AddressAccessor is AccessControl { AddressProvider public addressProvider; function setAddressProvider(AddressProvider _addressProvider) public virtual onlyRole(DEFAULT_ADMIN_ROLE) { addressProvider = _addressProvider; } } abstract contract AddressAccessorUpgradable is AccessControlUpgradeable { AddressProvider public addressProvider; function setAddressProvider(AddressProvider _addressProvider) public virtual onlyRole(DEFAULT_ADMIN_ROLE) { addressProvider = _addressProvider; } }
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity ^0.8.9; bytes32 constant pDAI_ADDRESS = bytes32(keccak256("pDAI")); bytes32 constant INSTANT_LIQUIDITY_ADDRESS = bytes32( keccak256("InstantLiquidity") ); bytes32 constant LIQUIDITY_MANAGER_ADDRESS = bytes32( keccak256("LiquidityManager") ); bytes32 constant TNGBL_LIQUIDITY_MANAGER_ADDRESS = bytes32( keccak256("TNGBLLiquidityManager") ); bytes32 constant PROMISSORY_ADDRESS = bytes32(keccak256("pDAI")); bytes32 constant RWA_CALCULATOR_ADDRESS = bytes32(keccak256("RWACalculator")); bytes32 constant TANGIBLE_MARKETPLACE_ADDRESS = bytes32( keccak256("TangibleMarketplace") ); bytes32 constant TANGIBLE_PRICE_MANAGER_ADDRESS = bytes32( keccak256("TangiblePriceManager") ); bytes32 constant TANGIBLE_RENT_SHARE_ADDRESS = bytes32( keccak256("TangibleRentShare") ); bytes32 constant TANGIBLE_REVENUE_SHARE_ADDRESS = bytes32( keccak256("TangibleRevenueShare") ); bytes32 constant TANGIBLE_PINFT_ADDRESS = bytes32(keccak256("TangiblePINFT")); bytes32 constant TNGBL_ADDRESS = bytes32(keccak256("TNGBL")); bytes32 constant TNGBL_ORACLE_ADDRESS = bytes32(keccak256("TNGBLPriceOracle")); bytes32 constant TOKEN_SWAP_ADDRESS = bytes32(keccak256("TokenSwap")); bytes32 constant TREASURY_ADDRESS = bytes32(keccak256("USDRTreasury")); bytes32 constant TREASURY_TRACKER_ADDRESS = bytes32( keccak256("TreasuryTracker") ); bytes32 constant UNDERLYING_ADDRESS = bytes32(keccak256("underlying")); bytes32 constant REVENUE_TOKEN_ADDRESS = bytes32(keccak256("revenueToken")); bytes32 constant UNISWAP_V3_FACTORY_ADDRESS = bytes32( keccak256("uniswapV3Factory") ); bytes32 constant UNISWAP_V3_NFT_MANAGER_ADDRESS = bytes32( keccak256("uniswapV3NonfungiblePositionManager") ); bytes32 constant UNISWAP_V3_POOL_ADDRESS = bytes32(keccak256("uniswapV3Pool")); bytes32 constant UNISWAP_V3_SWAP_ROUTER_ADDRESS = bytes32( keccak256("uniswapV3SwapRouter") ); bytes32 constant UNISWAP_V3_TOKEN_MATH_ADDRESS = bytes32( keccak256("LiquidityTokenMath") ); bytes32 constant USDR_ADDRESS = bytes32(keccak256("USDR")); bytes32 constant USDR_EXCHANGE_ADDRESS = bytes32(keccak256("USDRExchange")); //treasury managers bytes32 constant RE_PURCHASE_MANAGER_ADDRESS = bytes32( keccak256("RePurchaseManager") ); bytes32 constant RE_SELL_MANAGER_ADDRESS = bytes32(keccak256("ReSellManager")); bytes32 constant GOLD_PURCHASE_MANAGER_ADDRESS = bytes32( keccak256("GoldPurchaseManager") ); bytes32 constant GOLD_SELL_MANAGER_ADDRESS = bytes32( keccak256("GoldSellManager") ); bytes32 constant DAI_USD_ORACLE_ADDRESS = bytes32(keccak256("DaiUsdOracle")); bytes32 constant CURRENCY_FEED_ADDRESS = bytes32(keccak256("CurrencyFeed")); bytes32 constant VAULTS_TRACKER_ADDRESS = bytes32(keccak256("VaultsTracker"));
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity ^0.8.9; uint256 constant MAX_UINT128 = type(uint128).max; uint256 constant MAX_UINT256 = type(uint256).max;
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity ^0.8.9; bytes32 constant BURNER_ROLE = bytes32(keccak256("BURNER")); bytes32 constant MINTER_ROLE = bytes32(keccak256("MINTER")); bytes32 constant CONTROLLER_ROLE = bytes32(keccak256("CONTROLLER")); bytes32 constant TRACKER_ROLE = bytes32(keccak256("TRACKER")); bytes32 constant ROUTER_POLICY_ROLE = bytes32(keccak256("ROUTER_POLICY"));
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity ^0.8.9; interface IExchange { function scaleFromUnderlying(uint256 amount) external view returns (uint256); function scaleToUnderlying(uint256 amount) external view returns (uint256); function swapFromUnderlying(uint256 amountIn, address to) external returns (uint256 amountOut); function updateMintingStats(int128[7] calldata delta) external; }
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity ^0.8.9; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; interface IUSDR is IERC20Upgradeable { function burn(address account, uint256 amount) external; function mint(address account, uint256 amount) external; function rebase(uint256 supplyDelta) external; }
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity ^0.8.9; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/interfaces/IERC4626Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@layerzerolabs/solidity-examples/contracts/contracts-upgradable/token/oft/OFTUpgradeable.sol"; import "./WadRayMath.sol"; import "../interfaces/IUSDR.sol"; contract WrappedUSDR is PausableUpgradeable, OFTUpgradeable, IERC4626Upgradeable { using AddressUpgradeable for address; using WadRayMath for uint256; address public asset; function initialize( address _owner, address usdr, address lzEndpoint ) external initializer { __Ownable_init(); __Pausable_init(); __OFTUpgradeable_init("Wrapped USDR", "wUSDR", lzEndpoint); _transferOwnership(_owner); asset = usdr; } function reinitialize() external reinitializer(4) {} function decimals() public pure override(ERC20Upgradeable, IERC20MetadataUpgradeable) returns (uint8) { return 9; } function totalAssets() external view override returns (uint256) { return _convertToAssetsDown(totalSupply()); } function convertToShares(uint256 assets) external view override returns (uint256) { return _convertToSharesDown(assets); } function convertToAssets(uint256 shares) external view override returns (uint256) { return _convertToAssetsDown(shares); } function maxDeposit( address /*receiver*/ ) external pure override returns (uint256) { return type(uint256).max; } function previewDeposit(uint256 assets) external view override returns (uint256) { return _convertToSharesDown(assets); } function deposit(uint256 assets, address receiver) external override whenNotPaused returns (uint256 shares) { require( receiver != address(0), "Zero address for receiver not allowed" ); _pullAssets(msg.sender, assets); shares = _convertToSharesDown(assets); if (shares != 0) { _mint(receiver, shares); } emit Deposit(msg.sender, receiver, assets, shares); } function maxMint( address /*receiver*/ ) external pure override returns (uint256) { return type(uint256).max; } function previewMint(uint256 shares) external view override returns (uint256) { return _convertToAssetsUp(shares); } function mint(uint256 shares, address receiver) external override whenNotPaused returns (uint256 assets) { require( receiver != address(0), "Zero address for receiver not allowed" ); assets = _convertToAssetsUp(shares); if (assets != 0) { _pullAssets(msg.sender, assets); } _mint(receiver, shares); emit Deposit(msg.sender, receiver, assets, shares); } function maxWithdraw(address owner) external view override returns (uint256) { return _convertToAssetsDown(balanceOf(owner)); } function previewWithdraw(uint256 assets) external view override returns (uint256) { return _convertToSharesUp(assets); } function withdraw( uint256 assets, address receiver, address owner ) external override whenNotPaused returns (uint256 shares) { require( receiver != address(0), "Zero address for receiver not allowed" ); require(owner != address(0), "Zero address for owner not allowed"); shares = _convertToSharesUp(assets); if (owner != msg.sender) { uint256 currentAllowance = allowance(owner, msg.sender); require( currentAllowance >= shares, "Withdraw amount exceeds allowance" ); _approve(owner, msg.sender, currentAllowance - shares); } if (shares != 0) { _burn(owner, shares); } _pushAssets(receiver, assets); emit Withdraw(msg.sender, receiver, owner, assets, shares); } function maxRedeem(address owner) external view override returns (uint256) { return balanceOf(owner); } function previewRedeem(uint256 shares) external view override returns (uint256) { return _convertToAssetsDown(shares); } function redeem( uint256 shares, address receiver, address owner ) external override whenNotPaused returns (uint256 assets) { require( receiver != address(0), "Zero address for receiver not allowed" ); require(owner != address(0), "Zero address for owner not allowed"); if (owner != msg.sender) { uint256 currentAllowance = allowance(owner, msg.sender); require( currentAllowance >= shares, "Redeem amount exceeds allowance" ); _approve(owner, msg.sender, currentAllowance - shares); } _burn(owner, shares); assets = _convertToAssetsDown(shares); if (assets != 0) { _pushAssets(receiver, assets); } emit Withdraw(msg.sender, receiver, owner, assets, shares); } function _getRate() private view returns (uint256) { bytes memory data = asset.functionStaticCall( abi.encodeWithSignature("liquidityIndex()") ); return abi.decode(data, (uint256)); } function _convertToSharesUp(uint256 assets) private view returns (uint256) { return assets.rayDiv(_getRate()); } function _convertToAssetsUp(uint256 shares) private view returns (uint256) { return shares.rayMul(_getRate()); } function _convertToSharesDown(uint256 assets) private view returns (uint256) { return (assets * WadRayMath.RAY) / _getRate(); } function _convertToAssetsDown(uint256 shares) private view returns (uint256) { return (shares * _getRate()) / WadRayMath.RAY; } function _pullAssets(address from, uint256 amount) private { asset.functionCall( abi.encodeWithSelector( IERC20Upgradeable.transferFrom.selector, from, address(this), amount ) ); } function _pushAssets(address to, uint256 amount) private { asset.functionCall( abi.encodeWithSelector( IERC20Upgradeable.transfer.selector, to, amount ) ); } /// /// LayerZero overrides /// function sendFrom( address _from, uint16 _dstChainId, bytes calldata _toAddress, uint256 _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) public payable override whenNotPaused { _send( _from, _dstChainId, _toAddress, _amount, _refundAddress, _zroPaymentAddress, _adapterParams ); } function _debitFrom( address _from, uint16, bytes memory, uint256 _amount ) internal override returns (uint256) { address spender = _msgSender(); if (_from != spender) _spendAllowance(_from, spender, _amount); _transfer(_from, address(this), _amount); return _amount; } function _creditTo( uint16, address _toAddress, uint256 _amount ) internal override returns (uint256) { _transfer(address(this), _toAddress, _amount); return _amount; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface 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.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @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.7.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { 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}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _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 value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 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; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; 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; } _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 {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol"; import "../token/ERC20/extensions/IERC20Metadata.sol"; /** * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. * * _Available since v4.7._ */ interface IERC4626 is IERC20, IERC20Metadata { event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares); event Withdraw( address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /** * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing. * * - MUST be an ERC-20 token contract. * - MUST NOT revert. */ function asset() external view returns (address assetTokenAddress); /** * @dev Returns the total amount of the underlying asset that is “managed” by Vault. * * - SHOULD include any compounding that occurs from yield. * - MUST be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT revert. */ function totalAssets() external view returns (uint256 totalManagedAssets); /** * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToShares(uint256 assets) external view returns (uint256 shares); /** * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToAssets(uint256 shares) external view returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, * through a deposit call. * * - MUST return a limited value if receiver is subject to some deposit limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited. * - MUST NOT revert. */ function maxDeposit(address receiver) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given * current on-chain conditions. * * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called * in the same transaction. * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the * deposit would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewDeposit(uint256 assets) external view returns (uint256 shares); /** * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * deposit execution, and are accounted for during deposit. * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function deposit(uint256 assets, address receiver) external returns (uint256 shares); /** * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. * - MUST return a limited value if receiver is subject to some mint limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. * - MUST NOT revert. */ function maxMint(address receiver) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given * current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the * same transaction. * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint * would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by minting. */ function previewMint(uint256 shares) external view returns (uint256 assets); /** * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint * execution, and are accounted for during mint. * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function mint(uint256 shares, address receiver) external returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the * Vault, through a withdraw call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST NOT revert. */ function maxWithdraw(address owner) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, * given current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if * called * in the same transaction. * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though * the withdrawal would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewWithdraw(uint256 assets) external view returns (uint256 shares); /** * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * withdraw execution, and are accounted for during withdraw. * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function withdraw( uint256 assets, address receiver, address owner ) external returns (uint256 shares); /** * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, * through a redeem call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock. * - MUST NOT revert. */ function maxRedeem(address owner) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, * given current on-chain conditions. * * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the * same transaction. * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the * redemption would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by redeeming. */ function previewRedeem(uint256 shares) external view returns (uint256 assets); /** * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * redeem execution, and are accounted for during redeem. * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function redeem( uint256 shares, address receiver, address owner ) external returns (uint256 assets); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. It 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)`. // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`. // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`. // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a // good first aproximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1; uint256 x = a; if (x >> 128 > 0) { x >>= 128; result <<= 64; } if (x >> 64 > 0) { x >>= 64; result <<= 32; } if (x >> 32 > 0) { x >>= 32; result <<= 16; } if (x >> 16 > 0) { x >>= 16; result <<= 8; } if (x >> 8 > 0) { x >>= 8; result <<= 4; } if (x >> 4 > 0) { x >>= 4; result <<= 2; } if (x >> 2 > 0) { result <<= 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) { uint256 result = sqrt(a); if (rounding == Rounding.Up && result * result < a) { result += 1; } return result; } }
// 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 v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ 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. * * `initializer` is equivalent to `reinitializer(1)`, so 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. * * 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. */ 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. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @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.7.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.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => 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}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) 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 value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 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; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; 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; } _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 v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "./IOFTCoreUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; /** * @dev Interface of the OFT standard */ interface IOFTUpgradeable is IOFTCoreUpgradeable, IERC20Upgradeable { }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "./IOFTCoreUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol"; import "../../lzApp/NonblockingLzAppUpgradeable.sol"; abstract contract OFTCoreUpgradeable is Initializable, NonblockingLzAppUpgradeable, ERC165Upgradeable, IOFTCoreUpgradeable { using BytesLib for bytes; uint public constant NO_EXTRA_GAS = 0; // packet type uint16 public constant PT_SEND = 0; bool public useCustomAdapterParams; function __OFTCoreUpgradeable_init(address _lzEndpoint) internal onlyInitializing { __Ownable_init_unchained(); __LzAppUpgradeable_init_unchained(_lzEndpoint); } function __OFTCoreUpgradeable_init_unchained() internal onlyInitializing {} function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IOFTCoreUpgradeable).interfaceId || super.supportsInterface(interfaceId); } function estimateSendFee(uint16 _dstChainId, bytes calldata _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams) public view virtual override returns (uint nativeFee, uint zroFee) { // mock the payload for sendFrom() bytes memory payload = abi.encode(PT_SEND, _toAddress, _amount); return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams); } function sendFrom(address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) public payable virtual override { _send(_from, _dstChainId, _toAddress, _amount, _refundAddress, _zroPaymentAddress, _adapterParams); } function setUseCustomAdapterParams(bool _useCustomAdapterParams) public virtual onlyOwner { useCustomAdapterParams = _useCustomAdapterParams; emit SetUseCustomAdapterParams(_useCustomAdapterParams); } function _nonblockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual override { uint16 packetType; assembly { packetType := mload(add(_payload, 32)) } if (packetType == PT_SEND) { _sendAck(_srcChainId, _srcAddress, _nonce, _payload); } else { revert("OFTCore: unknown packet type"); } } function _send(address _from, uint16 _dstChainId, bytes memory _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams) internal virtual { _checkAdapterParams(_dstChainId, PT_SEND, _adapterParams, NO_EXTRA_GAS); uint amount = _debitFrom(_from, _dstChainId, _toAddress, _amount); bytes memory lzPayload = abi.encode(PT_SEND, _toAddress, amount); _lzSend(_dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value); emit SendToChain(_dstChainId, _from, _toAddress, amount); } function _sendAck(uint16 _srcChainId, bytes memory, uint64, bytes memory _payload) internal virtual { (, bytes memory toAddressBytes, uint amount) = abi.decode(_payload, (uint16, bytes, uint)); address to = toAddressBytes.toAddress(0); amount = _creditTo(_srcChainId, to, amount); emit ReceiveFromChain(_srcChainId, to, amount); } function _checkAdapterParams(uint16 _dstChainId, uint16 _pkType, bytes memory _adapterParams, uint _extraGas) internal virtual { if (useCustomAdapterParams) { _checkGasLimit(_dstChainId, _pkType, _adapterParams, _extraGas); } else { require(_adapterParams.length == 0, "OFTCore: _adapterParams must be empty."); } } function _debitFrom(address _from, uint16 _dstChainId, bytes memory _toAddress, uint _amount) internal virtual returns(uint); function _creditTo(uint16 _srcChainId, address _toAddress, uint _amount) internal virtual returns(uint); /** * @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 */ uint[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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 pragma solidity ^0.8.2; import "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol"; /** * @dev Interface of the IOFT core standard */ interface IOFTCoreUpgradeable is IERC165Upgradeable { /** * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`) * _dstChainId - L0 defined chain id to send tokens too * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain * _amount - amount of the tokens to transfer * _useZro - indicates to use zro to pay L0 fees * _adapterParam - flexible bytes array to indicate messaging adapter services in L0 */ function estimateSendFee(uint16 _dstChainId, bytes calldata _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee); /** * @dev send `_amount` amount of token to (`_dstChainId`, `_toAddress`) from `_from` * `_from` the owner of token * `_dstChainId` the destination chain identifier * `_toAddress` can be any size depending on the `dstChainId`. * `_amount` the quantity of tokens in wei * `_refundAddress` the address LayerZero refunds if too much message fee is sent * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token) * `_adapterParams` is a flexible bytes array to indicate messaging adapter services */ function sendFrom(address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable; /** * @dev returns the circulating amount of tokens on current chain */ function circulatingSupply() external view returns (uint); /** * @dev returns the address of the ERC20 token */ function token() external view returns (address); /** * @dev Emitted when `_amount` tokens are moved from the `_sender` to (`_dstChainId`, `_toAddress`) * `_nonce` is the outbound nonce */ event SendToChain(uint16 indexed _dstChainId, address indexed _from, bytes _toAddress, uint _amount); /** * @dev Emitted when `_amount` tokens are received from `_srcChainId` into the `_toAddress` on the local chain. * `_nonce` is the inbound nonce. */ event ReceiveFromChain(uint16 indexed _srcChainId, address indexed _to, uint _amount); event SetUseCustomAdapterParams(bool _useCustomAdapterParams); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @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 pragma solidity ^0.8.2; import "./LzAppUpgradeable.sol"; import "../../util/ExcessivelySafeCall.sol"; /* * the default LayerZero messaging behaviour is blocking, i.e. any failed message will block the channel * this abstract class try-catch all fail messages and store locally for future retry. hence, non-blocking * NOTE: if the srcAddress is not configured properly, it will still block the message pathway from (srcChainId, srcAddress) */ abstract contract NonblockingLzAppUpgradeable is Initializable, LzAppUpgradeable { using ExcessivelySafeCall for address; function __NonblockingLzAppUpgradeable_init(address _endpoint) internal onlyInitializing { __Ownable_init_unchained(); __LzAppUpgradeable_init_unchained(_endpoint); } function __NonblockingLzAppUpgradeable_init_unchained(address _endpoint) internal onlyInitializing {} mapping(uint16 => mapping(bytes => mapping(uint64 => bytes32))) public failedMessages; event MessageFailed(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes _payload, bytes _reason); event RetryMessageSuccess(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes32 _payloadHash); // overriding the virtual function in LzReceiver function _blockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual override { (bool success, bytes memory reason) = address(this).excessivelySafeCall(gasleft(), 150, abi.encodeWithSelector(this.nonblockingLzReceive.selector, _srcChainId, _srcAddress, _nonce, _payload)); // try-catch all errors/exceptions if (!success) { _storeFailedMessage(_srcChainId, _srcAddress, _nonce, _payload, reason); } } function _storeFailedMessage(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload, bytes memory _reason) internal virtual { failedMessages[_srcChainId][_srcAddress][_nonce] = keccak256(_payload); emit MessageFailed(_srcChainId, _srcAddress, _nonce, _payload, _reason); } function nonblockingLzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public virtual { // only internal transaction require(_msgSender() == address(this), "NonblockingLzApp: caller must be LzApp"); _nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); } //@notice override this function function _nonblockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual; function retryMessage(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public payable virtual { // assert there is message to retry bytes32 payloadHash = failedMessages[_srcChainId][_srcAddress][_nonce]; require(payloadHash != bytes32(0), "NonblockingLzApp: no stored message"); require(keccak256(_payload) == payloadHash, "NonblockingLzApp: invalid payload"); // clear the stored message failedMessages[_srcChainId][_srcAddress][_nonce] = bytes32(0); // execute the message. revert if it fails again _nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); emit RetryMessageSuccess(_srcChainId, _srcAddress, _nonce, payloadHash); } /** * @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 */ uint[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "../interfaces/ILayerZeroReceiverUpgradeable.sol"; import "../interfaces/ILayerZeroUserApplicationConfigUpgradeable.sol"; import "../interfaces/ILayerZeroEndpointUpgradeable.sol"; import "../../util/BytesLib.sol"; /* * a generic LzReceiver implementation */ abstract contract LzAppUpgradeable is Initializable, OwnableUpgradeable, ILayerZeroReceiverUpgradeable, ILayerZeroUserApplicationConfigUpgradeable { using BytesLib for bytes; // ua can not send payload larger than this by default, but it can be changed by the ua owner uint constant public DEFAULT_PAYLOAD_SIZE_LIMIT = 10000; ILayerZeroEndpointUpgradeable public lzEndpoint; mapping(uint16 => bytes) public trustedRemoteLookup; mapping(uint16 => mapping(uint16 => uint)) public minDstGasLookup; mapping(uint16 => uint) public payloadSizeLimitLookup; address public precrime; event SetPrecrime(address precrime); event SetTrustedRemote(uint16 _remoteChainId, bytes _path); event SetTrustedRemoteAddress(uint16 _remoteChainId, bytes _remoteAddress); event SetMinDstGas(uint16 _dstChainId, uint16 _type, uint _minDstGas); function __LzAppUpgradeable_init(address _endpoint) internal onlyInitializing { __Ownable_init_unchained(); __LzAppUpgradeable_init_unchained(_endpoint); } function __LzAppUpgradeable_init_unchained(address _endpoint) internal onlyInitializing { lzEndpoint = ILayerZeroEndpointUpgradeable(_endpoint); } function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public virtual override { // lzReceive must be called by the endpoint for security require(_msgSender() == address(lzEndpoint), "LzApp: invalid endpoint caller"); bytes memory trustedRemote = trustedRemoteLookup[_srcChainId]; // if will still block the message pathway from (srcChainId, srcAddress). should not receive message from untrusted remote. require(_srcAddress.length == trustedRemote.length && trustedRemote.length > 0 && keccak256(_srcAddress) == keccak256(trustedRemote), "LzApp: invalid source sending contract"); _blockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); } // abstract function - the default behaviour of LayerZero is blocking. See: NonblockingLzApp if you dont need to enforce ordered messaging function _blockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual; function _lzSend(uint16 _dstChainId, bytes memory _payload, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams, uint _nativeFee) internal virtual { bytes memory trustedRemote = trustedRemoteLookup[_dstChainId]; require(trustedRemote.length != 0, "LzApp: destination chain is not a trusted source"); _checkPayloadSize(_dstChainId, _payload.length); lzEndpoint.send{value: _nativeFee}(_dstChainId, trustedRemote, _payload, _refundAddress, _zroPaymentAddress, _adapterParams); } function _checkGasLimit(uint16 _dstChainId, uint16 _type, bytes memory _adapterParams, uint _extraGas) internal view virtual { uint providedGasLimit = _getGasLimit(_adapterParams); uint minGasLimit = minDstGasLookup[_dstChainId][_type] + _extraGas; require(minGasLimit > 0, "LzApp: minGasLimit not set"); require(providedGasLimit >= minGasLimit, "LzApp: gas limit is too low"); } function _getGasLimit(bytes memory _adapterParams) internal pure virtual returns (uint gasLimit) { require(_adapterParams.length >= 34, "LzApp: invalid adapterParams"); assembly { gasLimit := mload(add(_adapterParams, 34)) } } function _checkPayloadSize(uint16 _dstChainId, uint _payloadSize) internal view virtual { uint payloadSizeLimit = payloadSizeLimitLookup[_dstChainId]; if (payloadSizeLimit == 0) { // use default if not set payloadSizeLimit = DEFAULT_PAYLOAD_SIZE_LIMIT; } require(_payloadSize <= payloadSizeLimit, "LzApp: payload size is too large"); } //---------------------------UserApplication config---------------------------------------- function getConfig(uint16 _version, uint16 _chainId, address, uint _configType) external view returns (bytes memory) { return lzEndpoint.getConfig(_version, _chainId, address(this), _configType); } // generic config for LayerZero user Application function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external override onlyOwner { lzEndpoint.setConfig(_version, _chainId, _configType, _config); } function setSendVersion(uint16 _version) external override onlyOwner { lzEndpoint.setSendVersion(_version); } function setReceiveVersion(uint16 _version) external override onlyOwner { lzEndpoint.setReceiveVersion(_version); } function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external override onlyOwner { lzEndpoint.forceResumeReceive(_srcChainId, _srcAddress); } // _path = abi.encodePacked(remoteAddress, localAddress) // this function set the trusted path for the cross-chain communication function setTrustedRemote(uint16 _srcChainId, bytes calldata _path) external onlyOwner { trustedRemoteLookup[_srcChainId] = _path; emit SetTrustedRemote(_srcChainId, _path); } function setTrustedRemoteAddress(uint16 _remoteChainId, bytes calldata _remoteAddress) external onlyOwner { trustedRemoteLookup[_remoteChainId] = abi.encodePacked(_remoteAddress, address(this)); emit SetTrustedRemoteAddress(_remoteChainId, _remoteAddress); } function getTrustedRemoteAddress(uint16 _remoteChainId) external view returns (bytes memory) { bytes memory path = trustedRemoteLookup[_remoteChainId]; require(path.length != 0, "LzApp: no trusted path record"); return path.slice(0, path.length - 20); // the last 20 bytes should be address(this) } function setPrecrime(address _precrime) external onlyOwner { precrime = _precrime; emit SetPrecrime(_precrime); } function setMinDstGas(uint16 _dstChainId, uint16 _packetType, uint _minGas) external onlyOwner { require(_minGas > 0, "LzApp: invalid minGas"); minDstGasLookup[_dstChainId][_packetType] = _minGas; emit SetMinDstGas(_dstChainId, _packetType, _minGas); } // if the size is 0, it means default size limit function setPayloadSizeLimit(uint16 _dstChainId, uint _size) external onlyOwner { payloadSizeLimitLookup[_dstChainId] = _size; } //--------------------------- VIEW FUNCTION ---------------------------------------- function isTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool) { bytes memory trustedSource = trustedRemoteLookup[_srcChainId]; return keccak256(trustedSource) == keccak256(_srcAddress); } /** * @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 */ uint[45] private __gap; }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.7.6; library ExcessivelySafeCall { uint256 constant LOW_28_MASK = 0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff; /// @notice Use when you _really_ really _really_ don't trust the called /// contract. This prevents the called contract from causing reversion of /// the caller in as many ways as we can. /// @dev The main difference between this and a solidity low-level call is /// that we limit the number of bytes that the callee can cause to be /// copied to caller memory. This prevents stupid things like malicious /// contracts returning 10,000,000 bytes causing a local OOG when copying /// to memory. /// @param _target The address to call /// @param _gas The amount of gas to forward to the remote contract /// @param _maxCopy The maximum number of bytes of returndata to copy /// to memory. /// @param _calldata The data to send to the remote contract /// @return success and returndata, as `.call()`. Returndata is capped to /// `_maxCopy` bytes. function excessivelySafeCall( address _target, uint256 _gas, uint16 _maxCopy, bytes memory _calldata ) internal returns (bool, bytes memory) { // set up for assembly call uint256 _toCopy; bool _success; bytes memory _returnData = new bytes(_maxCopy); // dispatch message to recipient // by assembly calling "handle" function // we call via assembly to avoid memcopying a very large returndata // returned by a malicious contract assembly { _success := call( _gas, // gas _target, // recipient 0, // ether value add(_calldata, 0x20), // inloc mload(_calldata), // inlen 0, // outloc 0 // outlen ) // limit our copy to 256 bytes _toCopy := returndatasize() if gt(_toCopy, _maxCopy) { _toCopy := _maxCopy } // Store the length of the copied bytes mstore(_returnData, _toCopy) // copy the bytes from returndata[0:_toCopy] returndatacopy(add(_returnData, 0x20), 0, _toCopy) } return (_success, _returnData); } /// @notice Use when you _really_ really _really_ don't trust the called /// contract. This prevents the called contract from causing reversion of /// the caller in as many ways as we can. /// @dev The main difference between this and a solidity low-level call is /// that we limit the number of bytes that the callee can cause to be /// copied to caller memory. This prevents stupid things like malicious /// contracts returning 10,000,000 bytes causing a local OOG when copying /// to memory. /// @param _target The address to call /// @param _gas The amount of gas to forward to the remote contract /// @param _maxCopy The maximum number of bytes of returndata to copy /// to memory. /// @param _calldata The data to send to the remote contract /// @return success and returndata, as `.call()`. Returndata is capped to /// `_maxCopy` bytes. function excessivelySafeStaticCall( address _target, uint256 _gas, uint16 _maxCopy, bytes memory _calldata ) internal view returns (bool, bytes memory) { // set up for assembly call uint256 _toCopy; bool _success; bytes memory _returnData = new bytes(_maxCopy); // dispatch message to recipient // by assembly calling "handle" function // we call via assembly to avoid memcopying a very large returndata // returned by a malicious contract assembly { _success := staticcall( _gas, // gas _target, // recipient add(_calldata, 0x20), // inloc mload(_calldata), // inlen 0, // outloc 0 // outlen ) // limit our copy to 256 bytes _toCopy := returndatasize() if gt(_toCopy, _maxCopy) { _toCopy := _maxCopy } // Store the length of the copied bytes mstore(_returnData, _toCopy) // copy the bytes from returndata[0:_toCopy] returndatacopy(add(_returnData, 0x20), 0, _toCopy) } return (_success, _returnData); } /** * @notice Swaps function selectors in encoded contract calls * @dev Allows reuse of encoded calldata for functions with identical * argument types but different names. It simply swaps out the first 4 bytes * for the new selector. This function modifies memory in place, and should * only be used with caution. * @param _newSelector The new 4-byte selector * @param _buf The encoded contract args */ function swapSelector(bytes4 _newSelector, bytes memory _buf) internal pure { require(_buf.length >= 4); uint256 _mask = LOW_28_MASK; assembly { // load the first word of let _word := mload(add(_buf, 0x20)) // mask out the top 4 bytes // /x _word := and(_word, _mask) _word := or(_newSelector, _word) mstore(add(_buf, 0x20), _word) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; interface ILayerZeroReceiverUpgradeable { // @notice LayerZero endpoint will invoke this function to deliver the message on the destination // @param _srcChainId - the source endpoint identifier // @param _srcAddress - the source sending contract address from the source chain // @param _nonce - the ordered message nonce // @param _payload - the signed payload is the UA bytes has encoded to be sent function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; interface ILayerZeroUserApplicationConfigUpgradeable { // @notice set the configuration of the LayerZero messaging library of the specified version // @param _version - messaging library version // @param _chainId - the chainId for the pending config change // @param _configType - type of configuration. every messaging library has its own convention. // @param _config - configuration in the bytes. can encode arbitrary content. function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external; // @notice set the send() LayerZero messaging library version to _version // @param _version - new messaging library version function setSendVersion(uint16 _version) external; // @notice set the lzReceive() LayerZero messaging library version to _version // @param _version - new messaging library version function setReceiveVersion(uint16 _version) external; // @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload // @param _srcChainId - the chainId of the source chain // @param _srcAddress - the contract address of the source contract at the source chain function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "./ILayerZeroUserApplicationConfigUpgradeable.sol"; interface ILayerZeroEndpointUpgradeable is ILayerZeroUserApplicationConfigUpgradeable { // @notice send a LayerZero message to the specified address at a LayerZero endpoint. // @param _dstChainId - the destination chain identifier // @param _destination - the address on destination chain (in bytes). address length/format may vary by chains // @param _payload - a custom bytes payload to send to the destination contract // @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address // @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction // @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination function send(uint16 _dstChainId, bytes calldata _destination, bytes calldata _payload, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable; // @notice used by the messaging library to publish verified payload // @param _srcChainId - the source chain identifier // @param _srcAddress - the source contract (as bytes) at the source chain // @param _dstAddress - the address on destination chain // @param _nonce - the unbound message ordering nonce // @param _gasLimit - the gas limit for external contract execution // @param _payload - verified payload to send to the destination contract function receivePayload(uint16 _srcChainId, bytes calldata _srcAddress, address _dstAddress, uint64 _nonce, uint _gasLimit, bytes calldata _payload) external; // @notice get the inboundNonce of a lzApp from a source chain which could be EVM or non-EVM chain // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64); // @notice get the outboundNonce from this source chain which, consequently, is always an EVM // @param _srcAddress - the source chain contract address function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64); // @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery // @param _dstChainId - the destination chain identifier // @param _userApplication - the user app address on this EVM chain // @param _payload - the custom message to send over LayerZero // @param _payInZRO - if false, user app pays the protocol fee in native token // @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain function estimateFees(uint16 _dstChainId, address _userApplication, bytes calldata _payload, bool _payInZRO, bytes calldata _adapterParam) external view returns (uint nativeFee, uint zroFee); // @notice get this Endpoint's immutable source identifier function getChainId() external view returns (uint16); // @notice the interface to retry failed message on this Endpoint destination // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address // @param _payload - the payload to be retried function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external; // @notice query if any STORED payload (message blocking) at the endpoint. // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool); // @notice query if the _libraryAddress is valid for sending msgs. // @param _userApplication - the user app address on this EVM chain function getSendLibraryAddress(address _userApplication) external view returns (address); // @notice query if the _libraryAddress is valid for receiving msgs. // @param _userApplication - the user app address on this EVM chain function getReceiveLibraryAddress(address _userApplication) external view returns (address); // @notice query if the non-reentrancy guard for send() is on // @return true if the guard is on. false otherwise function isSendingPayload() external view returns (bool); // @notice query if the non-reentrancy guard for receive() is on // @return true if the guard is on. false otherwise function isReceivingPayload() external view returns (bool); // @notice get the configuration of the LayerZero messaging library of the specified version // @param _version - messaging library version // @param _chainId - the chainId for the pending config change // @param _userApplication - the contract address of the user application // @param _configType - type of configuration. every messaging library has its own convention. function getConfig(uint16 _version, uint16 _chainId, address _userApplication, uint _configType) external view returns (bytes memory); // @notice get the send() LayerZero messaging library version // @param _userApplication - the contract address of the user application function getSendVersion(address _userApplication) external view returns (uint16); // @notice get the lzReceive() LayerZero messaging library version // @param _userApplication - the contract address of the user application function getReceiveVersion(address _userApplication) external view returns (uint16); }
// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.8.0 <0.9.0; library BytesLib { function concat( bytes memory _preBytes, bytes memory _postBytes ) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore(0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. )) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore( sc, add( and( fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00 ), and(mload(mc), mask) ) ) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1 , "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage( bytes storage _preBytes, bytes memory _postBytes ) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for {} eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @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: AGPL-3.0-or-later pragma solidity ^0.8.9; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract AddressProvider is OwnableUpgradeable { event UpdatedAddress(bytes32 indexed component, address indexed newAddress); mapping(bytes32 => address) public getAddress; function initialize() public initializer { __Ownable_init(); } function setAddress(bytes32 component, address address_) external onlyOwner { getAddress[component] = address_; emit UpdatedAddress(component, address_); } function getAddresses(bytes calldata components) external view returns (bytes memory) { uint256 length = components.length; bytes memory result = new bytes(length); uint256 ptr; assembly { ptr := add(result, 0x20) } for (uint256 i = 0; i < length; i += 32) { address address_ = getAddress[bytes32(components[i:(i + 32)])]; assembly { mstore(ptr, address_) ptr := add(ptr, 0x20) } } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_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) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_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) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (interfaces/IERC4626.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20Upgradeable.sol"; import "../token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; /** * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626]. * * _Available since v4.7._ */ interface IERC4626Upgradeable is IERC20Upgradeable, IERC20MetadataUpgradeable { event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares); event Withdraw( address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /** * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing. * * - MUST be an ERC-20 token contract. * - MUST NOT revert. */ function asset() external view returns (address assetTokenAddress); /** * @dev Returns the total amount of the underlying asset that is “managed” by Vault. * * - SHOULD include any compounding that occurs from yield. * - MUST be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT revert. */ function totalAssets() external view returns (uint256 totalManagedAssets); /** * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToShares(uint256 assets) external view returns (uint256 shares); /** * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal * scenario where all the conditions are met. * * - MUST NOT be inclusive of any fees that are charged against assets in the Vault. * - MUST NOT show any variations depending on the caller. * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. * - MUST NOT revert. * * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and * from. */ function convertToAssets(uint256 shares) external view returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, * through a deposit call. * * - MUST return a limited value if receiver is subject to some deposit limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited. * - MUST NOT revert. */ function maxDeposit(address receiver) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given * current on-chain conditions. * * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called * in the same transaction. * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the * deposit would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewDeposit(uint256 assets) external view returns (uint256 shares); /** * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * deposit execution, and are accounted for during deposit. * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function deposit(uint256 assets, address receiver) external returns (uint256 shares); /** * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. * - MUST return a limited value if receiver is subject to some mint limit. * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. * - MUST NOT revert. */ function maxMint(address receiver) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given * current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the * same transaction. * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint * would be accepted, regardless if the user has enough tokens approved, etc. * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by minting. */ function previewMint(uint256 shares) external view returns (uint256 assets); /** * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. * * - MUST emit the Deposit event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint * execution, and are accounted for during mint. * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not * approving enough underlying tokens to the Vault contract, etc). * * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. */ function mint(uint256 shares, address receiver) external returns (uint256 assets); /** * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the * Vault, through a withdraw call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST NOT revert. */ function maxWithdraw(address owner) external view returns (uint256 maxAssets); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, * given current on-chain conditions. * * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if * called * in the same transaction. * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though * the withdrawal would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by depositing. */ function previewWithdraw(uint256 assets) external view returns (uint256 shares); /** * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * withdraw execution, and are accounted for during withdraw. * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function withdraw( uint256 assets, address receiver, address owner ) external returns (uint256 shares); /** * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, * through a redeem call. * * - MUST return a limited value if owner is subject to some withdrawal limit or timelock. * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock. * - MUST NOT revert. */ function maxRedeem(address owner) external view returns (uint256 maxShares); /** * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, * given current on-chain conditions. * * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the * same transaction. * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the * redemption would be accepted, regardless if the user has enough shares, etc. * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. * - MUST NOT revert. * * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in * share price or some other type of condition, meaning the depositor will lose assets by redeeming. */ function previewRedeem(uint256 shares) external view returns (uint256 assets); /** * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver. * * - MUST emit the Withdraw event. * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the * redeem execution, and are accounted for during redeem. * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner * not having enough shares, etc). * * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. * Those methods should be performed separately. */ function redeem( uint256 shares, address receiver, address owner ) external returns (uint256 assets); }
{ "optimizer": { "enabled": true, "runs": 10001 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"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":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"indexed":false,"internalType":"uint64","name":"_nonce","type":"uint64"},{"indexed":false,"internalType":"bytes","name":"_payload","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"_reason","type":"bytes"}],"name":"MessageFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"blockNumber","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"day","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"supply","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"supplyDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"Rebase","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"ReceiveFromChain","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"indexed":false,"internalType":"uint64","name":"_nonce","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"_payloadHash","type":"bytes32"}],"name":"RetryMessageSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":false,"internalType":"bytes","name":"_toAddress","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"SendToChain","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"_type","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"_minDstGas","type":"uint256"}],"name":"SetMinDstGas","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"precrime","type":"address"}],"name":"SetPrecrime","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_path","type":"bytes"}],"name":"SetTrustedRemote","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_remoteAddress","type":"bytes"}],"name":"SetTrustedRemoteAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_useCustomAdapterParams","type":"bool"}],"name":"SetUseCustomAdapterParams","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"srcChainId","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"liquidityIndex","type":"uint256"}],"name":"SyncFromChain","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"dstChainId","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"liquidityIndex","type":"uint256"}],"name":"SyncToChain","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_PAYLOAD_SIZE_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MULTICHAIN_VAULT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NO_EXTRA_GAS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PREVIOUS_WUSDR","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PT_SEND","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PT_SYNC","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"addressProvider","outputs":[{"internalType":"contract AddressProvider","name":"","type":"address"}],"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":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"circulatingSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","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":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"bytes","name":"_toAddress","type":"bytes"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bool","name":"_useZro","type":"bool"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"estimateSendFee","outputs":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"zroFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint64","name":"","type":"uint64"}],"name":"failedMessages","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"}],"name":"forceResumeReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_version","type":"uint16"},{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"_configType","type":"uint256"}],"name":"getConfig","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_remoteChainId","type":"uint16"}],"name":"getTrustedRemoteAddress","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"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":"_previousImplementation","type":"address"},{"internalType":"address","name":"_lzEndpoint","type":"address"},{"internalType":"bool","name":"_isMainChain","type":"bool"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isMain","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"}],"name":"isTrustedRemote","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidityIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lzEndpoint","outputs":[{"internalType":"contract ILayerZeroEndpointUpgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"internalType":"uint64","name":"_nonce","type":"uint64"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"uint16","name":"","type":"uint16"}],"name":"minDstGasLookup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"internalType":"uint64","name":"_nonce","type":"uint64"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"nonblockingLzReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"payloadSizeLimitLookup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"precrime","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"previousImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"supplyDelta","type":"uint256"}],"name":"rebase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reinitialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"resetInitialLiquidityIndex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"internalType":"uint64","name":"_nonce","type":"uint64"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"retryMessage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"bytes","name":"_toAddress","type":"bytes"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address payable","name":"_refundAddress","type":"address"},{"internalType":"address","name":"_zroPaymentAddress","type":"address"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"sendFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract AddressProvider","name":"_addressProvider","type":"address"}],"name":"setAddressProvider","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_version","type":"uint16"},{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"uint256","name":"_configType","type":"uint256"},{"internalType":"bytes","name":"_config","type":"bytes"}],"name":"setConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"uint16","name":"_packetType","type":"uint16"},{"internalType":"uint256","name":"_minGas","type":"uint256"}],"name":"setMinDstGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"uint256","name":"_size","type":"uint256"}],"name":"setPayloadSizeLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_precrime","type":"address"}],"name":"setPrecrime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_version","type":"uint16"}],"name":"setReceiveVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_version","type":"uint16"}],"name":"setSendVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_path","type":"bytes"}],"name":"setTrustedRemote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"internalType":"bytes","name":"_remoteAddress","type":"bytes"}],"name":"setTrustedRemoteAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_useCustomAdapterParams","type":"bool"}],"name":"setUseCustomAdapterParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"address payable","name":"_refundAddress","type":"address"},{"internalType":"address","name":"_zroPaymentAddress","type":"address"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"sync","outputs":[],"stateMutability":"payable","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":"to","type":"address"}],"name":"transferAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"}],"name":"transferAllFrom","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":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"trustedRemoteLookup","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"useCustomAdapterParams","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50615db280620000216000396000f3fe6080604052600436106104495760003560e01c80637533d78811610243578063baf3292d11610143578063df2a5b3b116100bb578063ed629c5c1161008a578063f5ecbdbc1161006f578063f5ecbdbc14610d02578063fc0c546a14610d22578063fecf973414610d3557600080fd5b8063ed629c5c14610cc7578063f2fde38b14610ce257600080fd5b8063df2a5b3b14610c3f578063e21f314a14610c5f578063eab45d9c14610c87578063eb8d72b714610ca757600080fd5b8063c446183411610112578063d1deba1f116100f7578063d1deba1f14610bc5578063d547741f14610bd8578063dd62ed3e14610bf857600080fd5b8063c446183414610b8f578063cbed8b9c14610ba557600080fd5b8063baf3292d14610b10578063bbf44f3314610b30578063bc4f2d6d14610b47578063c2c8486f14610b6757600080fd5b80639d0bcca0116101d6578063a3a7e7f3116101a5578063a6c3d1651161018a578063a6c3d16514610ab0578063a9059cbb14610ad0578063b353aaa714610af057600080fd5b8063a3a7e7f314610a70578063a457c2d714610a9057600080fd5b80639d0bcca014610a095780639dc29fac14610a305780639f38369a14610a50578063a217fddf1461076457600080fd5b806391d148541161021257806391d14854146109795780639358928b146109bf578063950c8a74146109d457806395d89b41146109f457600080fd5b80637533d788146108e357806384d4b410146109035780638cfd8f5c146109235780638da5cb5b1461095b57600080fd5b8063395093511161034e5780635b8c41e6116102e157806366ad5c8a116102b05780636c2eb350116102955780636c2eb3501461089957806370a08231146108ae578063715018a6146108ce57600080fd5b806366ad5c8a146108645780636965523a1461088457600080fd5b80635b8c41e6146107b45780635c975abb14610803578063604269d11461083457806363e57db91461084f57600080fd5b806342d65a8d1161031d57806342d65a8d1461074457806344770515146107645780634c42899a1461077957806351905636146107a157600080fd5b806339509351146106b75780633d8b38f6146106d75780633f1f4fa4146106f757806340c10f191461072457600080fd5b806318160ddd116103e15780632954018c116103b05780632f2ff15d116103955780632f2ff15d1461065b578063313ce5671461067b57806336568abe1461069757600080fd5b80632954018c146105ed5780632a205e3d1461062657600080fd5b806318160ddd1461055a5780631a5fa2e31461057d57806323b872dd1461059d578063248a9ca3146105bd57600080fd5b806307e0db171161041d57806307e0db17146104da578063095ea7b3146104fa5780630df374831461051a57806310ddb1371461053a57600080fd5b80621d35671461044e57806301ffc9a71461047057806304f23700146104a557806306fdde03146104b8575b600080fd5b34801561045a57600080fd5b5061046e610469366004614f3d565b610d55565b005b34801561047c57600080fd5b5061049061048b366004614fd3565b610f88565b60405190151581526020015b60405180910390f35b61046e6104b336600461502a565b610fa8565b3480156104c457600080fd5b506104cd611076565b60405161049c91906150fe565b3480156104e657600080fd5b5061046e6104f5366004615111565b611109565b34801561050657600080fd5b5061049061051536600461512e565b611188565b34801561052657600080fd5b5061046e61053536600461515a565b6111f5565b34801561054657600080fd5b5061046e610555366004615111565b611214565b34801561056657600080fd5b5061056f611269565b60405190815260200161049c565b34801561058957600080fd5b5061046e610598366004615178565b611471565b3480156105a957600080fd5b506104906105b8366004615195565b6114b8565b3480156105c957600080fd5b5061056f6105d83660046151d6565b600090815260fb602052604090206001015490565b3480156105f957600080fd5b5061012d5461060e906001600160a01b031681565b6040516001600160a01b03909116815260200161049c565b34801561063257600080fd5b506106466106413660046151ff565b611594565b6040805192835260208301919091520161049c565b34801561066757600080fd5b5061046e61067636600461529f565b611672565b34801561068757600080fd5b506040516009815260200161049c565b3480156106a357600080fd5b5061046e6106b236600461529f565b61169c565b3480156106c357600080fd5b506104906106d236600461512e565b611728565b3480156106e357600080fd5b506104906106f23660046152cf565b6117bb565b34801561070357600080fd5b5061056f610712366004615111565b60686020526000908152604090205481565b34801561073057600080fd5b5061046e61073f36600461512e565b611887565b34801561075057600080fd5b5061046e61075f3660046152cf565b611a27565b34801561077057600080fd5b5061056f600081565b34801561078557600080fd5b5061078e600081565b60405161ffff909116815260200161049c565b61046e6107af366004615324565b611aaa565b3480156107c057600080fd5b5061056f6107cf366004615476565b6097602090815260009384526040808520845180860184018051928152908401958401959095209452929052825290205481565b34801561080f57600080fd5b5061012d5474010000000000000000000000000000000000000000900460ff16610490565b34801561084057600080fd5b506101f5546104909060ff1681565b34801561085b57600080fd5b5061078e600181565b34801561087057600080fd5b5061046e61087f366004614f3d565b611b37565b34801561089057600080fd5b5061046e611c2a565b3480156108a557600080fd5b5061046e611dcb565b3480156108ba57600080fd5b5061056f6108c9366004615178565b611f27565b3480156108da57600080fd5b5061046e611f54565b3480156108ef57600080fd5b506104cd6108fe366004615111565b611f68565b34801561090f57600080fd5b5061049061091e366004615519565b612002565b34801561092f57600080fd5b5061056f61093e366004615547565b606760209081526000928352604080842090915290825290205481565b34801561096757600080fd5b506033546001600160a01b031661060e565b34801561098557600080fd5b5061049061099436600461529f565b600091825260fb602090815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156109cb57600080fd5b5061056f6120c1565b3480156109e057600080fd5b5060695461060e906001600160a01b031681565b348015610a0057600080fd5b506104cd6120d0565b348015610a1557600080fd5b506101f55461060e906201000090046001600160a01b031681565b348015610a3c57600080fd5b5061046e610a4b36600461512e565b6120e0565b348015610a5c57600080fd5b506104cd610a6b366004615111565b6122f1565b348015610a7c57600080fd5b50610490610a8b366004615178565b612408565b348015610a9c57600080fd5b50610490610aab36600461512e565b6124a9565b348015610abc57600080fd5b5061046e610acb3660046152cf565b612595565b348015610adc57600080fd5b50610490610aeb36600461512e565b612628565b348015610afc57600080fd5b5060655461060e906001600160a01b031681565b348015610b1c57600080fd5b5061046e610b2b366004615178565b6126d3565b348015610b3c57600080fd5b5061056f6101f85481565b348015610b5357600080fd5b5061046e610b623660046151d6565b612741565b348015610b7357600080fd5b5061060e7352b9d0f46451bd2c610ae6ab1f5312a35a6159e381565b348015610b9b57600080fd5b5061056f61271081565b348015610bb157600080fd5b5061046e610bc0366004615575565b612ad8565b61046e610bd3366004614f3d565b612b5f565b348015610be457600080fd5b5061046e610bf336600461529f565b612dad565b348015610c0457600080fd5b5061056f610c13366004615519565b6001600160a01b0391821660009081526101fa6020908152604080832093909416825291909152205490565b348015610c4b57600080fd5b5061046e610c5a3660046155cb565b612dd2565b348015610c6b57600080fd5b5061060e73af0d9d65fc54de245cda37af3d18cbec860a4d4b81565b348015610c9357600080fd5b5061046e610ca23660046155fb565b612e8c565b348015610cb357600080fd5b5061046e610cc23660046152cf565b612ef4565b348015610cd357600080fd5b5061015f546104909060ff1681565b348015610cee57600080fd5b5061046e610cfd366004615178565b612f4e565b348015610d0e57600080fd5b506104cd610d1d366004615616565b612fde565b348015610d2e57600080fd5b503061060e565b348015610d4157600080fd5b5061046e610d50366004615667565b613099565b6065546001600160a01b0316336001600160a01b031614610dbd5760405162461bcd60e51b815260206004820152601e60248201527f4c7a4170703a20696e76616c696420656e64706f696e742063616c6c6572000060448201526064015b60405180910390fd5b61ffff861660009081526066602052604081208054610ddb906156c1565b80601f0160208091040260200160405190810160405280929190818152602001828054610e07906156c1565b8015610e545780601f10610e2957610100808354040283529160200191610e54565b820191906000526020600020905b815481529060010190602001808311610e3757829003601f168201915b50505050509050805186869050148015610e6f575060008151115b8015610e97575080516020820120604051610e8d9088908890615715565b6040518091039020145b610f095760405162461bcd60e51b815260206004820152602660248201527f4c7a4170703a20696e76616c696420736f757263652073656e64696e6720636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401610db4565b610f7f8787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a018190048102820181019092528881528a93509150889088908190840183828082843760009201919091525061339c92505050565b50505050505050565b6000610f9382613442565b80610fa25750610fa2826134d9565b92915050565b610fb061355a565b6101f55460ff166110295760405162461bcd60e51b815260206004820152602360248201527f555344523a2063616e206f6e6c792073796e632066726f6d206d61696e20636860448201527f61696e00000000000000000000000000000000000000000000000000000000006064820152608401610db4565b61106f856101f854868686868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506135c692505050565b5050505050565b60606101948054611086906156c1565b80601f01602080910402602001604051908101604052809291908181526020018280546110b2906156c1565b80156110ff5780601f106110d4576101008083540402835291602001916110ff565b820191906000526020600020905b8154815290600101906020018083116110e257829003601f168201915b5050505050905090565b611111613649565b6065546040517f07e0db1700000000000000000000000000000000000000000000000000000000815261ffff831660048201526001600160a01b03909116906307e0db17906024015b600060405180830381600087803b15801561117457600080fd5b505af115801561106f573d6000803e3d6000fd5b3360008181526101fa602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906111e49086815260200190565b60405180910390a350600192915050565b6111fd613649565b61ffff909116600090815260686020526040902055565b61121c613649565b6065546040517f10ddb13700000000000000000000000000000000000000000000000000000000815261ffff831660048201526001600160a01b03909116906310ddb1379060240161115a565b6101f55460009081906201000090046001600160a01b03161561143f576040517f70a082310000000000000000000000000000000000000000000000000000000081527352b9d0f46451bd2c610ae6ab1f5312a35a6159e3600482015273af0d9d65fc54de245cda37af3d18cbec860a4d4b906307a2d13a9082906370a082319060240160206040518083038186803b15801561130557600080fd5b505afa158015611319573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133d9190615725565b6040518263ffffffff1660e01b815260040161135b91815260200190565b60206040518083038186803b15801561137357600080fd5b505afa158015611387573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ab9190615725565b6101f560029054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156113fa57600080fd5b505afa15801561140e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114329190615725565b61143c919061576d565b90505b8061146161145c6101f8546101f6546136a390919063ffffffff16565b6136dc565b61146b9190615784565b91505090565b600061147c81613703565b5061012d80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b60006114c261355a565b6114cd84338461370d565b60006114d983866137be565b6001600160a01b03861660009081526101f9602052604081208054929350839290919061150790849061576d565b90915550506001600160a01b03841660009081526101f9602052604081208054839290611535908490615784565b92505081905550836001600160a01b0316856001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161158191815260200190565b60405180910390a3506001949350505050565b6000806000808989896040516020016115b094939291906157c7565b60408051601f19818403018152908290526065547f40a7bb100000000000000000000000000000000000000000000000000000000083529092506001600160a01b0316906340a7bb1090611612908d90309086908c908c908c906004016157f6565b604080518083038186803b15801561162957600080fd5b505afa15801561163d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611661919061584a565b925092505097509795505050505050565b600082815260fb602052604090206001015461168d81613703565b6116978383613865565b505050565b6001600160a01b038116331461171a5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610db4565b6117248282613925565b5050565b3360009081526101fa602090815260408083206001600160a01b038616845290915281208054839190839061175e908490615784565b90915550503360008181526101fa602090815260408083206001600160a01b038816808552908352928190205490519081529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591016111e4565b61ffff8316600090815260666020526040812080548291906117dc906156c1565b80601f0160208091040260200160405190810160405280929190818152602001828054611808906156c1565b80156118555780601f1061182a57610100808354040283529160200191611855565b820191906000526020600020905b81548152906001019060200180831161183857829003601f168201915b50505050509050838360405161186c929190615715565b60405180910390208180519060200120149150509392505050565b7ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc96118b181613703565b6118b961355a565b6001600160a01b03831661190f5760405162461bcd60e51b815260206004820152601460248201527f6d696e7420746f207a65726f20616464726573730000000000000000000000006044820152606401610db4565b60006119276101f854611921856139c6565b906139d6565b9050611931611269565b61194b906fffffffffffffffffffffffffffffffff61576d565b81111561199a5760405162461bcd60e51b815260206004820152601360248201527f6d617820737570706c79206578636565646564000000000000000000000000006044820152606401610db4565b806101f660008282546119ad9190615784565b90915550506001600160a01b03841660009081526101f96020526040812080548392906119db908490615784565b90915550506040518381526001600160a01b038516906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a350505050565b611a2f613649565b6065546040517f42d65a8d0000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906342d65a8d90611a7c9086908690869060040161586e565b600060405180830381600087803b158015611a9657600080fd5b505af1158015610f7f573d6000803e3d6000fd5b611ab261355a565b611b2c898989898080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a018190048102820181019092528881528c93508b92508a918a908a9081908401838280828437600092019190915250613a0492505050565b505050505050505050565b333014611bac5760405162461bcd60e51b815260206004820152602660248201527f4e6f6e626c6f636b696e674c7a4170703a2063616c6c6572206d75737420626560448201527f204c7a41707000000000000000000000000000000000000000000000000000006064820152608401610db4565b611c228686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f890181900481028201810190925287815289935091508790879081908401838280828437600092019190915250613aab92505050565b505050505050565b611c32613649565b6101f55460ff16611c855760405162461bcd60e51b815260206004820152601460248201527f555344523a206e6f74206d61696e20636861696e0000000000000000000000006044820152606401610db4565b61012d546040517f21f8a7210000000000000000000000000000000000000000000000000000000081527f46368cfe9eb4bdc14a0db9efb4fd64daed77c6c7eed07a5ecc8636d750f4116c60048201526000916001600160a01b0316906321f8a7219060240160206040518083038186803b158015611d0357600080fd5b505afa158015611d17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3b919061588c565b90506001600160a01b038116301415611d5357600080fd5b806001600160a01b031663bbf44f336040518163ffffffff1660e01b815260040160206040518083038186803b158015611d8c57600080fd5b505afa158015611da0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc49190615725565b6101f85550565b600054600590610100900460ff16158015611ded575060005460ff8083169116105b611e5f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610db4565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001660ff80841691909117610100179091556101f55416611ec557611ea9600033613925565b611ec56000611ec06033546001600160a01b031690565b613865565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a150565b6101f8546001600160a01b03821660009081526101f960205260408120549091610fa29161145c916136a3565b611f5c613649565b611f666000613b29565b565b60666020526000908152604090208054611f81906156c1565b80601f0160208091040260200160405190810160405280929190818152602001828054611fad906156c1565b8015611ffa5780601f10611fcf57610100808354040283529160200191611ffa565b820191906000526020600020905b815481529060010190602001808311611fdd57829003601f168201915b505050505081565b600061200c61355a565b600061201784611f27565b6001600160a01b03851660009081526101f9602052604090205490915061203f85338461370d565b6001600160a01b0380861660009081526101f9602052604080822082905591861681529081208054839290612075908490615784565b92505081905550836001600160a01b0316856001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161158191815260200190565b60006120cb611269565b905090565b60606101958054611086906156c1565b6120e861355a565b6001600160a01b03821661213e5760405162461bcd60e51b815260206004820152601660248201527f6275726e2066726f6d207a65726f2061646472657373000000000000000000006044820152606401610db4565b336001600160a01b038316146121595761215982338361370d565b600061216483611f27565b9050818110156121b65760405162461bcd60e51b815260206004820152601b60248201527f6275726e20616d6f756e7420657863656564732062616c616e636500000000006044820152606401610db4565b81811415612210576001600160a01b03831660009081526101f960205260408120546101f68054919290916121ec90849061576d565b90915550506001600160a01b03831660009081526101f960205260408120556122aa565b60006122226101f854611921856139c6565b6001600160a01b03851660009081526101f9602052604090205490915081111561226257506001600160a01b03831660009081526101f960205260409020545b806101f66000828254612275919061576d565b90915550506001600160a01b03841660009081526101f96020526040812080548392906122a390849061576d565b9091555050505b6040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020015b60405180910390a3505050565b61ffff8116600090815260666020526040812080546060929190612314906156c1565b80601f0160208091040260200160405190810160405280929190818152602001828054612340906156c1565b801561238d5780601f106123625761010080835404028352916020019161238d565b820191906000526020600020905b81548152906001019060200180831161237057829003601f168201915b505050505090508051600014156123e65760405162461bcd60e51b815260206004820152601d60248201527f4c7a4170703a206e6f20747275737465642070617468207265636f72640000006044820152606401610db4565b6124016000601483516123f9919061576d565b839190613b93565b9392505050565b600061241261355a565b600061241d33611f27565b3360009081526101f960205260408082208054908390556001600160a01b038716835290822080549394509092839290612458908490615784565b90915550506040518281526001600160a01b0385169033907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a36001925050505b919050565b3360009081526101fa602090815260408083206001600160a01b03861684529091528120548083106124ff573360009081526101fa602090815260408083206001600160a01b038816845290915281205561252f565b612509838261576d565b3360009081526101fa602090815260408083206001600160a01b03891684529091529020555b3360008181526101fa602090815260408083206001600160a01b038916808552908352928190205490519081529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a35060019392505050565b61259d613649565b8181306040516020016125b2939291906158a9565b60408051601f1981840301815291815261ffff851660009081526066602090815291902082516125e793919290910190614d83565b507f8c0400cfe2d1199b1a725c78960bcc2a344d869b80590d0f2bd005db15a572ce83838360405161261b9392919061586e565b60405180910390a1505050565b600061263261355a565b600061263e83336137be565b3360009081526101f9602052604081208054929350839290919061266390849061576d565b90915550506001600160a01b03841660009081526101f9602052604081208054839290612691908490615784565b90915550506040518381526001600160a01b0385169033907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001612583565b6126db613649565b606980547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f5db758e995a17ec1ad84bdef7e8c3293a0bd6179bcce400dff5d4c3d87db726b90602001611f1c565b7f70546d1c92f8c2132ae23a23f5177aa8526356051c7510df99f50e012d22152961276b81613703565b61277361355a565b600061277d611269565b61012d54604080517fc83e4fd410f80be983b083c99898391186b0893751a26a9a1e5fdcb9d412970160208201527fd7b5cea1258f7a2acae3ed88fa9155d7a4e8425cafbbe0267f7d8ac75968341a8183015281518082038301815260608201928390527f7b7dfa550000000000000000000000000000000000000000000000000000000090925292935060009283926001600160a01b031691637b7dfa559161282a91906064016150fe565b60006040518083038186803b15801561284257600080fd5b505afa158015612856573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261287e9190810190615927565b806020019051810190612891919061595c565b9092509050336001600160a01b038316146128ee5760405162461bcd60e51b815260206004820152601660248201527f63616c6c6572206973206e6f74207472656173757279000000000000000000006044820152606401610db4565b8415612a7c576040517fbc5a6343000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b0382169063bc5a63439060240160206040518083038186803b15801561294d57600080fd5b505afa158015612961573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129859190615725565b945060006129a3846fffffffffffffffffffffffffffffffff61576d565b9050808611156129b1578095505b8515612a7a57836129c28782615784565b6101f8546129d0919061598b565b6129da91906159c8565b6101f8556129e6614e07565b846129ef611269565b6129f9919061576d565b600f0b60c08201526040517f152c60610000000000000000000000000000000000000000000000000000000081526001600160a01b0384169063152c606190612a46908490600401615a32565b600060405180830381600087803b158015612a6057600080fd5b505af1158015612a74573d6000803e3d6000fd5b50505050505b505b612a8962015180426159c8565b6101f85460408051868152602081018990529081019190915243907fa904dcf42a3461c90173c0b966672b2cb4350e529ea12d44e562fcec438363249060600160405180910390a35050505050565b612ae0613649565b6065546040517fcbed8b9c0000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063cbed8b9c90612b319088908890889088908890600401615a66565b600060405180830381600087803b158015612b4b57600080fd5b505af1158015611b2c573d6000803e3d6000fd5b61ffff86166000908152609760205260408082209051612b829088908890615715565b908152604080516020928190038301902067ffffffffffffffff871660009081529252902054905080612c1d5760405162461bcd60e51b815260206004820152602360248201527f4e6f6e626c6f636b696e674c7a4170703a206e6f2073746f726564206d65737360448201527f61676500000000000000000000000000000000000000000000000000000000006064820152608401610db4565b808383604051612c2e929190615715565b604051809103902014612ca95760405162461bcd60e51b815260206004820152602160248201527f4e6f6e626c6f636b696e674c7a4170703a20696e76616c6964207061796c6f6160448201527f64000000000000000000000000000000000000000000000000000000000000006064820152608401610db4565b61ffff87166000908152609760205260408082209051612ccc9089908990615715565b908152604080516020928190038301812067ffffffffffffffff8916600090815290845282902093909355601f88018290048202830182019052868252612d65918991899089908190840183828082843760009201919091525050604080516020601f8a018190048102820181019092528881528a935091508890889081908401838280828437600092019190915250613aab92505050565b7fc264d91f3adc5588250e1551f547752ca0cfa8f6b530d243b9f9f4cab10ea8e58787878785604051612d9c959493929190615a9f565b60405180910390a150505050505050565b600082815260fb6020526040902060010154612dc881613703565b6116978383613925565b612dda613649565b60008111612e2a5760405162461bcd60e51b815260206004820152601560248201527f4c7a4170703a20696e76616c6964206d696e47617300000000000000000000006044820152606401610db4565b61ffff83811660008181526067602090815260408083209487168084529482529182902085905581519283528201929092529081018290527f9d5c7c0b934da8fefa9c7760c98383778a12dfbfc0c3b3106518f43fb9508ac09060600161261b565b612e94613649565b61015f80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215159081179091556040519081527f1584ad594a70cbe1e6515592e1272a987d922b097ead875069cebe8b40c004a490602001611f1c565b612efc613649565b61ffff83166000908152606660205260409020612f1a908383614e25565b507ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab83838360405161261b9392919061586e565b612f56613649565b6001600160a01b038116612fd25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610db4565b612fdb81613b29565b50565b6065546040517ff5ecbdbc00000000000000000000000000000000000000000000000000000000815261ffff808716600483015285166024820152306044820152606481018390526060916001600160a01b03169063f5ecbdbc9060840160006040518083038186803b15801561305457600080fd5b505afa158015613068573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526130909190810190615927565b95945050505050565b600054610100900460ff16158080156130b95750600054600160ff909116105b806130d35750303b1580156130d3575060005460ff166001145b6131455760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610db4565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156131a357600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6131ab613cbb565b6131b3613d38565b6132286040518060400160405280600881526020017f5265616c205553440000000000000000000000000000000000000000000000008152506040518060400160405280600481526020017f555344520000000000000000000000000000000000000000000000000000000081525085613dbd565b61323185613b29565b61323c600086613865565b6101f580547fffffffffffffffffffff0000000000000000000000000000000000000000ff00168315157fffffffffffffffffffff0000000000000000000000000000000000000000ffff1617620100006001600160a01b038716908102919091179091551561332057836001600160a01b031663bbf44f336040518163ffffffff1660e01b815260040160206040518083038186803b1580156132df57600080fd5b505afa1580156132f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133179190615725565b6101f855613332565b6b033b2e3c9fd0803ce80000006101f8555b801561106f57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050505050565b60008061342c5a60966366ad5c8a60e01b898989896040516024016133c49493929190615adb565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915230929190613e55565b9150915081611c2257611c228686868685613ee0565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b000000000000000000000000000000000000000000000000000000001480610fa257507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610fa2565b60007fffffffff000000000000000000000000000000000000000000000000000000008216158061354b57507fffffffff0000000000000000000000000000000000000000000000000000000082167f36372b0700000000000000000000000000000000000000000000000000000000145b80610fa25750610fa282613f6f565b61012d5474010000000000000000000000000000000000000000900460ff1615611f665760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610db4565b6135d4856001836000613fc5565b60408051600160208201528082018690528151808203830181526060909101909152613604868286868634614057565b6040805161ffff88168152602081018790527f1befeeaacc17f53a3f6e7d3c364d04e69aea117bbc29a09334a5a97ba798e8a0910160405180910390a1505050505050565b6033546001600160a01b03163314611f665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610db4565b60006b033b2e3c9fd0803ce80000006136bc838561598b565b6136d2906b019d971e4fe8401e74000000615784565b61240191906159c8565b6000633b9aca00826136ef6002836159c8565b6136f99190615784565b610fa291906159c8565b612fdb8133614208565b6001600160a01b0383811660009081526101fa60209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146137b857818110156137ab5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610db4565b6137b88484848403614288565b50505050565b6000806137ca83611f27565b90508084111561381c5760405162461bcd60e51b815260206004820152601c60248201527f555344523a20616d6f756e7420657863656564732062616c616e6365000000006044820152606401610db4565b61382583611f27565b84141561384d5750506001600160a01b03811660009081526101f96020526040902054610fa2565b61385d6101f854611921866139c6565b949350505050565b600082815260fb602090815260408083206001600160a01b038516845290915290205460ff1661172457600082815260fb602090815260408083206001600160a01b0385168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556138e13390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260fb602090815260408083206001600160a01b038516845290915290205460ff161561172457600082815260fb602090815260408083206001600160a01b038516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610fa2633b9aca008361598b565b6000816139ef6b033b2e3c9fd0803ce80000008561598b565b6139fa6002856159c8565b6136d29190615784565b613a12866000836000613fc5565b6000613a20888888886142e2565b90506000808783604051602001613a3993929190615b1a565b6040516020818303038152906040529050613a58888287878734614057565b886001600160a01b03168861ffff167f39a4c66499bcf4b56d79f0dde8ed7a9d4925a0df55825206b2b8531e202be0d08985604051613a98929190615b47565b60405180910390a3505050505050505050565b602081015161ffff8116613aca57613ac585858585614426565b61106f565b61ffff811660011415613ae157613ac585836144b0565b60405162461bcd60e51b815260206004820152601960248201527f555344523a20756e6b6e6f776e207061636b65742074797065000000000000006044820152606401610db4565b603380546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b606081613ba181601f615784565b1015613bef5760405162461bcd60e51b815260206004820152600e60248201527f736c6963655f6f766572666c6f770000000000000000000000000000000000006044820152606401610db4565b613bf98284615784565b84511015613c495760405162461bcd60e51b815260206004820152601160248201527f736c6963655f6f75744f66426f756e64730000000000000000000000000000006044820152606401610db4565b606082158015613c685760405191506000825260208201604052613cb2565b6040519150601f8416801560200281840101858101878315602002848b0101015b81831015613ca1578051835260209283019201613c89565b5050858452601f01601f1916604052505b50949350505050565b600054610100900460ff16611f665760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b600054610100900460ff16613db55760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b611f6661455c565b600054610100900460ff16613e3a5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b613e448383614604565b613e4c6146aa565b61169781614730565b6000606060008060008661ffff1667ffffffffffffffff811115613e7b57613e7b6153ee565b6040519080825280601f01601f191660200182016040528015613ea5576020820181803683370190505b50905060008087516020890160008d8df191503d925086831115613ec7578692505b828152826000602083013e909890975095505050505050565b8180519060200120609760008761ffff1661ffff16815260200190815260200160002085604051613f119190615b69565b90815260408051918290036020908101832067ffffffffffffffff88166000908152915220919091557fe183f33de2837795525b4792ca4cd60535bd77c53b7e7030060bfcf5734d6b0c9061338d9087908790879087908790615b85565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f14e4ceea000000000000000000000000000000000000000000000000000000001480610fa25750610fa282613442565b61015f5460ff1615613fe257613fdd848484846147e7565b6137b8565b8151156137b85760405162461bcd60e51b815260206004820152602660248201527f4f4654436f72653a205f61646170746572506172616d73206d7573742062652060448201527f656d7074792e00000000000000000000000000000000000000000000000000006064820152608401610db4565b61ffff861660009081526066602052604081208054614075906156c1565b80601f01602080910402602001604051908101604052809291908181526020018280546140a1906156c1565b80156140ee5780601f106140c3576101008083540402835291602001916140ee565b820191906000526020600020905b8154815290600101906020018083116140d157829003601f168201915b5050505050905080516000141561416d5760405162461bcd60e51b815260206004820152603060248201527f4c7a4170703a2064657374696e6174696f6e20636861696e206973206e6f742060448201527f61207472757374656420736f75726365000000000000000000000000000000006064820152608401610db4565b6141788787516148c6565b6065546040517fc58031000000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063c58031009084906141cd908b9086908c908c908c908c90600401615be4565b6000604051808303818588803b1580156141e657600080fd5b505af11580156141fa573d6000803e3d6000fd5b505050505050505050505050565b600082815260fb602090815260408083206001600160a01b038516845290915290205460ff1661172457614246816001600160a01b03166014614934565b614251836020614934565b604051602001614262929190615c3e565b60408051601f198184030181529082905262461bcd60e51b8252610db4916004016150fe565b6001600160a01b0383811660008181526101fa602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591016122e4565b6000806142ef83876137be565b6101f55490915060ff1615614396576001600160a01b03861660009081526101f960205260408120805483929061432790849061576d565b90915550503060009081526101f960205260408120805483929061434c908490615784565b909155505060405183815230906001600160a01b038816907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3613090565b806101f660008282546143a9919061576d565b90915550506001600160a01b03861660009081526101f96020526040812080548392906143d790849061576d565b90915550506040518381526000906001600160a01b038816907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a395945050505050565b6000808280602001905181019061443d9190615cbf565b9093509150600090506144508382614b5d565b905061445d878284614bd3565b9150806001600160a01b03168761ffff167fbf551ec93859b170f9b2141bd9298bf3f64322c6f7beb2543a0cb669834118bf8460405161449f91815260200190565b60405180910390a350505050505050565b6000818060200190518101906144c69190615d19565b915050806101f854111561451c5760405162461bcd60e51b815260206004820152601d60248201527f555344523a206c697175696469747920696e64657820746f6f206c6f770000006044820152606401610db4565b6101f88190556040805161ffff85168152602081018390527f7e440917f4b380b174374b5de9ddaef8942c339334c0f41949d14db30c278949910161261b565b600054610100900460ff166145d95760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b61012d80547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b600054610100900460ff166146815760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b815161469590610194906020850190614d83565b50805161169790610195906020840190614d83565b600054610100900460ff166147275760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b611f6633613b29565b600054610100900460ff166147ad5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b606580547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b60006147f283614d27565b61ffff808716600090815260676020908152604080832093891683529290529081205491925090614824908490615784565b9050600081116148765760405162461bcd60e51b815260206004820152601a60248201527f4c7a4170703a206d696e4761734c696d6974206e6f74207365740000000000006044820152606401610db4565b80821015611c225760405162461bcd60e51b815260206004820152601b60248201527f4c7a4170703a20676173206c696d697420697320746f6f206c6f7700000000006044820152606401610db4565b61ffff8216600090815260686020526040902054806148e457506127105b808211156116975760405162461bcd60e51b815260206004820181905260248201527f4c7a4170703a207061796c6f61642073697a6520697320746f6f206c617267656044820152606401610db4565b6060600061494383600261598b565b61494e906002615784565b67ffffffffffffffff811115614966576149666153ee565b6040519080825280601f01601f191660200182016040528015614990576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106149c7576149c7615a03565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110614a2a57614a2a615a03565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000614a6684600261598b565b614a71906001615784565b90505b6001811115614b0e577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110614ab257614ab2615a03565b1a60f81b828281518110614ac857614ac8615a03565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93614b0781615d47565b9050614a74565b5083156124015760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610db4565b6000614b6a826014615784565b83511015614bba5760405162461bcd60e51b815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e647300000000000000000000006044820152606401610db4565b5001602001516c01000000000000000000000000900490565b600080614bef61145c6101f854856136a390919063ffffffff16565b6101f55490915060ff1615614c96573060009081526101f9602052604081208054859290614c1e90849061576d565b90915550506001600160a01b03841660009081526101f9602052604081208054859290614c4c908490615784565b90915550506040518181526001600160a01b0385169030907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3614d1e565b826101f66000828254614ca99190615784565b90915550506001600160a01b03841660009081526101f9602052604081208054859290614cd7908490615784565b90915550506040518181526001600160a01b038516906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35b50909392505050565b6000602282511015614d7b5760405162461bcd60e51b815260206004820152601c60248201527f4c7a4170703a20696e76616c69642061646170746572506172616d73000000006044820152606401610db4565b506022015190565b828054614d8f906156c1565b90600052602060002090601f016020900481019282614db15760008555614df7565b82601f10614dca57805160ff1916838001178555614df7565b82800160010185558215614df7579182015b82811115614df7578251825591602001919060010190614ddc565b50614e03929150614eb7565b5090565b6040518060e001604052806007906020820280368337509192915050565b828054614e31906156c1565b90600052602060002090601f016020900481019282614e535760008555614df7565b82601f10614e8a578280017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00823516178555614df7565b82800160010185558215614df7579182015b82811115614df7578235825591602001919060010190614e9c565b5b80821115614e035760008155600101614eb8565b61ffff81168114612fdb57600080fd5b60008083601f840112614eee57600080fd5b50813567ffffffffffffffff811115614f0657600080fd5b602083019150836020828501011115614f1e57600080fd5b9250929050565b803567ffffffffffffffff811681146124a457600080fd5b60008060008060008060808789031215614f5657600080fd5b8635614f6181614ecc565b9550602087013567ffffffffffffffff80821115614f7e57600080fd5b614f8a8a838b01614edc565b9097509550859150614f9e60408a01614f25565b94506060890135915080821115614fb457600080fd5b50614fc189828a01614edc565b979a9699509497509295939492505050565b600060208284031215614fe557600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461240157600080fd5b6001600160a01b0381168114612fdb57600080fd5b60008060008060006080868803121561504257600080fd5b853561504d81614ecc565b9450602086013561505d81615015565b9350604086013561506d81615015565b9250606086013567ffffffffffffffff81111561508957600080fd5b61509588828901614edc565b969995985093965092949392505050565b60005b838110156150c15781810151838201526020016150a9565b838111156137b85750506000910152565b600081518084526150ea8160208601602086016150a6565b601f01601f19169290920160200192915050565b60208152600061240160208301846150d2565b60006020828403121561512357600080fd5b813561240181614ecc565b6000806040838503121561514157600080fd5b823561514c81615015565b946020939093013593505050565b6000806040838503121561516d57600080fd5b823561514c81614ecc565b60006020828403121561518a57600080fd5b813561240181615015565b6000806000606084860312156151aa57600080fd5b83356151b581615015565b925060208401356151c581615015565b929592945050506040919091013590565b6000602082840312156151e857600080fd5b5035919050565b803580151581146124a457600080fd5b600080600080600080600060a0888a03121561521a57600080fd5b873561522581614ecc565b9650602088013567ffffffffffffffff8082111561524257600080fd5b61524e8b838c01614edc565b909850965060408a0135955086915061526960608b016151ef565b945060808a013591508082111561527f57600080fd5b5061528c8a828b01614edc565b989b979a50959850939692959293505050565b600080604083850312156152b257600080fd5b8235915060208301356152c481615015565b809150509250929050565b6000806000604084860312156152e457600080fd5b83356152ef81614ecc565b9250602084013567ffffffffffffffff81111561530b57600080fd5b61531786828701614edc565b9497909650939450505050565b600080600080600080600080600060e08a8c03121561534257600080fd5b893561534d81615015565b985060208a013561535d81614ecc565b975060408a013567ffffffffffffffff8082111561537a57600080fd5b6153868d838e01614edc565b909950975060608c0135965060808c013591506153a282615015565b90945060a08b0135906153b482615015565b90935060c08b013590808211156153ca57600080fd5b506153d78c828d01614edc565b915080935050809150509295985092959850929598565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715615446576154466153ee565b604052919050565b600067ffffffffffffffff821115615468576154686153ee565b50601f01601f191660200190565b60008060006060848603121561548b57600080fd5b833561549681614ecc565b9250602084013567ffffffffffffffff8111156154b257600080fd5b8401601f810186136154c357600080fd5b80356154d66154d18261544e565b61541d565b8181528760208385010111156154eb57600080fd5b8160208401602083013760006020838301015280945050505061551060408501614f25565b90509250925092565b6000806040838503121561552c57600080fd5b823561553781615015565b915060208301356152c481615015565b6000806040838503121561555a57600080fd5b823561556581614ecc565b915060208301356152c481614ecc565b60008060008060006080868803121561558d57600080fd5b853561559881614ecc565b945060208601356155a881614ecc565b935060408601359250606086013567ffffffffffffffff81111561508957600080fd5b6000806000606084860312156155e057600080fd5b83356155eb81614ecc565b925060208401356151c581614ecc565b60006020828403121561560d57600080fd5b612401826151ef565b6000806000806080858703121561562c57600080fd5b843561563781614ecc565b9350602085013561564781614ecc565b9250604085013561565781615015565b9396929550929360600135925050565b6000806000806080858703121561567d57600080fd5b843561568881615015565b9350602085013561569881615015565b925060408501356156a881615015565b91506156b6606086016151ef565b905092959194509250565b600181811c908216806156d557607f821691505b6020821081141561570f577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b8183823760009101908152919050565b60006020828403121561573757600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008282101561577f5761577f61573e565b500390565b600082198211156157975761579761573e565b500190565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b61ffff851681526060602082015260006157e560608301858761579c565b905082604083015295945050505050565b61ffff871681526001600160a01b038616602082015260a06040820152600061582260a08301876150d2565b8515156060840152828103608084015261583d81858761579c565b9998505050505050505050565b6000806040838503121561585d57600080fd5b505080516020909101519092909150565b61ffff8416815260406020820152600061309060408301848661579c565b60006020828403121561589e57600080fd5b815161240181615015565b8284823760609190911b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000169101908152601401919050565b600082601f8301126158f357600080fd5b81516159016154d18261544e565b81815284602083860101111561591657600080fd5b61385d8260208301602087016150a6565b60006020828403121561593957600080fd5b815167ffffffffffffffff81111561595057600080fd5b61385d848285016158e2565b6000806040838503121561596f57600080fd5b825161597a81615015565b60208401519092506152c481615015565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156159c3576159c361573e565b500290565b6000826159fe577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60e08101818360005b6007811015615a5d578151600f0b835260209283019290910190600101615a3b565b50505092915050565b600061ffff808816835280871660208401525084604083015260806060830152615a9460808301848661579c565b979650505050505050565b61ffff86168152608060208201526000615abd60808301868861579c565b67ffffffffffffffff94909416604083015250606001529392505050565b61ffff85168152608060208201526000615af860808301866150d2565b67ffffffffffffffff851660408401528281036060840152615a9481856150d2565b61ffff84168152606060208201526000615b3760608301856150d2565b9050826040830152949350505050565b604081526000615b5a60408301856150d2565b90508260208301529392505050565b60008251615b7b8184602087016150a6565b9190910192915050565b61ffff8616815260a060208201526000615ba260a08301876150d2565b67ffffffffffffffff861660408401528281036060840152615bc481866150d2565b90508281036080840152615bd881856150d2565b98975050505050505050565b61ffff8716815260c060208201526000615c0160c08301886150d2565b8281036040840152615c1381886150d2565b6001600160a01b0387811660608601528616608085015283810360a0850152905061583d81856150d2565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615c768160178501602088016150a6565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351615cb38160288401602088016150a6565b01602801949350505050565b600080600060608486031215615cd457600080fd5b8351615cdf81614ecc565b602085015190935067ffffffffffffffff811115615cfc57600080fd5b615d08868287016158e2565b925050604084015190509250925092565b60008060408385031215615d2c57600080fd5b8251615d3781614ecc565b6020939093015192949293505050565b600081615d5657615d5661573e565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212204e084ac72ddbc8f48fc9f8f544dc58183b40a33752f1fa7f6d96ffdb1f02d1a964736f6c63430008090033
Deployed Bytecode
0x6080604052600436106104495760003560e01c80637533d78811610243578063baf3292d11610143578063df2a5b3b116100bb578063ed629c5c1161008a578063f5ecbdbc1161006f578063f5ecbdbc14610d02578063fc0c546a14610d22578063fecf973414610d3557600080fd5b8063ed629c5c14610cc7578063f2fde38b14610ce257600080fd5b8063df2a5b3b14610c3f578063e21f314a14610c5f578063eab45d9c14610c87578063eb8d72b714610ca757600080fd5b8063c446183411610112578063d1deba1f116100f7578063d1deba1f14610bc5578063d547741f14610bd8578063dd62ed3e14610bf857600080fd5b8063c446183414610b8f578063cbed8b9c14610ba557600080fd5b8063baf3292d14610b10578063bbf44f3314610b30578063bc4f2d6d14610b47578063c2c8486f14610b6757600080fd5b80639d0bcca0116101d6578063a3a7e7f3116101a5578063a6c3d1651161018a578063a6c3d16514610ab0578063a9059cbb14610ad0578063b353aaa714610af057600080fd5b8063a3a7e7f314610a70578063a457c2d714610a9057600080fd5b80639d0bcca014610a095780639dc29fac14610a305780639f38369a14610a50578063a217fddf1461076457600080fd5b806391d148541161021257806391d14854146109795780639358928b146109bf578063950c8a74146109d457806395d89b41146109f457600080fd5b80637533d788146108e357806384d4b410146109035780638cfd8f5c146109235780638da5cb5b1461095b57600080fd5b8063395093511161034e5780635b8c41e6116102e157806366ad5c8a116102b05780636c2eb350116102955780636c2eb3501461089957806370a08231146108ae578063715018a6146108ce57600080fd5b806366ad5c8a146108645780636965523a1461088457600080fd5b80635b8c41e6146107b45780635c975abb14610803578063604269d11461083457806363e57db91461084f57600080fd5b806342d65a8d1161031d57806342d65a8d1461074457806344770515146107645780634c42899a1461077957806351905636146107a157600080fd5b806339509351146106b75780633d8b38f6146106d75780633f1f4fa4146106f757806340c10f191461072457600080fd5b806318160ddd116103e15780632954018c116103b05780632f2ff15d116103955780632f2ff15d1461065b578063313ce5671461067b57806336568abe1461069757600080fd5b80632954018c146105ed5780632a205e3d1461062657600080fd5b806318160ddd1461055a5780631a5fa2e31461057d57806323b872dd1461059d578063248a9ca3146105bd57600080fd5b806307e0db171161041d57806307e0db17146104da578063095ea7b3146104fa5780630df374831461051a57806310ddb1371461053a57600080fd5b80621d35671461044e57806301ffc9a71461047057806304f23700146104a557806306fdde03146104b8575b600080fd5b34801561045a57600080fd5b5061046e610469366004614f3d565b610d55565b005b34801561047c57600080fd5b5061049061048b366004614fd3565b610f88565b60405190151581526020015b60405180910390f35b61046e6104b336600461502a565b610fa8565b3480156104c457600080fd5b506104cd611076565b60405161049c91906150fe565b3480156104e657600080fd5b5061046e6104f5366004615111565b611109565b34801561050657600080fd5b5061049061051536600461512e565b611188565b34801561052657600080fd5b5061046e61053536600461515a565b6111f5565b34801561054657600080fd5b5061046e610555366004615111565b611214565b34801561056657600080fd5b5061056f611269565b60405190815260200161049c565b34801561058957600080fd5b5061046e610598366004615178565b611471565b3480156105a957600080fd5b506104906105b8366004615195565b6114b8565b3480156105c957600080fd5b5061056f6105d83660046151d6565b600090815260fb602052604090206001015490565b3480156105f957600080fd5b5061012d5461060e906001600160a01b031681565b6040516001600160a01b03909116815260200161049c565b34801561063257600080fd5b506106466106413660046151ff565b611594565b6040805192835260208301919091520161049c565b34801561066757600080fd5b5061046e61067636600461529f565b611672565b34801561068757600080fd5b506040516009815260200161049c565b3480156106a357600080fd5b5061046e6106b236600461529f565b61169c565b3480156106c357600080fd5b506104906106d236600461512e565b611728565b3480156106e357600080fd5b506104906106f23660046152cf565b6117bb565b34801561070357600080fd5b5061056f610712366004615111565b60686020526000908152604090205481565b34801561073057600080fd5b5061046e61073f36600461512e565b611887565b34801561075057600080fd5b5061046e61075f3660046152cf565b611a27565b34801561077057600080fd5b5061056f600081565b34801561078557600080fd5b5061078e600081565b60405161ffff909116815260200161049c565b61046e6107af366004615324565b611aaa565b3480156107c057600080fd5b5061056f6107cf366004615476565b6097602090815260009384526040808520845180860184018051928152908401958401959095209452929052825290205481565b34801561080f57600080fd5b5061012d5474010000000000000000000000000000000000000000900460ff16610490565b34801561084057600080fd5b506101f5546104909060ff1681565b34801561085b57600080fd5b5061078e600181565b34801561087057600080fd5b5061046e61087f366004614f3d565b611b37565b34801561089057600080fd5b5061046e611c2a565b3480156108a557600080fd5b5061046e611dcb565b3480156108ba57600080fd5b5061056f6108c9366004615178565b611f27565b3480156108da57600080fd5b5061046e611f54565b3480156108ef57600080fd5b506104cd6108fe366004615111565b611f68565b34801561090f57600080fd5b5061049061091e366004615519565b612002565b34801561092f57600080fd5b5061056f61093e366004615547565b606760209081526000928352604080842090915290825290205481565b34801561096757600080fd5b506033546001600160a01b031661060e565b34801561098557600080fd5b5061049061099436600461529f565b600091825260fb602090815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156109cb57600080fd5b5061056f6120c1565b3480156109e057600080fd5b5060695461060e906001600160a01b031681565b348015610a0057600080fd5b506104cd6120d0565b348015610a1557600080fd5b506101f55461060e906201000090046001600160a01b031681565b348015610a3c57600080fd5b5061046e610a4b36600461512e565b6120e0565b348015610a5c57600080fd5b506104cd610a6b366004615111565b6122f1565b348015610a7c57600080fd5b50610490610a8b366004615178565b612408565b348015610a9c57600080fd5b50610490610aab36600461512e565b6124a9565b348015610abc57600080fd5b5061046e610acb3660046152cf565b612595565b348015610adc57600080fd5b50610490610aeb36600461512e565b612628565b348015610afc57600080fd5b5060655461060e906001600160a01b031681565b348015610b1c57600080fd5b5061046e610b2b366004615178565b6126d3565b348015610b3c57600080fd5b5061056f6101f85481565b348015610b5357600080fd5b5061046e610b623660046151d6565b612741565b348015610b7357600080fd5b5061060e7352b9d0f46451bd2c610ae6ab1f5312a35a6159e381565b348015610b9b57600080fd5b5061056f61271081565b348015610bb157600080fd5b5061046e610bc0366004615575565b612ad8565b61046e610bd3366004614f3d565b612b5f565b348015610be457600080fd5b5061046e610bf336600461529f565b612dad565b348015610c0457600080fd5b5061056f610c13366004615519565b6001600160a01b0391821660009081526101fa6020908152604080832093909416825291909152205490565b348015610c4b57600080fd5b5061046e610c5a3660046155cb565b612dd2565b348015610c6b57600080fd5b5061060e73af0d9d65fc54de245cda37af3d18cbec860a4d4b81565b348015610c9357600080fd5b5061046e610ca23660046155fb565b612e8c565b348015610cb357600080fd5b5061046e610cc23660046152cf565b612ef4565b348015610cd357600080fd5b5061015f546104909060ff1681565b348015610cee57600080fd5b5061046e610cfd366004615178565b612f4e565b348015610d0e57600080fd5b506104cd610d1d366004615616565b612fde565b348015610d2e57600080fd5b503061060e565b348015610d4157600080fd5b5061046e610d50366004615667565b613099565b6065546001600160a01b0316336001600160a01b031614610dbd5760405162461bcd60e51b815260206004820152601e60248201527f4c7a4170703a20696e76616c696420656e64706f696e742063616c6c6572000060448201526064015b60405180910390fd5b61ffff861660009081526066602052604081208054610ddb906156c1565b80601f0160208091040260200160405190810160405280929190818152602001828054610e07906156c1565b8015610e545780601f10610e2957610100808354040283529160200191610e54565b820191906000526020600020905b815481529060010190602001808311610e3757829003601f168201915b50505050509050805186869050148015610e6f575060008151115b8015610e97575080516020820120604051610e8d9088908890615715565b6040518091039020145b610f095760405162461bcd60e51b815260206004820152602660248201527f4c7a4170703a20696e76616c696420736f757263652073656e64696e6720636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401610db4565b610f7f8787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a018190048102820181019092528881528a93509150889088908190840183828082843760009201919091525061339c92505050565b50505050505050565b6000610f9382613442565b80610fa25750610fa2826134d9565b92915050565b610fb061355a565b6101f55460ff166110295760405162461bcd60e51b815260206004820152602360248201527f555344523a2063616e206f6e6c792073796e632066726f6d206d61696e20636860448201527f61696e00000000000000000000000000000000000000000000000000000000006064820152608401610db4565b61106f856101f854868686868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506135c692505050565b5050505050565b60606101948054611086906156c1565b80601f01602080910402602001604051908101604052809291908181526020018280546110b2906156c1565b80156110ff5780601f106110d4576101008083540402835291602001916110ff565b820191906000526020600020905b8154815290600101906020018083116110e257829003601f168201915b5050505050905090565b611111613649565b6065546040517f07e0db1700000000000000000000000000000000000000000000000000000000815261ffff831660048201526001600160a01b03909116906307e0db17906024015b600060405180830381600087803b15801561117457600080fd5b505af115801561106f573d6000803e3d6000fd5b3360008181526101fa602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906111e49086815260200190565b60405180910390a350600192915050565b6111fd613649565b61ffff909116600090815260686020526040902055565b61121c613649565b6065546040517f10ddb13700000000000000000000000000000000000000000000000000000000815261ffff831660048201526001600160a01b03909116906310ddb1379060240161115a565b6101f55460009081906201000090046001600160a01b03161561143f576040517f70a082310000000000000000000000000000000000000000000000000000000081527352b9d0f46451bd2c610ae6ab1f5312a35a6159e3600482015273af0d9d65fc54de245cda37af3d18cbec860a4d4b906307a2d13a9082906370a082319060240160206040518083038186803b15801561130557600080fd5b505afa158015611319573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133d9190615725565b6040518263ffffffff1660e01b815260040161135b91815260200190565b60206040518083038186803b15801561137357600080fd5b505afa158015611387573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ab9190615725565b6101f560029054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156113fa57600080fd5b505afa15801561140e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114329190615725565b61143c919061576d565b90505b8061146161145c6101f8546101f6546136a390919063ffffffff16565b6136dc565b61146b9190615784565b91505090565b600061147c81613703565b5061012d80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b60006114c261355a565b6114cd84338461370d565b60006114d983866137be565b6001600160a01b03861660009081526101f9602052604081208054929350839290919061150790849061576d565b90915550506001600160a01b03841660009081526101f9602052604081208054839290611535908490615784565b92505081905550836001600160a01b0316856001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161158191815260200190565b60405180910390a3506001949350505050565b6000806000808989896040516020016115b094939291906157c7565b60408051601f19818403018152908290526065547f40a7bb100000000000000000000000000000000000000000000000000000000083529092506001600160a01b0316906340a7bb1090611612908d90309086908c908c908c906004016157f6565b604080518083038186803b15801561162957600080fd5b505afa15801561163d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611661919061584a565b925092505097509795505050505050565b600082815260fb602052604090206001015461168d81613703565b6116978383613865565b505050565b6001600160a01b038116331461171a5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610db4565b6117248282613925565b5050565b3360009081526101fa602090815260408083206001600160a01b038616845290915281208054839190839061175e908490615784565b90915550503360008181526101fa602090815260408083206001600160a01b038816808552908352928190205490519081529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591016111e4565b61ffff8316600090815260666020526040812080548291906117dc906156c1565b80601f0160208091040260200160405190810160405280929190818152602001828054611808906156c1565b80156118555780601f1061182a57610100808354040283529160200191611855565b820191906000526020600020905b81548152906001019060200180831161183857829003601f168201915b50505050509050838360405161186c929190615715565b60405180910390208180519060200120149150509392505050565b7ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc96118b181613703565b6118b961355a565b6001600160a01b03831661190f5760405162461bcd60e51b815260206004820152601460248201527f6d696e7420746f207a65726f20616464726573730000000000000000000000006044820152606401610db4565b60006119276101f854611921856139c6565b906139d6565b9050611931611269565b61194b906fffffffffffffffffffffffffffffffff61576d565b81111561199a5760405162461bcd60e51b815260206004820152601360248201527f6d617820737570706c79206578636565646564000000000000000000000000006044820152606401610db4565b806101f660008282546119ad9190615784565b90915550506001600160a01b03841660009081526101f96020526040812080548392906119db908490615784565b90915550506040518381526001600160a01b038516906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a350505050565b611a2f613649565b6065546040517f42d65a8d0000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906342d65a8d90611a7c9086908690869060040161586e565b600060405180830381600087803b158015611a9657600080fd5b505af1158015610f7f573d6000803e3d6000fd5b611ab261355a565b611b2c898989898080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a018190048102820181019092528881528c93508b92508a918a908a9081908401838280828437600092019190915250613a0492505050565b505050505050505050565b333014611bac5760405162461bcd60e51b815260206004820152602660248201527f4e6f6e626c6f636b696e674c7a4170703a2063616c6c6572206d75737420626560448201527f204c7a41707000000000000000000000000000000000000000000000000000006064820152608401610db4565b611c228686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f890181900481028201810190925287815289935091508790879081908401838280828437600092019190915250613aab92505050565b505050505050565b611c32613649565b6101f55460ff16611c855760405162461bcd60e51b815260206004820152601460248201527f555344523a206e6f74206d61696e20636861696e0000000000000000000000006044820152606401610db4565b61012d546040517f21f8a7210000000000000000000000000000000000000000000000000000000081527f46368cfe9eb4bdc14a0db9efb4fd64daed77c6c7eed07a5ecc8636d750f4116c60048201526000916001600160a01b0316906321f8a7219060240160206040518083038186803b158015611d0357600080fd5b505afa158015611d17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3b919061588c565b90506001600160a01b038116301415611d5357600080fd5b806001600160a01b031663bbf44f336040518163ffffffff1660e01b815260040160206040518083038186803b158015611d8c57600080fd5b505afa158015611da0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc49190615725565b6101f85550565b600054600590610100900460ff16158015611ded575060005460ff8083169116105b611e5f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610db4565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001660ff80841691909117610100179091556101f55416611ec557611ea9600033613925565b611ec56000611ec06033546001600160a01b031690565b613865565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a150565b6101f8546001600160a01b03821660009081526101f960205260408120549091610fa29161145c916136a3565b611f5c613649565b611f666000613b29565b565b60666020526000908152604090208054611f81906156c1565b80601f0160208091040260200160405190810160405280929190818152602001828054611fad906156c1565b8015611ffa5780601f10611fcf57610100808354040283529160200191611ffa565b820191906000526020600020905b815481529060010190602001808311611fdd57829003601f168201915b505050505081565b600061200c61355a565b600061201784611f27565b6001600160a01b03851660009081526101f9602052604090205490915061203f85338461370d565b6001600160a01b0380861660009081526101f9602052604080822082905591861681529081208054839290612075908490615784565b92505081905550836001600160a01b0316856001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161158191815260200190565b60006120cb611269565b905090565b60606101958054611086906156c1565b6120e861355a565b6001600160a01b03821661213e5760405162461bcd60e51b815260206004820152601660248201527f6275726e2066726f6d207a65726f2061646472657373000000000000000000006044820152606401610db4565b336001600160a01b038316146121595761215982338361370d565b600061216483611f27565b9050818110156121b65760405162461bcd60e51b815260206004820152601b60248201527f6275726e20616d6f756e7420657863656564732062616c616e636500000000006044820152606401610db4565b81811415612210576001600160a01b03831660009081526101f960205260408120546101f68054919290916121ec90849061576d565b90915550506001600160a01b03831660009081526101f960205260408120556122aa565b60006122226101f854611921856139c6565b6001600160a01b03851660009081526101f9602052604090205490915081111561226257506001600160a01b03831660009081526101f960205260409020545b806101f66000828254612275919061576d565b90915550506001600160a01b03841660009081526101f96020526040812080548392906122a390849061576d565b9091555050505b6040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906020015b60405180910390a3505050565b61ffff8116600090815260666020526040812080546060929190612314906156c1565b80601f0160208091040260200160405190810160405280929190818152602001828054612340906156c1565b801561238d5780601f106123625761010080835404028352916020019161238d565b820191906000526020600020905b81548152906001019060200180831161237057829003601f168201915b505050505090508051600014156123e65760405162461bcd60e51b815260206004820152601d60248201527f4c7a4170703a206e6f20747275737465642070617468207265636f72640000006044820152606401610db4565b6124016000601483516123f9919061576d565b839190613b93565b9392505050565b600061241261355a565b600061241d33611f27565b3360009081526101f960205260408082208054908390556001600160a01b038716835290822080549394509092839290612458908490615784565b90915550506040518281526001600160a01b0385169033907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a36001925050505b919050565b3360009081526101fa602090815260408083206001600160a01b03861684529091528120548083106124ff573360009081526101fa602090815260408083206001600160a01b038816845290915281205561252f565b612509838261576d565b3360009081526101fa602090815260408083206001600160a01b03891684529091529020555b3360008181526101fa602090815260408083206001600160a01b038916808552908352928190205490519081529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a35060019392505050565b61259d613649565b8181306040516020016125b2939291906158a9565b60408051601f1981840301815291815261ffff851660009081526066602090815291902082516125e793919290910190614d83565b507f8c0400cfe2d1199b1a725c78960bcc2a344d869b80590d0f2bd005db15a572ce83838360405161261b9392919061586e565b60405180910390a1505050565b600061263261355a565b600061263e83336137be565b3360009081526101f9602052604081208054929350839290919061266390849061576d565b90915550506001600160a01b03841660009081526101f9602052604081208054839290612691908490615784565b90915550506040518381526001600160a01b0385169033907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001612583565b6126db613649565b606980547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f5db758e995a17ec1ad84bdef7e8c3293a0bd6179bcce400dff5d4c3d87db726b90602001611f1c565b7f70546d1c92f8c2132ae23a23f5177aa8526356051c7510df99f50e012d22152961276b81613703565b61277361355a565b600061277d611269565b61012d54604080517fc83e4fd410f80be983b083c99898391186b0893751a26a9a1e5fdcb9d412970160208201527fd7b5cea1258f7a2acae3ed88fa9155d7a4e8425cafbbe0267f7d8ac75968341a8183015281518082038301815260608201928390527f7b7dfa550000000000000000000000000000000000000000000000000000000090925292935060009283926001600160a01b031691637b7dfa559161282a91906064016150fe565b60006040518083038186803b15801561284257600080fd5b505afa158015612856573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261287e9190810190615927565b806020019051810190612891919061595c565b9092509050336001600160a01b038316146128ee5760405162461bcd60e51b815260206004820152601660248201527f63616c6c6572206973206e6f74207472656173757279000000000000000000006044820152606401610db4565b8415612a7c576040517fbc5a6343000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b0382169063bc5a63439060240160206040518083038186803b15801561294d57600080fd5b505afa158015612961573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129859190615725565b945060006129a3846fffffffffffffffffffffffffffffffff61576d565b9050808611156129b1578095505b8515612a7a57836129c28782615784565b6101f8546129d0919061598b565b6129da91906159c8565b6101f8556129e6614e07565b846129ef611269565b6129f9919061576d565b600f0b60c08201526040517f152c60610000000000000000000000000000000000000000000000000000000081526001600160a01b0384169063152c606190612a46908490600401615a32565b600060405180830381600087803b158015612a6057600080fd5b505af1158015612a74573d6000803e3d6000fd5b50505050505b505b612a8962015180426159c8565b6101f85460408051868152602081018990529081019190915243907fa904dcf42a3461c90173c0b966672b2cb4350e529ea12d44e562fcec438363249060600160405180910390a35050505050565b612ae0613649565b6065546040517fcbed8b9c0000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063cbed8b9c90612b319088908890889088908890600401615a66565b600060405180830381600087803b158015612b4b57600080fd5b505af1158015611b2c573d6000803e3d6000fd5b61ffff86166000908152609760205260408082209051612b829088908890615715565b908152604080516020928190038301902067ffffffffffffffff871660009081529252902054905080612c1d5760405162461bcd60e51b815260206004820152602360248201527f4e6f6e626c6f636b696e674c7a4170703a206e6f2073746f726564206d65737360448201527f61676500000000000000000000000000000000000000000000000000000000006064820152608401610db4565b808383604051612c2e929190615715565b604051809103902014612ca95760405162461bcd60e51b815260206004820152602160248201527f4e6f6e626c6f636b696e674c7a4170703a20696e76616c6964207061796c6f6160448201527f64000000000000000000000000000000000000000000000000000000000000006064820152608401610db4565b61ffff87166000908152609760205260408082209051612ccc9089908990615715565b908152604080516020928190038301812067ffffffffffffffff8916600090815290845282902093909355601f88018290048202830182019052868252612d65918991899089908190840183828082843760009201919091525050604080516020601f8a018190048102820181019092528881528a935091508890889081908401838280828437600092019190915250613aab92505050565b7fc264d91f3adc5588250e1551f547752ca0cfa8f6b530d243b9f9f4cab10ea8e58787878785604051612d9c959493929190615a9f565b60405180910390a150505050505050565b600082815260fb6020526040902060010154612dc881613703565b6116978383613925565b612dda613649565b60008111612e2a5760405162461bcd60e51b815260206004820152601560248201527f4c7a4170703a20696e76616c6964206d696e47617300000000000000000000006044820152606401610db4565b61ffff83811660008181526067602090815260408083209487168084529482529182902085905581519283528201929092529081018290527f9d5c7c0b934da8fefa9c7760c98383778a12dfbfc0c3b3106518f43fb9508ac09060600161261b565b612e94613649565b61015f80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168215159081179091556040519081527f1584ad594a70cbe1e6515592e1272a987d922b097ead875069cebe8b40c004a490602001611f1c565b612efc613649565b61ffff83166000908152606660205260409020612f1a908383614e25565b507ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab83838360405161261b9392919061586e565b612f56613649565b6001600160a01b038116612fd25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610db4565b612fdb81613b29565b50565b6065546040517ff5ecbdbc00000000000000000000000000000000000000000000000000000000815261ffff808716600483015285166024820152306044820152606481018390526060916001600160a01b03169063f5ecbdbc9060840160006040518083038186803b15801561305457600080fd5b505afa158015613068573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526130909190810190615927565b95945050505050565b600054610100900460ff16158080156130b95750600054600160ff909116105b806130d35750303b1580156130d3575060005460ff166001145b6131455760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610db4565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156131a357600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6131ab613cbb565b6131b3613d38565b6132286040518060400160405280600881526020017f5265616c205553440000000000000000000000000000000000000000000000008152506040518060400160405280600481526020017f555344520000000000000000000000000000000000000000000000000000000081525085613dbd565b61323185613b29565b61323c600086613865565b6101f580547fffffffffffffffffffff0000000000000000000000000000000000000000ff00168315157fffffffffffffffffffff0000000000000000000000000000000000000000ffff1617620100006001600160a01b038716908102919091179091551561332057836001600160a01b031663bbf44f336040518163ffffffff1660e01b815260040160206040518083038186803b1580156132df57600080fd5b505afa1580156132f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133179190615725565b6101f855613332565b6b033b2e3c9fd0803ce80000006101f8555b801561106f57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15050505050565b60008061342c5a60966366ad5c8a60e01b898989896040516024016133c49493929190615adb565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915230929190613e55565b9150915081611c2257611c228686868685613ee0565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b000000000000000000000000000000000000000000000000000000001480610fa257507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610fa2565b60007fffffffff000000000000000000000000000000000000000000000000000000008216158061354b57507fffffffff0000000000000000000000000000000000000000000000000000000082167f36372b0700000000000000000000000000000000000000000000000000000000145b80610fa25750610fa282613f6f565b61012d5474010000000000000000000000000000000000000000900460ff1615611f665760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610db4565b6135d4856001836000613fc5565b60408051600160208201528082018690528151808203830181526060909101909152613604868286868634614057565b6040805161ffff88168152602081018790527f1befeeaacc17f53a3f6e7d3c364d04e69aea117bbc29a09334a5a97ba798e8a0910160405180910390a1505050505050565b6033546001600160a01b03163314611f665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610db4565b60006b033b2e3c9fd0803ce80000006136bc838561598b565b6136d2906b019d971e4fe8401e74000000615784565b61240191906159c8565b6000633b9aca00826136ef6002836159c8565b6136f99190615784565b610fa291906159c8565b612fdb8133614208565b6001600160a01b0383811660009081526101fa60209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146137b857818110156137ab5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610db4565b6137b88484848403614288565b50505050565b6000806137ca83611f27565b90508084111561381c5760405162461bcd60e51b815260206004820152601c60248201527f555344523a20616d6f756e7420657863656564732062616c616e6365000000006044820152606401610db4565b61382583611f27565b84141561384d5750506001600160a01b03811660009081526101f96020526040902054610fa2565b61385d6101f854611921866139c6565b949350505050565b600082815260fb602090815260408083206001600160a01b038516845290915290205460ff1661172457600082815260fb602090815260408083206001600160a01b0385168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556138e13390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260fb602090815260408083206001600160a01b038516845290915290205460ff161561172457600082815260fb602090815260408083206001600160a01b038516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610fa2633b9aca008361598b565b6000816139ef6b033b2e3c9fd0803ce80000008561598b565b6139fa6002856159c8565b6136d29190615784565b613a12866000836000613fc5565b6000613a20888888886142e2565b90506000808783604051602001613a3993929190615b1a565b6040516020818303038152906040529050613a58888287878734614057565b886001600160a01b03168861ffff167f39a4c66499bcf4b56d79f0dde8ed7a9d4925a0df55825206b2b8531e202be0d08985604051613a98929190615b47565b60405180910390a3505050505050505050565b602081015161ffff8116613aca57613ac585858585614426565b61106f565b61ffff811660011415613ae157613ac585836144b0565b60405162461bcd60e51b815260206004820152601960248201527f555344523a20756e6b6e6f776e207061636b65742074797065000000000000006044820152606401610db4565b603380546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b606081613ba181601f615784565b1015613bef5760405162461bcd60e51b815260206004820152600e60248201527f736c6963655f6f766572666c6f770000000000000000000000000000000000006044820152606401610db4565b613bf98284615784565b84511015613c495760405162461bcd60e51b815260206004820152601160248201527f736c6963655f6f75744f66426f756e64730000000000000000000000000000006044820152606401610db4565b606082158015613c685760405191506000825260208201604052613cb2565b6040519150601f8416801560200281840101858101878315602002848b0101015b81831015613ca1578051835260209283019201613c89565b5050858452601f01601f1916604052505b50949350505050565b600054610100900460ff16611f665760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b600054610100900460ff16613db55760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b611f6661455c565b600054610100900460ff16613e3a5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b613e448383614604565b613e4c6146aa565b61169781614730565b6000606060008060008661ffff1667ffffffffffffffff811115613e7b57613e7b6153ee565b6040519080825280601f01601f191660200182016040528015613ea5576020820181803683370190505b50905060008087516020890160008d8df191503d925086831115613ec7578692505b828152826000602083013e909890975095505050505050565b8180519060200120609760008761ffff1661ffff16815260200190815260200160002085604051613f119190615b69565b90815260408051918290036020908101832067ffffffffffffffff88166000908152915220919091557fe183f33de2837795525b4792ca4cd60535bd77c53b7e7030060bfcf5734d6b0c9061338d9087908790879087908790615b85565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f14e4ceea000000000000000000000000000000000000000000000000000000001480610fa25750610fa282613442565b61015f5460ff1615613fe257613fdd848484846147e7565b6137b8565b8151156137b85760405162461bcd60e51b815260206004820152602660248201527f4f4654436f72653a205f61646170746572506172616d73206d7573742062652060448201527f656d7074792e00000000000000000000000000000000000000000000000000006064820152608401610db4565b61ffff861660009081526066602052604081208054614075906156c1565b80601f01602080910402602001604051908101604052809291908181526020018280546140a1906156c1565b80156140ee5780601f106140c3576101008083540402835291602001916140ee565b820191906000526020600020905b8154815290600101906020018083116140d157829003601f168201915b5050505050905080516000141561416d5760405162461bcd60e51b815260206004820152603060248201527f4c7a4170703a2064657374696e6174696f6e20636861696e206973206e6f742060448201527f61207472757374656420736f75726365000000000000000000000000000000006064820152608401610db4565b6141788787516148c6565b6065546040517fc58031000000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063c58031009084906141cd908b9086908c908c908c908c90600401615be4565b6000604051808303818588803b1580156141e657600080fd5b505af11580156141fa573d6000803e3d6000fd5b505050505050505050505050565b600082815260fb602090815260408083206001600160a01b038516845290915290205460ff1661172457614246816001600160a01b03166014614934565b614251836020614934565b604051602001614262929190615c3e565b60408051601f198184030181529082905262461bcd60e51b8252610db4916004016150fe565b6001600160a01b0383811660008181526101fa602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591016122e4565b6000806142ef83876137be565b6101f55490915060ff1615614396576001600160a01b03861660009081526101f960205260408120805483929061432790849061576d565b90915550503060009081526101f960205260408120805483929061434c908490615784565b909155505060405183815230906001600160a01b038816907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3613090565b806101f660008282546143a9919061576d565b90915550506001600160a01b03861660009081526101f96020526040812080548392906143d790849061576d565b90915550506040518381526000906001600160a01b038816907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a395945050505050565b6000808280602001905181019061443d9190615cbf565b9093509150600090506144508382614b5d565b905061445d878284614bd3565b9150806001600160a01b03168761ffff167fbf551ec93859b170f9b2141bd9298bf3f64322c6f7beb2543a0cb669834118bf8460405161449f91815260200190565b60405180910390a350505050505050565b6000818060200190518101906144c69190615d19565b915050806101f854111561451c5760405162461bcd60e51b815260206004820152601d60248201527f555344523a206c697175696469747920696e64657820746f6f206c6f770000006044820152606401610db4565b6101f88190556040805161ffff85168152602081018390527f7e440917f4b380b174374b5de9ddaef8942c339334c0f41949d14db30c278949910161261b565b600054610100900460ff166145d95760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b61012d80547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff169055565b600054610100900460ff166146815760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b815161469590610194906020850190614d83565b50805161169790610195906020840190614d83565b600054610100900460ff166147275760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b611f6633613b29565b600054610100900460ff166147ad5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610db4565b606580547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b60006147f283614d27565b61ffff808716600090815260676020908152604080832093891683529290529081205491925090614824908490615784565b9050600081116148765760405162461bcd60e51b815260206004820152601a60248201527f4c7a4170703a206d696e4761734c696d6974206e6f74207365740000000000006044820152606401610db4565b80821015611c225760405162461bcd60e51b815260206004820152601b60248201527f4c7a4170703a20676173206c696d697420697320746f6f206c6f7700000000006044820152606401610db4565b61ffff8216600090815260686020526040902054806148e457506127105b808211156116975760405162461bcd60e51b815260206004820181905260248201527f4c7a4170703a207061796c6f61642073697a6520697320746f6f206c617267656044820152606401610db4565b6060600061494383600261598b565b61494e906002615784565b67ffffffffffffffff811115614966576149666153ee565b6040519080825280601f01601f191660200182016040528015614990576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106149c7576149c7615a03565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110614a2a57614a2a615a03565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000614a6684600261598b565b614a71906001615784565b90505b6001811115614b0e577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110614ab257614ab2615a03565b1a60f81b828281518110614ac857614ac8615a03565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93614b0781615d47565b9050614a74565b5083156124015760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610db4565b6000614b6a826014615784565b83511015614bba5760405162461bcd60e51b815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e647300000000000000000000006044820152606401610db4565b5001602001516c01000000000000000000000000900490565b600080614bef61145c6101f854856136a390919063ffffffff16565b6101f55490915060ff1615614c96573060009081526101f9602052604081208054859290614c1e90849061576d565b90915550506001600160a01b03841660009081526101f9602052604081208054859290614c4c908490615784565b90915550506040518181526001600160a01b0385169030907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3614d1e565b826101f66000828254614ca99190615784565b90915550506001600160a01b03841660009081526101f9602052604081208054859290614cd7908490615784565b90915550506040518181526001600160a01b038516906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35b50909392505050565b6000602282511015614d7b5760405162461bcd60e51b815260206004820152601c60248201527f4c7a4170703a20696e76616c69642061646170746572506172616d73000000006044820152606401610db4565b506022015190565b828054614d8f906156c1565b90600052602060002090601f016020900481019282614db15760008555614df7565b82601f10614dca57805160ff1916838001178555614df7565b82800160010185558215614df7579182015b82811115614df7578251825591602001919060010190614ddc565b50614e03929150614eb7565b5090565b6040518060e001604052806007906020820280368337509192915050565b828054614e31906156c1565b90600052602060002090601f016020900481019282614e535760008555614df7565b82601f10614e8a578280017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00823516178555614df7565b82800160010185558215614df7579182015b82811115614df7578235825591602001919060010190614e9c565b5b80821115614e035760008155600101614eb8565b61ffff81168114612fdb57600080fd5b60008083601f840112614eee57600080fd5b50813567ffffffffffffffff811115614f0657600080fd5b602083019150836020828501011115614f1e57600080fd5b9250929050565b803567ffffffffffffffff811681146124a457600080fd5b60008060008060008060808789031215614f5657600080fd5b8635614f6181614ecc565b9550602087013567ffffffffffffffff80821115614f7e57600080fd5b614f8a8a838b01614edc565b9097509550859150614f9e60408a01614f25565b94506060890135915080821115614fb457600080fd5b50614fc189828a01614edc565b979a9699509497509295939492505050565b600060208284031215614fe557600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461240157600080fd5b6001600160a01b0381168114612fdb57600080fd5b60008060008060006080868803121561504257600080fd5b853561504d81614ecc565b9450602086013561505d81615015565b9350604086013561506d81615015565b9250606086013567ffffffffffffffff81111561508957600080fd5b61509588828901614edc565b969995985093965092949392505050565b60005b838110156150c15781810151838201526020016150a9565b838111156137b85750506000910152565b600081518084526150ea8160208601602086016150a6565b601f01601f19169290920160200192915050565b60208152600061240160208301846150d2565b60006020828403121561512357600080fd5b813561240181614ecc565b6000806040838503121561514157600080fd5b823561514c81615015565b946020939093013593505050565b6000806040838503121561516d57600080fd5b823561514c81614ecc565b60006020828403121561518a57600080fd5b813561240181615015565b6000806000606084860312156151aa57600080fd5b83356151b581615015565b925060208401356151c581615015565b929592945050506040919091013590565b6000602082840312156151e857600080fd5b5035919050565b803580151581146124a457600080fd5b600080600080600080600060a0888a03121561521a57600080fd5b873561522581614ecc565b9650602088013567ffffffffffffffff8082111561524257600080fd5b61524e8b838c01614edc565b909850965060408a0135955086915061526960608b016151ef565b945060808a013591508082111561527f57600080fd5b5061528c8a828b01614edc565b989b979a50959850939692959293505050565b600080604083850312156152b257600080fd5b8235915060208301356152c481615015565b809150509250929050565b6000806000604084860312156152e457600080fd5b83356152ef81614ecc565b9250602084013567ffffffffffffffff81111561530b57600080fd5b61531786828701614edc565b9497909650939450505050565b600080600080600080600080600060e08a8c03121561534257600080fd5b893561534d81615015565b985060208a013561535d81614ecc565b975060408a013567ffffffffffffffff8082111561537a57600080fd5b6153868d838e01614edc565b909950975060608c0135965060808c013591506153a282615015565b90945060a08b0135906153b482615015565b90935060c08b013590808211156153ca57600080fd5b506153d78c828d01614edc565b915080935050809150509295985092959850929598565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715615446576154466153ee565b604052919050565b600067ffffffffffffffff821115615468576154686153ee565b50601f01601f191660200190565b60008060006060848603121561548b57600080fd5b833561549681614ecc565b9250602084013567ffffffffffffffff8111156154b257600080fd5b8401601f810186136154c357600080fd5b80356154d66154d18261544e565b61541d565b8181528760208385010111156154eb57600080fd5b8160208401602083013760006020838301015280945050505061551060408501614f25565b90509250925092565b6000806040838503121561552c57600080fd5b823561553781615015565b915060208301356152c481615015565b6000806040838503121561555a57600080fd5b823561556581614ecc565b915060208301356152c481614ecc565b60008060008060006080868803121561558d57600080fd5b853561559881614ecc565b945060208601356155a881614ecc565b935060408601359250606086013567ffffffffffffffff81111561508957600080fd5b6000806000606084860312156155e057600080fd5b83356155eb81614ecc565b925060208401356151c581614ecc565b60006020828403121561560d57600080fd5b612401826151ef565b6000806000806080858703121561562c57600080fd5b843561563781614ecc565b9350602085013561564781614ecc565b9250604085013561565781615015565b9396929550929360600135925050565b6000806000806080858703121561567d57600080fd5b843561568881615015565b9350602085013561569881615015565b925060408501356156a881615015565b91506156b6606086016151ef565b905092959194509250565b600181811c908216806156d557607f821691505b6020821081141561570f577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b8183823760009101908152919050565b60006020828403121561573757600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008282101561577f5761577f61573e565b500390565b600082198211156157975761579761573e565b500190565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b61ffff851681526060602082015260006157e560608301858761579c565b905082604083015295945050505050565b61ffff871681526001600160a01b038616602082015260a06040820152600061582260a08301876150d2565b8515156060840152828103608084015261583d81858761579c565b9998505050505050505050565b6000806040838503121561585d57600080fd5b505080516020909101519092909150565b61ffff8416815260406020820152600061309060408301848661579c565b60006020828403121561589e57600080fd5b815161240181615015565b8284823760609190911b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000169101908152601401919050565b600082601f8301126158f357600080fd5b81516159016154d18261544e565b81815284602083860101111561591657600080fd5b61385d8260208301602087016150a6565b60006020828403121561593957600080fd5b815167ffffffffffffffff81111561595057600080fd5b61385d848285016158e2565b6000806040838503121561596f57600080fd5b825161597a81615015565b60208401519092506152c481615015565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156159c3576159c361573e565b500290565b6000826159fe577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60e08101818360005b6007811015615a5d578151600f0b835260209283019290910190600101615a3b565b50505092915050565b600061ffff808816835280871660208401525084604083015260806060830152615a9460808301848661579c565b979650505050505050565b61ffff86168152608060208201526000615abd60808301868861579c565b67ffffffffffffffff94909416604083015250606001529392505050565b61ffff85168152608060208201526000615af860808301866150d2565b67ffffffffffffffff851660408401528281036060840152615a9481856150d2565b61ffff84168152606060208201526000615b3760608301856150d2565b9050826040830152949350505050565b604081526000615b5a60408301856150d2565b90508260208301529392505050565b60008251615b7b8184602087016150a6565b9190910192915050565b61ffff8616815260a060208201526000615ba260a08301876150d2565b67ffffffffffffffff861660408401528281036060840152615bc481866150d2565b90508281036080840152615bd881856150d2565b98975050505050505050565b61ffff8716815260c060208201526000615c0160c08301886150d2565b8281036040840152615c1381886150d2565b6001600160a01b0387811660608601528616608085015283810360a0850152905061583d81856150d2565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615c768160178501602088016150a6565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351615cb38160288401602088016150a6565b01602801949350505050565b600080600060608486031215615cd457600080fd5b8351615cdf81614ecc565b602085015190935067ffffffffffffffff811115615cfc57600080fd5b615d08868287016158e2565b925050604084015190509250925092565b60008060408385031215615d2c57600080fd5b8251615d3781614ecc565b6020939093015192949293505050565b600081615d5657615d5661573e565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212204e084ac72ddbc8f48fc9f8f544dc58183b40a33752f1fa7f6d96ffdb1f02d1a964736f6c63430008090033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.