Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00Multichain Info
N/A
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
AssetRouter
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {AccessControlDefaultAdminRulesUpgradeable} from "@openzeppelin/contracts-upgradeable/access/extensions/AccessControlDefaultAdminRulesUpgradeable.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import {ERC165Upgradeable, IERC165} from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {IBascule} from "../bascule/interfaces/IBascule.sol"; import {IAssetRouter} from "./interfaces/IAssetRouter.sol"; import {IAssetOperation} from "./interfaces/IAssetOperation.sol"; import {IOracle} from "./interfaces/IOracle.sol"; import {IHandler, GMPUtils} from "../gmp/IHandler.sol"; import {IMailbox} from "../gmp/IMailbox.sol"; import {IBaseLBTC} from "./interfaces/IBaseLBTC.sol"; import {Actions} from "../libs/Actions.sol"; import {BitcoinUtils} from "../libs/BitcoinUtils.sol"; import {LChainId} from "../libs/LChainId.sol"; import {Assert} from "./libraries/Assert.sol"; import {Assets} from "./libraries/Assets.sol"; import {Validation} from "./libraries/Validation.sol"; /** * @title Router to store xxxLBTC Staking paths and token's name. * @author Lombard.Finance * @notice This contract is part of the Lombard.Finance protocol */ contract AssetRouter is IAssetRouter, IHandler, AccessControlDefaultAdminRulesUpgradeable, ReentrancyGuardUpgradeable { struct TokenConfig { uint256 redeemFee; uint256 redeemForBtcMinAmount; uint256 maximumMintCommission; IOracle oracle; uint64 toNativeCommission; } /// @custom:storage-location erc7201:lombardfinance.storage.AssetRouter struct AssetRouterStorage { bytes32 ledgerChainId; bytes32 bitcoinChainId; mapping(bytes32 => Routes) routes; mapping(bytes32 => bool) usedPayloads; // sha256(rawPayload) => used IMailbox mailbox; IBascule bascule; address nativeToken; mapping(address => TokenConfig) tokenConfigs; } struct Routes { mapping(bytes32 => Route) direction; } struct Route { mapping(bytes32 => RouteType) toTokens; } // keccak256(abi.encode(uint256(keccak256("lombardfinance.storage.AssetRouter")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ASSETS_ROUTER_STORAGE_LOCATION = 0x634af38ba2564e2d74d7d4e289db84afe1b0f1c101e1349f6428c2bd44a09b00; bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE"); bytes32 public constant CALLER_ROLE = keccak256("CALLER_ROLE"); bytes32 public constant CLAIMER_ROLE = keccak256("CLAIMER_ROLE"); /// @dev https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializing_the_implementation_contract /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize( address owner_, uint48 initialOwnerDelay_, bytes32 ledgerChainId_, bytes32 bitcoinChainId_, address mailbox_, address bascule_ ) external initializer { __AccessControlDefaultAdminRules_init(initialOwnerDelay_, owner_); __ReentrancyGuard_init(); __AssetRouter_init(ledgerChainId_, bitcoinChainId_, mailbox_, bascule_); } function __AssetRouter_init( bytes32 ledgerChainId_, bytes32 bitcoinChainId_, address mailbox_, address bascule_ ) internal onlyInitializing { AssetRouterStorage storage $ = _getAssetRouterStorage(); _changeMailbox(mailbox_); _changeBascule(bascule_); $.ledgerChainId = ledgerChainId_; $.bitcoinChainId = bitcoinChainId_; } function setRoute( bytes32 fromToken, bytes32 fromChainId, bytes32 toToken, bytes32 toChainId, RouteType routeType ) external onlyRole(DEFAULT_ADMIN_ROLE) { AssetRouterStorage storage $ = _getAssetRouterStorage(); bytes32 key = keccak256(abi.encode(fromToken, fromChainId)); Route storage r = $.routes[key].direction[toChainId]; r.toTokens[toToken] = routeType; if (fromChainId == LChainId.get()) { _checkAndSetNativeToken($, fromToken); } if (toChainId == LChainId.get()) { _checkAndSetNativeToken($, toToken); } emit AssetRouter_RouteSet( fromToken, fromChainId, toToken, toChainId, routeType ); } function removeRoute( bytes32 fromToken, bytes32 fromChainId, bytes32 toToken, bytes32 toChainId ) external onlyRole(DEFAULT_ADMIN_ROLE) { AssetRouterStorage storage $ = _getAssetRouterStorage(); bytes32 key = keccak256(abi.encode(fromToken, fromChainId)); Route storage r = $.routes[key].direction[toChainId]; delete r.toTokens[toToken]; emit AssetRouter_RouteRemoved( fromToken, fromChainId, toToken, toChainId ); } function changeRedeemFee(uint256 fee) external onlyRole(CALLER_ROLE) { _setRedeemFeeForToken(_msgSender(), fee); } function changeRedeemFee( address token, uint256 fee ) external onlyRole(DEFAULT_ADMIN_ROLE) { _setRedeemFeeForToken(token, fee); } function changeRedeemForBtcMinAmount( uint256 minAmount ) external onlyRole(CALLER_ROLE) { _setRedeemForBtcMinAmountForToken(_msgSender(), minAmount); } function changeRedeemForBtcMinAmount( address token, uint256 minAmount ) external onlyRole(DEFAULT_ADMIN_ROLE) { _setRedeemForBtcMinAmountForToken(token, minAmount); } function toggleRedeem() external onlyRole(CALLER_ROLE) { _toggleRedeemForToken(_msgSender()); } function changeTokenConfig( address token, uint256 redeemFee, uint256 redeemForBtcMinAmount, bool redeemEnabled ) external onlyRole(DEFAULT_ADMIN_ROLE) { _setRedeemFeeForToken(token, redeemFee); _setRedeemForBtcMinAmountForToken(token, redeemForBtcMinAmount); _setRedeemForToken(token, redeemEnabled); } function changeTokenConfigExt( address token, uint256 redeemFee, uint256 redeemForBtcMinAmount, address oracle_, uint256 maximumMintCommission_, uint64 toNativeCommission_ ) external onlyRole(DEFAULT_ADMIN_ROLE) { _setRedeemFeeForToken(token, redeemFee); _setRedeemForBtcMinAmountForToken(token, redeemForBtcMinAmount); _changeOracle(token, oracle_); _changeToNativeCommission(token, toNativeCommission_); _setMaxMintCommission(token, maximumMintCommission_); } function tokenConfig( address token ) external view returns ( uint256 redeemFee, uint256 redeemForBtcMinAmount, bool isRedeemEnabled ) { (redeemFee, redeemForBtcMinAmount, isRedeemEnabled) = _getTokenConfig( token ); } function _checkAndSetNativeToken( AssetRouterStorage storage $, bytes32 token ) internal { address tokenAddress = GMPUtils.bytes32ToAddress(token); grantRole(CALLER_ROLE, tokenAddress); if (IBaseLBTC(tokenAddress).isNative()) { if ($.nativeToken != address(0) && $.nativeToken != tokenAddress) { revert AssetRouter_WrongNativeToken(); } $.nativeToken = tokenAddress; } } function getRouteType( bytes32 fromToken, bytes32 fromChainId, bytes32 toChainId, bytes32 toToken ) external view override returns (RouteType) { return _getRouteType(fromToken, fromChainId, toChainId, toToken); } function _getRouteType( bytes32 fromToken, bytes32 fromChainId, bytes32 toChainId, bytes32 toToken ) internal view returns (RouteType) { AssetRouterStorage storage $ = _getAssetRouterStorage(); bytes32 key = keccak256(abi.encode(fromToken, fromChainId)); Route storage r = $.routes[key].direction[toChainId]; return r.toTokens[toToken]; } function _isAllowedCaller(address caller) internal view returns (bool) { return hasRole(CALLER_ROLE, caller); } function ratio(address token) external view override returns (uint256) { AssetRouterStorage storage $ = _getAssetRouterStorage(); if ( IBaseLBTC(token).isNative() && (address($.tokenConfigs[token].oracle) == address(0)) ) { return 1 ether; } return $.tokenConfigs[token].oracle.ratio(); } function getRate(address token) external view override returns (uint256) { AssetRouterStorage storage $ = _getAssetRouterStorage(); if ( IBaseLBTC(token).isNative() && (address($.tokenConfigs[token].oracle) == address(0)) ) { return 1 ether; } return $.tokenConfigs[token].oracle.getRate(); } function bitcoinChainId() external view override returns (bytes32) { AssetRouterStorage storage $ = _getAssetRouterStorage(); return $.bitcoinChainId; } function _getAssetRouterStorage() private pure returns (AssetRouterStorage storage $) { assembly { $.slot := ASSETS_ROUTER_STORAGE_LOCATION } } /** * Change the address of the Bascule drawbridge contract. * Setting the address to 0 disables the Bascule check. * @param newVal The new address. * * Emits a {BasculeChanged} event. */ function changeBascule( address newVal ) external onlyRole(DEFAULT_ADMIN_ROLE) { _changeBascule(newVal); } function bascule() external view override returns (IBascule) { return _getAssetRouterStorage().bascule; } /** * Change the address of the Oracle contract. * Setting the address to 0 is nor allowed. * @param newVal The new address. * * Emits a {OracleChanged} event. */ function changeOracle( address token, address newVal ) external onlyRole(DEFAULT_ADMIN_ROLE) { _changeOracle(token, newVal); } function oracle(address token) external view override returns (IOracle) { return _getAssetRouterStorage().tokenConfigs[token].oracle; } /** * Change the address of the Mailbox contract. * Setting the address to 0 is not allowed. * @param newVal The new address. * * Emits a {MailboxChanged} event. */ function changeMailbox( address newVal ) external onlyRole(DEFAULT_ADMIN_ROLE) { _changeMailbox(newVal); } function mailbox() external view override returns (IMailbox) { return _getAssetRouterStorage().mailbox; } function changeToNativeCommission( address token, uint64 newValue ) external onlyRole(DEFAULT_ADMIN_ROLE) { _changeToNativeCommission(token, newValue); } function changeNativeToken( address newValue ) external onlyRole(DEFAULT_ADMIN_ROLE) { _changeNativeToken(newValue); } /** * @notice Set the contract current fee for mint * @param fee New fee value * @dev zero allowed to disable fee */ function setMaxMintCommission( address token, uint256 fee ) external onlyRole(OPERATOR_ROLE) { _setMaxMintCommission(token, fee); } function deposit( address fromAddress, address toToken, uint256 amount ) external nonReentrant { address sender = address(_msgSender()); if (sender != fromAddress && sender != toToken) { revert AssetRouter_Unauthorized(); } _deposit( fromAddress, LChainId.get(), GMPUtils.addressToBytes32(toToken), GMPUtils.addressToBytes32(fromAddress), amount ); } function deposit( bytes32 tolChainId, bytes32 toToken, bytes32 recipient, uint256 amount ) external nonReentrant { address sender = address(_msgSender()); _deposit(sender, tolChainId, toToken, recipient, amount); } function _deposit( address fromAddress, bytes32 tolChainId, bytes32 toToken, bytes32 recipient, uint256 amount ) internal { AssetRouterStorage storage $ = _getAssetRouterStorage(); if ( _getRouteType( GMPUtils.addressToBytes32($.nativeToken), LChainId.get(), tolChainId, toToken ) != RouteType.DEPOSIT ) { revert IAssetOperation.AssetOperation_DepositNotAllowed(); } bytes memory rawPayload = Assets.encodeDepositRequest( tolChainId, toToken, GMPUtils.addressToBytes32(fromAddress), recipient, amount ); $.mailbox.send( $.ledgerChainId, Assets.BTC_STAKING_MODULE_ADDRESS, Assets.LEDGER_CALLER, rawPayload ); IBaseLBTC($.nativeToken).burn(fromAddress, amount); } function calcUnstakeRequestAmount( address token, bytes calldata scriptPubkey, uint256 amount ) external view returns (uint256 amountAfterFee, bool isAboveMinLimit) { AssetRouterStorage storage $ = _getAssetRouterStorage(); TokenConfig storage tokenCfg = $.tokenConfigs[token]; if (amount <= tokenCfg.redeemFee) { revert AssetRouter_FeeGreaterThanAmount(); } if (IBaseLBTC(token).isNative()) { (amountAfterFee, , isAboveMinLimit) = Validation .calcFeeAndDustLimit( scriptPubkey, amount - tokenCfg.redeemFee, tokenCfg.toNativeCommission, tokenCfg.redeemForBtcMinAmount ); return (amountAfterFee, isAboveMinLimit); } (amountAfterFee, , isAboveMinLimit) = Validation.calcFeeAndDustLimit( scriptPubkey, amount - tokenCfg.redeemFee, tokenCfg.toNativeCommission, tokenCfg.redeemForBtcMinAmount ); return (amountAfterFee, isAboveMinLimit); } function redeemForBtc( address fromAddress, address fromToken, bytes calldata recipient, uint256 amount ) external nonReentrant { AssetRouterStorage storage $ = _getAssetRouterStorage(); uint256 amountAfterFee = 0; TokenConfig storage tokenCfg = $.tokenConfigs[fromToken]; if (amount <= tokenCfg.redeemFee) { revert AssetRouter_FeeGreaterThanAmount(); } bytes32 gmpRecipient; bool isNative = false; if (IBaseLBTC(fromToken).isNative()) { amountAfterFee = Validation.redeemFee( recipient, amount - tokenCfg.redeemFee, tokenCfg.toNativeCommission, tokenCfg.redeemForBtcMinAmount ); gmpRecipient = Assets.ASSETS_MODULE_ADDRESS; isNative = true; } else { amountAfterFee = Validation.redeemFee( recipient, amount - tokenCfg.redeemFee, tokenCfg.toNativeCommission, tokenCfg.redeemForBtcMinAmount ); gmpRecipient = Assets.BTC_STAKING_MODULE_ADDRESS; } _redeem( $, fromAddress, $.bitcoinChainId, fromToken, Assets.BITCOIN_NATIVE_COIN, recipient, amountAfterFee, amount - amountAfterFee, gmpRecipient, isNative ); } function redeem( address fromAddress, bytes32 tolChainId, address fromToken, bytes32 toToken, bytes32 recipient, uint256 amount ) external nonReentrant { AssetRouterStorage storage $ = _getAssetRouterStorage(); if (tolChainId == $.bitcoinChainId) { revert AssertRouter_WrongRedeemDestinationChain(); } _redeem( $, fromAddress, tolChainId, fromToken, toToken, abi.encodePacked(recipient), amount, 0, Assets.BTC_STAKING_MODULE_ADDRESS, false ); } function redeem( address fromAddress, address fromToken, uint256 amount ) external nonReentrant { AssetRouterStorage storage $ = _getAssetRouterStorage(); _redeem( $, fromAddress, LChainId.get(), fromToken, GMPUtils.addressToBytes32($.nativeToken), abi.encodePacked(GMPUtils.addressToBytes32(fromAddress)), amount, 0, Assets.BTC_STAKING_MODULE_ADDRESS, false ); } function _redeem( AssetRouterStorage storage $, address fromAddress, bytes32 tolChainId, address fromToken, bytes32 toToken, bytes memory recipient, uint256 amount, uint256 fee, bytes32 gmpRecipient, bool isNative ) internal { if (_msgSender() != fromAddress && _msgSender() != fromToken) { revert AssetRouter_Unauthorized(); } if (!_isAllowedCaller(fromToken)) { revert IAssetOperation.NotStakingToken(); } bytes32 fromTokenBytes = GMPUtils.addressToBytes32(fromToken); if ( _getRouteType( fromTokenBytes, LChainId.get(), tolChainId, toToken ) != RouteType.REDEEM ) { revert IAssetOperation.AssetOperation_RedeemNotAllowed(); } IBaseLBTC tokenContract = IBaseLBTC(fromToken); if (fee == 0) { uint256 redeemFee = $.tokenConfigs[fromToken].redeemFee; if (amount <= redeemFee) { revert AssetRouter_FeeGreaterThanAmount(); } amount -= redeemFee; fee = redeemFee; } bytes memory rawPayload; if (isNative) { rawPayload = Assets.encodeRedeemNativeRequest( GMPUtils.addressToBytes32(fromAddress), recipient, amount ); } else { rawPayload = Assets.encodeRedeemRequest( tolChainId, fromTokenBytes, GMPUtils.addressToBytes32(fromAddress), recipient, amount ); } $.mailbox.send( $.ledgerChainId, gmpRecipient, Assets.LEDGER_CALLER, rawPayload ); if (fee > 0) { tokenContract.mint(tokenContract.getTreasury(), fee); } tokenContract.burn(fromAddress, amount + fee); } function mint( bytes calldata rawPayload, bytes calldata proof ) external nonReentrant returns (address) { (bool success, address recipient, , ) = _mint(rawPayload, proof); if (!success) { revert AssetRouter_MintProcessingError(); } return recipient; } function batchMint( bytes[] calldata payload, bytes[] calldata proof ) external nonReentrant { Assert.equalLength(payload.length, proof.length); for (uint256 i; i < payload.length; ++i) { (bool success, , , ) = _mint(payload[i], proof[i]); if (!success) { bytes32 payloadHash = sha256(payload[i]); emit AssetRouter_BatchMintError(payloadHash, "", ""); } } } function mintWithFee( bytes calldata mintPayload, bytes calldata proof, bytes calldata feePayload, bytes calldata userSignature ) external nonReentrant onlyRole(CLAIMER_ROLE) { bool success = _mintWithFee( mintPayload, proof, feePayload, userSignature ); if (!success) { revert AssetRouter_MintProcessingError(); } } function batchMintWithFee( bytes[] calldata mintPayload, bytes[] calldata proof, bytes[] calldata feePayload, bytes[] calldata userSignature ) external nonReentrant onlyRole(CLAIMER_ROLE) { Assert.equalLength(mintPayload.length, proof.length); Assert.equalLength(mintPayload.length, feePayload.length); Assert.equalLength(mintPayload.length, userSignature.length); for (uint256 i; i < mintPayload.length; ++i) { bool success = _mintWithFee( mintPayload[i], proof[i], feePayload[i], userSignature[i] ); if (!success) { bytes32 payloadHash = sha256(mintPayload[i]); emit AssetRouter_BatchMintError(payloadHash, "", new bytes(0)); } } } function _mint( bytes calldata rawPayload, bytes calldata proof ) internal returns (bool, address, address, uint256) { AssetRouterStorage storage $ = _getAssetRouterStorage(); (, bool success, bytes memory result) = $.mailbox.deliverAndHandle( rawPayload, proof ); if (!success) { return (false, address(0), address(0), 0); } (address recipient, address token, uint256 amount) = abi.decode( result, (address, address, uint256) ); return (success, recipient, token, amount); } function _mintWithFee( bytes calldata mintPayload, bytes calldata proof, bytes calldata feePayload, bytes calldata userSignature ) internal virtual returns (bool) { ( bool success, address recipient, address token, uint256 amount ) = _mint(mintPayload, proof); if (!success) { return false; } IBaseLBTC tokenContract = IBaseLBTC(token); Assert.selector(feePayload, Actions.FEE_APPROVAL_ACTION); Actions.FeeApprovalAction memory feeAction = Actions.feeApproval( feePayload[4:] ); AssetRouterStorage storage $ = _getAssetRouterStorage(); address treasury = tokenContract.getTreasury(); uint256 fee = Math.min( $.tokenConfigs[token].maximumMintCommission, feeAction.fee ); { bytes32 digest = tokenContract.getFeeDigest( feeAction.fee, feeAction.expiry ); Assert.feeApproval(digest, recipient, userSignature); } if (amount < fee) { revert AssetRouter_FeeGreaterThanAmount(); } if (fee > 0) { tokenContract.burn(recipient, fee); tokenContract.mint(treasury, fee); } emit AssetRouter_FeeCharged(fee, userSignature); return true; } function supportsInterface( bytes4 interfaceId ) public view override(AccessControlDefaultAdminRulesUpgradeable, IERC165) returns (bool) { return type(IHandler).interfaceId == interfaceId || super.supportsInterface(interfaceId); } function handlePayload( GMPUtils.Payload memory payload ) external override returns (bytes memory) { AssetRouterStorage storage $ = _getAssetRouterStorage(); if (_msgSender() != address($.mailbox)) { revert AssetRouter_MailboxExpected(); } if (payload.msgSender != Assets.BTC_STAKING_MODULE_ADDRESS) { revert AssetRouter_WrongSender(); } // spend payload if ($.usedPayloads[payload.id]) { revert AssetRouter_PayloadAlreadyUsed(); } $.usedPayloads[payload.id] = true; (Assets.Release memory receipt, ) = Assets.decodeRelease( payload.msgBody ); _confirmDeposit($, payload.id, receipt.amount); IBaseLBTC(receipt.toToken).mint(receipt.recipient, receipt.amount); return abi.encode(receipt.recipient, receipt.toToken, receipt.amount); } /** * @dev Checks that the deposit was validated by the Bascule drawbridge. * @param $ LBTC storage. * @param depositID The unique ID of the deposit. * @param amount The withdrawal amount. */ function _confirmDeposit( AssetRouterStorage storage $, bytes32 depositID, uint256 amount ) internal { IBascule bascule_ = $.bascule; if (address(bascule_) != address(0)) { bascule_.validateWithdrawal(depositID, amount); } } /// @dev Zero Address allowed to disable bascule check function _changeBascule(address newVal) internal { AssetRouterStorage storage $ = _getAssetRouterStorage(); emit AssetRouter_BasculeChanged(address($.bascule), newVal); $.bascule = IBascule(newVal); } function _changeOracle(address token, address newVal) internal { AssetRouterStorage storage $ = _getAssetRouterStorage(); emit AssetRouter_OracleChanged( address($.tokenConfigs[token].oracle), newVal ); $.tokenConfigs[token].oracle = IOracle(newVal); } function _changeMailbox(address newVal) internal { if (address(newVal) == address(0)) revert AssetRouter_ZeroAddress(); AssetRouterStorage storage $ = _getAssetRouterStorage(); emit AssetRouter_MailboxChanged(address($.mailbox), newVal); $.mailbox = IMailbox(newVal); } /// @dev allow set to zero function _changeToNativeCommission( address token, uint64 newValue ) internal { AssetRouterStorage storage $ = _getAssetRouterStorage(); TokenConfig storage tokenCfg = $.tokenConfigs[token]; uint64 prevValue = tokenCfg.toNativeCommission; tokenCfg.toNativeCommission = newValue; emit AssetRouter_ToNativeCommissionChanged(prevValue, newValue); } /// @dev allow set to zero function _changeNativeToken(address newValue) internal { AssetRouterStorage storage $ = _getAssetRouterStorage(); address prevValue = $.nativeToken; $.nativeToken = newValue; bytes32 key = keccak256(abi.encode(prevValue, LChainId.get())); delete $.routes[key]; emit AssetRouter_NativeTokenChanged(prevValue, newValue); } function _setRedeemFeeForToken(address token, uint256 fee) internal { AssetRouterStorage storage $ = _getAssetRouterStorage(); TokenConfig storage tc = $.tokenConfigs[token]; emit AssetRouter_RedeemFeeChanged(token, tc.redeemFee, fee); tc.redeemFee = fee; } function _setRedeemForBtcMinAmountForToken( address token, uint256 minAmount ) internal { AssetRouterStorage storage $ = _getAssetRouterStorage(); TokenConfig storage tc = $.tokenConfigs[token]; emit AssetRouter_RedeemForBtcMinAmountChanged( token, tc.redeemForBtcMinAmount, minAmount ); tc.redeemForBtcMinAmount = minAmount; } function _toggleRedeemForToken(address token) internal { AssetRouterStorage storage $ = _getAssetRouterStorage(); bytes32 key = keccak256(abi.encode(token, LChainId.get())); Route storage btcRoute = $.routes[key].direction[$.bitcoinChainId]; bool redeemEnabled = false; if ( btcRoute.toTokens[Assets.BITCOIN_NATIVE_COIN] == RouteType.UNKNOWN ) { btcRoute.toTokens[Assets.BITCOIN_NATIVE_COIN] = RouteType.REDEEM; redeemEnabled = true; } else if ( btcRoute.toTokens[Assets.BITCOIN_NATIVE_COIN] == RouteType.REDEEM ) { btcRoute.toTokens[Assets.BITCOIN_NATIVE_COIN] = RouteType.UNKNOWN; } else { revert AssertRouter_WrongRouteType(); } emit AssetRouter_RedeemEnabled(token, redeemEnabled); } function _setRedeemForToken(address token, bool enabled) internal { AssetRouterStorage storage $ = _getAssetRouterStorage(); bytes32 key = keccak256(abi.encode(token, LChainId.get())); Route storage btcRoute = $.routes[key].direction[$.bitcoinChainId]; if (enabled) { btcRoute.toTokens[Assets.BITCOIN_NATIVE_COIN] = RouteType.REDEEM; } else { btcRoute.toTokens[Assets.BITCOIN_NATIVE_COIN] = RouteType.UNKNOWN; } emit AssetRouter_RedeemEnabled(token, enabled); } function _setMaxMintCommission(address token, uint256 fee) internal { AssetRouterStorage storage $ = _getAssetRouterStorage(); uint256 oldFee = $.tokenConfigs[token].maximumMintCommission; $.tokenConfigs[token].maximumMintCommission = fee; emit AssetRouter_MintFeeChanged(oldFee, fee); } function _getTokenConfig( address token ) internal view returns ( uint256 redeemFee, uint256 redeemForBtcMinAmount, bool isRedeemEnabled ) { AssetRouterStorage storage $ = _getAssetRouterStorage(); TokenConfig storage tc = $.tokenConfigs[token]; bytes32 key = keccak256(abi.encode(token, LChainId.get())); Route storage btcRoute = $.routes[key].direction[$.bitcoinChainId]; return ( tc.redeemFee, tc.redeemForBtcMinAmount, btcRoute.toTokens[Assets.BITCOIN_NATIVE_COIN] == RouteType.REDEEM ); } function toNativeCommission( address token ) external view override returns (uint64) { return _getAssetRouterStorage().tokenConfigs[token].toNativeCommission; } function nativeToken() external view override returns (address) { return _getAssetRouterStorage().nativeToken; } function maxMintCommission( address token ) external view override returns (uint256) { return _getAssetRouterStorage().tokenConfigs[token].maximumMintCommission; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol"; import {Initializable} from "../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: * * ```solidity * 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}: * * ```solidity * 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. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl struct AccessControlStorage { mapping(bytes32 role => RoleData) _roles; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800; function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) { assembly { $.slot := AccessControlStorageLocation } } /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } /** * @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 returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @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 returns (bytes32) { AccessControlStorage storage $ = _getAccessControlStorage(); 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 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 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 `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { AccessControlStorage storage $ = _getAccessControlStorage(); bytes32 previousAdminRole = getRoleAdmin(role); $._roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (!hasRole(role, account)) { $._roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (hasRole(role, account)) { $._roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlDefaultAdminRules.sol) pragma solidity ^0.8.20; import {IAccessControlDefaultAdminRules} from "@openzeppelin/contracts/access/extensions/IAccessControlDefaultAdminRules.sol"; import {AccessControlUpgradeable} from "../AccessControlUpgradeable.sol"; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {IERC5313} from "@openzeppelin/contracts/interfaces/IERC5313.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows specifying special rules to manage * the `DEFAULT_ADMIN_ROLE` holder, which is a sensitive role with special permissions * over other roles that may potentially have privileged rights in the system. * * If a specific role doesn't have an admin role assigned, the holder of the * `DEFAULT_ADMIN_ROLE` will have the ability to grant it and revoke it. * * This contract implements the following risk mitigations on top of {AccessControl}: * * * Only one account holds the `DEFAULT_ADMIN_ROLE` since deployment until it's potentially renounced. * * Enforces a 2-step process to transfer the `DEFAULT_ADMIN_ROLE` to another account. * * Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted. * * The delay can be changed by scheduling, see {changeDefaultAdminDelay}. * * It is not possible to use another role to manage the `DEFAULT_ADMIN_ROLE`. * * Example usage: * * ```solidity * contract MyToken is AccessControlDefaultAdminRules { * constructor() AccessControlDefaultAdminRules( * 3 days, * msg.sender // Explicit initial `DEFAULT_ADMIN_ROLE` holder * ) {} * } * ``` */ abstract contract AccessControlDefaultAdminRulesUpgradeable is Initializable, IAccessControlDefaultAdminRules, IERC5313, AccessControlUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.AccessControlDefaultAdminRules struct AccessControlDefaultAdminRulesStorage { // pending admin pair read/written together frequently address _pendingDefaultAdmin; uint48 _pendingDefaultAdminSchedule; // 0 == unset uint48 _currentDelay; address _currentDefaultAdmin; // pending delay pair read/written together frequently uint48 _pendingDelay; uint48 _pendingDelaySchedule; // 0 == unset } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControlDefaultAdminRules")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessControlDefaultAdminRulesStorageLocation = 0xeef3dac4538c82c8ace4063ab0acd2d15cdb5883aa1dff7c2673abb3d8698400; function _getAccessControlDefaultAdminRulesStorage() private pure returns (AccessControlDefaultAdminRulesStorage storage $) { assembly { $.slot := AccessControlDefaultAdminRulesStorageLocation } } /** * @dev Sets the initial values for {defaultAdminDelay} and {defaultAdmin} address. */ function __AccessControlDefaultAdminRules_init(uint48 initialDelay, address initialDefaultAdmin) internal onlyInitializing { __AccessControlDefaultAdminRules_init_unchained(initialDelay, initialDefaultAdmin); } function __AccessControlDefaultAdminRules_init_unchained(uint48 initialDelay, address initialDefaultAdmin) internal onlyInitializing { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); if (initialDefaultAdmin == address(0)) { revert AccessControlInvalidDefaultAdmin(address(0)); } $._currentDelay = initialDelay; _grantRole(DEFAULT_ADMIN_ROLE, initialDefaultAdmin); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlDefaultAdminRules).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC5313-owner}. */ function owner() public view virtual returns (address) { return defaultAdmin(); } /// /// Override AccessControl role management /// /** * @dev See {AccessControl-grantRole}. Reverts for `DEFAULT_ADMIN_ROLE`. */ function grantRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControl) { if (role == DEFAULT_ADMIN_ROLE) { revert AccessControlEnforcedDefaultAdminRules(); } super.grantRole(role, account); } /** * @dev See {AccessControl-revokeRole}. Reverts for `DEFAULT_ADMIN_ROLE`. */ function revokeRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControl) { if (role == DEFAULT_ADMIN_ROLE) { revert AccessControlEnforcedDefaultAdminRules(); } super.revokeRole(role, account); } /** * @dev See {AccessControl-renounceRole}. * * For the `DEFAULT_ADMIN_ROLE`, it only allows renouncing in two steps by first calling * {beginDefaultAdminTransfer} to the `address(0)`, so it's required that the {pendingDefaultAdmin} schedule * has also passed when calling this function. * * After its execution, it will not be possible to call `onlyRole(DEFAULT_ADMIN_ROLE)` functions. * * NOTE: Renouncing `DEFAULT_ADMIN_ROLE` will leave the contract without a {defaultAdmin}, * thereby disabling any functionality that is only available for it, and the possibility of reassigning a * non-administrated role. */ function renounceRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControl) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) { (address newDefaultAdmin, uint48 schedule) = pendingDefaultAdmin(); if (newDefaultAdmin != address(0) || !_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) { revert AccessControlEnforcedDefaultAdminDelay(schedule); } delete $._pendingDefaultAdminSchedule; } super.renounceRole(role, account); } /** * @dev See {AccessControl-_grantRole}. * * For `DEFAULT_ADMIN_ROLE`, it only allows granting if there isn't already a {defaultAdmin} or if the * role has been previously renounced. * * NOTE: Exposing this function through another mechanism may make the `DEFAULT_ADMIN_ROLE` * assignable again. Make sure to guarantee this is the expected behavior in your implementation. */ function _grantRole(bytes32 role, address account) internal virtual override returns (bool) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); if (role == DEFAULT_ADMIN_ROLE) { if (defaultAdmin() != address(0)) { revert AccessControlEnforcedDefaultAdminRules(); } $._currentDefaultAdmin = account; } return super._grantRole(role, account); } /** * @dev See {AccessControl-_revokeRole}. */ function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) { delete $._currentDefaultAdmin; } return super._revokeRole(role, account); } /** * @dev See {AccessControl-_setRoleAdmin}. Reverts for `DEFAULT_ADMIN_ROLE`. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual override { if (role == DEFAULT_ADMIN_ROLE) { revert AccessControlEnforcedDefaultAdminRules(); } super._setRoleAdmin(role, adminRole); } /// /// AccessControlDefaultAdminRules accessors /// /** * @inheritdoc IAccessControlDefaultAdminRules */ function defaultAdmin() public view virtual returns (address) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); return $._currentDefaultAdmin; } /** * @inheritdoc IAccessControlDefaultAdminRules */ function pendingDefaultAdmin() public view virtual returns (address newAdmin, uint48 schedule) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); return ($._pendingDefaultAdmin, $._pendingDefaultAdminSchedule); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function defaultAdminDelay() public view virtual returns (uint48) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); uint48 schedule = $._pendingDelaySchedule; return (_isScheduleSet(schedule) && _hasSchedulePassed(schedule)) ? $._pendingDelay : $._currentDelay; } /** * @inheritdoc IAccessControlDefaultAdminRules */ function pendingDefaultAdminDelay() public view virtual returns (uint48 newDelay, uint48 schedule) { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); schedule = $._pendingDelaySchedule; return (_isScheduleSet(schedule) && !_hasSchedulePassed(schedule)) ? ($._pendingDelay, schedule) : (0, 0); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function defaultAdminDelayIncreaseWait() public view virtual returns (uint48) { return 5 days; } /// /// AccessControlDefaultAdminRules public and internal setters for defaultAdmin/pendingDefaultAdmin /// /** * @inheritdoc IAccessControlDefaultAdminRules */ function beginDefaultAdminTransfer(address newAdmin) public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _beginDefaultAdminTransfer(newAdmin); } /** * @dev See {beginDefaultAdminTransfer}. * * Internal function without access restriction. */ function _beginDefaultAdminTransfer(address newAdmin) internal virtual { uint48 newSchedule = SafeCast.toUint48(block.timestamp) + defaultAdminDelay(); _setPendingDefaultAdmin(newAdmin, newSchedule); emit DefaultAdminTransferScheduled(newAdmin, newSchedule); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function cancelDefaultAdminTransfer() public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _cancelDefaultAdminTransfer(); } /** * @dev See {cancelDefaultAdminTransfer}. * * Internal function without access restriction. */ function _cancelDefaultAdminTransfer() internal virtual { _setPendingDefaultAdmin(address(0), 0); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function acceptDefaultAdminTransfer() public virtual { (address newDefaultAdmin, ) = pendingDefaultAdmin(); if (_msgSender() != newDefaultAdmin) { // Enforce newDefaultAdmin explicit acceptance. revert AccessControlInvalidDefaultAdmin(_msgSender()); } _acceptDefaultAdminTransfer(); } /** * @dev See {acceptDefaultAdminTransfer}. * * Internal function without access restriction. */ function _acceptDefaultAdminTransfer() internal virtual { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); (address newAdmin, uint48 schedule) = pendingDefaultAdmin(); if (!_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) { revert AccessControlEnforcedDefaultAdminDelay(schedule); } _revokeRole(DEFAULT_ADMIN_ROLE, defaultAdmin()); _grantRole(DEFAULT_ADMIN_ROLE, newAdmin); delete $._pendingDefaultAdmin; delete $._pendingDefaultAdminSchedule; } /// /// AccessControlDefaultAdminRules public and internal setters for defaultAdminDelay/pendingDefaultAdminDelay /// /** * @inheritdoc IAccessControlDefaultAdminRules */ function changeDefaultAdminDelay(uint48 newDelay) public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _changeDefaultAdminDelay(newDelay); } /** * @dev See {changeDefaultAdminDelay}. * * Internal function without access restriction. */ function _changeDefaultAdminDelay(uint48 newDelay) internal virtual { uint48 newSchedule = SafeCast.toUint48(block.timestamp) + _delayChangeWait(newDelay); _setPendingDelay(newDelay, newSchedule); emit DefaultAdminDelayChangeScheduled(newDelay, newSchedule); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function rollbackDefaultAdminDelay() public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _rollbackDefaultAdminDelay(); } /** * @dev See {rollbackDefaultAdminDelay}. * * Internal function without access restriction. */ function _rollbackDefaultAdminDelay() internal virtual { _setPendingDelay(0, 0); } /** * @dev Returns the amount of seconds to wait after the `newDelay` will * become the new {defaultAdminDelay}. * * The value returned guarantees that if the delay is reduced, it will go into effect * after a wait that honors the previously set delay. * * See {defaultAdminDelayIncreaseWait}. */ function _delayChangeWait(uint48 newDelay) internal view virtual returns (uint48) { uint48 currentDelay = defaultAdminDelay(); // When increasing the delay, we schedule the delay change to occur after a period of "new delay" has passed, up // to a maximum given by defaultAdminDelayIncreaseWait, by default 5 days. For example, if increasing from 1 day // to 3 days, the new delay will come into effect after 3 days. If increasing from 1 day to 10 days, the new // delay will come into effect after 5 days. The 5 day wait period is intended to be able to fix an error like // using milliseconds instead of seconds. // // When decreasing the delay, we wait the difference between "current delay" and "new delay". This guarantees // that an admin transfer cannot be made faster than "current delay" at the time the delay change is scheduled. // For example, if decreasing from 10 days to 3 days, the new delay will come into effect after 7 days. return newDelay > currentDelay ? uint48(Math.min(newDelay, defaultAdminDelayIncreaseWait())) // no need to safecast, both inputs are uint48 : currentDelay - newDelay; } /// /// Private setters /// /** * @dev Setter of the tuple for pending admin and its schedule. * * May emit a DefaultAdminTransferCanceled event. */ function _setPendingDefaultAdmin(address newAdmin, uint48 newSchedule) private { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); (, uint48 oldSchedule) = pendingDefaultAdmin(); $._pendingDefaultAdmin = newAdmin; $._pendingDefaultAdminSchedule = newSchedule; // An `oldSchedule` from `pendingDefaultAdmin()` is only set if it hasn't been accepted. if (_isScheduleSet(oldSchedule)) { // Emit for implicit cancellations when another default admin was scheduled. emit DefaultAdminTransferCanceled(); } } /** * @dev Setter of the tuple for pending delay and its schedule. * * May emit a DefaultAdminDelayChangeCanceled event. */ function _setPendingDelay(uint48 newDelay, uint48 newSchedule) private { AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage(); uint48 oldSchedule = $._pendingDelaySchedule; if (_isScheduleSet(oldSchedule)) { if (_hasSchedulePassed(oldSchedule)) { // Materialize a virtual delay $._currentDelay = $._pendingDelay; } else { // Emit for implicit cancellations when another delay was scheduled. emit DefaultAdminDelayChangeCanceled(); } } $._pendingDelay = newDelay; $._pendingDelaySchedule = newSchedule; } /// /// Private helpers /// /** * @dev Defines if an `schedule` is considered set. For consistency purposes. */ function _isScheduleSet(uint48 schedule) private pure returns (bool) { return schedule != 0; } /** * @dev Defines if an `schedule` is considered passed. For consistency purposes. */ function _hasSchedulePassed(uint48 schedule) private view returns (bool) { return schedule < block.timestamp; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._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() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {Initializable} from "../../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); * } * ``` */ abstract contract ERC165Upgradeable is Initializable, IERC165 { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard struct ReentrancyGuardStorage { uint256 _status; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) { assembly { $.slot := ReentrancyGuardStorageLocation } } /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); $._status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // On the first call to nonReentrant, _status will be NOT_ENTERED if ($._status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail $._status = ENTERED; } function _nonReentrantAfter() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) $._status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); return $._status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlDefaultAdminRules.sol) pragma solidity ^0.8.20; import {IAccessControl} from "../IAccessControl.sol"; /** * @dev External interface of AccessControlDefaultAdminRules declared to support ERC165 detection. */ interface IAccessControlDefaultAdminRules is IAccessControl { /** * @dev The new default admin is not a valid default admin. */ error AccessControlInvalidDefaultAdmin(address defaultAdmin); /** * @dev At least one of the following rules was violated: * * - The `DEFAULT_ADMIN_ROLE` must only be managed by itself. * - The `DEFAULT_ADMIN_ROLE` must only be held by one account at the time. * - Any `DEFAULT_ADMIN_ROLE` transfer must be in two delayed steps. */ error AccessControlEnforcedDefaultAdminRules(); /** * @dev The delay for transferring the default admin delay is enforced and * the operation must wait until `schedule`. * * NOTE: `schedule` can be 0 indicating there's no transfer scheduled. */ error AccessControlEnforcedDefaultAdminDelay(uint48 schedule); /** * @dev Emitted when a {defaultAdmin} transfer is started, setting `newAdmin` as the next * address to become the {defaultAdmin} by calling {acceptDefaultAdminTransfer} only after `acceptSchedule` * passes. */ event DefaultAdminTransferScheduled(address indexed newAdmin, uint48 acceptSchedule); /** * @dev Emitted when a {pendingDefaultAdmin} is reset if it was never accepted, regardless of its schedule. */ event DefaultAdminTransferCanceled(); /** * @dev Emitted when a {defaultAdminDelay} change is started, setting `newDelay` as the next * delay to be applied between default admin transfer after `effectSchedule` has passed. */ event DefaultAdminDelayChangeScheduled(uint48 newDelay, uint48 effectSchedule); /** * @dev Emitted when a {pendingDefaultAdminDelay} is reset if its schedule didn't pass. */ event DefaultAdminDelayChangeCanceled(); /** * @dev Returns the address of the current `DEFAULT_ADMIN_ROLE` holder. */ function defaultAdmin() external view returns (address); /** * @dev Returns a tuple of a `newAdmin` and an accept schedule. * * After the `schedule` passes, the `newAdmin` will be able to accept the {defaultAdmin} role * by calling {acceptDefaultAdminTransfer}, completing the role transfer. * * A zero value only in `acceptSchedule` indicates no pending admin transfer. * * NOTE: A zero address `newAdmin` means that {defaultAdmin} is being renounced. */ function pendingDefaultAdmin() external view returns (address newAdmin, uint48 acceptSchedule); /** * @dev Returns the delay required to schedule the acceptance of a {defaultAdmin} transfer started. * * This delay will be added to the current timestamp when calling {beginDefaultAdminTransfer} to set * the acceptance schedule. * * NOTE: If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this * function returns the new delay. See {changeDefaultAdminDelay}. */ function defaultAdminDelay() external view returns (uint48); /** * @dev Returns a tuple of `newDelay` and an effect schedule. * * After the `schedule` passes, the `newDelay` will get into effect immediately for every * new {defaultAdmin} transfer started with {beginDefaultAdminTransfer}. * * A zero value only in `effectSchedule` indicates no pending delay change. * * NOTE: A zero value only for `newDelay` means that the next {defaultAdminDelay} * will be zero after the effect schedule. */ function pendingDefaultAdminDelay() external view returns (uint48 newDelay, uint48 effectSchedule); /** * @dev Starts a {defaultAdmin} transfer by setting a {pendingDefaultAdmin} scheduled for acceptance * after the current timestamp plus a {defaultAdminDelay}. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * Emits a DefaultAdminRoleChangeStarted event. */ function beginDefaultAdminTransfer(address newAdmin) external; /** * @dev Cancels a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}. * * A {pendingDefaultAdmin} not yet accepted can also be cancelled with this function. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * May emit a DefaultAdminTransferCanceled event. */ function cancelDefaultAdminTransfer() external; /** * @dev Completes a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}. * * After calling the function: * * - `DEFAULT_ADMIN_ROLE` should be granted to the caller. * - `DEFAULT_ADMIN_ROLE` should be revoked from the previous holder. * - {pendingDefaultAdmin} should be reset to zero values. * * Requirements: * * - Only can be called by the {pendingDefaultAdmin}'s `newAdmin`. * - The {pendingDefaultAdmin}'s `acceptSchedule` should've passed. */ function acceptDefaultAdminTransfer() external; /** * @dev Initiates a {defaultAdminDelay} update by setting a {pendingDefaultAdminDelay} scheduled for getting * into effect after the current timestamp plus a {defaultAdminDelay}. * * This function guarantees that any call to {beginDefaultAdminTransfer} done between the timestamp this * method is called and the {pendingDefaultAdminDelay} effect schedule will use the current {defaultAdminDelay} * set before calling. * * The {pendingDefaultAdminDelay}'s effect schedule is defined in a way that waiting until the schedule and then * calling {beginDefaultAdminTransfer} with the new delay will take at least the same as another {defaultAdmin} * complete transfer (including acceptance). * * The schedule is designed for two scenarios: * * - When the delay is changed for a larger one the schedule is `block.timestamp + newDelay` capped by * {defaultAdminDelayIncreaseWait}. * - When the delay is changed for a shorter one, the schedule is `block.timestamp + (current delay - new delay)`. * * A {pendingDefaultAdminDelay} that never got into effect will be canceled in favor of a new scheduled change. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event. */ function changeDefaultAdminDelay(uint48 newDelay) external; /** * @dev Cancels a scheduled {defaultAdminDelay} change. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * May emit a DefaultAdminDelayChangeCanceled event. */ function rollbackDefaultAdminDelay() external; /** * @dev Maximum time in seconds for an increase to {defaultAdminDelay} (that is scheduled using {changeDefaultAdminDelay}) * to take effect. Default to 5 days. * * When the {defaultAdminDelay} is scheduled to be increased, it goes into effect after the new delay has passed with * the purpose of giving enough time for reverting any accidental change (i.e. using milliseconds instead of seconds) * that may lock the contract. However, to avoid excessive schedules, the wait is capped by this function and it can * be overrode for a custom {defaultAdminDelay} increase scheduling. * * IMPORTANT: Make sure to add a reasonable amount of time while overriding this value, otherwise, * there's a risk of setting a high new delay that goes into effect almost immediately without the * possibility of human intervention in the case of an input error (eg. set milliseconds instead of seconds). */ function defaultAdminDelayIncreaseWait() external view returns (uint48); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @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. */ 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 `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1271.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC1271 standard signature validation method for * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. */ interface IERC1271 { /** * @dev Should return whether the signature provided is valid for the provided data * @param hash Hash of the data to be signed * @param signature Signature byte array associated with _data */ function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5313.sol) pragma solidity ^0.8.20; /** * @dev Interface for the Light Contract Ownership Standard. * * A standardized minimal interface required to identify an account that controls a contract */ interface IERC5313 { /** * @dev Gets the address of the owner. */ function owner() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.20; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS } /** * @dev The signature derives the `address(0)`. */ error ECDSAInvalidSignature(); /** * @dev The signature has an invalid length. */ error ECDSAInvalidSignatureLength(uint256 length); /** * @dev The signature has an S value that is in the upper half order. */ error ECDSAInvalidSignatureS(bytes32 s); /** * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not * return address(0) without also returning an error description. Errors are documented using an enum (error type) * and a bytes32 providing additional information about the error. * * If no error is returned, then the address can be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length)); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) { unchecked { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); // We do not check for an overflow here since the shift operation results in 0 or 1. uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError, bytes32) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS, s); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature, bytes32(0)); } return (signer, RecoverError.NoError, bytes32(0)); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s); _throwError(error, errorArg); return recovered; } /** * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. */ function _throwError(RecoverError error, bytes32 errorArg) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert ECDSAInvalidSignature(); } else if (error == RecoverError.InvalidSignatureLength) { revert ECDSAInvalidSignatureLength(uint256(errorArg)); } else if (error == RecoverError.InvalidSignatureS) { revert ECDSAInvalidSignatureS(errorArg); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @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 towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (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 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 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. uint256 twos = denominator & (0 - denominator); 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 (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } }
// SPDX-License-Identifier: MIT // Compatible with OpenZeppelin Contracts ^5.0.0 pragma solidity 0.8.24; /// Interface of the Bascule contract as used by on-chain contracts. /// @custom:security-contact [email protected] interface IBascule { /** * Event emitted when a withdrawal is validated. * @param withdrawalAmount Amount of the withdrawal. * @param depositID Unique identifier for a deposit that took place on another chain and was withdrawn on this chain. */ event WithdrawalValidated(bytes32 depositID, uint256 withdrawalAmount); /** * Error on attempt to withdraw an already withdrawn deposit. * @param depositID Unique identifier for deposit that failed validation. * @param withdrawalAmount Amount of the withdrawal. */ error AlreadyWithdrawn(bytes32 depositID, uint256 withdrawalAmount); /** * Error when a withdrawal fails validation. * This means the corresponding deposit is not in the map. * @param depositID Unique identifier for deposit that failed validation. * @param withdrawalAmount Amount of the withdrawal. */ error WithdrawalFailedValidation( bytes32 depositID, uint256 withdrawalAmount ); /** * Validate a withdrawal (before executing it) if the amount is above * threshold. * * This function checks if our accounting has recorded a deposit that * corresponds to this withdrawal request. A deposit can only be withdrawn * once. * * @param depositID Unique identifier of the deposit on another chain. * @param withdrawalAmount Amount of the withdrawal. * * Emits {WithdrawalValidated}. */ function validateWithdrawal( bytes32 depositID, uint256 withdrawalAmount ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {GMPUtils} from "./libs/GMPUtils.sol"; import {MessagePath} from "./libs/MessagePath.sol"; interface IHandler is IERC165 { /// /// @return Could return some result, that will be emitted in `MessageHandled` event function handlePayload( GMPUtils.Payload memory ) external returns (bytes memory); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; interface IMailbox { error Mailbox_ZeroChainId(); error Mailbox_ZeroConsortium(); error Mailbox_ZeroMailbox(); error Mailbox_ZeroRecipient(); error Mailbox_ZeroAmount(); error Mailbox_MessagePathEnabled(bytes32 id); error Mailbox_MessagePathDisabled(bytes32 id); error Mailbox_UnexpectedDestinationCaller(address expected, address actual); error Mailbox_HandlerNotImplemented(); error Mailbox_PayloadOversize(uint32 max, uint256 actual); error Mailbox_NotEnoughFee(uint256 expected, uint256 actual); error Mailbox_CallFailed(); event MessagePathEnabled( bytes32 indexed destinationChain, bytes32 indexed inboundMessagePath, bytes32 indexed outboundMessagePath, bytes32 destinationMailbox ); event MessagePathDisabled( bytes32 indexed destinationChain, bytes32 indexed inboundMessagePath, bytes32 indexed outboundMessagePath, bytes32 destinationMailbox ); event MessageSent( bytes32 indexed destinationLChainId, address indexed msgSender, bytes32 indexed recipient, bytes payload ); /// Message payment receipt event MessagePaid( bytes32 indexed payloadHash, address indexed msgSender, uint256 payloadSize, uint256 value ); event MessageDelivered( bytes32 indexed payloadHash, address indexed caller, uint256 indexed nonce, bytes32 msgSender, bytes payload ); event MessageHandled( bytes32 indexed payloadHash, address indexed destinationCaller, bytes executionResult ); event MessageHandleError( bytes32 indexed payloadHash, address indexed destinationCaller, string reason, bytes customError ); event SenderConfigUpdated( address indexed sender, uint64 maxPayloadSize, bool feeDisabled ); event DefaultPayloadSizeSet(uint64 maxPayloadSize); event FeePerByteSet(uint256 fee); event FeeWithdrawn(address indexed treasury, uint256 amount); function getFee( address sender, bytes calldata body ) external view returns (uint256); function getInboundMessagePath( bytes32 pathId ) external view returns (bytes32); function send( bytes32 destinationChain, bytes32 recipient, bytes32 destinationCaller, bytes calldata body ) external payable returns (uint256, bytes32); function deliverAndHandle( bytes calldata rawPayload, bytes calldata proof ) external returns (bytes32, bool, bytes memory); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {LChainId} from "../../libs/LChainId.sol"; library GMPUtils { // bytes4(keccak256("MessageV1(bytes32,uint256,bytes32,bytes32,bytes32,bytes)")) bytes4 public constant GMP_V1_SELECTOR = 0xe288fb4a; uint256 internal constant MIN_GMP_LENGTH = 32 * 6 + 4; // This length includes selector error GMP_ZeroChainId(); error GMP_ZeroSender(); error GMP_ZeroRecipient(); error GMP_WrongPayloadLength(); error GMP_InvalidAddess(); error GMP_InvalidAction(bytes4 expectedVal, bytes4 actualVal); struct Payload { bytes32 id; bytes32 msgPath; uint256 msgNonce; bytes32 msgSender; address msgRecipient; // it's okay to use address instead bytes32, because delivered to EVM address msgDestinationCaller; bytes msgBody; } function encodePayload( bytes32 msgPath, uint256 msgNonce, bytes32 msgSender, bytes32 msgRecipient, bytes32 msgDestinationCaller, bytes memory msgBody ) internal pure returns (bytes memory) { return abi.encodeWithSelector( GMP_V1_SELECTOR, msgPath, msgNonce, msgSender, msgRecipient, msgDestinationCaller, msgBody ); } function decodeAndValidatePayload( bytes calldata rawPayload ) internal pure returns (Payload memory payload) { validatePayload(rawPayload); ( payload.msgPath, payload.msgNonce, payload.msgSender, payload.msgRecipient, payload.msgDestinationCaller, payload.msgBody ) = abi.decode( rawPayload[4:], (bytes32, uint256, bytes32, address, address, bytes) ); // no need to verify msg path, because mailbox verifies it to be enabled if (payload.msgSender == bytes32(0)) { revert GMP_ZeroSender(); } if (payload.msgRecipient == address(0)) { revert GMP_ZeroRecipient(); } payload.id = hash(rawPayload); return payload; } // @notice Returns message's selector function selector(bytes memory payload) internal pure returns (bytes4) { return bytes4(payload); } function hash(bytes memory rawPayload) internal pure returns (bytes32) { return sha256(rawPayload); } /** * @notice converts address to bytes32 (alignment preserving cast.) * @param addr the address to convert to bytes32 */ function addressToBytes32(address addr) internal pure returns (bytes32) { return bytes32(uint256(uint160(addr))); } /** * @notice converts bytes32 to address (alignment preserving cast.) * @dev This function explicitly checks if the first 12 bytes are zeros to ensure 1 to 1 mapping * @param _buf the bytes32 to convert to address */ function bytes32ToAddress(bytes32 _buf) internal pure returns (address) { if (uint256(_buf) >> 160 != 0) { revert GMP_InvalidAddess(); } return address(uint160(uint256(_buf))); } function validatePayload(bytes calldata rawPayload) internal pure { if (bytes4(rawPayload) != GMP_V1_SELECTOR) { revert GMP_InvalidAction(GMP_V1_SELECTOR, bytes4(rawPayload)); } if (rawPayload.length < MIN_GMP_LENGTH) { revert GMP_WrongPayloadLength(); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; library MessagePath { struct Details { bytes32 sourceContract; bytes32 sourceChain; bytes32 destinationChain; } function id(Details memory self) internal pure returns (bytes32) { return keccak256( abi.encode( self.sourceContract, self.sourceChain, self.destinationChain ) ); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; interface IAssetOperation { error AssetOperation_DepositNotAllowed(); error NotStakingToken(); error AssetOperation_RedeemNotAllowed(); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {IBascule} from "../../bascule/interfaces/IBascule.sol"; import {IMailbox} from "../../gmp/IMailbox.sol"; import {IOracle} from "../interfaces/IOracle.sol"; interface IAssetRouter { // Describes types of possible routes. UNKNOWN means no route or disabled route enum RouteType { UNKNOWN, // unknown must be '0' DEPOSIT, REDEEM } error AssetRouter_ZeroMailbox(); error AssetRouter_MailboxExpected(); error AssetRouter_PayloadAlreadyUsed(); error AssetRouter_ZeroAddress(); error AssetRouter_Unauthorized(); error AssetRouter_WrongOperation(); error AssetRouter_WrongSender(); error AssetRouter_WrongNativeToken(); error AssetRouter_MintProcessingError(); error AssetRouter_FeeGreaterThanAmount(); error AssertRouter_UnauthorizedAccount(); error AssertRouter_WrongRedeemDestinationChain(); error AssertRouter_WrongRouteType(); error AssertRouter_WrongToken(); event AssetRouter_FeeCharged(uint256 indexed fee, bytes userSignature); event AssetRouter_RedeemFeeChanged( address indexed token, uint256 oldFee, uint256 newFee ); event AssetRouter_RedeemForBtcMinAmountChanged( address indexed token, uint256 oldMinAmount, uint256 newMinAmount ); event AssetRouter_RedeemEnabled(address indexed token, bool enabled); event AssetRouter_RouteSet( bytes32 indexed fromToken, bytes32 indexed fromChainId, bytes32 indexed toToken, bytes32 toChainId, RouteType routeType ); event AssetRouter_RouteRemoved( bytes32 indexed fromToken, bytes32 indexed fromChainId, bytes32 indexed toToken, bytes32 toChainId ); event AssetRouter_BasculeChanged( address indexed prevVal, address indexed newVal ); event AssetRouter_OracleChanged( address indexed prevVal, address indexed newVal ); event AssetRouter_MailboxChanged( address indexed prevVal, address indexed newVal ); event AssetRouter_MintFeeChanged( uint256 indexed oldFee, uint256 indexed newFee ); event AssetRouter_ToNativeCommissionChanged( uint256 indexed oldCommission, uint256 indexed newCommission ); event AssetRouter_NativeTokenChanged( address indexed oldAddress, address indexed newAddress ); event AssetRouter_BatchMintError( bytes32 indexed payloadHash, string reason, bytes customError ); event AssetRouter_DustFeeRateChanged( uint256 indexed oldRate, uint256 indexed newRate ); function getRouteType( bytes32 fromToken, bytes32 fromChainId, bytes32 toChainId, bytes32 toToken ) external view returns (RouteType); function maxMintCommission(address token) external view returns (uint256); function ratio(address token) external view returns (uint256); function getRate(address token) external view returns (uint256); function bitcoinChainId() external view returns (bytes32); function bascule() external view returns (IBascule); function oracle(address token) external view returns (IOracle); function mailbox() external view returns (IMailbox); function toNativeCommission(address token) external view returns (uint64); function nativeToken() external view returns (address); function tokenConfig( address token ) external view returns ( uint256 redeemFee, uint256 redeemForBtcMinAmount, bool isRedeemEnabled ); function deposit( bytes32 tolChainId, bytes32 toToken, bytes32 recipient, uint256 amount ) external; function deposit( address fromAddress, address toToken, uint256 amount ) external; function redeemForBtc( address fromAddress, address fromToken, bytes calldata recipient, uint256 amount ) external; function redeem( address fromAddress, bytes32 tolChainId, address fromToken, bytes32 toToken, bytes32 recipient, uint256 amount ) external; function redeem( address fromAddress, address fromToken, uint256 amount ) external; function mint( bytes calldata rawPayload, bytes calldata proof ) external returns (address); function mintWithFee( bytes calldata mintPayload, bytes calldata proof, bytes calldata feePayload, bytes calldata userSignature ) external; function batchMint( bytes[] calldata payload, bytes[] calldata proof ) external; function batchMintWithFee( bytes[] calldata mintPayload, bytes[] calldata proof, bytes[] calldata feePayload, bytes[] calldata userSignature ) external; function calcUnstakeRequestAmount( address token, bytes calldata scriptPubkey, uint256 amount ) external view returns (uint256 amountAfterFee, bool isAboveDust); function changeRedeemFee(uint256 fee) external; function changeRedeemForBtcMinAmount(uint256 minAmount) external; function toggleRedeem() external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; interface IBaseLBTC { error RedeemForBtcDisabled(); error PayloadAlreadyUsed(); error InvalidMintAmount(); error AssetRouterNotSet(); event RedeemRequest( address indexed from, uint256 indexed nonce, uint256 amount, uint256 fee, bytes payload ); event RedeemsForBtcEnabled(bool); event NameAndSymbolChanged(string name, string symbol); event ConsortiumChanged(address indexed prevVal, address indexed newVal); event TreasuryAddressChanged( address indexed prevValue, address indexed newValue ); event BurnCommissionChanged( uint64 indexed prevValue, uint64 indexed newValue ); event DustFeeRateChanged(uint256 indexed oldRate, uint256 indexed newRate); event BasculeChanged(address indexed prevVal, address indexed newVal); event FeeCharged(uint256 indexed fee, bytes userSignature); event FeeChanged(uint256 indexed oldFee, uint256 indexed newFee); event RedeemFeeChanged(uint256 indexed oldFee, uint256 indexed newFee); event MintProofConsumed( address indexed recipient, bytes32 indexed payloadHash, bytes payload ); event BatchMintSkipped(bytes32 indexed payloadHash, bytes payload); event AssetRouterChanged(address indexed newVal, address indexed prevVal); function burn(uint256 amount) external; function burn(address from, uint256 amount) external; function mint(address to, uint256 amount) external; function getTreasury() external view returns (address); function getAssetRouter() external view returns (address); function isNative() external view returns (bool); function getRedeemFee() external view returns (uint256); function getFeeDigest( uint256 fee, uint256 expiry ) external view returns (bytes32); function isRedeemsEnabled() external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; interface IOracle { event Oracle_RatioChanged( uint256 prevVal, uint256 newVal, uint256 switchTime ); function ratio() external view returns (uint256); function getRate() external view returns (uint256); function token() external view returns (address); function denomHash() external view returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {EIP1271SignatureUtils} from "../../libs/EIP1271SignatureUtils.sol"; /// @dev collection of assertions used in ERC20 contracts library Assert { error InvalidDustFeeRate(); error NonEqualLength(uint256 a, uint256 b); error InvalidAction(bytes4 expected, bytes4 actual); error InvalidFeeApprovalSignature(); error ZeroAddress(); function zeroAddress(address addr) internal pure { if (addr == address(0)) revert ZeroAddress(); } function dustFeeRate(uint256 rate) internal pure { if (rate == 0) revert InvalidDustFeeRate(); } function equalLength(uint256 lengthA, uint256 lengthB) internal pure { if (lengthA != lengthB) revert NonEqualLength(lengthA, lengthB); } function selector( bytes calldata payload, bytes4 expectedAction ) internal pure { if (bytes4(payload) != expectedAction) revert InvalidAction(expectedAction, bytes4(payload)); } function feeApproval( bytes32 digest, address recipient, bytes calldata signature ) internal view { if ( !EIP1271SignatureUtils.checkSignature(recipient, digest, signature) ) { revert InvalidFeeApprovalSignature(); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {GMPUtils} from "../../gmp/libs/GMPUtils.sol"; library Assets { /// @dev Error thrown when payload length is too big error Assets_InvalidPayloadSize(uint256 expected, uint256 actual); error Assets_ZeroRequestHash(); error Assets_ChainIdMismatch(bytes32 expected, bytes32 actual); error Assets_ZeroAmount(); error Assets_ZeroRecipient(); error Assets_InvalidRecipient(); error Assets_ZeroFromToken(); error Assets_ZeroToToken(); error Assets_InvalidToToken(); error Assets_InvalidSelector(bytes4 expected, bytes4 actual); struct Receipt { address recipient; uint256 amount; bytes32 fromToken; address toToken; bytes32 lChainId; } struct Release { address toToken; address recipient; uint256 amount; } // bytes4(keccak256("deposit(bytes32,bytes32,bytes32,bytes32,uint256)")) bytes4 internal constant DEPOSIT_REQUEST_SELECTOR = 0xccb41215; // bytes4(keccak256("redeem(bytes32,bytes32,bytes32,bytes,uint256)")) bytes4 internal constant REDEEM_REQUEST_SELECTOR = 0xaa3db85f; // bytes4(keccak256("redeemForBTC(bytes32,bytes,uint256)")) bytes4 internal constant REDEEM_FROM_NATIVE_TOKEN_SELECTOR = 0x4e3e5047; // bytes4(keccak256("mint(bytes32,bytes32,uint256)")) bytes4 internal constant MINT_SELECTOR = 0x155b6b13; /// @dev A constant representing the number of bytes for a slot of information in a payload. uint256 internal constant ABI_SLOT_SIZE = 32; bytes32 public constant BTC_STAKING_MODULE_ADDRESS = bytes32(uint256(0x0089e3e4e7a699d6f131d893aeef7ee143706ac23a)); bytes32 public constant ASSETS_MODULE_ADDRESS = bytes32(uint256(0x008bf729ffe074caee622c02928173467e658e19e2)); bytes32 public constant LEDGER_CALLER = bytes32(uint256(0x0)); bytes32 public constant BITCOIN_NATIVE_COIN = bytes32(uint256(0x00000000000000000000000000000000000001)); function encodeDepositRequest( bytes32 toChain, bytes32 toToken, bytes32 sender, bytes32 recipient, uint256 amount ) internal pure returns (bytes memory) { if (amount == 0) { revert Assets_ZeroAmount(); } if (recipient == bytes32(0)) { revert Assets_ZeroRecipient(); } return abi.encodeWithSelector( DEPOSIT_REQUEST_SELECTOR, toChain, toToken, sender, recipient, amount ); } function encodeRedeemRequest( bytes32 toChain, bytes32 fromToken, bytes32 sender, bytes memory recipient, uint256 amount ) internal pure returns (bytes memory) { if (amount == 0) { revert Assets_ZeroAmount(); } if (recipient.length == 0) { revert Assets_ZeroRecipient(); } bool recipientValid = false; for (uint256 i = 0; i < recipient.length; ++i) { if (recipient[i] != 0x0) { recipientValid = true; break; } } if (!recipientValid) { revert Assets_ZeroRecipient(); } return abi.encodeWithSelector( REDEEM_REQUEST_SELECTOR, toChain, fromToken, sender, recipient, amount ); } function encodeRedeemNativeRequest( bytes32 sender, bytes memory recipient, uint256 amount ) internal pure returns (bytes memory) { if (amount == 0) { revert Assets_ZeroAmount(); } if (recipient.length == 0) { revert Assets_ZeroRecipient(); } bool recipientValid = false; for (uint256 i = 0; i < recipient.length; ++i) { if (recipient[i] != 0x0) { recipientValid = true; break; } } if (!recipientValid) { revert Assets_ZeroRecipient(); } return abi.encodeWithSelector( REDEEM_FROM_NATIVE_TOKEN_SELECTOR, sender, recipient, amount ); } function decodeRelease( bytes memory rawPayload ) internal pure returns (Release memory, bytes32) { if (rawPayload.length != ABI_SLOT_SIZE * 3 + 4) { revert Assets_InvalidPayloadSize( ABI_SLOT_SIZE * 3 + 4, rawPayload.length ); } bytes4 selector; bytes32 rawToToken; bytes32 rawRecipient; uint256 amount; assembly { selector := mload(add(rawPayload, 0x20)) // first 4 bytes rawToToken := mload(add(rawPayload, 0x24)) // bytes 4..36 rawRecipient := mload(add(rawPayload, 0x44)) // bytes 37..68 amount := mload(add(rawPayload, 0x64)) // bytes 69..100 } if (selector != MINT_SELECTOR) { revert Assets_InvalidSelector(MINT_SELECTOR, selector); } if (amount == 0) { revert Assets_ZeroAmount(); } address recipient = GMPUtils.bytes32ToAddress(rawRecipient); if (recipient == address(0)) { revert Assets_ZeroRecipient(); } address toToken = GMPUtils.bytes32ToAddress(rawToToken); if (toToken == address(0)) { revert Assets_ZeroToToken(); } return (Release(toToken, recipient, amount), sha256(rawPayload)); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {BitcoinUtils} from "../../libs/BitcoinUtils.sol"; /// @dev collection of validations used in ERC20 contracts library Validation { error AmountLessThanCommission(uint256 fee); error AmountBelowMinLimit(uint256 dustLimit); error ScriptPubkeyUnsupported(); function redeemFee( bytes calldata scriptPubkey, uint256 amount, uint64 fee, uint256 minAmount ) internal pure returns (uint256) { ( uint256 amountAfterFee, bool isAboveFee, bool isAboveMinLimit ) = calcFeeAndDustLimit(scriptPubkey, amount, fee, minAmount); if (!isAboveFee) { revert AmountLessThanCommission(fee); } if (!isAboveMinLimit) { revert AmountBelowMinLimit(minAmount); } return amountAfterFee; } function calcFeeAndDustLimit( bytes calldata scriptPubkey, uint256 amount, uint64 fee, uint256 minAmount ) internal pure returns (uint256, bool, bool) { BitcoinUtils.OutputType outType = BitcoinUtils.getOutputType( scriptPubkey ); if (outType == BitcoinUtils.OutputType.UNSUPPORTED) { revert ScriptPubkeyUnsupported(); } if (amount <= fee) { return (0, false, false); } uint256 amountAfterFee = amount - fee; bool isAboveMinLimit = amountAfterFee >= minAmount; return (amountAfterFee, true, isAboveMinLimit); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; library Actions { /// @dev toChain, recipient, amount, txid are validated struct DepositBtcActionV0 { uint256 toChain; address recipient; uint256 amount; bytes32 txid; uint32 vout; } /// @dev toChain, recipient, amount, txid, token are validated struct DepositBtcActionV1 { uint256 toChain; address recipient; uint256 amount; bytes32 txid; uint32 vout; address token; } struct DepositBridgeAction { uint256 fromChain; bytes32 fromContract; uint256 toChain; address toContract; address recipient; uint64 amount; uint256 nonce; } struct ValSetAction { uint256 epoch; address[] validators; uint256[] weights; uint256 weightThreshold; uint256 height; } struct FeeApprovalAction { uint256 fee; uint256 expiry; } struct RatioUpdate { bytes32 denom; uint256 ratio; uint256 switchTime; } /// @dev Error thrown when invalid public key is provided error InvalidPublicKey(bytes pubKey); /// @dev Error thrown when signatures length is not equal to signers length error Actions_LengthMismatch(); /// @dev Error thrown when threshold is invalid error InvalidThreshold(); /// @dev Error thrown when validator set size is invalid error InvalidValidatorSetSize(); /// @dev Error thrown when zero validator is provided error ZeroValidator(); /// @dev Error thrown when wrong chain id is provided error WrongChainId(); /// @dev Error thrown when wrong contract is provided error WrongContract(); /// @dev Error thrown when zero address is provided error Actions_ZeroAddress(); /// @dev Error thrown when zero amount is provided error ZeroAmount(); /// @dev Error thrown when zero weight is provided error ZeroWeight(); /// @dev Error thrown when fee approval is expired error UserSignatureExpired(uint256 expiry); /// @dev Error thrown when amount is below fee error NotEnoughAmountToUseApproval(); /// @dev Error thrown when zero fee is used error ZeroFee(); /// @dev Error thrown when payload length is too big error InvalidPayloadSize(uint256 expected, uint256 actual); error ZeroTxId(); error InvalidDestinationToken(address expected, address actual); error Actions_ZeroDenom(); error Actions_ZeroRatio(); // bytes4(keccak256("feeApproval(uint256,uint256)")) bytes4 internal constant FEE_APPROVAL_ACTION = 0x8175ca94; // keccak256("feeApproval(uint256 chainId,uint256 fee,uint256 expiry)") bytes32 internal constant FEE_APPROVAL_EIP712_ACTION = 0x40ac9f6aa27075e64c1ed1ea2e831b20b8c25efdeb6b79fd0cf683c9a9c50725; // bytes4(keccak256("payload(bytes32,bytes32,uint64,bytes32,uint32)")) bytes4 internal constant DEPOSIT_BTC_ACTION_V0 = 0xf2e73f7c; // bytes4(keccak256("payload(bytes32,bytes32,uint64,bytes32,uint32,bytes32)")) bytes4 internal constant DEPOSIT_BTC_ACTION_V1 = 0xce25e7c2; // bytes4(keccak256("payload(bytes32,bytes32,bytes32,bytes32,bytes32,uint64,uint256)")) bytes4 internal constant DEPOSIT_BRIDGE_ACTION = 0x5c70a505; // bytes4(keccak256("payload(uint256,bytes[],uint256[],uint256,uint256)")) bytes4 internal constant NEW_VALSET = 0x4aab1d6f; // bytes4(keccak256("payload(bytes32,uint256,uint256)")) bytes4 internal constant RATIO_UPDATE = 0x6c722c2c; /// @dev Maximum number of validators allowed in the consortium. /// @notice This value is determined by the minimum of CometBFT consensus limitations and gas considerations: /// - CometBFT has a hard limit of 10,000 validators (https://docs.cometbft.com/v0.38/spec/core/state) /// - Gas-based calculation: /// - Assumes 4281 gas per ECDSA signature verification /// - Uses a conservative 30 million gas block limit /// - Maximum possible signatures: 30,000,000 / 4,281 ≈ 7007 /// - Reverse calculated for BFT consensus (2/3 + 1): /// 7,007 = (10,509 * 2/3 + 1) rounded down /// - The lower value of 10,000 (CometBFT limit) and 10,509 (gas calculation) is chosen /// @dev This limit ensures compatibility with CometBFT while also considering gas limitations /// for signature verification within a single block. uint256 private constant MAX_VALIDATOR_SET_SIZE = 102; /// @dev Minimum number of validators allowed in the system. /// @notice While set to 1 to allow for non-distributed scenarios, this configuration /// does not provide Byzantine fault tolerance. For a truly distributed and /// fault-tolerant system, a minimum of 4 validators would be recommended to tolerate /// at least one Byzantine fault. uint256 private constant MIN_VALIDATOR_SET_SIZE = 1; /// @dev A constant representing the number of bytes for a slot of information in a payload. uint256 internal constant ABI_SLOT_SIZE = 32; /** * @notice Returns decoded deposit btc msg v0 * @dev Message should not contain the selector * @param payload Body of the mint payload */ function depositBtcV0( bytes memory payload ) internal view returns (DepositBtcActionV0 memory) { if (payload.length != ABI_SLOT_SIZE * 5) revert InvalidPayloadSize(ABI_SLOT_SIZE * 5, payload.length); ( uint256 toChain, address recipient, uint256 amount, bytes32 txid, uint32 vout ) = abi.decode(payload, (uint256, address, uint256, bytes32, uint32)); if (toChain != block.chainid) { revert WrongChainId(); } if (recipient == address(0)) { revert Actions_ZeroAddress(); } if (amount == 0) { revert ZeroAmount(); } if (txid == bytes32(0)) { revert ZeroTxId(); } return DepositBtcActionV0(toChain, recipient, amount, txid, vout); } /** * @notice Returns decoded deposit btc msg v1 * @dev Message should not contain the selector * @param payload Body of the mint payload */ function depositBtcV1( bytes memory payload ) internal view returns (DepositBtcActionV1 memory) { if (payload.length != ABI_SLOT_SIZE * 6) revert InvalidPayloadSize(ABI_SLOT_SIZE * 6, payload.length); ( uint256 toChain, address recipient, uint256 amount, bytes32 txid, uint32 vout, address token ) = abi.decode( payload, (uint256, address, uint256, bytes32, uint32, address) ); if (toChain != block.chainid) { revert WrongChainId(); } if (recipient == address(0)) { revert Actions_ZeroAddress(); } if (amount == 0) { revert ZeroAmount(); } if (txid == bytes32(0)) { revert ZeroTxId(); } if (token != address(this)) { revert InvalidDestinationToken(address(this), token); } return DepositBtcActionV1(toChain, recipient, amount, txid, vout, token); } /** * @notice Returns decoded bridge payload * @dev Payload should not contain the selector * @param payload Body of the burn payload */ function depositBridge( bytes memory payload ) internal view returns (DepositBridgeAction memory) { if (payload.length != ABI_SLOT_SIZE * 7) revert InvalidPayloadSize(ABI_SLOT_SIZE * 7, payload.length); ( uint256 fromChain, bytes32 fromContract, uint256 toChain, address toContract, address recipient, uint64 amount, uint256 nonce ) = abi.decode( payload, (uint256, bytes32, uint256, address, address, uint64, uint256) ); if (toChain != block.chainid) { revert WrongChainId(); } if (recipient == address(0)) { revert Actions_ZeroAddress(); } if (amount == 0) { revert ZeroAmount(); } return DepositBridgeAction( fromChain, fromContract, toChain, toContract, recipient, amount, nonce ); } /** * @notice Returns decoded validator set * @dev Payload should not contain the selector * @param payload Body of the set validators set payload */ function validateValSet( bytes memory payload ) internal pure returns (ValSetAction memory) { ( uint256 epoch, bytes[] memory pubKeys, uint256[] memory weights, uint256 weightThreshold, uint256 height ) = abi.decode( payload, (uint256, bytes[], uint256[], uint256, uint256) ); // Since dynamic arrays can variably insert more slots of data for things such as data length, // offset etc., we will just encode the received variables again and check for a length match. bytes memory reEncodedPayload = abi.encode( epoch, pubKeys, weights, weightThreshold, height ); if (reEncodedPayload.length != payload.length) revert InvalidPayloadSize(payload.length, reEncodedPayload.length); if ( pubKeys.length < MIN_VALIDATOR_SET_SIZE || pubKeys.length > MAX_VALIDATOR_SET_SIZE ) revert InvalidValidatorSetSize(); if (pubKeys.length != weights.length) revert Actions_LengthMismatch(); if (weightThreshold == 0) revert InvalidThreshold(); uint256 sum = 0; for (uint256 i; i < weights.length; ) { if (weights[i] == 0) { revert ZeroWeight(); } sum += weights[i]; unchecked { ++i; } } if (sum < weightThreshold) revert InvalidThreshold(); address[] memory validators = pubKeysToAddress(pubKeys); return ValSetAction(epoch, validators, weights, weightThreshold, height); } function pubKeysToAddress( bytes[] memory _pubKeys ) internal pure returns (address[] memory) { address[] memory addresses = new address[](_pubKeys.length); for (uint256 i; i < _pubKeys.length; ) { // each pubkey represented as uncompressed if (_pubKeys[i].length == 65) { bytes memory data = _pubKeys[i]; // Ensure that first byte of pubkey is 0x04 if (_pubKeys[i][0] != 0x04) revert InvalidPublicKey(_pubKeys[i]); // create a new array with length - 1 (excluding the first 0x04 byte) bytes memory result = new bytes(data.length - 1); // use inline assembly for memory manipulation assembly { // calculate the start of the `result` and `data` in memory let resultData := add(result, 0x20) // points to the first byte of the result let dataStart := add(data, 0x21) // points to the second byte of data (skip 0x04) // copy 64 bytes from input (excluding the first byte) to result mstore(resultData, mload(dataStart)) // copy the first 32 bytes mstore(add(resultData, 0x20), mload(add(dataStart, 0x20))) // copy the next 32 bytes } addresses[i] = address(uint160(uint256(keccak256(result)))); } else { revert InvalidPublicKey(_pubKeys[i]); } unchecked { ++i; } } return addresses; } /** * @notice Returns decoded fee approval * @dev Payload should not contain the selector * @param payload Body of the fee approval payload */ function feeApproval( bytes memory payload ) internal view returns (FeeApprovalAction memory) { if (payload.length != ABI_SLOT_SIZE * 2) revert InvalidPayloadSize(ABI_SLOT_SIZE * 2, payload.length); (uint256 fee, uint256 expiry) = abi.decode(payload, (uint256, uint256)); if (block.timestamp > expiry) { revert UserSignatureExpired(expiry); } if (fee == 0) { revert ZeroFee(); } return FeeApprovalAction(fee, expiry); } /** * @notice Returns decoded ratio update message * @dev Message should not contain the selector * @param payload Body of the ratio update message */ function ratioUpdate( bytes memory payload ) internal pure returns (RatioUpdate memory) { if (payload.length != ABI_SLOT_SIZE * 3) revert InvalidPayloadSize(ABI_SLOT_SIZE * 3, payload.length); (bytes32 denom, uint256 ratio, uint256 timestamp) = abi.decode( payload, (bytes32, uint256, uint256) ); if (denom == bytes32(0)) { revert Actions_ZeroDenom(); } if (ratio == uint256(0)) { revert Actions_ZeroRatio(); } return RatioUpdate(denom, ratio, timestamp); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; bytes1 constant OP_0 = 0x00; bytes1 constant OP_1 = 0x51; bytes1 constant OP_DATA_32 = 0x20; bytes1 constant OP_DATA_20 = 0x14; uint256 constant BASE_SPEND_COST = 49; // 32 (txid) + 4 (vout) + 1 (scriptSig size) + 4 (nSequence) + 8 (amount) // Size of inputs spending different output types uint256 constant NON_WITNESS_INPUT_SIZE = 107; // Used for non-witness outputs (P2PKH, P2SH) uint256 constant WITNESS_INPUT_SIZE = 26; // floor(107 / 4), used for witness outputs (P2WPKH, P2WSH, P2TR) library BitcoinUtils { enum OutputType { UNSUPPORTED, P2TR, P2WPKH, P2WSH } uint256 public constant DEFAULT_DUST_FEE_RATE = 3000; // Default value - 3 satoshis per byte function getOutputType( bytes calldata scriptPubkey ) internal pure returns (OutputType) { if ( scriptPubkey.length == 22 && scriptPubkey[0] == OP_0 && scriptPubkey[1] == OP_DATA_20 ) { return OutputType.P2WPKH; } if ( scriptPubkey.length == 34 && scriptPubkey[0] == OP_1 && scriptPubkey[1] == OP_DATA_32 ) { return OutputType.P2TR; } if ( scriptPubkey.length == 34 && scriptPubkey[0] == OP_0 && scriptPubkey[1] == OP_DATA_32 ) { return OutputType.P2WSH; } return OutputType.UNSUPPORTED; } /// @notice Compute the dust limit for a given Bitcoin script public key /// @dev The dust limit is the minimum payment to an address that is considered /// spendable under consensus rules. This function is based on Bitcoin Core's /// implementation. /// @param scriptPubkey The Bitcoin script public key as a byte array /// @param dustFeeRate The current dust fee rate (in satoshis per 1000 bytes) /// @return dustLimit The calculated dust limit in satoshis /// @custom:reference https://github.com/bitcoin/bitcoin/blob/43740f4971f45cd5499470b6a085b3ecd8b96d28/src/policy/policy.cpp#L54 function getDustLimitForOutput( OutputType outType, bytes calldata scriptPubkey, uint256 dustFeeRate ) internal pure returns (uint256 dustLimit) { uint256 spendCost = BASE_SPEND_COST; if ( outType == OutputType.P2TR || outType == OutputType.P2WPKH || outType == OutputType.P2WSH ) { // witness v0 and v1 has a cheaper payment formula spendCost += WITNESS_INPUT_SIZE; // The current addition creates a discrepancy of 1, and our final value should be 98 bytes. // Thus, we add 1 here. spendCost += 1; } else { spendCost += NON_WITNESS_INPUT_SIZE; } spendCost += scriptPubkey.length; // Calculate dust limit dustLimit = Math.ceilDiv(spendCost * dustFeeRate, 1000); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; /** * @title Library of utilities for making EIP1271-compliant signature checks. * @author Lombard.Finance * @notice The contracts is a part of Lombard.Finace protocol */ library EIP1271SignatureUtils { // bytes4(keccak256("isValidSignature(bytes32,bytes)") bytes4 internal constant EIP1271_MAGICVALUE = 0x1626ba7e; bytes4 internal constant EIP1271_WRONGVALUE = 0xffffffff; /** * @notice Checks @param signature is a valid signature of @param digest from @param signer. * If the `signer` contains no code -- i.e. it is not (yet, at least) a contract address, then checks using standard ECDSA logic * Otherwise, passes on the signature to the signer to verify the signature and checks that it returns the `EIP1271_MAGICVALUE`. */ function checkSignature( address signer, bytes32 digest, bytes memory signature ) internal view returns (bool) { if (signer.code.length != 0) { if ( IERC1271(signer).isValidSignature(digest, signature) != EIP1271_MAGICVALUE ) { return false; } } else { if (ECDSA.recover(digest, signature) != signer) { return false; } } return true; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.24; library LChainId { function get() internal view returns (bytes32) { // Ensure first byte is zero by masking the highest byte return bytes32( block.chainid & 0x00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"uint48","name":"schedule","type":"uint48"}],"name":"AccessControlEnforcedDefaultAdminDelay","type":"error"},{"inputs":[],"name":"AccessControlEnforcedDefaultAdminRules","type":"error"},{"inputs":[{"internalType":"address","name":"defaultAdmin","type":"address"}],"name":"AccessControlInvalidDefaultAdmin","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"uint256","name":"dustLimit","type":"uint256"}],"name":"AmountBelowMinLimit","type":"error"},{"inputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"AmountLessThanCommission","type":"error"},{"inputs":[],"name":"AssertRouter_UnauthorizedAccount","type":"error"},{"inputs":[],"name":"AssertRouter_WrongRedeemDestinationChain","type":"error"},{"inputs":[],"name":"AssertRouter_WrongRouteType","type":"error"},{"inputs":[],"name":"AssertRouter_WrongToken","type":"error"},{"inputs":[],"name":"AssetOperation_DepositNotAllowed","type":"error"},{"inputs":[],"name":"AssetOperation_RedeemNotAllowed","type":"error"},{"inputs":[],"name":"AssetRouter_FeeGreaterThanAmount","type":"error"},{"inputs":[],"name":"AssetRouter_MailboxExpected","type":"error"},{"inputs":[],"name":"AssetRouter_MintProcessingError","type":"error"},{"inputs":[],"name":"AssetRouter_PayloadAlreadyUsed","type":"error"},{"inputs":[],"name":"AssetRouter_Unauthorized","type":"error"},{"inputs":[],"name":"AssetRouter_WrongNativeToken","type":"error"},{"inputs":[],"name":"AssetRouter_WrongOperation","type":"error"},{"inputs":[],"name":"AssetRouter_WrongSender","type":"error"},{"inputs":[],"name":"AssetRouter_ZeroAddress","type":"error"},{"inputs":[],"name":"AssetRouter_ZeroMailbox","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"Assets_InvalidPayloadSize","type":"error"},{"inputs":[{"internalType":"bytes4","name":"expected","type":"bytes4"},{"internalType":"bytes4","name":"actual","type":"bytes4"}],"name":"Assets_InvalidSelector","type":"error"},{"inputs":[],"name":"Assets_ZeroAmount","type":"error"},{"inputs":[],"name":"Assets_ZeroRecipient","type":"error"},{"inputs":[],"name":"Assets_ZeroToToken","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"GMP_InvalidAddess","type":"error"},{"inputs":[{"internalType":"bytes4","name":"expected","type":"bytes4"},{"internalType":"bytes4","name":"actual","type":"bytes4"}],"name":"InvalidAction","type":"error"},{"inputs":[],"name":"InvalidFeeApprovalSignature","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"InvalidPayloadSize","type":"error"},{"inputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"}],"name":"NonEqualLength","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NotStakingToken","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[],"name":"ScriptPubkeyUnsupported","type":"error"},{"inputs":[{"internalType":"uint256","name":"expiry","type":"uint256"}],"name":"UserSignatureExpired","type":"error"},{"inputs":[],"name":"ZeroFee","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"prevVal","type":"address"},{"indexed":true,"internalType":"address","name":"newVal","type":"address"}],"name":"AssetRouter_BasculeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"payloadHash","type":"bytes32"},{"indexed":false,"internalType":"string","name":"reason","type":"string"},{"indexed":false,"internalType":"bytes","name":"customError","type":"bytes"}],"name":"AssetRouter_BatchMintError","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oldRate","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newRate","type":"uint256"}],"name":"AssetRouter_DustFeeRateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"userSignature","type":"bytes"}],"name":"AssetRouter_FeeCharged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"prevVal","type":"address"},{"indexed":true,"internalType":"address","name":"newVal","type":"address"}],"name":"AssetRouter_MailboxChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oldFee","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"AssetRouter_MintFeeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldAddress","type":"address"},{"indexed":true,"internalType":"address","name":"newAddress","type":"address"}],"name":"AssetRouter_NativeTokenChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"prevVal","type":"address"},{"indexed":true,"internalType":"address","name":"newVal","type":"address"}],"name":"AssetRouter_OracleChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"AssetRouter_RedeemEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"AssetRouter_RedeemFeeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldMinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newMinAmount","type":"uint256"}],"name":"AssetRouter_RedeemForBtcMinAmountChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"fromToken","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"fromChainId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"toToken","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"toChainId","type":"bytes32"}],"name":"AssetRouter_RouteRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"fromToken","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"fromChainId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"toToken","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"toChainId","type":"bytes32"},{"indexed":false,"internalType":"enum IAssetRouter.RouteType","name":"routeType","type":"uint8"}],"name":"AssetRouter_RouteSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oldCommission","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newCommission","type":"uint256"}],"name":"AssetRouter_ToNativeCommissionChanged","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminDelayChangeCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint48","name":"newDelay","type":"uint48"},{"indexed":false,"internalType":"uint48","name":"effectSchedule","type":"uint48"}],"name":"DefaultAdminDelayChangeScheduled","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminTransferCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"},{"indexed":false,"internalType":"uint48","name":"acceptSchedule","type":"uint48"}],"name":"DefaultAdminTransferScheduled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"CALLER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CLAIMER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"bascule","outputs":[{"internalType":"contract IBascule","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"payload","type":"bytes[]"},{"internalType":"bytes[]","name":"proof","type":"bytes[]"}],"name":"batchMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"mintPayload","type":"bytes[]"},{"internalType":"bytes[]","name":"proof","type":"bytes[]"},{"internalType":"bytes[]","name":"feePayload","type":"bytes[]"},{"internalType":"bytes[]","name":"userSignature","type":"bytes[]"}],"name":"batchMintWithFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"beginDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"bitcoinChainId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"bytes","name":"scriptPubkey","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calcUnstakeRequestAmount","outputs":[{"internalType":"uint256","name":"amountAfterFee","type":"uint256"},{"internalType":"bool","name":"isAboveMinLimit","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newVal","type":"address"}],"name":"changeBascule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"}],"name":"changeDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newVal","type":"address"}],"name":"changeMailbox","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newValue","type":"address"}],"name":"changeNativeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"newVal","type":"address"}],"name":"changeOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"changeRedeemFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"changeRedeemFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"minAmount","type":"uint256"}],"name":"changeRedeemForBtcMinAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"minAmount","type":"uint256"}],"name":"changeRedeemForBtcMinAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint64","name":"newValue","type":"uint64"}],"name":"changeToNativeCommission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"redeemFee","type":"uint256"},{"internalType":"uint256","name":"redeemForBtcMinAmount","type":"uint256"},{"internalType":"bool","name":"redeemEnabled","type":"bool"}],"name":"changeTokenConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"redeemFee","type":"uint256"},{"internalType":"uint256","name":"redeemForBtcMinAmount","type":"uint256"},{"internalType":"address","name":"oracle_","type":"address"},{"internalType":"uint256","name":"maximumMintCommission_","type":"uint256"},{"internalType":"uint64","name":"toNativeCommission_","type":"uint64"}],"name":"changeTokenConfigExt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelay","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelayIncreaseWait","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"tolChainId","type":"bytes32"},{"internalType":"bytes32","name":"toToken","type":"bytes32"},{"internalType":"bytes32","name":"recipient","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"fromToken","type":"bytes32"},{"internalType":"bytes32","name":"fromChainId","type":"bytes32"},{"internalType":"bytes32","name":"toChainId","type":"bytes32"},{"internalType":"bytes32","name":"toToken","type":"bytes32"}],"name":"getRouteType","outputs":[{"internalType":"enum IAssetRouter.RouteType","name":"","type":"uint8"}],"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":[{"components":[{"internalType":"bytes32","name":"id","type":"bytes32"},{"internalType":"bytes32","name":"msgPath","type":"bytes32"},{"internalType":"uint256","name":"msgNonce","type":"uint256"},{"internalType":"bytes32","name":"msgSender","type":"bytes32"},{"internalType":"address","name":"msgRecipient","type":"address"},{"internalType":"address","name":"msgDestinationCaller","type":"address"},{"internalType":"bytes","name":"msgBody","type":"bytes"}],"internalType":"struct GMPUtils.Payload","name":"payload","type":"tuple"}],"name":"handlePayload","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"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":"owner_","type":"address"},{"internalType":"uint48","name":"initialOwnerDelay_","type":"uint48"},{"internalType":"bytes32","name":"ledgerChainId_","type":"bytes32"},{"internalType":"bytes32","name":"bitcoinChainId_","type":"bytes32"},{"internalType":"address","name":"mailbox_","type":"address"},{"internalType":"address","name":"bascule_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mailbox","outputs":[{"internalType":"contract IMailbox","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"maxMintCommission","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"rawPayload","type":"bytes"},{"internalType":"bytes","name":"proof","type":"bytes"}],"name":"mint","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"mintPayload","type":"bytes"},{"internalType":"bytes","name":"proof","type":"bytes"},{"internalType":"bytes","name":"feePayload","type":"bytes"},{"internalType":"bytes","name":"userSignature","type":"bytes"}],"name":"mintWithFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nativeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"oracle","outputs":[{"internalType":"contract IOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdmin","outputs":[{"internalType":"address","name":"newAdmin","type":"address"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdminDelay","outputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"ratio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"bytes32","name":"tolChainId","type":"bytes32"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"bytes32","name":"toToken","type":"bytes32"},{"internalType":"bytes32","name":"recipient","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"bytes","name":"recipient","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"redeemForBtc","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"fromToken","type":"bytes32"},{"internalType":"bytes32","name":"fromChainId","type":"bytes32"},{"internalType":"bytes32","name":"toToken","type":"bytes32"},{"internalType":"bytes32","name":"toChainId","type":"bytes32"}],"name":"removeRoute","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":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rollbackDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"setMaxMintCommission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"fromToken","type":"bytes32"},{"internalType":"bytes32","name":"fromChainId","type":"bytes32"},{"internalType":"bytes32","name":"toToken","type":"bytes32"},{"internalType":"bytes32","name":"toChainId","type":"bytes32"},{"internalType":"enum IAssetRouter.RouteType","name":"routeType","type":"uint8"}],"name":"setRoute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"toNativeCommission","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"toggleRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"tokenConfig","outputs":[{"internalType":"uint256","name":"redeemFee","type":"uint256"},{"internalType":"uint256","name":"redeemForBtcMinAmount","type":"uint256"},{"internalType":"bool","name":"isRedeemEnabled","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506200001c62000022565b620000d6565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000735760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d35780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6151fa80620000e66000396000f3fe608060405234801561001057600080fd5b50600436106103995760003560e01c8063774237fc116101e9578063cf6eefb71161010f578063e1758bd8116100ad578063fb17cab71161007c578063fb17cab71461080c578063fc5f18d314610814578063fe136c4e1461083b578063fe38ae871461086b57600080fd5b8063e1758bd8146107b7578063e9fae4ee146107bf578063eb37d349146107d2578063f5b541a6146107e557600080fd5b8063d5438eae116100e9578063d5438eae14610781578063d547741f14610789578063d602b9fd1461079c578063e0fbc8bc146107a457600080fd5b8063cf6eefb714610720578063d073787a1461074e578063d4ecb4811461076157600080fd5b80639b91447011610187578063ab384d1811610156578063ab384d18146106d5578063aba905f0146106e8578063cc8463c814610710578063cefc14291461071857600080fd5b80639b91447014610680578063a129d18614610693578063a1eda53c146106a6578063a217fddf146106cd57600080fd5b806384ef8ffc116101c357806384ef8ffc1461064a5780638da5cb5b1461065257806391d148541461065a578063943592001461066d57600080fd5b8063774237fc1461060f5780637f56945e146106245780638340f5491461063757600080fd5b806337a9bdc9116102ce5780634dc809ce1161026c578063649a5ec71161023b578063649a5ec7146105c357806368cc6100146105d65780636bc63893146105e9578063757a6103146105fc57600080fd5b80634dc809ce1461055f5780635698732f1461057257806359aae4ba1461059d578063634e93da146105b057600080fd5b806342d05b9b116102a857806342d05b9b1461051157806343f340f614610519578063464b7f5e1461052c5780634b1c9b281461053f57600080fd5b806337a9bdc9146104d857806337cef791146104eb57806340b3fc79146104fe57600080fd5b80630e6dfcd51161033b57806318551f061161031557806318551f061461048c578063248a9ca31461049f5780632f2ff15d146104b257806336568abe146104c557600080fd5b80630e6dfcd5146104535780631478ac0714610466578063156796db1461047957600080fd5b806305112d001161037757806305112d001461040257806306689495146104175780630aa6220b1461042a5780630b40495b1461043257600080fd5b806301ffc9a71461039e578063022d63fb146103c657806302d9f221146103e2575b600080fd5b6103b16103ac36600461433f565b61087e565b60405190151581526020015b60405180910390f35b620697805b60405165ffffffffffff90911681526020016103bd565b6103ea6108a9565b6040516001600160a01b0390911681526020016103bd565b610415610410366004614381565b6108c5565b005b6104156104253660046143f5565b6108df565b610415610966565b6104456104403660046144b8565b61097c565b6040519081526020016103bd565b6104156104613660046144d5565b610aaf565b610415610474366004614524565b610b44565b6104456104873660046144b8565b610b74565b61041561049a366004614584565b610ba3565b6104456104ad3660046145f2565b610ccb565b6104156104c036600461460b565b610ced565b6104156104d336600461460b565b610d19565b6104156104e636600461463b565b610ddd565b6104456104f93660046144b8565b610f9c565b61041561050c3660046146a7565b6110a4565b6104156111b4565b6104156105273660046144b8565b6111d5565b61041561053a3660046146f8565b6111e9565b61055261054d366004614815565b61129f565b6040516103bd919061491b565b61041561056d36600461492e565b611446565b6105856105803660046144b8565b61145b565b6040516001600160401b0390911681526020016103bd565b6104156105ab3660046149a0565b61149a565b6104156105be3660046144b8565b611660565b6104156105d1366004614a4f565b611674565b6104156105e43660046144b8565b611688565b6103ea6105f7366004614a6a565b61169c565b61041561060a366004614381565b6116fb565b61044560008051602061512583398151915281565b6104156106323660046144b8565b611710565b6104156106453660046144d5565b611724565b6103ea61179e565b6103ea6117ba565b6103b161066836600461460b565b6117c9565b61041561067b3660046145f2565b611801565b61041561068e366004614ad5565b611823565b6104156106a13660046146f8565b61198d565b6106ae6119a3565b6040805165ffffffffffff9384168152929091166020830152016103bd565b610445600081565b6104156106e3366004614b4b565b611a16565b6106fb6106f6366004614bae565b611a5c565b604080519283529015156020830152016103bd565b6103cb611b7d565b610415611bfb565b610728611c3b565b604080516001600160a01b03909316835265ffffffffffff9091166020830152016103bd565b61041561075c366004614381565b611c69565b61077461076f3660046146f8565b611c9d565b6040516103bd9190614c41565b6103ea611cb4565b61041561079736600461460b565b611cd0565b610415611cf8565b6104156107b2366004614c4f565b611d0b565b6103ea611d20565b6104156107cd366004614c84565b611d3c565b6103ea6107e03660046144b8565b611daf565b6104457f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b610445611de2565b6104457f11a8cb5a02bd6c42679835e867ef2118ba78f088f8300511420c6603c21d9c7881565b61084e6108493660046144b8565b611df7565b6040805193845260208401929092521515908201526060016103bd565b6104156108793660046145f2565b611e12565b6000630963936560e31b6001600160e01b0319831614806108a357506108a382611e34565b92915050565b60006108b3611e59565b600501546001600160a01b0316919050565b60006108d081611e7d565b6108da8383611e87565b505050565b6108e7611ef2565b7f11a8cb5a02bd6c42679835e867ef2118ba78f088f8300511420c6603c21d9c7861091181611e7d565b60006109238a8a8a8a8a8a8a8a611f2a565b9050806109435760405163778df52760e01b815260040160405180910390fd5b505061095c600160008051602061518583398151915255565b5050505050505050565b600061097181611e7d565b610979612238565b50565b600080610987611e59565b9050826001600160a01b03166373cfc6b26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109eb9190614ce0565b8015610a1457506001600160a01b03838116600090815260078301602052604090206003015416155b15610a295750670de0b6b3a764000092915050565b6001600160a01b0380841660009081526007830160209081526040918290206003015482516371ca337d60e01b815292519316926371ca337d9260048082019392918290030181865afa158015610a84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa89190614cfd565b9392505050565b610ab7611ef2565b6000610ac1611e59565b9050610b2c8185466001600160f81b0316600685015487906001600160a01b03166001600160a01b038a16604051602001610afe91815260200190565b60408051601f198184030181529190528860007389e3e4e7a699d6f131d893aeef7ee143706ac23a81612245565b506108da600160008051602061518583398151915255565b6000610b4f81611e7d565b610b598585611e87565b610b638584612548565b610b6d85836125b9565b5050505050565b6000610b7e611e59565b6001600160a01b03909216600090815260079290920160205250604090206002015490565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b0316600081158015610be85750825b90506000826001600160401b03166001148015610c045750303b155b905081158015610c12575080155b15610c305760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610c5a57845460ff60401b1916600160401b1785555b610c648a8c6126a3565b610c6c6126b5565b610c78898989896126c5565b8315610cbe57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b6000908152600080516020615165833981519152602052604090206001015490565b81610d0b57604051631fe1e13d60e11b815260040160405180910390fd5b610d1582826126f8565b5050565b60008051602061514583398151915282158015610d4e5750610d3961179e565b6001600160a01b0316826001600160a01b0316145b15610dd357600080610d5e611c3b565b90925090506001600160a01b038216151580610d80575065ffffffffffff8116155b80610d9357504265ffffffffffff821610155b15610dc0576040516319ca5ebb60e01b815265ffffffffffff821660048201526024015b60405180910390fd5b5050805465ffffffffffff60a01b191681555b6108da8383612714565b610de5611ef2565b6000610def611e59565b6001600160a01b03861660009081526007820160205260408120805492935090918411610e2f57604051638e2d830960e01b815260040160405180910390fd5b60008060009050886001600160a01b03166373cfc6b26040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e989190614ce0565b15610ef657610ed48888856000015489610eb29190614d2c565b8660030160149054906101000a90046001600160401b03168760010154612747565b9350738bf729ffe074caee622c02928173467e658e19e2915060019050610f25565b610f0b8888856000015489610eb29190614d2c565b93507389e3e4e7a699d6f131d893aeef7ee143706ac23a91505b610f80858b87600101548c600160001b8d8d8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508d9250610f7991508290508f614d2c565b8a8a612245565b5050505050610b6d600160008051602061518583398151915255565b600080610fa7611e59565b9050826001600160a01b03166373cfc6b26040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fe7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100b9190614ce0565b801561103457506001600160a01b03838116600090815260078301602052604090206003015416155b156110495750670de0b6b3a764000092915050565b6001600160a01b0380841660009081526007830160209081526040918290206003015482516333cd77e760e11b8152925193169263679aefce9260048082019392918290030181865afa158015610a84573d6000803e3d6000fd5b60006110af81611e7d565b60006110b9611e59565b9050600087876040516020016110d9929190918252602082015260400190565b60408051601f1981840301815291815281516020928301206000818152600280870185528382208a835285528382208b83529485905292902080549194508792909160ff191690600190849081111561113457611134614c09565b0217905550466001600160f81b0316880361115357611153838a6127b7565b466001600160f81b0316860361116d5761116d83886127b7565b86888a7f65d345579617d61433f1ecd9a50794a2c910037a17b3e91bce3ac6e2b6b061a489896040516111a1929190614d3f565b60405180910390a4505050505050505050565b6000805160206151258339815191526111cc81611e7d565b610979336128b1565b60006111e081611e7d565b610d15826129fd565b60006111f481611e7d565b60006111fe611e59565b90506000868660405160200161121e929190918252602082015260400190565b60408051808303601f190181528282528051602091820120600081815260028701835283812089825283528381208a8252808452939020805460ff1916905587845293509091879189918b917fc5386d2e751ac4e54d3265f9f137c5468532e2c31aad50019b3e4ea19927c0de910160405180910390a45050505050505050565b606060006112ab611e59565b60048101549091506001600160a01b0316336001600160a01b0316146112e45760405163372b4bf360e11b815260040160405180910390fd5b60608301517389e3e4e7a699d6f131d893aeef7ee143706ac23a1461131c576040516303cefbf360e01b815260040160405180910390fd5b8251600090815260038201602052604090205460ff1615611350576040516309eae50960e41b815260040160405180910390fd5b825160009081526003820160205260408120805460ff1916600117905560c084015161137b90612aaf565b5090506113918285600001518360400151612c9a565b8051602082015160408084015190516340c10f1960e01b81526001600160a01b03909316926340c10f19926113ca929091600401614d53565b600060405180830381600087803b1580156113e457600080fd5b505af11580156113f8573d6000803e3d6000fd5b50505050602081810151825160408085015181516001600160a01b03948516958101959095529290911690830152606082015260800160405160208183030381529060405292505050919050565b600061145181611e7d565b6108da8383612d0b565b6000611465611e59565b6001600160a01b039290921660009081526007909201602052506040902060030154600160a01b90046001600160401b031690565b6114a2611ef2565b7f11a8cb5a02bd6c42679835e867ef2118ba78f088f8300511420c6603c21d9c786114cc81611e7d565b6114d68887612d9a565b6114e08885612d9a565b6114ea8883612d9a565b60005b8881101561094357600061158f8b8b8481811061150c5761150c614d6c565b905060200281019061151e9190614d82565b8b8b8681811061153057611530614d6c565b90506020028101906115429190614d82565b8b8b8881811061155457611554614d6c565b90506020028101906115669190614d82565b8b8b8a81811061157857611578614d6c565b905060200281019061158a9190614d82565b611f2a565b90508061165757600060028c8c858181106115ac576115ac614d6c565b90506020028101906115be9190614d82565b6040516115cc929190614dc8565b602060405180830381855afa1580156115e9573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061160c9190614cfd565b6040805160008152602081019182905291925082917fa3bb38c016dd194a0062f340c984fe709ae20573fac5363ec9d67f140864a99c9161164d9190614dd8565b60405180910390a2505b506001016114ed565b600061166b81611e7d565b610d1582612dc4565b600061167f81611e7d565b610d1582612e37565b600061169381611e7d565b610d1582612ea7565b60006116a6611ef2565b6000806116b587878787612f3b565b505091509150816116d95760405163778df52760e01b815260040160405180910390fd5b9150506116f3600160008051602061518583398151915255565b949350505050565b600061170681611e7d565b6108da8383612548565b600061171b81611e7d565b610d1582613026565b61172c611ef2565b336001600160a01b03841681148015906117585750826001600160a01b0316816001600160a01b031614155b156117765760405163553925af60e11b815260040160405180910390fd5b610b2c84466001600160f81b03166001600160a01b0386166001600160a01b03881686613093565b6000805160206151a5833981519152546001600160a01b031690565b60006117c461179e565b905090565b6000918252600080516020615165833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60008051602061512583398151915261181981611e7d565b610d153383611e87565b61182b611ef2565b6118358382612d9a565b60005b8381101561196f57600061189286868481811061185757611857614d6c565b90506020028101906118699190614d82565b86868681811061187b5761187b614d6c565b905060200281019061188d9190614d82565b612f3b565b50505090508061196657600060028787858181106118b2576118b2614d6c565b90506020028101906118c49190614d82565b6040516118d2929190614dc8565b602060405180830381855afa1580156118ef573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906119129190614cfd565b9050807fa3bb38c016dd194a0062f340c984fe709ae20573fac5363ec9d67f140864a99c60405161195c906040808252600090820181905260606020830181905282015260800190565b60405180910390a2505b50600101611838565b50611987600160008051602061518583398151915255565b50505050565b611995611ef2565b3361196f8186868686613093565b6000805160206151a583398151915254600090600160d01b900465ffffffffffff1660008051602061514583398151915281158015906119eb57504265ffffffffffff831610155b6119f757600080611a0d565b6001810154600160a01b900465ffffffffffff16825b92509250509091565b6000611a2181611e7d565b611a2b8787611e87565b611a358786612548565b611a3f8785612d0b565b611a498783613201565b611a53878461328e565b50505050505050565b6000806000611a69611e59565b6001600160a01b038816600090815260078201602052604090208054919250908511611aa857604051638e2d830960e01b815260040160405180910390fd5b876001600160a01b03166373cfc6b26040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ae6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0a9190614ce0565b15611b5557611b468787836000015488611b249190614d2c565b8460030160149054906101000a90046001600160401b031685600101546132f0565b919550909350611b7492505050565b611b6a8787836000015488611b249190614d2c565b9195509093505050505b94509492505050565b6000805160206151a58339815191525460009060008051602061514583398151915290600160d01b900465ffffffffffff168015801590611bc557504265ffffffffffff8216105b611bdf578154600160d01b900465ffffffffffff16611bf4565b6001820154600160a01b900465ffffffffffff165b9250505090565b6000611c05611c3b565b509050336001600160a01b03821614611c3357604051636116401160e11b8152336004820152602401610db7565b610979613383565b600080516020615145833981519152546001600160a01b03811691600160a01b90910465ffffffffffff1690565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929611c9381611e7d565b6108da838361328e565b6000611cab85858585613420565b95945050505050565b6000611cbe611e59565b600401546001600160a01b0316919050565b81611cee57604051631fe1e13d60e11b815260040160405180910390fd5b610d158282613492565b6000611d0381611e7d565b6109796134ae565b6000611d1681611e7d565b6108da8383613201565b6000611d2a611e59565b600601546001600160a01b0316919050565b611d44611ef2565b6000611d4e611e59565b905080600101548603611d7457604051630d712d2160e21b815260040160405180910390fd5b611d8f818888888888604051602001610afe91815260200190565b50611da7600160008051602061518583398151915255565b505050505050565b6000611db9611e59565b6001600160a01b0392831660009081526007919091016020526040902060030154909116919050565b600080611ded611e59565b6001015492915050565b6000806000611e05846134b9565b9196909550909350915050565b600080516020615125833981519152611e2a81611e7d565b610d153383612548565b60006001600160e01b031982166318a4c3c360e11b14806108a357506108a382613576565b7f634af38ba2564e2d74d7d4e289db84afe1b0f1c101e1349f6428c2bd44a09b0090565b61097981336135ab565b6000611e91611e59565b6001600160a01b0384166000818152600783016020908152604091829020805483519081529182018790529394507fc9ed75bd1b7e1ec0b10331ec0f4df28b7c6c1c9b34a7215508bca77a638612b1910160405180910390a2919091555050565b600080516020615185833981519152805460011901611f2457604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6000806000806000611f3e8d8d8d8d612f3b565b935093509350935083611f58576000945050505050612218565b81611f6b8a8a63205d72a560e21b6135d6565b6000611fb7611f7d8b6004818f614df9565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061363292505050565b90506000611fc3611e59565b90506000836001600160a01b0316633b19e84a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612005573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120299190614e23565b6001600160a01b0387166000908152600784016020526040812060020154855192935090916120589190613701565b8451602086015160405163af25311d60e01b81529293506000926001600160a01b0389169263af25311d9261209892600401918252602082015260400190565b602060405180830381865afa1580156120b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d99190614cfd565b90506120e7818a8f8f613717565b508086101561210957604051638e2d830960e01b815260040160405180910390fd5b80156121d057604051632770a7eb60e21b81526001600160a01b03861690639dc29fac9061213d908b908590600401614d53565b600060405180830381600087803b15801561215757600080fd5b505af115801561216b573d6000803e3d6000fd5b50506040516340c10f1960e01b81526001600160a01b03881692506340c10f19915061219d9085908590600401614d53565b600060405180830381600087803b1580156121b757600080fd5b505af11580156121cb573d6000803e3d6000fd5b505050505b807ff08753429caf643a11ec73a1d53fbaf28d062bfb8bdb0d7c6a564ebd20fdcb598d8d604051612202929190614e69565b60405180910390a2600199505050505050505050505b98975050505050505050565b600160008051602061518583398151915255565b612243600080613775565b565b336001600160a01b038a16148015906122675750336001600160a01b03881614155b156122855760405163553925af60e11b815260040160405180910390fd5b61228e87613850565b6122ab57604051630f2ea0b160e31b815260040160405180910390fd5b6001600160a01b03871660026122cc826001600160f81b0346168c8b613420565b60028111156122dd576122dd614c09565b146122fb57604051631581c4c960e21b815260040160405180910390fd5b87600085900361234f576001600160a01b038916600090815260078d01602052604090205480871161234057604051638e2d830960e01b815260040160405180910390fd5b61234a8188614d2c565b965094505b606083156123725761236b6001600160a01b038d16898961386a565b905061238b565b6123888b846001600160a01b038f168b8b61396c565b90505b6004808e01548e54604051630a9fb35560e41b81526001600160a01b039092169263a9fb3550926123c492918a91600091889101614e7d565b60408051808303816000875af11580156123e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124069190614eac565b505085156124d057816001600160a01b03166340c10f19836001600160a01b0316633b19e84a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561245b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247f9190614e23565b886040518363ffffffff1660e01b815260040161249d929190614d53565b600060405180830381600087803b1580156124b757600080fd5b505af11580156124cb573d6000803e3d6000fd5b505050505b6001600160a01b038216639dc29fac8d6124ea898b614ed0565b6040518363ffffffff1660e01b8152600401612507929190614d53565b600060405180830381600087803b15801561252157600080fd5b505af1158015612535573d6000803e3d6000fd5b5050505050505050505050505050505050565b6000612552611e59565b6001600160a01b0384166000818152600783016020908152604091829020600181015483519081529182018790529394507f5018e1e9226f7af379146e7eb39b88b3a058e3b0edff07fb275e74289dda34fd910160405180910390a2600101919091555050565b60006125c3611e59565b9050600083466001600160f81b03166040516020016125e3929190614d53565b60408051601f1981840301815291815281516020928301206000818152600286018452828120600187015482529093529120909150831561263e5760016000908152602082905260409020805460ff19166002179055612657565b60016000908152602082905260409020805460ff191690555b846001600160a01b03167f4d2950449b08e3396339fac49e659de29da01927f1fee34d98590e5c28a135f585604051612694911515815260200190565b60405180910390a25050505050565b6126ab613a74565b610d158282613abd565b6126bd613a74565b612243613b26565b6126cd613a74565b60006126d7611e59565b90506126e283612ea7565b6126eb82613026565b9384555050600190910155565b61270182610ccb565b61270a81611e7d565b6119878383613b2e565b6001600160a01b038116331461273d5760405163334bd91960e11b815260040160405180910390fd5b6108da8282613b9d565b60008060008061275a89898989896132f0565b9250925092508161278957604051630a01b54160e11b81526001600160401b0387166004820152602401610db7565b806127aa5760405163082938a160e01b815260048101869052602401610db7565b5090979650505050505050565b60006127c282613bf6565b90506127dc60008051602061512583398151915282610ced565b806001600160a01b03166373cfc6b26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561281a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061283e9190614ce0565b156108da5760068301546001600160a01b03161580159061286f575060068301546001600160a01b03828116911614155b1561288d5760405163097a76d360e31b815260040160405180910390fd5b6006830180546001600160a01b0383166001600160a01b0319909116179055505050565b60006128bb611e59565b9050600082466001600160f81b03166040516020016128db929190614d53565b60408051601f1981840301815291815281516020928301206000818152600286018452828120600187015482529093529082209092509080600160009081526020849052604090205460ff16600281111561293857612938614c09565b0361295e575060016000818152602083905260409020805460ff191660021790556129c0565b6002600160009081526020849052604090205460ff16600281111561298557612985614c09565b036129a75760016000908152602083905260409020805460ff191690556129c0565b604051631e6857ef60e21b815260040160405180910390fd5b846001600160a01b03167f4d2950449b08e3396339fac49e659de29da01927f1fee34d98590e5c28a135f582604051612694911515815260200190565b6000612a07611e59565b6006810180546001600160a01b038581166001600160a01b031983161790925591925016600081612a3e6001600160f81b03461690565b604051602001612a4f929190614d53565b60408051601f1981840301815290829052805160209182012060008181526002870190925292506001600160a01b0380871692908516917f7f20e25483f9f8d43d6f064900d3ce09760b2d4ab4826c1459e89c60ac5831ec91a350505050565b60408051606081018252600080825260208201819052918101919091526000612ada60206003614ee3565b612ae5906004614ed0565b835114612b2757612af860206003614ee3565b612b03906004614ed0565b83516040516361bf537160e11b815260048101929092526024820152604401610db7565b60208301516024840151604485015160648601516001600160e01b0319841663155b6b1360e01b14612b8557604051634632bef360e01b815263155b6b1360e01b60048201526001600160e01b031985166024820152604401610db7565b80600003612ba65760405163bb0cabf160e01b815260040160405180910390fd5b6000612bb183613bf6565b90506001600160a01b038116612bda576040516351a5d83960e01b815260040160405180910390fd5b6000612be585613bf6565b90506001600160a01b038116612c0e57604051630ca4d1c360e01b815260040160405180910390fd5b6040518060600160405280826001600160a01b03168152602001836001600160a01b031681526020018481525060028a604051612c4b9190614efa565b602060405180830381855afa158015612c68573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250810190612c8b9190614cfd565b97509750505050505050915091565b60058301546001600160a01b0316801561198757604051632f0d338d60e11b815260048101849052602481018390526001600160a01b03821690635e1a671a90604401600060405180830381600087803b158015612cf757600080fd5b505af115801561095c573d6000803e3d6000fd5b6000612d15611e59565b6001600160a01b038481166000908152600783016020526040808220600301549051939450828616939216917f98b13b834cc7362f7965a7c806ce6de3ba8b38c9f35a407d0650bf7bac466b889190a36001600160a01b0392831660009081526007919091016020526040902060030180546001600160a01b03191691909216179055565b808214610d1557604051633f9b6c7760e21b81526004810183905260248101829052604401610db7565b6000612dce611b7d565b612dd742613c1f565b612de19190614f16565b9050612ded8282613c52565b60405165ffffffffffff821681526001600160a01b038316907f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed69060200160405180910390a25050565b6000612e4282613cdf565b612e4b42613c1f565b612e559190614f16565b9050612e618282613775565b6040805165ffffffffffff8085168252831660208201527ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b910160405180910390a15050565b6001600160a01b038116612ece57604051637eb5110560e11b815260040160405180910390fd5b6000612ed8611e59565b60048101546040519192506001600160a01b03808516929116907f038f2bf7924b7a1bbf759b99ac2b99fcc29a3981e21add650354abfad89a3bf390600090a360040180546001600160a01b0319166001600160a01b0392909216919091179055565b6000806000806000612f4b611e59565b600480820154604051635310428360e11b815292935060009283926001600160a01b039092169163a620850691612f8a918f918f918f918f9101614f35565b6000604051808303816000875af1158015612fa9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612fd19190810190614f67565b925092505081612ff157600080600080965096509650965050505061301b565b60008060008380602001905181019061300a9190614ffc565b969b50909950975093955050505050505b945094509450949050565b6000613030611e59565b60058101546040519192506001600160a01b03808516929116907fe7cfa96a5822cda6c84186494722763ab3f06adc731fabdd74d1c79d5db6a07390600090a360050180546001600160a01b0319166001600160a01b0392909216919091179055565b600061309d611e59565b9050600160068201546130c4906001600160a01b0316466001600160f81b03168888613420565b60028111156130d5576130d5614c09565b146130f35760405163b3f6ccfd60e01b815260040160405180910390fd5b600061310b86866001600160a01b038a168787613d27565b6004808401548454604051630a9fb35560e41b81529394506001600160a01b039091169263a9fb35509261315b92917389e3e4e7a699d6f131d893aeef7ee143706ac23a91600091889101614e7d565b60408051808303816000875af1158015613179573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061319d9190614eac565b50506006820154604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac906131d3908a908790600401614d53565b600060405180830381600087803b1580156131ed57600080fd5b505af1158015610cbe573d6000803e3d6000fd5b600061320b611e59565b6001600160a01b03841660009081526007820160205260408082206003810180546001600160401b03888116600160a01b81810267ffffffffffffffff60a01b1985161790945594519697509295919004919091169283917f4691de403b48fea6cdc2f7d816eb63f62b96b56b2fb25fdf55375943908a86df9190a35050505050565b6000613298611e59565b6001600160a01b0384166000908152600782016020526040808220600201805490869055905192935091849183917f43aafec62cbe5feda09499e1888afa1c53cc311278ca0cb40fe7d0275df16f9b9190a350505050565b6000806000806133008989613dc1565b9050600081600381111561331657613316614c09565b0361333457604051632695fabb60e01b815260040160405180910390fd5b856001600160401b0316871161335557600080600093509350935050613378565b600061336a6001600160401b03881689614d2c565b945060019350505050828210155b955095509592505050565b60008051602061514583398151915260008061339d611c3b565b915091506133b28165ffffffffffff16151590565b15806133c657504265ffffffffffff821610155b156133ee576040516319ca5ebb60e01b815265ffffffffffff82166004820152602401610db7565b61340060006133fb61179e565b613b9d565b5061340c600083613b2e565b505081546001600160d01b03191690915550565b60008061342b611e59565b90506000868660405160200161344b929190918252602082015260400190565b60408051601f19818403018152918152815160209283012060009081526002909401825280842087855282528084208685529091529091205460ff16915050949350505050565b61349b82610ccb565b6134a481611e7d565b6119878383613b9d565b612243600080613c52565b6000806000806134c7611e59565b6001600160a01b0386166000908152600782016020526040812091925086466001600160f81b0316604051602001613500929190614d53565b60408051601f1981840301815291815281516020928301206000818152600280880185528382206001808a0154845295529290208554938601549194509291600160009081526020859052604090205460ff16600281111561356457613564614c09565b14965096509650505050509193909250565b60006001600160e01b03198216637965db0b60e01b14806108a357506301ffc9a760e01b6001600160e01b03198316146108a3565b6135b582826117c9565b610d1557808260405163e2517d3f60e01b8152600401610db7929190614d53565b6001600160e01b031981166135eb838561503f565b6001600160e01b031916146108da5780613605838561503f565b604051632e35ad2d60e11b81526001600160e01b0319928316600482015291166024820152604401610db7565b604080518082019091526000808252602082015261365260206002614ee3565b8251146136895761366560206002614ee3565b82516040516371cccdf360e11b815260048101929092526024820152604401610db7565b600080838060200190518101906136a09190614eac565b91509150804211156136c85760405163954aba7160e01b815260048101829052602401610db7565b816000036136e95760405163af13986d60e01b815260040160405180910390fd5b60408051808201909152918252602082015292915050565b60008183106137105781610aa8565b5090919050565b613758838584848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613f2f92505050565b611987576040516379543d1d60e01b815260040160405180910390fd5b6000805160206151a58339815191525460008051602061514583398151915290600160d01b900465ffffffffffff168015613812574265ffffffffffff821610156137e857600182015482546001600160d01b0316600160a01b90910465ffffffffffff16600160d01b02178255613812565b6040517f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec590600090a15b5060010180546001600160a01b0316600160a01b65ffffffffffff948516026001600160d01b031617600160d01b9290931691909102919091179055565b60006108a3600080516020615125833981519152836117c9565b60608160000361388d5760405163bb0cabf160e01b815260040160405180910390fd5b82516000036138af576040516351a5d83960e01b815260040160405180910390fd5b6000805b84518110156138f3578481815181106138ce576138ce614d6c565b01602001516001600160f81b031916156138eb57600191506138f3565b6001016138b3565b5080613912576040516351a5d83960e01b815260040160405180910390fd5b604051634e3e504760e01b906139309087908790879060240161506f565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091529150509392505050565b60608160000361398f5760405163bb0cabf160e01b815260040160405180910390fd5b82516000036139b1576040516351a5d83960e01b815260040160405180910390fd5b6000805b84518110156139f5578481815181106139d0576139d0614d6c565b01602001516001600160f81b031916156139ed57600191506139f5565b6001016139b5565b5080613a14576040516351a5d83960e01b815260040160405180910390fd5b60405163aa3db85f60e01b90613a369089908990899089908990602401615098565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915291505095945050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661224357604051631afcd79f60e31b815260040160405180910390fd5b613ac5613a74565b6000805160206151458339815191526001600160a01b038216613afe57604051636116401160e11b815260006004820152602401610db7565b80546001600160d01b0316600160d01b65ffffffffffff851602178155611987600083613b2e565b612224613a74565b600060008051602061514583398151915283613b93576000613b4e61179e565b6001600160a01b031614613b7557604051631fe1e13d60e11b815260040160405180910390fd5b6001810180546001600160a01b0319166001600160a01b0385161790555b6116f38484614002565b600060008051602061514583398151915283158015613bd45750613bbf61179e565b6001600160a01b0316836001600160a01b0316145b15613bec576001810180546001600160a01b03191690555b6116f384846140ae565b600060a082901c15613c1b57604051630f75c10d60e01b815260040160405180910390fd5b5090565b600065ffffffffffff821115613c1b576040516306dfcc6560e41b81526030600482015260248101839052604401610db7565b6000805160206151458339815191526000613c6b611c3b565b835465ffffffffffff8616600160a01b026001600160d01b03199091166001600160a01b038816171784559150613cab90508165ffffffffffff16151590565b15611987576040517f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a960510990600090a150505050565b600080613cea611b7d565b90508065ffffffffffff168365ffffffffffff1611613d1257613d0d83826150cf565b610aa8565b610aa865ffffffffffff841662069780613701565b606081600003613d4a5760405163bb0cabf160e01b815260040160405180910390fd5b82613d68576040516351a5d83960e01b815260040160405180910390fd5b5060408051602481019690965260448601949094526064850192909252608484015260a4808401919091528151808403909101815260c490920190526020810180516001600160e01b031663ccb4121560e01b17905290565b6000601682148015613df65750600083838281613de057613de0614d6c565b9050013560f81c60f81b6001600160f81b031916145b8015613e2b5750600560fa1b83836001818110613e1557613e15614d6c565b9050013560f81c60f81b6001600160f81b031916145b15613e38575060026108a3565b602282148015613e6f5750605160f81b8383600081613e5957613e59614d6c565b9050013560f81c60f81b6001600160f81b031916145b8015613ea45750600160fd1b83836001818110613e8e57613e8e614d6c565b9050013560f81c60f81b6001600160f81b031916145b15613eb1575060016108a3565b602282148015613ee45750600083838281613ece57613ece614d6c565b9050013560f81c60f81b6001600160f81b031916145b8015613f195750600160fd1b83836001818110613f0357613f03614d6c565b9050013560f81c60f81b6001600160f81b031916145b15613f26575060036108a3565b50600092915050565b60006001600160a01b0384163b15613fce57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e90613f7190879087906004016150ee565b602060405180830381865afa158015613f8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fb29190615107565b6001600160e01b03191614613fc957506000610aa8565b613ff8565b836001600160a01b0316613fe2848461412a565b6001600160a01b031614613ff857506000610aa8565b5060019392505050565b600060008051602061516583398151915261401d84846117c9565b61409d576000848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556140533390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506108a3565b60009150506108a3565b5092915050565b60006000805160206151658339815191526140c984846117c9565b1561409d576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506108a3565b60008060008061413a8686614154565b92509250925061414a82826141a1565b5090949350505050565b6000806000835160410361418e5760208401516040850151606086015160001a6141808882858561425a565b95509550955050505061419a565b50508151600091506002905b9250925092565b60008260038111156141b5576141b5614c09565b036141be575050565b60018260038111156141d2576141d2614c09565b036141f05760405163f645eedf60e01b815260040160405180910390fd5b600282600381111561420457614204614c09565b036142255760405163fce698f760e01b815260048101829052602401610db7565b600382600381111561423957614239614c09565b03610d15576040516335e2f38360e21b815260048101829052602401610db7565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115614295575060009150600390508261431f565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa1580156142e9573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166143155750600092506001915082905061431f565b9250600091508190505b9450945094915050565b6001600160e01b03198116811461097957600080fd5b60006020828403121561435157600080fd5b8135610aa881614329565b6001600160a01b038116811461097957600080fd5b803561437c8161435c565b919050565b6000806040838503121561439457600080fd5b823561439f8161435c565b946020939093013593505050565b60008083601f8401126143bf57600080fd5b5081356001600160401b038111156143d657600080fd5b6020830191508360208285010111156143ee57600080fd5b9250929050565b6000806000806000806000806080898b03121561441157600080fd5b88356001600160401b038082111561442857600080fd5b6144348c838d016143ad565b909a50985060208b013591508082111561444d57600080fd5b6144598c838d016143ad565b909850965060408b013591508082111561447257600080fd5b61447e8c838d016143ad565b909650945060608b013591508082111561449757600080fd5b506144a48b828c016143ad565b999c989b5096995094979396929594505050565b6000602082840312156144ca57600080fd5b8135610aa88161435c565b6000806000606084860312156144ea57600080fd5b83356144f58161435c565b925060208401356145058161435c565b929592945050506040919091013590565b801515811461097957600080fd5b6000806000806080858703121561453a57600080fd5b84356145458161435c565b93506020850135925060408501359150606085013561456381614516565b939692955090935050565b803565ffffffffffff8116811461437c57600080fd5b60008060008060008060c0878903121561459d57600080fd5b86356145a88161435c565b95506145b66020880161456e565b9450604087013593506060870135925060808701356145d48161435c565b915060a08701356145e48161435c565b809150509295509295509295565b60006020828403121561460457600080fd5b5035919050565b6000806040838503121561461e57600080fd5b8235915060208301356146308161435c565b809150509250929050565b60008060008060006080868803121561465357600080fd5b853561465e8161435c565b9450602086013561466e8161435c565b935060408601356001600160401b0381111561468957600080fd5b614695888289016143ad565b96999598509660600135949350505050565b600080600080600060a086880312156146bf57600080fd5b853594506020860135935060408601359250606086013591506080860135600381106146ea57600080fd5b809150509295509295909350565b6000806000806080858703121561470e57600080fd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b600052604160045260246000fd5b60405160e081016001600160401b03811182821017156147625761476261472a565b60405290565b604051601f8201601f191681016001600160401b03811182821017156147905761479061472a565b604052919050565b60006001600160401b038211156147b1576147b161472a565b50601f01601f191660200190565b600082601f8301126147d057600080fd5b81356147e36147de82614798565b614768565b8181528460208386010111156147f857600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561482757600080fd5b81356001600160401b038082111561483e57600080fd5b9083019060e0828603121561485257600080fd5b61485a614740565b8235815260208301356020820152604083013560408201526060830135606082015261488860808401614371565b608082015261489960a08401614371565b60a082015260c0830135828111156148b057600080fd5b6148bc878286016147bf565b60c08301525095945050505050565b60005b838110156148e65781810151838201526020016148ce565b50506000910152565b600081518084526149078160208601602086016148cb565b601f01601f19169290920160200192915050565b602081526000610aa860208301846148ef565b6000806040838503121561494157600080fd5b823561494c8161435c565b915060208301356146308161435c565b60008083601f84011261496e57600080fd5b5081356001600160401b0381111561498557600080fd5b6020830191508360208260051b85010111156143ee57600080fd5b6000806000806000806000806080898b0312156149bc57600080fd5b88356001600160401b03808211156149d357600080fd5b6149df8c838d0161495c565b909a50985060208b01359150808211156149f857600080fd5b614a048c838d0161495c565b909850965060408b0135915080821115614a1d57600080fd5b614a298c838d0161495c565b909650945060608b0135915080821115614a4257600080fd5b506144a48b828c0161495c565b600060208284031215614a6157600080fd5b610aa88261456e565b60008060008060408587031215614a8057600080fd5b84356001600160401b0380821115614a9757600080fd5b614aa3888389016143ad565b90965094506020870135915080821115614abc57600080fd5b50614ac9878288016143ad565b95989497509550505050565b60008060008060408587031215614aeb57600080fd5b84356001600160401b0380821115614b0257600080fd5b614b0e8883890161495c565b90965094506020870135915080821115614b2757600080fd5b50614ac98782880161495c565b80356001600160401b038116811461437c57600080fd5b60008060008060008060c08789031215614b6457600080fd5b8635614b6f8161435c565b955060208701359450604087013593506060870135614b8d8161435c565b925060808701359150614ba260a08801614b34565b90509295509295509295565b60008060008060608587031215614bc457600080fd5b8435614bcf8161435c565b935060208501356001600160401b03811115614bea57600080fd5b614bf6878288016143ad565b9598909750949560400135949350505050565b634e487b7160e01b600052602160045260246000fd5b60038110614c3d57634e487b7160e01b600052602160045260246000fd5b9052565b602081016108a38284614c1f565b60008060408385031215614c6257600080fd5b8235614c6d8161435c565b9150614c7b60208401614b34565b90509250929050565b60008060008060008060c08789031215614c9d57600080fd5b8635614ca88161435c565b9550602087013594506040870135614cbf8161435c565b959894975094956060810135955060808101359460a0909101359350915050565b600060208284031215614cf257600080fd5b8151610aa881614516565b600060208284031215614d0f57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156108a3576108a3614d16565b82815260408101610aa86020830184614c1f565b6001600160a01b03929092168252602082015260400190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112614d9957600080fd5b8301803591506001600160401b03821115614db357600080fd5b6020019150368190038213156143ee57600080fd5b8183823760009101908152919050565b6040815260006040820152606060208201526000610aa860608301846148ef565b60008085851115614e0957600080fd5b83861115614e1657600080fd5b5050820193919092039150565b600060208284031215614e3557600080fd5b8151610aa88161435c565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6020815260006116f3602083018486614e40565b848152836020820152826040820152608060608201526000614ea260808301846148ef565b9695505050505050565b60008060408385031215614ebf57600080fd5b505080516020909101519092909150565b808201808211156108a3576108a3614d16565b80820281158282048414176108a3576108a3614d16565b60008251614f0c8184602087016148cb565b9190910192915050565b65ffffffffffff8181168382160190808211156140a7576140a7614d16565b604081526000614f49604083018688614e40565b8281036020840152614f5c818587614e40565b979650505050505050565b600080600060608486031215614f7c57600080fd5b835192506020840151614f8e81614516565b60408501519092506001600160401b03811115614faa57600080fd5b8401601f81018613614fbb57600080fd5b8051614fc96147de82614798565b818152876020838501011115614fde57600080fd5b614fef8260208301602086016148cb565b8093505050509250925092565b60008060006060848603121561501157600080fd5b835161501c8161435c565b602085015190935061502d8161435c565b80925050604084015190509250925092565b6001600160e01b031981358181169160048510156150675780818660040360031b1b83161692505b505092915050565b83815260606020820152600061508860608301856148ef565b9050826040830152949350505050565b85815284602082015283604082015260a0606082015260006150bd60a08301856148ef565b90508260808301529695505050505050565b65ffffffffffff8281168282160390808211156140a7576140a7614d16565b8281526040602082015260006116f360408301846148ef565b60006020828403121561511957600080fd5b8151610aa88161432956fe843c3a00fa95510a35f425371231fd3fe4642e719cb4595160763d6d02594b50eef3dac4538c82c8ace4063ab0acd2d15cdb5883aa1dff7c2673abb3d869840002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00eef3dac4538c82c8ace4063ab0acd2d15cdb5883aa1dff7c2673abb3d8698401a26469706673582212201d39a210f5c2cd7870bc80dde0e5df035fd706fea2318e4fb12a75163320b57c64736f6c63430008180033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106103995760003560e01c8063774237fc116101e9578063cf6eefb71161010f578063e1758bd8116100ad578063fb17cab71161007c578063fb17cab71461080c578063fc5f18d314610814578063fe136c4e1461083b578063fe38ae871461086b57600080fd5b8063e1758bd8146107b7578063e9fae4ee146107bf578063eb37d349146107d2578063f5b541a6146107e557600080fd5b8063d5438eae116100e9578063d5438eae14610781578063d547741f14610789578063d602b9fd1461079c578063e0fbc8bc146107a457600080fd5b8063cf6eefb714610720578063d073787a1461074e578063d4ecb4811461076157600080fd5b80639b91447011610187578063ab384d1811610156578063ab384d18146106d5578063aba905f0146106e8578063cc8463c814610710578063cefc14291461071857600080fd5b80639b91447014610680578063a129d18614610693578063a1eda53c146106a6578063a217fddf146106cd57600080fd5b806384ef8ffc116101c357806384ef8ffc1461064a5780638da5cb5b1461065257806391d148541461065a578063943592001461066d57600080fd5b8063774237fc1461060f5780637f56945e146106245780638340f5491461063757600080fd5b806337a9bdc9116102ce5780634dc809ce1161026c578063649a5ec71161023b578063649a5ec7146105c357806368cc6100146105d65780636bc63893146105e9578063757a6103146105fc57600080fd5b80634dc809ce1461055f5780635698732f1461057257806359aae4ba1461059d578063634e93da146105b057600080fd5b806342d05b9b116102a857806342d05b9b1461051157806343f340f614610519578063464b7f5e1461052c5780634b1c9b281461053f57600080fd5b806337a9bdc9146104d857806337cef791146104eb57806340b3fc79146104fe57600080fd5b80630e6dfcd51161033b57806318551f061161031557806318551f061461048c578063248a9ca31461049f5780632f2ff15d146104b257806336568abe146104c557600080fd5b80630e6dfcd5146104535780631478ac0714610466578063156796db1461047957600080fd5b806305112d001161037757806305112d001461040257806306689495146104175780630aa6220b1461042a5780630b40495b1461043257600080fd5b806301ffc9a71461039e578063022d63fb146103c657806302d9f221146103e2575b600080fd5b6103b16103ac36600461433f565b61087e565b60405190151581526020015b60405180910390f35b620697805b60405165ffffffffffff90911681526020016103bd565b6103ea6108a9565b6040516001600160a01b0390911681526020016103bd565b610415610410366004614381565b6108c5565b005b6104156104253660046143f5565b6108df565b610415610966565b6104456104403660046144b8565b61097c565b6040519081526020016103bd565b6104156104613660046144d5565b610aaf565b610415610474366004614524565b610b44565b6104456104873660046144b8565b610b74565b61041561049a366004614584565b610ba3565b6104456104ad3660046145f2565b610ccb565b6104156104c036600461460b565b610ced565b6104156104d336600461460b565b610d19565b6104156104e636600461463b565b610ddd565b6104456104f93660046144b8565b610f9c565b61041561050c3660046146a7565b6110a4565b6104156111b4565b6104156105273660046144b8565b6111d5565b61041561053a3660046146f8565b6111e9565b61055261054d366004614815565b61129f565b6040516103bd919061491b565b61041561056d36600461492e565b611446565b6105856105803660046144b8565b61145b565b6040516001600160401b0390911681526020016103bd565b6104156105ab3660046149a0565b61149a565b6104156105be3660046144b8565b611660565b6104156105d1366004614a4f565b611674565b6104156105e43660046144b8565b611688565b6103ea6105f7366004614a6a565b61169c565b61041561060a366004614381565b6116fb565b61044560008051602061512583398151915281565b6104156106323660046144b8565b611710565b6104156106453660046144d5565b611724565b6103ea61179e565b6103ea6117ba565b6103b161066836600461460b565b6117c9565b61041561067b3660046145f2565b611801565b61041561068e366004614ad5565b611823565b6104156106a13660046146f8565b61198d565b6106ae6119a3565b6040805165ffffffffffff9384168152929091166020830152016103bd565b610445600081565b6104156106e3366004614b4b565b611a16565b6106fb6106f6366004614bae565b611a5c565b604080519283529015156020830152016103bd565b6103cb611b7d565b610415611bfb565b610728611c3b565b604080516001600160a01b03909316835265ffffffffffff9091166020830152016103bd565b61041561075c366004614381565b611c69565b61077461076f3660046146f8565b611c9d565b6040516103bd9190614c41565b6103ea611cb4565b61041561079736600461460b565b611cd0565b610415611cf8565b6104156107b2366004614c4f565b611d0b565b6103ea611d20565b6104156107cd366004614c84565b611d3c565b6103ea6107e03660046144b8565b611daf565b6104457f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b610445611de2565b6104457f11a8cb5a02bd6c42679835e867ef2118ba78f088f8300511420c6603c21d9c7881565b61084e6108493660046144b8565b611df7565b6040805193845260208401929092521515908201526060016103bd565b6104156108793660046145f2565b611e12565b6000630963936560e31b6001600160e01b0319831614806108a357506108a382611e34565b92915050565b60006108b3611e59565b600501546001600160a01b0316919050565b60006108d081611e7d565b6108da8383611e87565b505050565b6108e7611ef2565b7f11a8cb5a02bd6c42679835e867ef2118ba78f088f8300511420c6603c21d9c7861091181611e7d565b60006109238a8a8a8a8a8a8a8a611f2a565b9050806109435760405163778df52760e01b815260040160405180910390fd5b505061095c600160008051602061518583398151915255565b5050505050505050565b600061097181611e7d565b610979612238565b50565b600080610987611e59565b9050826001600160a01b03166373cfc6b26040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109eb9190614ce0565b8015610a1457506001600160a01b03838116600090815260078301602052604090206003015416155b15610a295750670de0b6b3a764000092915050565b6001600160a01b0380841660009081526007830160209081526040918290206003015482516371ca337d60e01b815292519316926371ca337d9260048082019392918290030181865afa158015610a84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa89190614cfd565b9392505050565b610ab7611ef2565b6000610ac1611e59565b9050610b2c8185466001600160f81b0316600685015487906001600160a01b03166001600160a01b038a16604051602001610afe91815260200190565b60408051601f198184030181529190528860007389e3e4e7a699d6f131d893aeef7ee143706ac23a81612245565b506108da600160008051602061518583398151915255565b6000610b4f81611e7d565b610b598585611e87565b610b638584612548565b610b6d85836125b9565b5050505050565b6000610b7e611e59565b6001600160a01b03909216600090815260079290920160205250604090206002015490565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b0316600081158015610be85750825b90506000826001600160401b03166001148015610c045750303b155b905081158015610c12575080155b15610c305760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610c5a57845460ff60401b1916600160401b1785555b610c648a8c6126a3565b610c6c6126b5565b610c78898989896126c5565b8315610cbe57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b6000908152600080516020615165833981519152602052604090206001015490565b81610d0b57604051631fe1e13d60e11b815260040160405180910390fd5b610d1582826126f8565b5050565b60008051602061514583398151915282158015610d4e5750610d3961179e565b6001600160a01b0316826001600160a01b0316145b15610dd357600080610d5e611c3b565b90925090506001600160a01b038216151580610d80575065ffffffffffff8116155b80610d9357504265ffffffffffff821610155b15610dc0576040516319ca5ebb60e01b815265ffffffffffff821660048201526024015b60405180910390fd5b5050805465ffffffffffff60a01b191681555b6108da8383612714565b610de5611ef2565b6000610def611e59565b6001600160a01b03861660009081526007820160205260408120805492935090918411610e2f57604051638e2d830960e01b815260040160405180910390fd5b60008060009050886001600160a01b03166373cfc6b26040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e989190614ce0565b15610ef657610ed48888856000015489610eb29190614d2c565b8660030160149054906101000a90046001600160401b03168760010154612747565b9350738bf729ffe074caee622c02928173467e658e19e2915060019050610f25565b610f0b8888856000015489610eb29190614d2c565b93507389e3e4e7a699d6f131d893aeef7ee143706ac23a91505b610f80858b87600101548c600160001b8d8d8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508d9250610f7991508290508f614d2c565b8a8a612245565b5050505050610b6d600160008051602061518583398151915255565b600080610fa7611e59565b9050826001600160a01b03166373cfc6b26040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fe7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061100b9190614ce0565b801561103457506001600160a01b03838116600090815260078301602052604090206003015416155b156110495750670de0b6b3a764000092915050565b6001600160a01b0380841660009081526007830160209081526040918290206003015482516333cd77e760e11b8152925193169263679aefce9260048082019392918290030181865afa158015610a84573d6000803e3d6000fd5b60006110af81611e7d565b60006110b9611e59565b9050600087876040516020016110d9929190918252602082015260400190565b60408051601f1981840301815291815281516020928301206000818152600280870185528382208a835285528382208b83529485905292902080549194508792909160ff191690600190849081111561113457611134614c09565b0217905550466001600160f81b0316880361115357611153838a6127b7565b466001600160f81b0316860361116d5761116d83886127b7565b86888a7f65d345579617d61433f1ecd9a50794a2c910037a17b3e91bce3ac6e2b6b061a489896040516111a1929190614d3f565b60405180910390a4505050505050505050565b6000805160206151258339815191526111cc81611e7d565b610979336128b1565b60006111e081611e7d565b610d15826129fd565b60006111f481611e7d565b60006111fe611e59565b90506000868660405160200161121e929190918252602082015260400190565b60408051808303601f190181528282528051602091820120600081815260028701835283812089825283528381208a8252808452939020805460ff1916905587845293509091879189918b917fc5386d2e751ac4e54d3265f9f137c5468532e2c31aad50019b3e4ea19927c0de910160405180910390a45050505050505050565b606060006112ab611e59565b60048101549091506001600160a01b0316336001600160a01b0316146112e45760405163372b4bf360e11b815260040160405180910390fd5b60608301517389e3e4e7a699d6f131d893aeef7ee143706ac23a1461131c576040516303cefbf360e01b815260040160405180910390fd5b8251600090815260038201602052604090205460ff1615611350576040516309eae50960e41b815260040160405180910390fd5b825160009081526003820160205260408120805460ff1916600117905560c084015161137b90612aaf565b5090506113918285600001518360400151612c9a565b8051602082015160408084015190516340c10f1960e01b81526001600160a01b03909316926340c10f19926113ca929091600401614d53565b600060405180830381600087803b1580156113e457600080fd5b505af11580156113f8573d6000803e3d6000fd5b50505050602081810151825160408085015181516001600160a01b03948516958101959095529290911690830152606082015260800160405160208183030381529060405292505050919050565b600061145181611e7d565b6108da8383612d0b565b6000611465611e59565b6001600160a01b039290921660009081526007909201602052506040902060030154600160a01b90046001600160401b031690565b6114a2611ef2565b7f11a8cb5a02bd6c42679835e867ef2118ba78f088f8300511420c6603c21d9c786114cc81611e7d565b6114d68887612d9a565b6114e08885612d9a565b6114ea8883612d9a565b60005b8881101561094357600061158f8b8b8481811061150c5761150c614d6c565b905060200281019061151e9190614d82565b8b8b8681811061153057611530614d6c565b90506020028101906115429190614d82565b8b8b8881811061155457611554614d6c565b90506020028101906115669190614d82565b8b8b8a81811061157857611578614d6c565b905060200281019061158a9190614d82565b611f2a565b90508061165757600060028c8c858181106115ac576115ac614d6c565b90506020028101906115be9190614d82565b6040516115cc929190614dc8565b602060405180830381855afa1580156115e9573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061160c9190614cfd565b6040805160008152602081019182905291925082917fa3bb38c016dd194a0062f340c984fe709ae20573fac5363ec9d67f140864a99c9161164d9190614dd8565b60405180910390a2505b506001016114ed565b600061166b81611e7d565b610d1582612dc4565b600061167f81611e7d565b610d1582612e37565b600061169381611e7d565b610d1582612ea7565b60006116a6611ef2565b6000806116b587878787612f3b565b505091509150816116d95760405163778df52760e01b815260040160405180910390fd5b9150506116f3600160008051602061518583398151915255565b949350505050565b600061170681611e7d565b6108da8383612548565b600061171b81611e7d565b610d1582613026565b61172c611ef2565b336001600160a01b03841681148015906117585750826001600160a01b0316816001600160a01b031614155b156117765760405163553925af60e11b815260040160405180910390fd5b610b2c84466001600160f81b03166001600160a01b0386166001600160a01b03881686613093565b6000805160206151a5833981519152546001600160a01b031690565b60006117c461179e565b905090565b6000918252600080516020615165833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60008051602061512583398151915261181981611e7d565b610d153383611e87565b61182b611ef2565b6118358382612d9a565b60005b8381101561196f57600061189286868481811061185757611857614d6c565b90506020028101906118699190614d82565b86868681811061187b5761187b614d6c565b905060200281019061188d9190614d82565b612f3b565b50505090508061196657600060028787858181106118b2576118b2614d6c565b90506020028101906118c49190614d82565b6040516118d2929190614dc8565b602060405180830381855afa1580156118ef573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906119129190614cfd565b9050807fa3bb38c016dd194a0062f340c984fe709ae20573fac5363ec9d67f140864a99c60405161195c906040808252600090820181905260606020830181905282015260800190565b60405180910390a2505b50600101611838565b50611987600160008051602061518583398151915255565b50505050565b611995611ef2565b3361196f8186868686613093565b6000805160206151a583398151915254600090600160d01b900465ffffffffffff1660008051602061514583398151915281158015906119eb57504265ffffffffffff831610155b6119f757600080611a0d565b6001810154600160a01b900465ffffffffffff16825b92509250509091565b6000611a2181611e7d565b611a2b8787611e87565b611a358786612548565b611a3f8785612d0b565b611a498783613201565b611a53878461328e565b50505050505050565b6000806000611a69611e59565b6001600160a01b038816600090815260078201602052604090208054919250908511611aa857604051638e2d830960e01b815260040160405180910390fd5b876001600160a01b03166373cfc6b26040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ae6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0a9190614ce0565b15611b5557611b468787836000015488611b249190614d2c565b8460030160149054906101000a90046001600160401b031685600101546132f0565b919550909350611b7492505050565b611b6a8787836000015488611b249190614d2c565b9195509093505050505b94509492505050565b6000805160206151a58339815191525460009060008051602061514583398151915290600160d01b900465ffffffffffff168015801590611bc557504265ffffffffffff8216105b611bdf578154600160d01b900465ffffffffffff16611bf4565b6001820154600160a01b900465ffffffffffff165b9250505090565b6000611c05611c3b565b509050336001600160a01b03821614611c3357604051636116401160e11b8152336004820152602401610db7565b610979613383565b600080516020615145833981519152546001600160a01b03811691600160a01b90910465ffffffffffff1690565b7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929611c9381611e7d565b6108da838361328e565b6000611cab85858585613420565b95945050505050565b6000611cbe611e59565b600401546001600160a01b0316919050565b81611cee57604051631fe1e13d60e11b815260040160405180910390fd5b610d158282613492565b6000611d0381611e7d565b6109796134ae565b6000611d1681611e7d565b6108da8383613201565b6000611d2a611e59565b600601546001600160a01b0316919050565b611d44611ef2565b6000611d4e611e59565b905080600101548603611d7457604051630d712d2160e21b815260040160405180910390fd5b611d8f818888888888604051602001610afe91815260200190565b50611da7600160008051602061518583398151915255565b505050505050565b6000611db9611e59565b6001600160a01b0392831660009081526007919091016020526040902060030154909116919050565b600080611ded611e59565b6001015492915050565b6000806000611e05846134b9565b9196909550909350915050565b600080516020615125833981519152611e2a81611e7d565b610d153383612548565b60006001600160e01b031982166318a4c3c360e11b14806108a357506108a382613576565b7f634af38ba2564e2d74d7d4e289db84afe1b0f1c101e1349f6428c2bd44a09b0090565b61097981336135ab565b6000611e91611e59565b6001600160a01b0384166000818152600783016020908152604091829020805483519081529182018790529394507fc9ed75bd1b7e1ec0b10331ec0f4df28b7c6c1c9b34a7215508bca77a638612b1910160405180910390a2919091555050565b600080516020615185833981519152805460011901611f2457604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6000806000806000611f3e8d8d8d8d612f3b565b935093509350935083611f58576000945050505050612218565b81611f6b8a8a63205d72a560e21b6135d6565b6000611fb7611f7d8b6004818f614df9565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061363292505050565b90506000611fc3611e59565b90506000836001600160a01b0316633b19e84a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612005573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120299190614e23565b6001600160a01b0387166000908152600784016020526040812060020154855192935090916120589190613701565b8451602086015160405163af25311d60e01b81529293506000926001600160a01b0389169263af25311d9261209892600401918252602082015260400190565b602060405180830381865afa1580156120b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d99190614cfd565b90506120e7818a8f8f613717565b508086101561210957604051638e2d830960e01b815260040160405180910390fd5b80156121d057604051632770a7eb60e21b81526001600160a01b03861690639dc29fac9061213d908b908590600401614d53565b600060405180830381600087803b15801561215757600080fd5b505af115801561216b573d6000803e3d6000fd5b50506040516340c10f1960e01b81526001600160a01b03881692506340c10f19915061219d9085908590600401614d53565b600060405180830381600087803b1580156121b757600080fd5b505af11580156121cb573d6000803e3d6000fd5b505050505b807ff08753429caf643a11ec73a1d53fbaf28d062bfb8bdb0d7c6a564ebd20fdcb598d8d604051612202929190614e69565b60405180910390a2600199505050505050505050505b98975050505050505050565b600160008051602061518583398151915255565b612243600080613775565b565b336001600160a01b038a16148015906122675750336001600160a01b03881614155b156122855760405163553925af60e11b815260040160405180910390fd5b61228e87613850565b6122ab57604051630f2ea0b160e31b815260040160405180910390fd5b6001600160a01b03871660026122cc826001600160f81b0346168c8b613420565b60028111156122dd576122dd614c09565b146122fb57604051631581c4c960e21b815260040160405180910390fd5b87600085900361234f576001600160a01b038916600090815260078d01602052604090205480871161234057604051638e2d830960e01b815260040160405180910390fd5b61234a8188614d2c565b965094505b606083156123725761236b6001600160a01b038d16898961386a565b905061238b565b6123888b846001600160a01b038f168b8b61396c565b90505b6004808e01548e54604051630a9fb35560e41b81526001600160a01b039092169263a9fb3550926123c492918a91600091889101614e7d565b60408051808303816000875af11580156123e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124069190614eac565b505085156124d057816001600160a01b03166340c10f19836001600160a01b0316633b19e84a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561245b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247f9190614e23565b886040518363ffffffff1660e01b815260040161249d929190614d53565b600060405180830381600087803b1580156124b757600080fd5b505af11580156124cb573d6000803e3d6000fd5b505050505b6001600160a01b038216639dc29fac8d6124ea898b614ed0565b6040518363ffffffff1660e01b8152600401612507929190614d53565b600060405180830381600087803b15801561252157600080fd5b505af1158015612535573d6000803e3d6000fd5b5050505050505050505050505050505050565b6000612552611e59565b6001600160a01b0384166000818152600783016020908152604091829020600181015483519081529182018790529394507f5018e1e9226f7af379146e7eb39b88b3a058e3b0edff07fb275e74289dda34fd910160405180910390a2600101919091555050565b60006125c3611e59565b9050600083466001600160f81b03166040516020016125e3929190614d53565b60408051601f1981840301815291815281516020928301206000818152600286018452828120600187015482529093529120909150831561263e5760016000908152602082905260409020805460ff19166002179055612657565b60016000908152602082905260409020805460ff191690555b846001600160a01b03167f4d2950449b08e3396339fac49e659de29da01927f1fee34d98590e5c28a135f585604051612694911515815260200190565b60405180910390a25050505050565b6126ab613a74565b610d158282613abd565b6126bd613a74565b612243613b26565b6126cd613a74565b60006126d7611e59565b90506126e283612ea7565b6126eb82613026565b9384555050600190910155565b61270182610ccb565b61270a81611e7d565b6119878383613b2e565b6001600160a01b038116331461273d5760405163334bd91960e11b815260040160405180910390fd5b6108da8282613b9d565b60008060008061275a89898989896132f0565b9250925092508161278957604051630a01b54160e11b81526001600160401b0387166004820152602401610db7565b806127aa5760405163082938a160e01b815260048101869052602401610db7565b5090979650505050505050565b60006127c282613bf6565b90506127dc60008051602061512583398151915282610ced565b806001600160a01b03166373cfc6b26040518163ffffffff1660e01b8152600401602060405180830381865afa15801561281a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061283e9190614ce0565b156108da5760068301546001600160a01b03161580159061286f575060068301546001600160a01b03828116911614155b1561288d5760405163097a76d360e31b815260040160405180910390fd5b6006830180546001600160a01b0383166001600160a01b0319909116179055505050565b60006128bb611e59565b9050600082466001600160f81b03166040516020016128db929190614d53565b60408051601f1981840301815291815281516020928301206000818152600286018452828120600187015482529093529082209092509080600160009081526020849052604090205460ff16600281111561293857612938614c09565b0361295e575060016000818152602083905260409020805460ff191660021790556129c0565b6002600160009081526020849052604090205460ff16600281111561298557612985614c09565b036129a75760016000908152602083905260409020805460ff191690556129c0565b604051631e6857ef60e21b815260040160405180910390fd5b846001600160a01b03167f4d2950449b08e3396339fac49e659de29da01927f1fee34d98590e5c28a135f582604051612694911515815260200190565b6000612a07611e59565b6006810180546001600160a01b038581166001600160a01b031983161790925591925016600081612a3e6001600160f81b03461690565b604051602001612a4f929190614d53565b60408051601f1981840301815290829052805160209182012060008181526002870190925292506001600160a01b0380871692908516917f7f20e25483f9f8d43d6f064900d3ce09760b2d4ab4826c1459e89c60ac5831ec91a350505050565b60408051606081018252600080825260208201819052918101919091526000612ada60206003614ee3565b612ae5906004614ed0565b835114612b2757612af860206003614ee3565b612b03906004614ed0565b83516040516361bf537160e11b815260048101929092526024820152604401610db7565b60208301516024840151604485015160648601516001600160e01b0319841663155b6b1360e01b14612b8557604051634632bef360e01b815263155b6b1360e01b60048201526001600160e01b031985166024820152604401610db7565b80600003612ba65760405163bb0cabf160e01b815260040160405180910390fd5b6000612bb183613bf6565b90506001600160a01b038116612bda576040516351a5d83960e01b815260040160405180910390fd5b6000612be585613bf6565b90506001600160a01b038116612c0e57604051630ca4d1c360e01b815260040160405180910390fd5b6040518060600160405280826001600160a01b03168152602001836001600160a01b031681526020018481525060028a604051612c4b9190614efa565b602060405180830381855afa158015612c68573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250810190612c8b9190614cfd565b97509750505050505050915091565b60058301546001600160a01b0316801561198757604051632f0d338d60e11b815260048101849052602481018390526001600160a01b03821690635e1a671a90604401600060405180830381600087803b158015612cf757600080fd5b505af115801561095c573d6000803e3d6000fd5b6000612d15611e59565b6001600160a01b038481166000908152600783016020526040808220600301549051939450828616939216917f98b13b834cc7362f7965a7c806ce6de3ba8b38c9f35a407d0650bf7bac466b889190a36001600160a01b0392831660009081526007919091016020526040902060030180546001600160a01b03191691909216179055565b808214610d1557604051633f9b6c7760e21b81526004810183905260248101829052604401610db7565b6000612dce611b7d565b612dd742613c1f565b612de19190614f16565b9050612ded8282613c52565b60405165ffffffffffff821681526001600160a01b038316907f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed69060200160405180910390a25050565b6000612e4282613cdf565b612e4b42613c1f565b612e559190614f16565b9050612e618282613775565b6040805165ffffffffffff8085168252831660208201527ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b910160405180910390a15050565b6001600160a01b038116612ece57604051637eb5110560e11b815260040160405180910390fd5b6000612ed8611e59565b60048101546040519192506001600160a01b03808516929116907f038f2bf7924b7a1bbf759b99ac2b99fcc29a3981e21add650354abfad89a3bf390600090a360040180546001600160a01b0319166001600160a01b0392909216919091179055565b6000806000806000612f4b611e59565b600480820154604051635310428360e11b815292935060009283926001600160a01b039092169163a620850691612f8a918f918f918f918f9101614f35565b6000604051808303816000875af1158015612fa9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612fd19190810190614f67565b925092505081612ff157600080600080965096509650965050505061301b565b60008060008380602001905181019061300a9190614ffc565b969b50909950975093955050505050505b945094509450949050565b6000613030611e59565b60058101546040519192506001600160a01b03808516929116907fe7cfa96a5822cda6c84186494722763ab3f06adc731fabdd74d1c79d5db6a07390600090a360050180546001600160a01b0319166001600160a01b0392909216919091179055565b600061309d611e59565b9050600160068201546130c4906001600160a01b0316466001600160f81b03168888613420565b60028111156130d5576130d5614c09565b146130f35760405163b3f6ccfd60e01b815260040160405180910390fd5b600061310b86866001600160a01b038a168787613d27565b6004808401548454604051630a9fb35560e41b81529394506001600160a01b039091169263a9fb35509261315b92917389e3e4e7a699d6f131d893aeef7ee143706ac23a91600091889101614e7d565b60408051808303816000875af1158015613179573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061319d9190614eac565b50506006820154604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac906131d3908a908790600401614d53565b600060405180830381600087803b1580156131ed57600080fd5b505af1158015610cbe573d6000803e3d6000fd5b600061320b611e59565b6001600160a01b03841660009081526007820160205260408082206003810180546001600160401b03888116600160a01b81810267ffffffffffffffff60a01b1985161790945594519697509295919004919091169283917f4691de403b48fea6cdc2f7d816eb63f62b96b56b2fb25fdf55375943908a86df9190a35050505050565b6000613298611e59565b6001600160a01b0384166000908152600782016020526040808220600201805490869055905192935091849183917f43aafec62cbe5feda09499e1888afa1c53cc311278ca0cb40fe7d0275df16f9b9190a350505050565b6000806000806133008989613dc1565b9050600081600381111561331657613316614c09565b0361333457604051632695fabb60e01b815260040160405180910390fd5b856001600160401b0316871161335557600080600093509350935050613378565b600061336a6001600160401b03881689614d2c565b945060019350505050828210155b955095509592505050565b60008051602061514583398151915260008061339d611c3b565b915091506133b28165ffffffffffff16151590565b15806133c657504265ffffffffffff821610155b156133ee576040516319ca5ebb60e01b815265ffffffffffff82166004820152602401610db7565b61340060006133fb61179e565b613b9d565b5061340c600083613b2e565b505081546001600160d01b03191690915550565b60008061342b611e59565b90506000868660405160200161344b929190918252602082015260400190565b60408051601f19818403018152918152815160209283012060009081526002909401825280842087855282528084208685529091529091205460ff16915050949350505050565b61349b82610ccb565b6134a481611e7d565b6119878383613b9d565b612243600080613c52565b6000806000806134c7611e59565b6001600160a01b0386166000908152600782016020526040812091925086466001600160f81b0316604051602001613500929190614d53565b60408051601f1981840301815291815281516020928301206000818152600280880185528382206001808a0154845295529290208554938601549194509291600160009081526020859052604090205460ff16600281111561356457613564614c09565b14965096509650505050509193909250565b60006001600160e01b03198216637965db0b60e01b14806108a357506301ffc9a760e01b6001600160e01b03198316146108a3565b6135b582826117c9565b610d1557808260405163e2517d3f60e01b8152600401610db7929190614d53565b6001600160e01b031981166135eb838561503f565b6001600160e01b031916146108da5780613605838561503f565b604051632e35ad2d60e11b81526001600160e01b0319928316600482015291166024820152604401610db7565b604080518082019091526000808252602082015261365260206002614ee3565b8251146136895761366560206002614ee3565b82516040516371cccdf360e11b815260048101929092526024820152604401610db7565b600080838060200190518101906136a09190614eac565b91509150804211156136c85760405163954aba7160e01b815260048101829052602401610db7565b816000036136e95760405163af13986d60e01b815260040160405180910390fd5b60408051808201909152918252602082015292915050565b60008183106137105781610aa8565b5090919050565b613758838584848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613f2f92505050565b611987576040516379543d1d60e01b815260040160405180910390fd5b6000805160206151a58339815191525460008051602061514583398151915290600160d01b900465ffffffffffff168015613812574265ffffffffffff821610156137e857600182015482546001600160d01b0316600160a01b90910465ffffffffffff16600160d01b02178255613812565b6040517f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec590600090a15b5060010180546001600160a01b0316600160a01b65ffffffffffff948516026001600160d01b031617600160d01b9290931691909102919091179055565b60006108a3600080516020615125833981519152836117c9565b60608160000361388d5760405163bb0cabf160e01b815260040160405180910390fd5b82516000036138af576040516351a5d83960e01b815260040160405180910390fd5b6000805b84518110156138f3578481815181106138ce576138ce614d6c565b01602001516001600160f81b031916156138eb57600191506138f3565b6001016138b3565b5080613912576040516351a5d83960e01b815260040160405180910390fd5b604051634e3e504760e01b906139309087908790879060240161506f565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091529150509392505050565b60608160000361398f5760405163bb0cabf160e01b815260040160405180910390fd5b82516000036139b1576040516351a5d83960e01b815260040160405180910390fd5b6000805b84518110156139f5578481815181106139d0576139d0614d6c565b01602001516001600160f81b031916156139ed57600191506139f5565b6001016139b5565b5080613a14576040516351a5d83960e01b815260040160405180910390fd5b60405163aa3db85f60e01b90613a369089908990899089908990602401615098565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915291505095945050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661224357604051631afcd79f60e31b815260040160405180910390fd5b613ac5613a74565b6000805160206151458339815191526001600160a01b038216613afe57604051636116401160e11b815260006004820152602401610db7565b80546001600160d01b0316600160d01b65ffffffffffff851602178155611987600083613b2e565b612224613a74565b600060008051602061514583398151915283613b93576000613b4e61179e565b6001600160a01b031614613b7557604051631fe1e13d60e11b815260040160405180910390fd5b6001810180546001600160a01b0319166001600160a01b0385161790555b6116f38484614002565b600060008051602061514583398151915283158015613bd45750613bbf61179e565b6001600160a01b0316836001600160a01b0316145b15613bec576001810180546001600160a01b03191690555b6116f384846140ae565b600060a082901c15613c1b57604051630f75c10d60e01b815260040160405180910390fd5b5090565b600065ffffffffffff821115613c1b576040516306dfcc6560e41b81526030600482015260248101839052604401610db7565b6000805160206151458339815191526000613c6b611c3b565b835465ffffffffffff8616600160a01b026001600160d01b03199091166001600160a01b038816171784559150613cab90508165ffffffffffff16151590565b15611987576040517f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a960510990600090a150505050565b600080613cea611b7d565b90508065ffffffffffff168365ffffffffffff1611613d1257613d0d83826150cf565b610aa8565b610aa865ffffffffffff841662069780613701565b606081600003613d4a5760405163bb0cabf160e01b815260040160405180910390fd5b82613d68576040516351a5d83960e01b815260040160405180910390fd5b5060408051602481019690965260448601949094526064850192909252608484015260a4808401919091528151808403909101815260c490920190526020810180516001600160e01b031663ccb4121560e01b17905290565b6000601682148015613df65750600083838281613de057613de0614d6c565b9050013560f81c60f81b6001600160f81b031916145b8015613e2b5750600560fa1b83836001818110613e1557613e15614d6c565b9050013560f81c60f81b6001600160f81b031916145b15613e38575060026108a3565b602282148015613e6f5750605160f81b8383600081613e5957613e59614d6c565b9050013560f81c60f81b6001600160f81b031916145b8015613ea45750600160fd1b83836001818110613e8e57613e8e614d6c565b9050013560f81c60f81b6001600160f81b031916145b15613eb1575060016108a3565b602282148015613ee45750600083838281613ece57613ece614d6c565b9050013560f81c60f81b6001600160f81b031916145b8015613f195750600160fd1b83836001818110613f0357613f03614d6c565b9050013560f81c60f81b6001600160f81b031916145b15613f26575060036108a3565b50600092915050565b60006001600160a01b0384163b15613fce57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e90613f7190879087906004016150ee565b602060405180830381865afa158015613f8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fb29190615107565b6001600160e01b03191614613fc957506000610aa8565b613ff8565b836001600160a01b0316613fe2848461412a565b6001600160a01b031614613ff857506000610aa8565b5060019392505050565b600060008051602061516583398151915261401d84846117c9565b61409d576000848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556140533390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506108a3565b60009150506108a3565b5092915050565b60006000805160206151658339815191526140c984846117c9565b1561409d576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506108a3565b60008060008061413a8686614154565b92509250925061414a82826141a1565b5090949350505050565b6000806000835160410361418e5760208401516040850151606086015160001a6141808882858561425a565b95509550955050505061419a565b50508151600091506002905b9250925092565b60008260038111156141b5576141b5614c09565b036141be575050565b60018260038111156141d2576141d2614c09565b036141f05760405163f645eedf60e01b815260040160405180910390fd5b600282600381111561420457614204614c09565b036142255760405163fce698f760e01b815260048101829052602401610db7565b600382600381111561423957614239614c09565b03610d15576040516335e2f38360e21b815260048101829052602401610db7565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115614295575060009150600390508261431f565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa1580156142e9573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166143155750600092506001915082905061431f565b9250600091508190505b9450945094915050565b6001600160e01b03198116811461097957600080fd5b60006020828403121561435157600080fd5b8135610aa881614329565b6001600160a01b038116811461097957600080fd5b803561437c8161435c565b919050565b6000806040838503121561439457600080fd5b823561439f8161435c565b946020939093013593505050565b60008083601f8401126143bf57600080fd5b5081356001600160401b038111156143d657600080fd5b6020830191508360208285010111156143ee57600080fd5b9250929050565b6000806000806000806000806080898b03121561441157600080fd5b88356001600160401b038082111561442857600080fd5b6144348c838d016143ad565b909a50985060208b013591508082111561444d57600080fd5b6144598c838d016143ad565b909850965060408b013591508082111561447257600080fd5b61447e8c838d016143ad565b909650945060608b013591508082111561449757600080fd5b506144a48b828c016143ad565b999c989b5096995094979396929594505050565b6000602082840312156144ca57600080fd5b8135610aa88161435c565b6000806000606084860312156144ea57600080fd5b83356144f58161435c565b925060208401356145058161435c565b929592945050506040919091013590565b801515811461097957600080fd5b6000806000806080858703121561453a57600080fd5b84356145458161435c565b93506020850135925060408501359150606085013561456381614516565b939692955090935050565b803565ffffffffffff8116811461437c57600080fd5b60008060008060008060c0878903121561459d57600080fd5b86356145a88161435c565b95506145b66020880161456e565b9450604087013593506060870135925060808701356145d48161435c565b915060a08701356145e48161435c565b809150509295509295509295565b60006020828403121561460457600080fd5b5035919050565b6000806040838503121561461e57600080fd5b8235915060208301356146308161435c565b809150509250929050565b60008060008060006080868803121561465357600080fd5b853561465e8161435c565b9450602086013561466e8161435c565b935060408601356001600160401b0381111561468957600080fd5b614695888289016143ad565b96999598509660600135949350505050565b600080600080600060a086880312156146bf57600080fd5b853594506020860135935060408601359250606086013591506080860135600381106146ea57600080fd5b809150509295509295909350565b6000806000806080858703121561470e57600080fd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b600052604160045260246000fd5b60405160e081016001600160401b03811182821017156147625761476261472a565b60405290565b604051601f8201601f191681016001600160401b03811182821017156147905761479061472a565b604052919050565b60006001600160401b038211156147b1576147b161472a565b50601f01601f191660200190565b600082601f8301126147d057600080fd5b81356147e36147de82614798565b614768565b8181528460208386010111156147f857600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561482757600080fd5b81356001600160401b038082111561483e57600080fd5b9083019060e0828603121561485257600080fd5b61485a614740565b8235815260208301356020820152604083013560408201526060830135606082015261488860808401614371565b608082015261489960a08401614371565b60a082015260c0830135828111156148b057600080fd5b6148bc878286016147bf565b60c08301525095945050505050565b60005b838110156148e65781810151838201526020016148ce565b50506000910152565b600081518084526149078160208601602086016148cb565b601f01601f19169290920160200192915050565b602081526000610aa860208301846148ef565b6000806040838503121561494157600080fd5b823561494c8161435c565b915060208301356146308161435c565b60008083601f84011261496e57600080fd5b5081356001600160401b0381111561498557600080fd5b6020830191508360208260051b85010111156143ee57600080fd5b6000806000806000806000806080898b0312156149bc57600080fd5b88356001600160401b03808211156149d357600080fd5b6149df8c838d0161495c565b909a50985060208b01359150808211156149f857600080fd5b614a048c838d0161495c565b909850965060408b0135915080821115614a1d57600080fd5b614a298c838d0161495c565b909650945060608b0135915080821115614a4257600080fd5b506144a48b828c0161495c565b600060208284031215614a6157600080fd5b610aa88261456e565b60008060008060408587031215614a8057600080fd5b84356001600160401b0380821115614a9757600080fd5b614aa3888389016143ad565b90965094506020870135915080821115614abc57600080fd5b50614ac9878288016143ad565b95989497509550505050565b60008060008060408587031215614aeb57600080fd5b84356001600160401b0380821115614b0257600080fd5b614b0e8883890161495c565b90965094506020870135915080821115614b2757600080fd5b50614ac98782880161495c565b80356001600160401b038116811461437c57600080fd5b60008060008060008060c08789031215614b6457600080fd5b8635614b6f8161435c565b955060208701359450604087013593506060870135614b8d8161435c565b925060808701359150614ba260a08801614b34565b90509295509295509295565b60008060008060608587031215614bc457600080fd5b8435614bcf8161435c565b935060208501356001600160401b03811115614bea57600080fd5b614bf6878288016143ad565b9598909750949560400135949350505050565b634e487b7160e01b600052602160045260246000fd5b60038110614c3d57634e487b7160e01b600052602160045260246000fd5b9052565b602081016108a38284614c1f565b60008060408385031215614c6257600080fd5b8235614c6d8161435c565b9150614c7b60208401614b34565b90509250929050565b60008060008060008060c08789031215614c9d57600080fd5b8635614ca88161435c565b9550602087013594506040870135614cbf8161435c565b959894975094956060810135955060808101359460a0909101359350915050565b600060208284031215614cf257600080fd5b8151610aa881614516565b600060208284031215614d0f57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156108a3576108a3614d16565b82815260408101610aa86020830184614c1f565b6001600160a01b03929092168252602082015260400190565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112614d9957600080fd5b8301803591506001600160401b03821115614db357600080fd5b6020019150368190038213156143ee57600080fd5b8183823760009101908152919050565b6040815260006040820152606060208201526000610aa860608301846148ef565b60008085851115614e0957600080fd5b83861115614e1657600080fd5b5050820193919092039150565b600060208284031215614e3557600080fd5b8151610aa88161435c565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6020815260006116f3602083018486614e40565b848152836020820152826040820152608060608201526000614ea260808301846148ef565b9695505050505050565b60008060408385031215614ebf57600080fd5b505080516020909101519092909150565b808201808211156108a3576108a3614d16565b80820281158282048414176108a3576108a3614d16565b60008251614f0c8184602087016148cb565b9190910192915050565b65ffffffffffff8181168382160190808211156140a7576140a7614d16565b604081526000614f49604083018688614e40565b8281036020840152614f5c818587614e40565b979650505050505050565b600080600060608486031215614f7c57600080fd5b835192506020840151614f8e81614516565b60408501519092506001600160401b03811115614faa57600080fd5b8401601f81018613614fbb57600080fd5b8051614fc96147de82614798565b818152876020838501011115614fde57600080fd5b614fef8260208301602086016148cb565b8093505050509250925092565b60008060006060848603121561501157600080fd5b835161501c8161435c565b602085015190935061502d8161435c565b80925050604084015190509250925092565b6001600160e01b031981358181169160048510156150675780818660040360031b1b83161692505b505092915050565b83815260606020820152600061508860608301856148ef565b9050826040830152949350505050565b85815284602082015283604082015260a0606082015260006150bd60a08301856148ef565b90508260808301529695505050505050565b65ffffffffffff8281168282160390808211156140a7576140a7614d16565b8281526040602082015260006116f360408301846148ef565b60006020828403121561511957600080fd5b8151610aa88161432956fe843c3a00fa95510a35f425371231fd3fe4642e719cb4595160763d6d02594b50eef3dac4538c82c8ace4063ab0acd2d15cdb5883aa1dff7c2673abb3d869840002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00eef3dac4538c82c8ace4063ab0acd2d15cdb5883aa1dff7c2673abb3d8698401a26469706673582212201d39a210f5c2cd7870bc80dde0e5df035fd706fea2318e4fb12a75163320b57c64736f6c63430008180033
Loading...
Loading
Loading...
Loading

Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.