Source Code
Latest 25 from a total of 35,984 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Fill Order | 22648901 | 11 secs ago | IN | 0.00877665 ETH | 0.00016432 | ||||
Fill Order | 22648899 | 35 secs ago | IN | 0.01674443 ETH | 0.00016318 | ||||
Fill Order | 22648894 | 1 min ago | IN | 0 ETH | 0.00026751 | ||||
Fill Order | 22648854 | 9 mins ago | IN | 0.00035119 ETH | 0.00023815 | ||||
Fill Order | 22648846 | 11 mins ago | IN | 0.00082741 ETH | 0.00020784 | ||||
Fill Order | 22648835 | 13 mins ago | IN | 0 ETH | 0.00025239 | ||||
Fill Order | 22648831 | 14 mins ago | IN | 0 ETH | 0.00030698 | ||||
Fill Order | 22648830 | 14 mins ago | IN | 0.00304632 ETH | 0.00019675 | ||||
Fill Order | 22648825 | 15 mins ago | IN | 0.18814855 ETH | 0.00019336 | ||||
Fill Order | 22648807 | 18 mins ago | IN | 0.00898451 ETH | 0.00017138 | ||||
Fill Order | 22648763 | 27 mins ago | IN | 0.03990519 ETH | 0.00018723 | ||||
Fill Order | 22648753 | 29 mins ago | IN | 1.71848188 ETH | 0.00020383 | ||||
Fill Order | 22648744 | 31 mins ago | IN | 0 ETH | 0.00033758 | ||||
Fill Order | 22648712 | 37 mins ago | IN | 0.00639165 ETH | 0.00022463 | ||||
Fill Order | 22648711 | 38 mins ago | IN | 0 ETH | 0.0003706 | ||||
Fill Order | 22648681 | 44 mins ago | IN | 0 ETH | 0.00033321 | ||||
Fill Order | 22648647 | 50 mins ago | IN | 0.13074492 ETH | 0.00031265 | ||||
Fill Order | 22648639 | 52 mins ago | IN | 0.20538189 ETH | 0.00047314 | ||||
Fill Order | 22648618 | 56 mins ago | IN | 0.00042911 ETH | 0.00049572 | ||||
Fill Order | 22648600 | 1 hr ago | IN | 0.0050938 ETH | 0.00047136 | ||||
Fill Order | 22648589 | 1 hr ago | IN | 0.00719731 ETH | 0.00053277 | ||||
Create Order | 22648588 | 1 hr ago | IN | 0 ETH | 0.00053282 | ||||
Forward Settleme... | 22648575 | 1 hr ago | IN | 0.004527 ETH | 0.00243691 | ||||
Fill Order | 22648570 | 1 hr ago | IN | 0 ETH | 0.00108486 | ||||
Create Order | 22648560 | 1 hr ago | IN | 0 ETH | 0.00090312 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Method | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|---|
Transfer | 22648899 | 35 secs ago | 0.01674443 ETH | ||||
Create Order | 22648858 | 8 mins ago | 0.0297375 ETH | ||||
Create Order | 22648857 | 8 mins ago | 0.0297375 ETH | ||||
Transfer | 22648854 | 9 mins ago | 0.00035119 ETH | ||||
Transfer | 22648846 | 11 mins ago | 0.00082741 ETH | ||||
Create Order | 22648836 | 13 mins ago | 0.01288625 ETH | ||||
Transfer | 22648830 | 14 mins ago | 0.00304632 ETH | ||||
Create Order | 22648829 | 14 mins ago | 0.07236125 ETH | ||||
Create Order | 22648826 | 15 mins ago | 0.0495625 ETH | ||||
Transfer | 22648825 | 15 mins ago | 0.18814855 ETH | ||||
Create Order | 22648817 | 16 mins ago | 0.3172 ETH | ||||
Transfer | 22648807 | 18 mins ago | 0.00898451 ETH | ||||
Create Order | 22648806 | 19 mins ago | 0.00495625 ETH | ||||
Create Order | 22648800 | 20 mins ago | 0.0376675 ETH | ||||
Create Order | 22648797 | 20 mins ago | 0.35685 ETH | ||||
Create Order | 22648772 | 25 mins ago | 0.16553875 ETH | ||||
Create Order | 22648764 | 27 mins ago | 0.0773175 ETH | ||||
Transfer | 22648763 | 27 mins ago | 0.03990519 ETH | ||||
Create Order | 22648762 | 27 mins ago | 0.01288625 ETH | ||||
Create Order | 22648754 | 29 mins ago | 0.019825 ETH | ||||
Transfer | 22648753 | 29 mins ago | 1.71848188 ETH | ||||
Transfer | 22648712 | 37 mins ago | 0.00639165 ETH | ||||
Create Order | 22648688 | 42 mins ago | 0.00227987 ETH | ||||
Create Order | 22648672 | 45 mins ago | 0.1486875 ETH | ||||
Create Order | 22648649 | 50 mins ago | 0.0495625 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
Spoke
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 9999 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {AxelarExecutable} from "./axelar/AxelarExecutable.sol"; import {IAxelarGateway} from "./interfaces/IAxelarGateway.sol"; import {IAxelarGasService} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGasService.sol"; import {InterchainAddressTracker} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/InterchainAddressTracker.sol"; import {OApp, Origin, MessagingFee} from "./oapp/OApp.sol"; import {ILayerZeroEndpointV2} from "./oapp/interfaces/ILayerZeroEndpointV2.sol"; import {OptionsBuilder} from "@layerzerolabs/oapp-evm/contracts/oapp/libs/OptionsBuilder.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {ISquidMulticall} from "./interfaces/ISquidMulticall.sol"; import {IPermit2} from "./interfaces/IPermit2.sol"; import {ISpoke} from "./interfaces/ISpoke.sol"; import {Utils} from "./libraries/Utils.sol"; contract Spoke is ISpoke, OApp, AxelarExecutable, Initializable, InterchainAddressTracker, ReentrancyGuard, EIP712 { using Address for address payable; using SafeERC20 for IERC20; using OptionsBuilder for bytes; /// @dev token address => fee amount collected in this token mapping(address => uint256) public tokenToCollectedFees; mapping(bytes32 => OrderStatus) public orderHashToStatus; mapping(bytes32 => SettlementStatus) public settlementToStatus; IAxelarGasService public gasService; IPermit2 public permit2; ISquidMulticall public squidMulticall; address public feeCollector; /// @dev Chain name must follow Axelar format /// https://docs.axelar.dev/dev/reference/mainnet-contract-addresses string public hubChainName; string public hubAddress; /// @dev Endpoint must follow LayerZero format /// https://docs.layerzero.network/v2/developers/evm/technical-reference/deployed-contracts uint32 public hubEndpoint; bytes32 public hubAddressBytes32; modifier onlyFeeCollector() { if (msg.sender != feeCollector) revert OnlyFeeCollector(); _; } modifier onlyTrustedAddress(string calldata fromChainName, string calldata fromContractAddress) { if (!isTrustedAddress(fromChainName, fromContractAddress)) revert OnlyTrustedAddress(); _; } constructor() AxelarExecutable(0xC012A11111111111111111111111111111111111) EIP712("Spoke", "1") OApp(0xC012A11111111111111111111111111111111111, msg.sender) Ownable(msg.sender) {} ////////////////////////////////////////////////////////////// // // // Initializer // // // ////////////////////////////////////////////////////////////// /// @notice One-time use initialize function for the protocol. This function is required to be called /// within the deploying transaction to set the initial state of the Spoke.sol contract. These parameters /// cannot be updated after initialization. /// @notice The _hubChainName and _hubAddress will be set as the trusted chain and address for Axelar /// general message passing. Only the trusted Hub.sol contract can execute interchain transactions /// in the Spoke.sol contract. /// @param _axelarGateway Address of the relevant Axelar's AxelarGateway.sol contract deployment. /// @param _axelarGasService Address of the relevant Axelar's AxelarGasService.sol contract deployment. /// @param _permit2 Address of the relevant Uniswap's Permit2.sol contract deployment /// Can be zero address if not available on current network. /// @param _squidMulticall Address of the relevant Squid's SquidMulticall.sol contract deployment. /// @param _feeCollector Address of the EOA that would collect fees from the protocol. Recommended to use /// a multisig wallet. /// @param _hubChainName Chain name of the chain the Hub.sol contract will be deployed to, must follow /// Axelar's chain name format. This chain name will be passed to the Axelar Gateway to determine the /// target chain for general message passing from the Spoke. /// @param _hubAddress String for the address of the relevant Hub.sol contract, this should be computed /// deterministically using the CREATE2 opcode to remain permissionless. /// @param _endpoint Address of the LayerZero EndpointV2 contract, responsible for managing cross-chain /// communications. /// @param _owner Address set as the owner of the Spoke.sol contract upon deployment. /// @param _hub Address of the relevant Hub.sol contract, this should be computed deterministically /// using the CREATE2 opcode to remain permissionless. /// @param _hubEndpoint Endpoint ID as specified by LayerZero: /// https://docs.layerzero.network/v2/developers/evm/technical-reference/deployed-contracts function initialize( IAxelarGateway _axelarGateway, IAxelarGasService _axelarGasService, IPermit2 _permit2, ISquidMulticall _squidMulticall, address _feeCollector, string memory _hubChainName, string memory _hubAddress, ILayerZeroEndpointV2 _endpoint, address _owner, address _hub, uint32 _hubEndpoint ) external initializer { transferOwnership(_owner); gateway = _axelarGateway; gasService = _axelarGasService; permit2 = _permit2; squidMulticall = _squidMulticall; feeCollector = _feeCollector; hubChainName = _hubChainName; hubAddress = _hubAddress; _setTrustedAddress(_hubChainName, _hubAddress); if (address(_endpoint) != 0x1111111111111111111111111111111111111111) { endpoint = _endpoint; _endpoint.setDelegate(_owner); hubEndpoint = _hubEndpoint; _setPeer(_hubEndpoint, addressToBytes32(_hub)); hubAddressBytes32 = addressToBytes32(_hub); } emit SpokeInitialized( gateway, gasService, permit2, squidMulticall, feeCollector, hubChainName, hubAddress ); } ////////////////////////////////////////////////////////////// // // // Source endpoints // // // ////////////////////////////////////////////////////////////// /// @inheritdoc ISpoke function createOrder(Order calldata order) external payable { _createOrder(order, msg.sender); } /// @inheritdoc ISpoke function sponsorOrder(Order calldata order, bytes calldata signature) external { if (order.fromToken == Utils.NATIVE_TOKEN) revert NativeTokensNotAllowed(); if ( !SignatureChecker.isValidSignatureNow( order.fromAddress, _hashTypedDataV4(_hashOrderTyped(order)), signature ) ) revert InvalidUserSignature(); _createOrder(order, order.fromAddress); } /// @notice Executes the intent on the source chain, locking the ERC20 or native tokens in the /// Spoke.sol contract, setting the OrderStatus to CREATED, and making the order eligible /// to be filled on the destination chain. /// @dev Orders are tied to the keccak256 hash of the Order therefore each Order is unique /// according to the parameters in the Order and can only be executed a single time. /// @param order Order to be executed by the Spoke.sol contract in the format of the Order struct. /// @param fromAddress Address of the holder of funds for a particular order. function _createOrder(Order calldata order, address fromAddress) private nonReentrant { bytes32 orderHash = keccak256(abi.encode(order)); if (orderHashToStatus[orderHash] != OrderStatus.EMPTY) revert OrderAlreadyExists(); if (block.timestamp > order.expiry) revert OrderExpired(); if (order.fromChain != _getChainId()) revert InvalidSourceChain(); if (order.fromToken != Utils.NATIVE_TOKEN && msg.value != 0) revert UnexpectedNativeToken(); orderHashToStatus[orderHash] = OrderStatus.CREATED; if (order.fromToken == Utils.NATIVE_TOKEN) { if (msg.value != order.fromAmount) revert InvalidNativeAmount(); } else { IERC20(order.fromToken).safeTransferFrom(fromAddress, address(this), order.fromAmount); } emit OrderCreated(orderHash, order); } /// @inheritdoc ISpoke function sponsorOrderUsingPermit2( Order calldata order, IPermit2.PermitTransferFrom calldata permit, bytes calldata signature ) external nonReentrant { bytes32 orderHash = keccak256(abi.encode(order)); if (orderHashToStatus[orderHash] != OrderStatus.EMPTY) revert OrderAlreadyExists(); if (block.timestamp > order.expiry) revert OrderExpired(); if (order.fromChain != _getChainId()) revert InvalidSourceChain(); if (order.fromToken == Utils.NATIVE_TOKEN) revert NativeTokensNotAllowed(); orderHashToStatus[orderHash] = OrderStatus.CREATED; IPermit2.SignatureTransferDetails memory transferDetails; transferDetails.to = address(this); transferDetails.requestedAmount = order.fromAmount; bytes32 witness = _hashOrderTyped(order); permit2.permitWitnessTransferFrom( permit, transferDetails, order.fromAddress, witness, Utils.ORDER_WITNESS_TYPE_STRING, signature ); emit OrderCreated(orderHash, order); } /// @inheritdoc ISpoke function refundOrder(Order calldata order) external nonReentrant { bytes32 orderHash = keccak256(abi.encode(order)); if (orderHashToStatus[orderHash] != OrderStatus.CREATED) revert OrderStateNotCreated(); if (msg.sender != order.filler) { if (!(block.timestamp > (order.expiry + 1 days))) revert OrderNotExpired(); } if (order.fromChain != _getChainId()) revert InvalidSourceChain(); orderHashToStatus[orderHash] = OrderStatus.REFUNDED; if (order.fromToken == Utils.NATIVE_TOKEN) { payable(order.fromAddress).sendValue(order.fromAmount); } else { IERC20(order.fromToken).safeTransfer(order.fromAddress, order.fromAmount); } emit OrderRefunded(orderHash); } /// @inheritdoc ISpoke function collectFees(address[] calldata tokens) external onlyFeeCollector { if (tokens.length == 0) revert InvalidArrayLength(); for (uint256 i = 0; i < tokens.length; i++) { uint256 feeAmount = tokenToCollectedFees[tokens[i]]; if (feeAmount > 0) { tokenToCollectedFees[tokens[i]] = 0; if (tokens[i] == Utils.NATIVE_TOKEN) { payable(feeCollector).sendValue(feeAmount); } else { IERC20(tokens[i]).safeTransfer(feeCollector, feeAmount); } } emit FeesCollected(feeCollector, tokens[i], feeAmount); } } ////////////////////////////////////////////////////////////// // // // Destination endpoints // // // ////////////////////////////////////////////////////////////// /// @inheritdoc ISpoke function batchFillOrder(Order[] calldata orders, ISquidMulticall.Call[][] calldata calls) external payable { if ( orders.length == 0 || orders.length != calls.length ) revert InvalidArrayLength(); uint256 remainingNativeTokenValue = msg.value; for (uint256 i = 0; i < orders.length; i++) { if (orders[i].toToken == Utils.NATIVE_TOKEN) { if (remainingNativeTokenValue < orders[i].fillAmount) revert InvalidTotalNativeAmount(); remainingNativeTokenValue -= orders[i].fillAmount; } _fillOrder(orders[i], calls[i]); } } /// @inheritdoc ISpoke function fillOrder(Order calldata order, ISquidMulticall.Call[] calldata calls) public payable { if (order.toToken == Utils.NATIVE_TOKEN && msg.value != order.fillAmount) { revert InvalidNativeAmount(); } _fillOrder(order, calls); } /// @notice Fills an order on the destination chain, transferring the order.fillAmount of /// order.toToken from the order.filler to the order.toAddress, setting the SettlementStatus to /// FILLED, and making the order eligible to be forwarded to the Hub for processing. /// @dev Orders that contain post hooks (postHookHash != bytes32(0)) require SquidMulticall calls /// to be provided during fill. These extra calls will be ran by SquidMulticall after filling the /// order during the same transaction. /// @dev Only the order.filler can fill any particular order. /// @param order Order to be filled by the Spoke.sol contract in the format of the Order struct. /// @param calls Calls to be ran by the multicall after fill, formatted to the SquidMulticall Call struct. function _fillOrder(Order memory order, ISquidMulticall.Call[] calldata calls) internal nonReentrant { bytes32 orderHash = keccak256(abi.encode(order)); if (settlementToStatus[orderHash] != SettlementStatus.EMPTY) revert OrderAlreadySettled(); if (msg.sender != order.filler) revert OnlyFillerCanSettle(); if (order.toChain != _getChainId()) revert InvalidDestinationChain(); settlementToStatus[orderHash] = SettlementStatus.FILLED; if (order.toToken == Utils.NATIVE_TOKEN) { if (order.postHookHash != bytes32(0)) { bytes memory callsData = abi.encode(calls); if (keccak256(callsData) != order.postHookHash) revert InvalidPostHookProvided(); ISquidMulticall(squidMulticall).run{value: order.fillAmount}(calls); } else { payable(order.toAddress).sendValue(order.fillAmount); } } else { if (order.postHookHash != bytes32(0)) { bytes memory callsData = abi.encode(calls); if (keccak256(callsData) != order.postHookHash) revert InvalidPostHookProvided(); IERC20(order.toToken).safeTransferFrom( order.filler, address(squidMulticall), order.fillAmount ); ISquidMulticall(squidMulticall).run(calls); } else { IERC20(order.toToken).safeTransferFrom( order.filler, order.toAddress, order.fillAmount ); } } emit OrderFilled(orderHash, order); } /// @inheritdoc ISpoke function forwardSettlements( bytes32[] calldata orderHashes, uint256 lzFee, uint128 gasLimit, Provider provider ) external payable nonReentrant { if (msg.value == 0) revert GasRequired(); if (orderHashes.length == 0) revert InvalidArrayLength(); for (uint256 i = 0; i < orderHashes.length; i++) { if ( settlementToStatus[orderHashes[i]] == SettlementStatus.EMPTY ) revert OrderNotSettled(); settlementToStatus[orderHashes[i]] = SettlementStatus.FORWARDED; emit SettlementForwarded(orderHashes[i]); } bytes memory payload = abi.encode(orderHashes); if (provider == Provider.AXELAR) { gasService.payNativeGasForContractCall{value: msg.value}( address(this), hubChainName, hubAddress, payload, msg.sender ); gateway.callContract(hubChainName, hubAddress, payload); } else if (provider == Provider.LAYERZERO) { bytes memory options = OptionsBuilder.newOptions().addExecutorLzReceiveOption(gasLimit, 0); _lzSend( hubEndpoint, payload, options, MessagingFee(msg.value, lzFee), payable(msg.sender) ); } else { revert InvalidProvider(); } } ////////////////////////////////////////////////////////////// // // // Single chain endpoints // // // ////////////////////////////////////////////////////////////// /// @inheritdoc ISpoke function batchMultiTokenSingleChainSettlements( Order[] calldata orders, address[] calldata fromTokens, address filler ) external payable { if (orders.length == 0 || fromTokens.length < 2) revert InvalidArrayLength(); bytes32[] memory orderHashes = new bytes32[](orders.length); uint256[] memory fromAmounts = new uint256[](fromTokens.length); uint256[] memory fees = new uint256[](fromTokens.length); for (uint256 i = 0; i < orders.length; i++) { bytes32 orderHash = keccak256(abi.encode(orders[i])); if (settlementToStatus[orderHash] != SettlementStatus.FILLED) revert OrderNotSettled(); if (orders[i].fromChain != _getChainId()) revert InvalidDestinationChain(); if (orders[i].toChain != _getChainId()) revert InvalidSourceChain(); if (orders[i].filler != filler) revert InvalidSettlementFiller(); uint256 tokenIndex = _findTokenIndex(orders[i].fromToken, fromTokens); if (tokenIndex == type(uint256).max) revert InvalidSettlementSourceToken(); uint256 fee = (orders[i].fromAmount * orders[i].feeRate) / Utils.FEE_DIVISOR; settlementToStatus[orderHash] = SettlementStatus.FORWARDED; fees[tokenIndex] += fee; fromAmounts[tokenIndex] += orders[i].fromAmount - fee; orderHashes[i] = orderHash; } _releaseMultiTokenBatched(orderHashes, filler, fromAmounts, fees, fromTokens); } ////////////////////////////////////////////////////////////// // // // Message passing endpoints // // // ////////////////////////////////////////////////////////////// /// @notice Called by Axelar protocol when receiving a GMP on the destination chain from the Hub. /// Contains logic that will parse the payload and release tokens for eligible orders to the order.filler. /// @dev This method will only accept GMP's from the hubChain and hubAddress set within the Spoke.sol /// initializer at the time of contract deployment. /// @dev There are two options for FillType: SINGLE and MULTI /// SINGLE is used when a batch of orders only contains a single unique order.fromToken, and only requires /// a single transfer to release the tokens for the batch of orders to the order.filler. /// MULTI is used when a batch of orders contains multiple unique order.fromToken, and will use as many /// transfers as there are unique tokens in the batch. /// @param fromChain Chain name of the chain that sent the GMP according to Axelar's chain name format: /// https://docs.axelar.dev/dev/reference/mainnet-contract-addresses /// @param fromContractAddress Address that sent the GMP. /// @param payload Value provided by the Hub containing the aggregated data for the orders being processed. /// Expected format is: abi.encode(ICoral.FillType fillType, bytes32[] orderHashes, address filler, /// uint256[] fromAmounts, uint256[] fees, address[] fromTokens) function _execute( string calldata fromChain, string calldata fromContractAddress, bytes calldata payload ) internal virtual override onlyTrustedAddress(fromChain, fromContractAddress) { ( FillType fillType, bytes32[] memory orderHashes, address filler, uint256[] memory fromAmounts, uint256[] memory processedFees, address[] memory fromTokens ) = abi.decode( payload, (FillType, bytes32[], address, uint256[], uint256[], address[]) ); if (fillType == FillType.SINGLE) { if ( fromTokens.length != 1 || fromAmounts.length != 1 || processedFees.length != 1 ) revert InvalidArrayLength(); _releaseBatched(orderHashes, filler, fromAmounts[0], processedFees[0], fromTokens[0]); } else if (fillType == FillType.MULTI) { _releaseMultiTokenBatched(orderHashes, filler, fromAmounts, processedFees, fromTokens); } else { revert InvalidFillType(); } } /// @notice Receives and processes a LayerZero message on the destination chain from the Hub. /// This function decodes the message payload and releases tokens for eligible orders to the order.filler. /// @dev This function will only accept messages originating from the hubEndpoint and hubAddressBytes32 /// that are configured during initialization. /// @dev Utilizes LayerZero's OApp standard for cross-chain messaging. /// @param _origin Struct containing the message's origin information, including the source chain's /// Endpoint ID, the sender's address, and a message nonce. /// @param _guid A globally unique identifier for tracking the LayerZero message packet. /// @param payload The encoded message payload containing order details, formatted as: /// abi.encode(ICoral.FillType fillType, bytes32[] orderHashes, address filler, /// uint256[] fromAmounts, uint256[] fees, address[] fromTokens). /// @param _executor The address of the Executor contract that called EndpointV2's lzReceive function. /// This is primarily for auditing purposes and not utilized in logic. /// @param _extraData Additional arbitrary data appended by the Executor to accompany the message payload. /// It is not modified by the OApp and can include metadata or instructions for execution. function _lzReceive( Origin calldata _origin, bytes32 _guid, bytes calldata payload, address _executor, bytes calldata _extraData ) internal override { if (_origin.sender != hubAddressBytes32) revert UnauthorizedOriginAddress(); if (_origin.srcEid != hubEndpoint) revert UnauthorizedOriginEndpoint(); ( FillType fillType, bytes32[] memory orderHashes, address filler, uint256[] memory fromAmounts, uint256[] memory processedFees, address[] memory fromTokens ) = abi.decode( payload, (FillType, bytes32[], address, uint256[], uint256[], address[]) ); if (fillType == FillType.SINGLE) { if ( fromTokens.length != 1 || fromAmounts.length != 1 || processedFees.length != 1 ) revert InvalidArrayLength(); _releaseBatched(orderHashes, filler, fromAmounts[0], processedFees[0], fromTokens[0]); } else if (fillType == FillType.MULTI) { _releaseMultiTokenBatched(orderHashes, filler, fromAmounts, processedFees, fromTokens); } else { revert InvalidFillType(); } } /// @notice Checks the OrderStatus of each order hash provided to ensure all orders are set to CREATED, /// set the OrderStatus of all order hashes to SETTLED, increments the fees for the provided token and /// processedFees, and transfers the fromAmount of ERC20 or native token from the Spoke.sol contract /// to the filler in a single transfer for all orders in the batch. /// @dev The provided order hashes are computed on the Hub based on orders that were processed and had /// a matching order hash that was processed on the order.toChain of the particular orders. Orders are /// eligible on the Hub to be forwarded to the order.fromChain once they've been filled on the /// order.toChain. Cross chain messages secured by Axelar protocol allow this function to receive /// confirmation that derived from the order.toChain Spoke.sol contract. /// @dev This method is called by the SINGLE FillType, therefore this will process orders for a single /// unique filler and token. /// @param orderHashes Array of keccak256 hashes of Orders being finalized. /// @param filler Address of the order.filler for all orders in the particular batch. /// @param fromAmount Amount of order.fromToken to be released to the filler. /// @param processedFees Amount of order.fromToken to be reserved as protocol fees. /// @param fromToken Address of the order.fromToken for all orders in the particular batch. function _releaseBatched( bytes32[] memory orderHashes, address filler, uint256 fromAmount, uint256 processedFees, address fromToken ) internal nonReentrant { if (orderHashes.length == 0) revert InvalidArrayLength(); for (uint256 i = 0; i < orderHashes.length; i++) { bytes32 orderHash = orderHashes[i]; if (orderHashToStatus[orderHash] != OrderStatus.CREATED) revert OrderStateNotCreated(); orderHashToStatus[orderHash] = OrderStatus.SETTLED; emit TokensReleased(orderHash); } tokenToCollectedFees[fromToken] += processedFees; if (fromToken == Utils.NATIVE_TOKEN) { payable(filler).sendValue(fromAmount); } else { IERC20(fromToken).safeTransfer(filler, fromAmount); } } /// @notice Checks the OrderStatus of each order hash provided to ensure all orders are set to CREATED, /// set the OrderStatus of all order hashes to SETTLED, increments the fees for each unique token provided /// and the related processedFees according to the array position, and transfers the fromAmounts of native /// token or each unique ERC20 token from the Spoke.sol contract to the filler with a transfer for each /// unique token in the particular batch. /// @dev The provided order hashes are computed on the Hub based on orders that were processed and had /// a matching order hash that was processed on the order.toChain of the particular orders. Orders are /// eligible on the Hub to be forwarded to the order.fromChain once they've been filled on the /// order.toChain. Cross chain messages secured by Axelar protocol allow this function to receive /// confirmation that derived from the order.toChain Spoke.sol contract. /// @dev This method is called by the MULTI FillType, therefore this will process orders for all unique /// tokens in the particular batch and a single filler. /// @param orderHashes Array of keccak256 hashes of Orders being finalized. /// @param filler Address of the order.filler for all orders in the particular batch. /// @param fromAmounts Array of amounts of order.fromToken to be released to the filler. /// @param processedFees Array of amounts of order.fromToken to be reserved as protocol fees. /// @param fromTokens Array of addresses for all unique order.fromToken in a particular batch. function _releaseMultiTokenBatched( bytes32[] memory orderHashes, address filler, uint256[] memory fromAmounts, uint256[] memory processedFees, address[] memory fromTokens ) internal nonReentrant { if ( orderHashes.length == 0 || fromAmounts.length != fromTokens.length || processedFees.length != fromTokens.length || fromTokens.length < 2 ) revert InvalidArrayLength(); for (uint256 i = 0; i < orderHashes.length; i++) { bytes32 orderHash = orderHashes[i]; if (orderHashToStatus[orderHash] != OrderStatus.CREATED) revert OrderStateNotCreated(); orderHashToStatus[orderHash] = OrderStatus.SETTLED; emit TokensReleased(orderHash); } for (uint256 i = 0; i < fromTokens.length; i++) { tokenToCollectedFees[fromTokens[i]] += processedFees[i]; if (fromTokens[i] == Utils.NATIVE_TOKEN) { payable(filler).sendValue(fromAmounts[i]); } else { IERC20(fromTokens[i]).safeTransfer(filler, fromAmounts[i]); } } } ////////////////////////////////////////////////////////////// // // // Utilities // // // ////////////////////////////////////////////////////////////// /// @notice Hashes the provided order using a typed EIP-712 struct. /// @param order Order struct containing information about the order to be hashed. /// @return bytes32 EIP-712 typed hash of the provided order. function _hashOrderTyped(Order calldata order) private pure returns (bytes32) { return keccak256(abi.encode( Utils.ORDER_TYPEHASH, order.fromAddress, order.toAddress, order.filler, order.fromToken, order.toToken, order.expiry, order.fromAmount, order.fillAmount, order.feeRate, order.fromChain, order.toChain, order.postHookHash )); } /// @notice Finds the index of a given token in an array of tokens. /// @param token Address of the token to find in the array. /// @param fromTokens Array of token addresses to search for the given token. /// @return uint256 Index of the token in the array, or the maximum value of uint256 if the token /// is not found. function _findTokenIndex( address token, address[] calldata fromTokens ) private pure returns (uint256) { for (uint256 i = 0; i < fromTokens.length; i++) { if (fromTokens[i] == token) { return i; } } return type(uint256).max; } /// @notice Retrieves the current chain ID. /// @return uint256 The current chain ID. function _getChainId() private view returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } function addressToBytes32(address _addr) public pure returns (bytes32) { return bytes32(uint256(uint160(_addr))); } /// @notice Provides a gas fee estimate for sending a message to a specified destination chain /// through LayerZero. /// Computes fees required for executing a LayerZero cross-chain message considering the native and /// optional ZRO token fees. /// @param _dstEid Destination chain's Endpoint ID as specified by LayerZero documentation. /// @param orderHashes An array of order hashes to be encapsulated in the message payload for /// processing at the destination. /// @param gasLimit The gas limit to be used for executing the lzReceive function on the destination /// chain, affecting the fee. /// @param _payInLzToken A boolean indicating if part of the fee will be paid in LayerZero's ZRO /// token, impacting the fee structure. /// @return nativeFee The estimated fee in native tokens required for processing the message on /// the destination chain. /// @return lzTokenFee The estimated fee in ZRO tokens, if opted for payment through LayerZero's /// token mechanism. function quote( uint32 _dstEid, bytes32[] calldata orderHashes, uint128 gasLimit, bool _payInLzToken ) public view returns (uint256 nativeFee, uint256 lzTokenFee) { bytes memory payload = abi.encode(orderHashes); bytes memory options = OptionsBuilder.newOptions().addExecutorLzReceiveOption(gasLimit, 0); MessagingFee memory fee = _quote(_dstEid, payload, options, _payInLzToken); return (fee.nativeFee, fee.lzTokenFee); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { GasInfo } from '../types/GasEstimationTypes.sol'; import { IInterchainGasEstimation } from './IInterchainGasEstimation.sol'; import { IUpgradable } from './IUpgradable.sol'; /** * @title IAxelarGasService Interface * @notice This is an interface for the AxelarGasService contract which manages gas payments * and refunds for cross-chain communication on the Axelar network. * @dev This interface inherits IUpgradable */ interface IAxelarGasService is IInterchainGasEstimation, IUpgradable { error InvalidAddress(); error NotCollector(); error InvalidAmounts(); error InvalidGasUpdates(); error InvalidParams(); error InsufficientGasPayment(uint256 required, uint256 provided); event GasPaidForContractCall( address indexed sourceAddress, string destinationChain, string destinationAddress, bytes32 indexed payloadHash, address gasToken, uint256 gasFeeAmount, address refundAddress ); event GasPaidForContractCallWithToken( address indexed sourceAddress, string destinationChain, string destinationAddress, bytes32 indexed payloadHash, string symbol, uint256 amount, address gasToken, uint256 gasFeeAmount, address refundAddress ); event NativeGasPaidForContractCall( address indexed sourceAddress, string destinationChain, string destinationAddress, bytes32 indexed payloadHash, uint256 gasFeeAmount, address refundAddress ); event NativeGasPaidForContractCallWithToken( address indexed sourceAddress, string destinationChain, string destinationAddress, bytes32 indexed payloadHash, string symbol, uint256 amount, uint256 gasFeeAmount, address refundAddress ); event GasPaidForExpressCall( address indexed sourceAddress, string destinationChain, string destinationAddress, bytes32 indexed payloadHash, address gasToken, uint256 gasFeeAmount, address refundAddress ); event GasPaidForExpressCallWithToken( address indexed sourceAddress, string destinationChain, string destinationAddress, bytes32 indexed payloadHash, string symbol, uint256 amount, address gasToken, uint256 gasFeeAmount, address refundAddress ); event NativeGasPaidForExpressCall( address indexed sourceAddress, string destinationChain, string destinationAddress, bytes32 indexed payloadHash, uint256 gasFeeAmount, address refundAddress ); event NativeGasPaidForExpressCallWithToken( address indexed sourceAddress, string destinationChain, string destinationAddress, bytes32 indexed payloadHash, string symbol, uint256 amount, uint256 gasFeeAmount, address refundAddress ); event GasAdded( bytes32 indexed txHash, uint256 indexed logIndex, address gasToken, uint256 gasFeeAmount, address refundAddress ); event NativeGasAdded(bytes32 indexed txHash, uint256 indexed logIndex, uint256 gasFeeAmount, address refundAddress); event ExpressGasAdded( bytes32 indexed txHash, uint256 indexed logIndex, address gasToken, uint256 gasFeeAmount, address refundAddress ); event NativeExpressGasAdded( bytes32 indexed txHash, uint256 indexed logIndex, uint256 gasFeeAmount, address refundAddress ); event Refunded( bytes32 indexed txHash, uint256 indexed logIndex, address payable receiver, address token, uint256 amount ); /** * @notice Pay for gas for any type of contract execution on a destination chain. * @dev This function is called on the source chain before calling the gateway to execute a remote contract. * @dev If estimateOnChain is true, the function will estimate the gas cost and revert if the payment is insufficient. * @param sender The address making the payment * @param destinationChain The target chain where the contract call will be made * @param destinationAddress The target address on the destination chain * @param payload Data payload for the contract call * @param executionGasLimit The gas limit for the contract call * @param estimateOnChain Flag to enable on-chain gas estimation * @param refundAddress The address where refunds, if any, should be sent * @param params Additional parameters for gas payment. This can be left empty for normal contract call payments. */ function payGas( address sender, string calldata destinationChain, string calldata destinationAddress, bytes calldata payload, uint256 executionGasLimit, bool estimateOnChain, address refundAddress, bytes calldata params ) external payable; /** * @notice Pay for gas using ERC20 tokens for a contract call on a destination chain. * @dev This function is called on the source chain before calling the gateway to execute a remote contract. * @param sender The address making the payment * @param destinationChain The target chain where the contract call will be made * @param destinationAddress The target address on the destination chain * @param payload Data payload for the contract call * @param gasToken The address of the ERC20 token used to pay for gas * @param gasFeeAmount The amount of tokens to pay for gas * @param refundAddress The address where refunds, if any, should be sent */ function payGasForContractCall( address sender, string calldata destinationChain, string calldata destinationAddress, bytes calldata payload, address gasToken, uint256 gasFeeAmount, address refundAddress ) external; /** * @notice Pay for gas using ERC20 tokens for a contract call with tokens on a destination chain. * @dev This function is called on the source chain before calling the gateway to execute a remote contract. * @param sender The address making the payment * @param destinationChain The target chain where the contract call with tokens will be made * @param destinationAddress The target address on the destination chain * @param payload Data payload for the contract call with tokens * @param symbol The symbol of the token to be sent with the call * @param amount The amount of tokens to be sent with the call * @param gasToken The address of the ERC20 token used to pay for gas * @param gasFeeAmount The amount of tokens to pay for gas * @param refundAddress The address where refunds, if any, should be sent */ function payGasForContractCallWithToken( address sender, string calldata destinationChain, string calldata destinationAddress, bytes calldata payload, string calldata symbol, uint256 amount, address gasToken, uint256 gasFeeAmount, address refundAddress ) external; /** * @notice Pay for gas using native currency for a contract call on a destination chain. * @dev This function is called on the source chain before calling the gateway to execute a remote contract. * @param sender The address making the payment * @param destinationChain The target chain where the contract call will be made * @param destinationAddress The target address on the destination chain * @param payload Data payload for the contract call * @param refundAddress The address where refunds, if any, should be sent */ function payNativeGasForContractCall( address sender, string calldata destinationChain, string calldata destinationAddress, bytes calldata payload, address refundAddress ) external payable; /** * @notice Pay for gas using native currency for a contract call with tokens on a destination chain. * @dev This function is called on the source chain before calling the gateway to execute a remote contract. * @param sender The address making the payment * @param destinationChain The target chain where the contract call with tokens will be made * @param destinationAddress The target address on the destination chain * @param payload Data payload for the contract call with tokens * @param symbol The symbol of the token to be sent with the call * @param amount The amount of tokens to be sent with the call * @param refundAddress The address where refunds, if any, should be sent */ function payNativeGasForContractCallWithToken( address sender, string calldata destinationChain, string calldata destinationAddress, bytes calldata payload, string calldata symbol, uint256 amount, address refundAddress ) external payable; /** * @notice Pay for gas using ERC20 tokens for an express contract call on a destination chain. * @dev This function is called on the source chain before calling the gateway to express execute a remote contract. * @param sender The address making the payment * @param destinationChain The target chain where the contract call will be made * @param destinationAddress The target address on the destination chain * @param payload Data payload for the contract call * @param gasToken The address of the ERC20 token used to pay for gas * @param gasFeeAmount The amount of tokens to pay for gas * @param refundAddress The address where refunds, if any, should be sent */ function payGasForExpressCall( address sender, string calldata destinationChain, string calldata destinationAddress, bytes calldata payload, address gasToken, uint256 gasFeeAmount, address refundAddress ) external; /** * @notice Pay for gas using ERC20 tokens for an express contract call with tokens on a destination chain. * @dev This function is called on the source chain before calling the gateway to express execute a remote contract. * @param sender The address making the payment * @param destinationChain The target chain where the contract call with tokens will be made * @param destinationAddress The target address on the destination chain * @param payload Data payload for the contract call with tokens * @param symbol The symbol of the token to be sent with the call * @param amount The amount of tokens to be sent with the call * @param gasToken The address of the ERC20 token used to pay for gas * @param gasFeeAmount The amount of tokens to pay for gas * @param refundAddress The address where refunds, if any, should be sent */ function payGasForExpressCallWithToken( address sender, string calldata destinationChain, string calldata destinationAddress, bytes calldata payload, string calldata symbol, uint256 amount, address gasToken, uint256 gasFeeAmount, address refundAddress ) external; /** * @notice Pay for gas using native currency for an express contract call on a destination chain. * @dev This function is called on the source chain before calling the gateway to execute a remote contract. * @param sender The address making the payment * @param destinationChain The target chain where the contract call will be made * @param destinationAddress The target address on the destination chain * @param payload Data payload for the contract call * @param refundAddress The address where refunds, if any, should be sent */ function payNativeGasForExpressCall( address sender, string calldata destinationChain, string calldata destinationAddress, bytes calldata payload, address refundAddress ) external payable; /** * @notice Pay for gas using native currency for an express contract call with tokens on a destination chain. * @dev This function is called on the source chain before calling the gateway to execute a remote contract. * @param sender The address making the payment * @param destinationChain The target chain where the contract call with tokens will be made * @param destinationAddress The target address on the destination chain * @param payload Data payload for the contract call with tokens * @param symbol The symbol of the token to be sent with the call * @param amount The amount of tokens to be sent with the call * @param refundAddress The address where refunds, if any, should be sent */ function payNativeGasForExpressCallWithToken( address sender, string calldata destinationChain, string calldata destinationAddress, bytes calldata payload, string calldata symbol, uint256 amount, address refundAddress ) external payable; /** * @notice Add additional gas payment using ERC20 tokens after initiating a cross-chain call. * @dev This function can be called on the source chain after calling the gateway to execute a remote contract. * @param txHash The transaction hash of the cross-chain call * @param logIndex The log index for the cross-chain call * @param gasToken The ERC20 token address used to add gas * @param gasFeeAmount The amount of tokens to add as gas * @param refundAddress The address where refunds, if any, should be sent */ function addGas( bytes32 txHash, uint256 logIndex, address gasToken, uint256 gasFeeAmount, address refundAddress ) external; /** * @notice Add additional gas payment using native currency after initiating a cross-chain call. * @dev This function can be called on the source chain after calling the gateway to execute a remote contract. * @param txHash The transaction hash of the cross-chain call * @param logIndex The log index for the cross-chain call * @param refundAddress The address where refunds, if any, should be sent */ function addNativeGas( bytes32 txHash, uint256 logIndex, address refundAddress ) external payable; /** * @notice Add additional gas payment using ERC20 tokens after initiating an express cross-chain call. * @dev This function can be called on the source chain after calling the gateway to express execute a remote contract. * @param txHash The transaction hash of the cross-chain call * @param logIndex The log index for the cross-chain call * @param gasToken The ERC20 token address used to add gas * @param gasFeeAmount The amount of tokens to add as gas * @param refundAddress The address where refunds, if any, should be sent */ function addExpressGas( bytes32 txHash, uint256 logIndex, address gasToken, uint256 gasFeeAmount, address refundAddress ) external; /** * @notice Add additional gas payment using native currency after initiating an express cross-chain call. * @dev This function can be called on the source chain after calling the gateway to express execute a remote contract. * @param txHash The transaction hash of the cross-chain call * @param logIndex The log index for the cross-chain call * @param refundAddress The address where refunds, if any, should be sent */ function addNativeExpressGas( bytes32 txHash, uint256 logIndex, address refundAddress ) external payable; /** * @notice Updates the gas price for a specific chain. * @dev This function is called by the gas oracle to update the gas prices for a specific chains. * @param chains Array of chain names * @param gasUpdates Array of gas updates */ function updateGasInfo(string[] calldata chains, GasInfo[] calldata gasUpdates) external; /** * @notice Allows the gasCollector to collect accumulated fees from the contract. * @dev Use address(0) as the token address for native currency. * @param receiver The address to receive the collected fees * @param tokens Array of token addresses to be collected * @param amounts Array of amounts to be collected for each respective token address */ function collectFees( address payable receiver, address[] calldata tokens, uint256[] calldata amounts ) external; /** * @notice Refunds gas payment to the receiver in relation to a specific cross-chain transaction. * @dev Only callable by the gasCollector. * @dev Use address(0) as the token address to refund native currency. * @param txHash The transaction hash of the cross-chain call * @param logIndex The log index for the cross-chain call * @param receiver The address to receive the refund * @param token The token address to be refunded * @param amount The amount to refund */ function refund( bytes32 txHash, uint256 logIndex, address payable receiver, address token, uint256 amount ) external; /** * @notice Returns the address of the designated gas collector. * @return address of the gas collector */ function gasCollector() external returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // General interface for upgradable contracts interface IContractIdentifier { /** * @notice Returns the contract ID. It can be used as a check during upgrades. * @dev Meant to be overridden in derived contracts. * @return bytes32 The contract ID */ function contractId() external pure returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { IContractIdentifier } from './IContractIdentifier.sol'; interface IImplementation is IContractIdentifier { error NotProxy(); function setup(bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title IInterchainAddressTracker * @dev Manages trusted addresses by chain, keeps track of addresses supported by the Axelar gateway contract */ interface IInterchainAddressTracker { error ZeroAddress(); error LengthMismatch(); error ZeroStringLength(); error UntrustedChain(); event TrustedAddressSet(string chain, string address_); event TrustedAddressRemoved(string chain); /** * @dev Gets the name of the chain this is deployed at */ function chainName() external view returns (string memory); /** * @dev Gets the trusted address at a remote chain * @param chain Chain name of the remote chain * @return trustedAddress_ The trusted address for the chain. Returns '' if the chain is untrusted */ function trustedAddress(string memory chain) external view returns (string memory trustedAddress_); /** * @dev Gets the trusted address hash for a chain * @param chain Chain name * @return trustedAddressHash_ the hash of the trusted address for that chain */ function trustedAddressHash(string memory chain) external view returns (bytes32 trustedAddressHash_); /** * @dev Checks whether the interchain sender is a trusted address * @param chain Chain name of the sender * @param address_ Address of the sender * @return bool true if the sender chain/address are trusted, false otherwise */ function isTrustedAddress(string calldata chain, string calldata address_) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { GasEstimationType, GasInfo } from '../types/GasEstimationTypes.sol'; /** * @title IInterchainGasEstimation Interface * @notice This is an interface for the InterchainGasEstimation contract * which allows for estimating gas fees for cross-chain communication on the Axelar network. */ interface IInterchainGasEstimation { error UnsupportedEstimationType(GasEstimationType gasEstimationType); /** * @notice Event emitted when the gas price for a specific chain is updated. * @param chain The name of the chain * @param info The gas info for the chain */ event GasInfoUpdated(string chain, GasInfo info); /** * @notice Returns the gas price for a specific chain. * @param chain The name of the chain * @return gasInfo The gas info for the chain */ function getGasInfo(string calldata chain) external view returns (GasInfo memory); /** * @notice Estimates the gas fee for a cross-chain contract call. * @param destinationChain Axelar registered name of the destination chain * @param destinationAddress Destination contract address being called * @param executionGasLimit The gas limit to be used for the destination contract execution, * e.g. pass in 200k if your app consumes needs upto 200k for this contract call * @param params Additional parameters for the gas estimation * @return gasEstimate The cross-chain gas estimate, in terms of source chain's native gas token that should be forwarded to the gas service. */ function estimateGasFee( string calldata destinationChain, string calldata destinationAddress, bytes calldata payload, uint256 executionGasLimit, bytes calldata params ) external view returns (uint256 gasEstimate); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title IOwnable Interface * @notice IOwnable is an interface that abstracts the implementation of a * contract with ownership control features. It's commonly used in upgradable * contracts and includes the functionality to get current owner, transfer * ownership, and propose and accept ownership. */ interface IOwnable { error NotOwner(); error InvalidOwner(); error InvalidOwnerAddress(); event OwnershipTransferStarted(address indexed newOwner); event OwnershipTransferred(address indexed newOwner); /** * @notice Returns the current owner of the contract. * @return address The address of the current owner */ function owner() external view returns (address); /** * @notice Returns the address of the pending owner of the contract. * @return address The address of the pending owner */ function pendingOwner() external view returns (address); /** * @notice Transfers ownership of the contract to a new address * @param newOwner The address to transfer ownership to */ function transferOwnership(address newOwner) external; /** * @notice Proposes to transfer the contract's ownership to a new address. * The new owner needs to accept the ownership explicitly. * @param newOwner The address to transfer ownership to */ function proposeOwnership(address newOwner) external; /** * @notice Transfers ownership to the pending owner. * @dev Can only be called by the pending owner */ function acceptOwnership() external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { IOwnable } from './IOwnable.sol'; import { IImplementation } from './IImplementation.sol'; // General interface for upgradable contracts interface IUpgradable is IOwnable, IImplementation { error InvalidCodeHash(); error InvalidImplementation(); error SetupFailed(); event Upgraded(address indexed newImplementation); function implementation() external view returns (address); function upgrade( address newImplementation, bytes32 newImplementationCodeHash, bytes calldata params ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library StringStorage { struct Wrapper { string value; } function set(bytes32 slot, string memory value) internal { _getStorageStruct(slot).value = value; } function get(bytes32 slot) internal view returns (string memory value) { value = _getStorageStruct(slot).value; } function clear(bytes32 slot) internal { delete _getStorageStruct(slot).value; } function _getStorageStruct(bytes32 slot) internal pure returns (Wrapper storage wrapper) { assembly { wrapper.slot := slot } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title GasEstimationType * @notice This enum represents the gas estimation types for different chains. */ enum GasEstimationType { Default, OptimismEcotone, OptimismBedrock, Arbitrum, Scroll } /** * @title GasInfo * @notice This struct represents the gas pricing information for a specific chain. * @dev Smaller uint types are used for efficient struct packing to save storage costs. */ struct GasInfo { /// @dev Custom gas pricing rule, such as L1 data fee on L2s uint64 gasEstimationType; /// @dev Scalar value needed for specific gas estimation types, expected to be less than 1e10 uint64 l1FeeScalar; /// @dev Axelar base fee for cross-chain message approval on destination, in terms of source native gas token uint128 axelarBaseFee; /// @dev Gas price of destination chain, in terms of the source chain token, i.e dest_gas_price * dest_token_market_price / src_token_market_price uint128 relativeGasPrice; /// @dev Needed for specific gas estimation types. Blob base fee of destination chain, in terms of the source chain token, i.e dest_blob_base_fee * dest_token_market_price / src_token_market_price uint128 relativeBlobBaseFee; /// @dev Axelar express fee for express execution, in terms of source chain token uint128 expressFee; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { IInterchainAddressTracker } from '../interfaces/IInterchainAddressTracker.sol'; import { StringStorage } from '../libs/StringStorage.sol'; /** * @title InterchainAddressTracker * @dev Manages and validates trusted interchain addresses of an application. */ contract InterchainAddressTracker is IInterchainAddressTracker { bytes32 internal constant PREFIX_ADDRESS_MAPPING = keccak256('interchain-address-tracker-address-mapping'); bytes32 internal constant PREFIX_ADDRESS_HASH_MAPPING = keccak256('interchain-address-tracker-address-hash-mapping'); // bytes32(uint256(keccak256('interchain-address-tracker-chain-name')) - 1) bytes32 internal constant _CHAIN_NAME_SLOT = 0x0e2c162a1f4b5cff9fdbd6b34678a9bcb9898a0b9fbca695b112d61688d8b2ac; function _setChainName(string memory chainName_) internal { StringStorage.set(_CHAIN_NAME_SLOT, chainName_); } /** * @dev Gets the name of the chain this is deployed at */ function chainName() external view returns (string memory chainName_) { chainName_ = StringStorage.get(_CHAIN_NAME_SLOT); } /** * @dev Gets the trusted address at a remote chain * @param chain Chain name of the remote chain * @return trustedAddress_ The trusted address for the chain. Returns '' if the chain is untrusted */ function trustedAddress(string memory chain) public view returns (string memory trustedAddress_) { trustedAddress_ = StringStorage.get(_getTrustedAddressSlot(chain)); } /** * @dev Gets the trusted address hash for a chain * @param chain Chain name * @return trustedAddressHash_ the hash of the trusted address for that chain */ function trustedAddressHash(string memory chain) public view returns (bytes32 trustedAddressHash_) { bytes32 slot = _getTrustedAddressHashSlot(chain); assembly { trustedAddressHash_ := sload(slot) } } /** * @dev Checks whether the interchain sender is a trusted address * @param chain Chain name of the sender * @param address_ Address of the sender * @return bool true if the sender chain/address are trusted, false otherwise */ function isTrustedAddress(string calldata chain, string calldata address_) public view returns (bool) { bytes32 addressHash = keccak256(bytes(address_)); return addressHash == trustedAddressHash(chain); } /** * @dev Gets the key for the trusted address at a remote chain * @param chain Chain name of the remote chain * @return slot the slot to store the trusted address in */ function _getTrustedAddressSlot(string memory chain) internal pure returns (bytes32 slot) { slot = keccak256(abi.encode(PREFIX_ADDRESS_MAPPING, chain)); } /** * @dev Gets the key for the trusted address at a remote chain * @param chain Chain name of the remote chain * @return slot the slot to store the trusted address hash in */ function _getTrustedAddressHashSlot(string memory chain) internal pure returns (bytes32 slot) { slot = keccak256(abi.encode(PREFIX_ADDRESS_HASH_MAPPING, chain)); } /** * @dev Sets the trusted address and its hash for a remote chain * @param chain Chain name of the remote chain * @param address_ the string representation of the trusted address */ function _setTrustedAddress(string memory chain, string memory address_) internal { if (bytes(chain).length == 0) revert ZeroStringLength(); if (bytes(address_).length == 0) revert ZeroStringLength(); StringStorage.set(_getTrustedAddressSlot(chain), address_); bytes32 slot = _getTrustedAddressHashSlot(chain); bytes32 addressHash = keccak256(bytes(address_)); assembly { sstore(slot, addressHash) } emit TrustedAddressSet(chain, address_); } /** * @dev Remove the trusted address of the chain. * @param chain Chain name that should be made untrusted */ function _removeTrustedAddress(string memory chain) internal { if (bytes(chain).length == 0) revert ZeroStringLength(); StringStorage.clear(_getTrustedAddressSlot(chain)); bytes32 slot = _getTrustedAddressHashSlot(chain); assembly { sstore(slot, 0) } emit TrustedAddressRemoved(chain); } }
// SPDX-License-Identifier: LZBL-1.2 pragma solidity ^0.8.20; import "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/CalldataBytesLib.sol"; library ExecutorOptions { using CalldataBytesLib for bytes; uint8 internal constant WORKER_ID = 1; uint8 internal constant OPTION_TYPE_LZRECEIVE = 1; uint8 internal constant OPTION_TYPE_NATIVE_DROP = 2; uint8 internal constant OPTION_TYPE_LZCOMPOSE = 3; uint8 internal constant OPTION_TYPE_ORDERED_EXECUTION = 4; uint8 internal constant OPTION_TYPE_LZREAD = 5; error Executor_InvalidLzReceiveOption(); error Executor_InvalidNativeDropOption(); error Executor_InvalidLzComposeOption(); error Executor_InvalidLzReadOption(); /// @dev decode the next executor option from the options starting from the specified cursor /// @param _options [executor_id][executor_option][executor_id][executor_option]... /// executor_option = [option_size][option_type][option] /// option_size = len(option_type) + len(option) /// executor_id: uint8, option_size: uint16, option_type: uint8, option: bytes /// @param _cursor the cursor to start decoding from /// @return optionType the type of the option /// @return option the option of the executor /// @return cursor the cursor to start decoding the next executor option function nextExecutorOption( bytes calldata _options, uint256 _cursor ) internal pure returns (uint8 optionType, bytes calldata option, uint256 cursor) { unchecked { // skip worker id cursor = _cursor + 1; // read option size uint16 size = _options.toU16(cursor); cursor += 2; // read option type optionType = _options.toU8(cursor); // startCursor and endCursor are used to slice the option from _options uint256 startCursor = cursor + 1; // skip option type uint256 endCursor = cursor + size; option = _options[startCursor:endCursor]; cursor += size; } } function decodeLzReceiveOption(bytes calldata _option) internal pure returns (uint128 gas, uint128 value) { if (_option.length != 16 && _option.length != 32) revert Executor_InvalidLzReceiveOption(); gas = _option.toU128(0); value = _option.length == 32 ? _option.toU128(16) : 0; } function decodeNativeDropOption(bytes calldata _option) internal pure returns (uint128 amount, bytes32 receiver) { if (_option.length != 48) revert Executor_InvalidNativeDropOption(); amount = _option.toU128(0); receiver = _option.toB32(16); } function decodeLzComposeOption( bytes calldata _option ) internal pure returns (uint16 index, uint128 gas, uint128 value) { if (_option.length != 18 && _option.length != 34) revert Executor_InvalidLzComposeOption(); index = _option.toU16(0); gas = _option.toU128(2); value = _option.length == 34 ? _option.toU128(18) : 0; } function decodeLzReadOption( bytes calldata _option ) internal pure returns (uint128 gas, uint32 calldataSize, uint128 value) { if (_option.length != 20 && _option.length != 36) revert Executor_InvalidLzReadOption(); gas = _option.toU128(0); calldataSize = _option.toU32(16); value = _option.length == 36 ? _option.toU128(20) : 0; } function encodeLzReceiveOption(uint128 _gas, uint128 _value) internal pure returns (bytes memory) { return _value == 0 ? abi.encodePacked(_gas) : abi.encodePacked(_gas, _value); } function encodeNativeDropOption(uint128 _amount, bytes32 _receiver) internal pure returns (bytes memory) { return abi.encodePacked(_amount, _receiver); } function encodeLzComposeOption(uint16 _index, uint128 _gas, uint128 _value) internal pure returns (bytes memory) { return _value == 0 ? abi.encodePacked(_index, _gas) : abi.encodePacked(_index, _gas, _value); } function encodeLzReadOption( uint128 _gas, uint32 _calldataSize, uint128 _value ) internal pure returns (bytes memory) { return _value == 0 ? abi.encodePacked(_gas, _calldataSize) : abi.encodePacked(_gas, _calldataSize, _value); } }
// SPDX-License-Identifier: LZBL-1.2 pragma solidity ^0.8.20; import { BytesLib } from "solidity-bytes-utils/contracts/BytesLib.sol"; import { BitMap256 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/BitMaps.sol"; import { CalldataBytesLib } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/CalldataBytesLib.sol"; library DVNOptions { using CalldataBytesLib for bytes; using BytesLib for bytes; uint8 internal constant WORKER_ID = 2; uint8 internal constant OPTION_TYPE_PRECRIME = 1; error DVN_InvalidDVNIdx(); error DVN_InvalidDVNOptions(uint256 cursor); /// @dev group dvn options by its idx /// @param _options [dvn_id][dvn_option][dvn_id][dvn_option]... /// dvn_option = [option_size][dvn_idx][option_type][option] /// option_size = len(dvn_idx) + len(option_type) + len(option) /// dvn_id: uint8, dvn_idx: uint8, option_size: uint16, option_type: uint8, option: bytes /// @return dvnOptions the grouped options, still share the same format of _options /// @return dvnIndices the dvn indices function groupDVNOptionsByIdx( bytes memory _options ) internal pure returns (bytes[] memory dvnOptions, uint8[] memory dvnIndices) { if (_options.length == 0) return (dvnOptions, dvnIndices); uint8 numDVNs = getNumDVNs(_options); // if there is only 1 dvn, we can just return the whole options if (numDVNs == 1) { dvnOptions = new bytes[](1); dvnOptions[0] = _options; dvnIndices = new uint8[](1); dvnIndices[0] = _options.toUint8(3); // dvn idx return (dvnOptions, dvnIndices); } // otherwise, we need to group the options by dvn_idx dvnIndices = new uint8[](numDVNs); dvnOptions = new bytes[](numDVNs); unchecked { uint256 cursor = 0; uint256 start = 0; uint8 lastDVNIdx = 255; // 255 is an invalid dvn_idx while (cursor < _options.length) { ++cursor; // skip worker_id // optionLength asserted in getNumDVNs (skip check) uint16 optionLength = _options.toUint16(cursor); cursor += 2; // dvnIdx asserted in getNumDVNs (skip check) uint8 dvnIdx = _options.toUint8(cursor); // dvnIdx must equal to the lastDVNIdx for the first option // so it is always skipped in the first option // this operation slices out options whenever the scan finds a different lastDVNIdx if (lastDVNIdx == 255) { lastDVNIdx = dvnIdx; } else if (dvnIdx != lastDVNIdx) { uint256 len = cursor - start - 3; // 3 is for worker_id and option_length bytes memory opt = _options.slice(start, len); _insertDVNOptions(dvnOptions, dvnIndices, lastDVNIdx, opt); // reset the start and lastDVNIdx start += len; lastDVNIdx = dvnIdx; } cursor += optionLength; } // skip check the cursor here because the cursor is asserted in getNumDVNs // if we have reached the end of the options, we need to process the last dvn uint256 size = cursor - start; bytes memory op = _options.slice(start, size); _insertDVNOptions(dvnOptions, dvnIndices, lastDVNIdx, op); // revert dvnIndices to start from 0 for (uint8 i = 0; i < numDVNs; ++i) { --dvnIndices[i]; } } } function _insertDVNOptions( bytes[] memory _dvnOptions, uint8[] memory _dvnIndices, uint8 _dvnIdx, bytes memory _newOptions ) internal pure { // dvnIdx starts from 0 but default value of dvnIndices is 0, // so we tell if the slot is empty by adding 1 to dvnIdx if (_dvnIdx == 255) revert DVN_InvalidDVNIdx(); uint8 dvnIdxAdj = _dvnIdx + 1; for (uint256 j = 0; j < _dvnIndices.length; ++j) { uint8 index = _dvnIndices[j]; if (dvnIdxAdj == index) { _dvnOptions[j] = abi.encodePacked(_dvnOptions[j], _newOptions); break; } else if (index == 0) { // empty slot, that means it is the first time we see this dvn _dvnIndices[j] = dvnIdxAdj; _dvnOptions[j] = _newOptions; break; } } } /// @dev get the number of unique dvns /// @param _options the format is the same as groupDVNOptionsByIdx function getNumDVNs(bytes memory _options) internal pure returns (uint8 numDVNs) { uint256 cursor = 0; BitMap256 bitmap; // find number of unique dvn_idx unchecked { while (cursor < _options.length) { ++cursor; // skip worker_id uint16 optionLength = _options.toUint16(cursor); cursor += 2; if (optionLength < 2) revert DVN_InvalidDVNOptions(cursor); // at least 1 byte for dvn_idx and 1 byte for option_type uint8 dvnIdx = _options.toUint8(cursor); // if dvnIdx is not set, increment numDVNs // max num of dvns is 255, 255 is an invalid dvn_idx // The order of the dvnIdx is not required to be sequential, as enforcing the order may weaken // the composability of the options. e.g. if we refrain from enforcing the order, an OApp that has // already enforced certain options can append additional options to the end of the enforced // ones without restrictions. if (dvnIdx == 255) revert DVN_InvalidDVNIdx(); if (!bitmap.get(dvnIdx)) { ++numDVNs; bitmap = bitmap.set(dvnIdx); } cursor += optionLength; } } if (cursor != _options.length) revert DVN_InvalidDVNOptions(cursor); } /// @dev decode the next dvn option from _options starting from the specified cursor /// @param _options the format is the same as groupDVNOptionsByIdx /// @param _cursor the cursor to start decoding /// @return optionType the type of the option /// @return option the option /// @return cursor the cursor to start decoding the next option function nextDVNOption( bytes calldata _options, uint256 _cursor ) internal pure returns (uint8 optionType, bytes calldata option, uint256 cursor) { unchecked { // skip worker id cursor = _cursor + 1; // read option size uint16 size = _options.toU16(cursor); cursor += 2; // read option type optionType = _options.toU8(cursor + 1); // skip dvn_idx // startCursor and endCursor are used to slice the option from _options uint256 startCursor = cursor + 2; // skip option type and dvn_idx uint256 endCursor = cursor + size; option = _options[startCursor:endCursor]; cursor += size; } } }
// SPDX-License-Identifier: LZBL-1.2 pragma solidity ^0.8.20; library CalldataBytesLib { function toU8(bytes calldata _bytes, uint256 _start) internal pure returns (uint8) { return uint8(_bytes[_start]); } function toU16(bytes calldata _bytes, uint256 _start) internal pure returns (uint16) { unchecked { uint256 end = _start + 2; return uint16(bytes2(_bytes[_start:end])); } } function toU32(bytes calldata _bytes, uint256 _start) internal pure returns (uint32) { unchecked { uint256 end = _start + 4; return uint32(bytes4(_bytes[_start:end])); } } function toU64(bytes calldata _bytes, uint256 _start) internal pure returns (uint64) { unchecked { uint256 end = _start + 8; return uint64(bytes8(_bytes[_start:end])); } } function toU128(bytes calldata _bytes, uint256 _start) internal pure returns (uint128) { unchecked { uint256 end = _start + 16; return uint128(bytes16(_bytes[_start:end])); } } function toU256(bytes calldata _bytes, uint256 _start) internal pure returns (uint256) { unchecked { uint256 end = _start + 32; return uint256(bytes32(_bytes[_start:end])); } } function toAddr(bytes calldata _bytes, uint256 _start) internal pure returns (address) { unchecked { uint256 end = _start + 20; return address(bytes20(_bytes[_start:end])); } } function toB32(bytes calldata _bytes, uint256 _start) internal pure returns (bytes32) { unchecked { uint256 end = _start + 32; return bytes32(_bytes[_start:end]); } } }
// SPDX-License-Identifier: MIT // modified from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/BitMaps.sol pragma solidity ^0.8.20; type BitMap256 is uint256; using BitMaps for BitMap256 global; library BitMaps { /** * @dev Returns whether the bit at `index` is set. */ function get(BitMap256 bitmap, uint8 index) internal pure returns (bool) { uint256 mask = 1 << index; return BitMap256.unwrap(bitmap) & mask != 0; } /** * @dev Sets the bit at `index`. */ function set(BitMap256 bitmap, uint8 index) internal pure returns (BitMap256) { uint256 mask = 1 << index; return BitMap256.wrap(BitMap256.unwrap(bitmap) | mask); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { BytesLib } from "solidity-bytes-utils/contracts/BytesLib.sol"; import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import { ExecutorOptions } from "@layerzerolabs/lz-evm-messagelib-v2/contracts/libs/ExecutorOptions.sol"; import { DVNOptions } from "@layerzerolabs/lz-evm-messagelib-v2/contracts/uln/libs/DVNOptions.sol"; /** * @title OptionsBuilder * @dev Library for building and encoding various message options. */ library OptionsBuilder { using SafeCast for uint256; using BytesLib for bytes; // Constants for options types uint16 internal constant TYPE_1 = 1; // legacy options type 1 uint16 internal constant TYPE_2 = 2; // legacy options type 2 uint16 internal constant TYPE_3 = 3; // Custom error message error InvalidSize(uint256 max, uint256 actual); error InvalidOptionType(uint16 optionType); // Modifier to ensure only options of type 3 are used modifier onlyType3(bytes memory _options) { if (_options.toUint16(0) != TYPE_3) revert InvalidOptionType(_options.toUint16(0)); _; } /** * @dev Creates a new options container with type 3. * @return options The newly created options container. */ function newOptions() internal pure returns (bytes memory) { return abi.encodePacked(TYPE_3); } /** * @dev Adds an executor LZ receive option to the existing options. * @param _options The existing options container. * @param _gas The gasLimit used on the lzReceive() function in the OApp. * @param _value The msg.value passed to the lzReceive() function in the OApp. * @return options The updated options container. * * @dev When multiples of this option are added, they are summed by the executor * eg. if (_gas: 200k, and _value: 1 ether) AND (_gas: 100k, _value: 0.5 ether) are sent in an option to the LayerZeroEndpoint, * that becomes (300k, 1.5 ether) when the message is executed on the remote lzReceive() function. */ function addExecutorLzReceiveOption( bytes memory _options, uint128 _gas, uint128 _value ) internal pure onlyType3(_options) returns (bytes memory) { bytes memory option = ExecutorOptions.encodeLzReceiveOption(_gas, _value); return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_LZRECEIVE, option); } /** * @dev Adds an executor native drop option to the existing options. * @param _options The existing options container. * @param _amount The amount for the native value that is airdropped to the 'receiver'. * @param _receiver The receiver address for the native drop option. * @return options The updated options container. * * @dev When multiples of this option are added, they are summed by the executor on the remote chain. */ function addExecutorNativeDropOption( bytes memory _options, uint128 _amount, bytes32 _receiver ) internal pure onlyType3(_options) returns (bytes memory) { bytes memory option = ExecutorOptions.encodeNativeDropOption(_amount, _receiver); return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_NATIVE_DROP, option); } // /** // * @dev Adds an executor native drop option to the existing options. // * @param _options The existing options container. // * @param _amount The amount for the native value that is airdropped to the 'receiver'. // * @param _receiver The receiver address for the native drop option. // * @return options The updated options container. // * // * @dev When multiples of this option are added, they are summed by the executor on the remote chain. // */ function addExecutorLzReadOption( bytes memory _options, uint128 _gas, uint32 _size, uint128 _value ) internal pure onlyType3(_options) returns (bytes memory) { bytes memory option = ExecutorOptions.encodeLzReadOption(_gas, _size, _value); return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_LZREAD, option); } /** * @dev Adds an executor LZ compose option to the existing options. * @param _options The existing options container. * @param _index The index for the lzCompose() function call. * @param _gas The gasLimit for the lzCompose() function call. * @param _value The msg.value for the lzCompose() function call. * @return options The updated options container. * * @dev When multiples of this option are added, they are summed PER index by the executor on the remote chain. * @dev If the OApp sends N lzCompose calls on the remote, you must provide N incremented indexes starting with 0. * ie. When your remote OApp composes (N = 3) messages, you must set this option for index 0,1,2 */ function addExecutorLzComposeOption( bytes memory _options, uint16 _index, uint128 _gas, uint128 _value ) internal pure onlyType3(_options) returns (bytes memory) { bytes memory option = ExecutorOptions.encodeLzComposeOption(_index, _gas, _value); return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_LZCOMPOSE, option); } /** * @dev Adds an executor ordered execution option to the existing options. * @param _options The existing options container. * @return options The updated options container. */ function addExecutorOrderedExecutionOption( bytes memory _options ) internal pure onlyType3(_options) returns (bytes memory) { return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_ORDERED_EXECUTION, bytes("")); } /** * @dev Adds a DVN pre-crime option to the existing options. * @param _options The existing options container. * @param _dvnIdx The DVN index for the pre-crime option. * @return options The updated options container. */ function addDVNPreCrimeOption( bytes memory _options, uint8 _dvnIdx ) internal pure onlyType3(_options) returns (bytes memory) { return addDVNOption(_options, _dvnIdx, DVNOptions.OPTION_TYPE_PRECRIME, bytes("")); } /** * @dev Adds an executor option to the existing options. * @param _options The existing options container. * @param _optionType The type of the executor option. * @param _option The encoded data for the executor option. * @return options The updated options container. */ function addExecutorOption( bytes memory _options, uint8 _optionType, bytes memory _option ) internal pure onlyType3(_options) returns (bytes memory) { return abi.encodePacked( _options, ExecutorOptions.WORKER_ID, _option.length.toUint16() + 1, // +1 for optionType _optionType, _option ); } /** * @dev Adds a DVN option to the existing options. * @param _options The existing options container. * @param _dvnIdx The DVN index for the DVN option. * @param _optionType The type of the DVN option. * @param _option The encoded data for the DVN option. * @return options The updated options container. */ function addDVNOption( bytes memory _options, uint8 _dvnIdx, uint8 _optionType, bytes memory _option ) internal pure onlyType3(_options) returns (bytes memory) { return abi.encodePacked( _options, DVNOptions.WORKER_ID, _option.length.toUint16() + 2, // +2 for optionType and dvnIdx _dvnIdx, _optionType, _option ); } /** * @dev Encodes legacy options of type 1. * @param _executionGas The gasLimit value passed to lzReceive(). * @return legacyOptions The encoded legacy options. */ function encodeLegacyOptionsType1(uint256 _executionGas) internal pure returns (bytes memory) { if (_executionGas > type(uint128).max) revert InvalidSize(type(uint128).max, _executionGas); return abi.encodePacked(TYPE_1, _executionGas); } /** * @dev Encodes legacy options of type 2. * @param _executionGas The gasLimit value passed to lzReceive(). * @param _nativeForDst The amount of native air dropped to the receiver. * @param _receiver The _nativeForDst receiver address. * @return legacyOptions The encoded legacy options of type 2. */ function encodeLegacyOptionsType2( uint256 _executionGas, uint256 _nativeForDst, bytes memory _receiver // @dev Use bytes instead of bytes32 in legacy type 2 for _receiver. ) internal pure returns (bytes memory) { if (_executionGas > type(uint128).max) revert InvalidSize(type(uint128).max, _executionGas); if (_nativeForDst > type(uint128).max) revert InvalidSize(type(uint128).max, _nativeForDst); if (_receiver.length > 32) revert InvalidSize(32, _receiver.length); return abi.encodePacked(TYPE_2, _executionGas, _nativeForDst, _receiver); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// 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/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated 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.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// 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/cryptography/EIP712.sol) pragma solidity ^0.8.20; import {MessageHashUtils} from "./MessageHashUtils.sol"; import {ShortStrings, ShortString} from "../ShortStrings.sol"; import {IERC5267} from "../../interfaces/IERC5267.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * @custom:oz-upgrades-unsafe-allow state-variable-immutable */ abstract contract EIP712 is IERC5267 { using ShortStrings for *; bytes32 private constant TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _cachedDomainSeparator; uint256 private immutable _cachedChainId; address private immutable _cachedThis; bytes32 private immutable _hashedName; bytes32 private immutable _hashedVersion; ShortString private immutable _name; ShortString private immutable _version; string private _nameFallback; string private _versionFallback; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _name = name.toShortStringWithFallback(_nameFallback); _version = version.toShortStringWithFallback(_versionFallback); _hashedName = keccak256(bytes(name)); _hashedVersion = keccak256(bytes(version)); _cachedChainId = block.chainid; _cachedDomainSeparator = _buildDomainSeparator(); _cachedThis = address(this); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _cachedThis && block.chainid == _cachedChainId) { return _cachedDomainSeparator; } else { return _buildDomainSeparator(); } } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {IERC-5267}. */ function eip712Domain() public view virtual returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: By default this function reads _name which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Name() internal view returns (string memory) { return _name.toStringWithFallback(_nameFallback); } /** * @dev The version parameter for the EIP712 domain. * * NOTE: By default this function reads _version which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Version() internal view returns (string memory) { return _version.toStringWithFallback(_versionFallback); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol) pragma solidity ^0.8.20; import {Strings} from "../Strings.sol"; /** * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing. * * The library provides methods for generating a hash of a message that conforms to the * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] * specifications. */ library MessageHashUtils { /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing a bytes32 `messageHash` with * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with * keccak256, although any bytes32 value can be safely used because the final digest will * be re-hashed. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20) } } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing an arbitrary `message` with * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) { return keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message)); } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x00` (data with intended validator). * * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended * `validator` address. Then hashing the result. * * See {ECDSA-recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked(hex"19_00", validator, data)); } /** * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`). * * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with * `\x19\x01` and hashing the result. It corresponds to the hash signed by the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. * * See {ECDSA-recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, hex"19_01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) digest := keccak256(ptr, 0x42) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/SignatureChecker.sol) pragma solidity ^0.8.20; import {ECDSA} from "./ECDSA.sol"; import {IERC1271} from "../../interfaces/IERC1271.sol"; /** * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like * Argent and Safe Wallet (previously Gnosis Safe). */ library SignatureChecker { /** * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) { (address recovered, ECDSA.RecoverError error, ) = ECDSA.tryRecover(hash, signature); return (error == ECDSA.RecoverError.NoError && recovered == signer) || isValidERC1271SignatureNow(signer, hash, signature); } /** * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated * against the signer smart contract using ERC1271. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidERC1271SignatureNow( address signer, bytes32 hash, bytes memory signature ) internal view returns (bool) { (bool success, bytes memory result) = signer.staticcall( abi.encodeCall(IERC1271.isValidSignature, (hash, signature)) ); return (success && result.length >= 32 && abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector)); } }
// 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 // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; /** * @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 ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; uint256 private _status; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); constructor() { _status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be NOT_ENTERED if (_status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail _status = ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = NOT_ENTERED; } /** * @dev 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) { return _status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol) pragma solidity ^0.8.20; import {StorageSlot} from "./StorageSlot.sol"; // | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | // | length | 0x BB | type ShortString is bytes32; /** * @dev This library provides functions to convert short memory strings * into a `ShortString` type that can be used as an immutable variable. * * Strings of arbitrary length can be optimized using this library if * they are short enough (up to 31 bytes) by packing them with their * length (1 byte) in a single EVM word (32 bytes). Additionally, a * fallback mechanism can be used for every other case. * * Usage example: * * ```solidity * contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * } * ``` */ library ShortStrings { // Used as an identifier for strings longer than 31 bytes. bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF; error StringTooLong(string str); error InvalidShortString(); /** * @dev Encode a string of at most 31 chars into a `ShortString`. * * This will trigger a `StringTooLong` error is the input string is too long. */ function toShortString(string memory str) internal pure returns (ShortString) { bytes memory bstr = bytes(str); if (bstr.length > 31) { revert StringTooLong(str); } return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length)); } /** * @dev Decode a `ShortString` back to a "normal" string. */ function toString(ShortString sstr) internal pure returns (string memory) { uint256 len = byteLength(sstr); // using `new string(len)` would work locally but is not memory safe. string memory str = new string(32); /// @solidity memory-safe-assembly assembly { mstore(str, len) mstore(add(str, 0x20), sstr) } return str; } /** * @dev Return the length of a `ShortString`. */ function byteLength(ShortString sstr) internal pure returns (uint256) { uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF; if (result > 31) { revert InvalidShortString(); } return result; } /** * @dev Encode a string into a `ShortString`, or write it to storage if it is too long. */ function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) { if (bytes(value).length < 32) { return toShortString(value); } else { StorageSlot.getStringSlot(store).value = value; return ShortString.wrap(FALLBACK_SENTINEL); } } /** * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}. */ function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return toString(value); } else { return store; } } /** * @dev Return the length of a string that was encoded to `ShortString` or written to storage using * {setWithFallback}. * * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of * actual characters as the UTF-8 encoding of a single character can span over multiple bytes. */ function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return byteLength(value); } else { return bytes(store).length; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { IAxelarGateway } from '../interfaces/IAxelarGateway.sol'; import { IAxelarExecutable } from '../interfaces/IAxelarExecutable.sol'; contract AxelarExecutable is IAxelarExecutable { IAxelarGateway public gateway; constructor(address gateway_) { if (gateway_ == address(0)) revert InvalidAddress(); gateway = IAxelarGateway(gateway_); } function execute( bytes32 commandId, string calldata sourceChain, string calldata sourceAddress, bytes calldata payload ) external { bytes32 payloadHash = keccak256(payload); if (!gateway.validateContractCall(commandId, sourceChain, sourceAddress, payloadHash)) revert NotApprovedByGateway(); _execute(sourceChain, sourceAddress, payload); } function executeWithToken( bytes32 commandId, string calldata sourceChain, string calldata sourceAddress, bytes calldata payload, string calldata tokenSymbol, uint256 amount ) external { bytes32 payloadHash = keccak256(payload); if ( !gateway.validateContractCallAndMint( commandId, sourceChain, sourceAddress, payloadHash, tokenSymbol, amount ) ) revert NotApprovedByGateway(); _executeWithToken(sourceChain, sourceAddress, payload, tokenSymbol, amount); } function _execute( string calldata sourceChain, string calldata sourceAddress, bytes calldata payload ) internal virtual {} function _executeWithToken( string calldata sourceChain, string calldata sourceAddress, bytes calldata payload, string calldata tokenSymbol, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IEIP712} from "./IEIP712.sol"; /// @title AllowanceTransfer /// @notice Handles ERC20 token permissions through signature based allowance setting and ERC20 token transfers by checking allowed amounts /// @dev Requires user's token approval on the Permit2 contract interface IAllowanceTransfer is IEIP712 { /// @notice Thrown when an allowance on a token has expired. /// @param deadline The timestamp at which the allowed amount is no longer valid error AllowanceExpired(uint256 deadline); /// @notice Thrown when an allowance on a token has been depleted. /// @param amount The maximum amount allowed error InsufficientAllowance(uint256 amount); /// @notice Thrown when too many nonces are invalidated. error ExcessiveInvalidation(); /// @notice Thrown when a transferFrom2 call does not either have regular ERC20 or permit2 allowance. error TransferFailed(); /// @notice Emits an event when the owner successfully invalidates an ordered nonce. event NonceInvalidation( address indexed owner, address indexed token, address indexed spender, uint48 newNonce, uint48 oldNonce ); /// @notice Emits an event when the owner successfully sets permissions on a token for the spender. event Approval( address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration ); /// @notice Emits an event when the owner successfully sets permissions using a permit signature on a token for the spender. event Permit( address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration, uint48 nonce ); /// @notice Emits an event when the owner sets the allowance back to 0 with the lockdown function. event Lockdown(address indexed owner, address token, address spender); /// @notice The permit data for a token struct PermitDetails { // ERC20 token address address token; // the maximum amount allowed to spend uint160 amount; // timestamp at which a spender's token allowances become invalid uint48 expiration; // an incrementing value indexed per owner,token,and spender for each signature uint48 nonce; } /// @notice The permit message signed for a single token allowance struct PermitSingle { // the permit data for a single token alownce PermitDetails details; // address permissioned on the allowed tokens address spender; // deadline on the permit signature uint256 sigDeadline; } /// @notice The permit message signed for multiple token allowances struct PermitBatch { // the permit data for multiple token allowances PermitDetails[] details; // address permissioned on the allowed tokens address spender; // deadline on the permit signature uint256 sigDeadline; } /// @notice The saved permissions /// @dev This info is saved per owner, per token, per spender and all signed over in the permit message /// @dev Setting amount to type(uint160).max sets an unlimited approval struct PackedAllowance { // amount allowed uint160 amount; // permission expiry uint48 expiration; // an incrementing value indexed per owner,token,and spender for each signature uint48 nonce; } /// @notice A token spender pair. struct TokenSpenderPair { // the token the spender is approved address token; // the spender address address spender; } /// @notice Details for a token transfer. struct AllowanceTransferDetails { // the owner of the token address from; // the recipient of the token address to; // the amount of the token uint160 amount; // the token to be transferred address token; } /// @notice A mapping from owner address to token address to spender address to PackedAllowance struct, which contains details and conditions of the approval. /// @notice The mapping is indexed in the above order see: allowance[ownerAddress][tokenAddress][spenderAddress] /// @dev The packed slot holds the allowed amount, expiration at which the allowed amount is no longer valid, and current nonce thats updated on any signature based approvals. function allowance(address user, address token, address spender) external view returns (uint160 amount, uint48 expiration, uint48 nonce); /// @notice Approves the spender to use up to amount of the specified token up until the expiration /// @param token The token to approve /// @param spender The spender address to approve /// @param amount The approved amount of the token /// @param expiration The timestamp at which the approval is no longer valid /// @dev The packed allowance also holds a nonce, which will stay unchanged in approve /// @dev Setting amount to type(uint160).max sets an unlimited approval function approve(address token, address spender, uint160 amount, uint48 expiration) external; /// @notice Permit a spender to a given amount of the owners token via the owner's EIP-712 signature /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce /// @param owner The owner of the tokens being approved /// @param permitSingle Data signed over by the owner specifying the terms of approval /// @param signature The owner's signature over the permit data function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external; /// @notice Permit a spender to the signed amounts of the owners tokens via the owner's EIP-712 signature /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce /// @param owner The owner of the tokens being approved /// @param permitBatch Data signed over by the owner specifying the terms of approval /// @param signature The owner's signature over the permit data function permit(address owner, PermitBatch memory permitBatch, bytes calldata signature) external; /// @notice Transfer approved tokens from one address to another /// @param from The address to transfer from /// @param to The address of the recipient /// @param amount The amount of the token to transfer /// @param token The token address to transfer /// @dev Requires the from address to have approved at least the desired amount /// of tokens to msg.sender. function transferFrom(address from, address to, uint160 amount, address token) external; /// @notice Transfer approved tokens in a batch /// @param transferDetails Array of owners, recipients, amounts, and tokens for the transfers /// @dev Requires the from addresses to have approved at least the desired amount /// of tokens to msg.sender. function transferFrom(AllowanceTransferDetails[] calldata transferDetails) external; /// @notice Enables performing a "lockdown" of the sender's Permit2 identity /// by batch revoking approvals /// @param approvals Array of approvals to revoke. function lockdown(TokenSpenderPair[] calldata approvals) external; /// @notice Invalidate nonces for a given (token, spender) pair /// @param token The token to invalidate nonces for /// @param spender The spender to invalidate nonces for /// @param newNonce The new nonce to set. Invalidates all nonces less than it. /// @dev Can't invalidate more than 2**16 nonces per transaction. function invalidateNonces(address token, address spender, uint48 newNonce) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { IAxelarGateway } from './IAxelarGateway.sol'; interface IAxelarExecutable { error InvalidAddress(); error NotApprovedByGateway(); function gateway() external view returns (IAxelarGateway); function execute( bytes32 commandId, string calldata sourceChain, string calldata sourceAddress, bytes calldata payload ) external; function executeWithToken( bytes32 commandId, string calldata sourceChain, string calldata sourceAddress, bytes calldata payload, string calldata tokenSymbol, uint256 amount ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { IGovernable } from './IGovernable.sol'; import { IImplementation } from './IImplementation.sol'; interface IAxelarGateway is IImplementation, IGovernable { /**********\ |* Errors *| \**********/ error NotSelf(); error InvalidCodeHash(); error SetupFailed(); error InvalidAuthModule(); error InvalidTokenDeployer(); error InvalidAmount(); error InvalidChainId(); error InvalidCommands(); error TokenDoesNotExist(string symbol); error TokenAlreadyExists(string symbol); error TokenDeployFailed(string symbol); error TokenContractDoesNotExist(address token); error BurnFailed(string symbol); error MintFailed(string symbol); error InvalidSetMintLimitsParams(); error ExceedMintLimit(string symbol); /**********\ |* Events *| \**********/ event TokenSent( address indexed sender, string destinationChain, string destinationAddress, string symbol, uint256 amount ); event ContractCall( address indexed sender, string destinationChain, string destinationContractAddress, bytes32 indexed payloadHash, bytes payload ); event ContractCallWithToken( address indexed sender, string destinationChain, string destinationContractAddress, bytes32 indexed payloadHash, bytes payload, string symbol, uint256 amount ); event Executed(bytes32 indexed commandId); event TokenDeployed(string symbol, address tokenAddresses); event ContractCallApproved( bytes32 indexed commandId, string sourceChain, string sourceAddress, address indexed contractAddress, bytes32 indexed payloadHash, bytes32 sourceTxHash, uint256 sourceEventIndex ); event ContractCallApprovedWithMint( bytes32 indexed commandId, string sourceChain, string sourceAddress, address indexed contractAddress, bytes32 indexed payloadHash, string symbol, uint256 amount, bytes32 sourceTxHash, uint256 sourceEventIndex ); event ContractCallExecuted(bytes32 indexed commandId); event TokenMintLimitUpdated(string symbol, uint256 limit); event OperatorshipTransferred(bytes newOperatorsData); event Upgraded(address indexed implementation); /********************\ |* Public Functions *| \********************/ function sendToken( string calldata destinationChain, string calldata destinationAddress, string calldata symbol, uint256 amount ) external; function callContract( string calldata destinationChain, string calldata contractAddress, bytes calldata payload ) external; function callContractWithToken( string calldata destinationChain, string calldata contractAddress, bytes calldata payload, string calldata symbol, uint256 amount ) external; function isContractCallApproved( bytes32 commandId, string calldata sourceChain, string calldata sourceAddress, address contractAddress, bytes32 payloadHash ) external view returns (bool); function isContractCallAndMintApproved( bytes32 commandId, string calldata sourceChain, string calldata sourceAddress, address contractAddress, bytes32 payloadHash, string calldata symbol, uint256 amount ) external view returns (bool); function validateContractCall( bytes32 commandId, string calldata sourceChain, string calldata sourceAddress, bytes32 payloadHash ) external returns (bool); function validateContractCallAndMint( bytes32 commandId, string calldata sourceChain, string calldata sourceAddress, bytes32 payloadHash, string calldata symbol, uint256 amount ) external returns (bool); /***********\ |* Getters *| \***********/ function authModule() external view returns (address); function tokenDeployer() external view returns (address); function tokenMintLimit(string memory symbol) external view returns (uint256); function tokenMintAmount(string memory symbol) external view returns (uint256); function allTokensFrozen() external view returns (bool); function implementation() external view returns (address); function tokenAddresses(string memory symbol) external view returns (address); function tokenFrozen(string memory symbol) external view returns (bool); function isCommandExecuted(bytes32 commandId) external view returns (bool); /************************\ |* Governance Functions *| \************************/ function setTokenMintLimits(string[] calldata symbols, uint256[] calldata limits) external; function upgrade( address newImplementation, bytes32 newImplementationCodeHash, bytes calldata setupParams ) external; /**********************\ |* External Functions *| \**********************/ function execute(bytes calldata input) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // General interface for upgradable contracts interface IContractIdentifier { /** * @notice Returns the contract ID. It can be used as a check during upgrades. * @dev Meant to be overridden in derived contracts. * @return bytes32 The contract ID */ function contractId() external pure returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ICoral { /// @notice Fill type that designates what method to be used on the Spoke on the source chain /// upon releasing tokens to the filler. /// SINGLE is used when a batch of orders only contains a single unique order.fromToken, and only requires /// a single transfer to release the tokens for the batch of orders to the order.filler. /// MULTI is used when a batch of orders contains multiple unique order.fromToken, and will use as many /// transfers as there are unique tokens in the batch. enum FillType { // Single token release. SINGLE, // Multi token release. MULTI } /// @notice Defines the cross-chain messaging provider options available for executing interchain transactions. /// Each provider represents a specific protocol for sending and receiving messages across blockchains. enum Provider { AXELAR, LAYERZERO } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IEIP712 { function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title IGovernable Interface * @notice This is an interface used by the AxelarGateway contract to manage governance and mint limiter roles. */ interface IGovernable { error NotGovernance(); error NotMintLimiter(); error InvalidGovernance(); error InvalidMintLimiter(); event GovernanceTransferred(address indexed previousGovernance, address indexed newGovernance); event MintLimiterTransferred(address indexed previousGovernance, address indexed newGovernance); /** * @notice Returns the governance address. * @return address of the governance */ function governance() external view returns (address); /** * @notice Returns the mint limiter address. * @return address of the mint limiter */ function mintLimiter() external view returns (address); /** * @notice Transfer the governance role to another address. * @param newGovernance The new governance address */ function transferGovernance(address newGovernance) external; /** * @notice Transfer the mint limiter role to another address. * @param newGovernance The new mint limiter address */ function transferMintLimiter(address newGovernance) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { IContractIdentifier } from './IContractIdentifier.sol'; interface IImplementation is IContractIdentifier { error NotProxy(); function setup(bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {ISignatureTransfer} from "./ISignatureTransfer.sol"; import {IAllowanceTransfer} from "./IAllowanceTransfer.sol"; /// @notice Permit2 handles signature-based transfers in SignatureTransfer and allowance-based transfers in AllowanceTransfer. /// @dev Users must approve Permit2 before calling any of the transfer functions. interface IPermit2 is ISignatureTransfer, IAllowanceTransfer { // IPermit2 unifies the two interfaces so users have maximal flexibility with their approval. }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IEIP712} from "./IEIP712.sol"; /// @title SignatureTransfer /// @notice Handles ERC20 token transfers through signature based actions /// @dev Requires user's token approval on the Permit2 contract interface ISignatureTransfer is IEIP712 { /// @notice Thrown when the requested amount for a transfer is larger than the permissioned amount /// @param maxAmount The maximum amount a spender can request to transfer error InvalidAmount(uint256 maxAmount); /// @notice Thrown when the number of tokens permissioned to a spender does not match the number of tokens being transferred /// @dev If the spender does not need to transfer the number of tokens permitted, the spender can request amount 0 to be transferred error LengthMismatch(); /// @notice Emits an event when the owner successfully invalidates an unordered nonce. event UnorderedNonceInvalidation(address indexed owner, uint256 word, uint256 mask); /// @notice The token and amount details for a transfer signed in the permit transfer signature struct TokenPermissions { // ERC20 token address address token; // the maximum amount that can be spent uint256 amount; } /// @notice The signed permit message for a single token transfer struct PermitTransferFrom { TokenPermissions permitted; // a unique value for every token owner's signature to prevent signature replays uint256 nonce; // deadline on the permit signature uint256 deadline; } /// @notice Specifies the recipient address and amount for batched transfers. /// @dev Recipients and amounts correspond to the index of the signed token permissions array. /// @dev Reverts if the requested amount is greater than the permitted signed amount. struct SignatureTransferDetails { // recipient address address to; // spender requested amount uint256 requestedAmount; } /// @notice Used to reconstruct the signed permit message for multiple token transfers /// @dev Do not need to pass in spender address as it is required that it is msg.sender /// @dev Note that a user still signs over a spender address struct PermitBatchTransferFrom { // the tokens and corresponding amounts permitted for a transfer TokenPermissions[] permitted; // a unique value for every token owner's signature to prevent signature replays uint256 nonce; // deadline on the permit signature uint256 deadline; } /// @notice A map from token owner address and a caller specified word index to a bitmap. Used to set bits in the bitmap to prevent against signature replay protection /// @dev Uses unordered nonces so that permit messages do not need to be spent in a certain order /// @dev The mapping is indexed first by the token owner, then by an index specified in the nonce /// @dev It returns a uint256 bitmap /// @dev The index, or wordPosition is capped at type(uint248).max function nonceBitmap(address, uint256) external view returns (uint256); /// @notice Transfers a token using a signed permit message /// @dev Reverts if the requested amount is greater than the permitted signed amount /// @param permit The permit data signed over by the owner /// @param owner The owner of the tokens to transfer /// @param transferDetails The spender's requested transfer details for the permitted token /// @param signature The signature to verify function permitTransferFrom( PermitTransferFrom memory permit, SignatureTransferDetails calldata transferDetails, address owner, bytes calldata signature ) external; /// @notice Transfers a token using a signed permit message /// @notice Includes extra data provided by the caller to verify signature over /// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition /// @dev Reverts if the requested amount is greater than the permitted signed amount /// @param permit The permit data signed over by the owner /// @param owner The owner of the tokens to transfer /// @param transferDetails The spender's requested transfer details for the permitted token /// @param witness Extra data to include when checking the user signature /// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash /// @param signature The signature to verify function permitWitnessTransferFrom( PermitTransferFrom memory permit, SignatureTransferDetails calldata transferDetails, address owner, bytes32 witness, string calldata witnessTypeString, bytes calldata signature ) external; /// @notice Transfers multiple tokens using a signed permit message /// @param permit The permit data signed over by the owner /// @param owner The owner of the tokens to transfer /// @param transferDetails Specifies the recipient and requested amount for the token transfer /// @param signature The signature to verify function permitTransferFrom( PermitBatchTransferFrom memory permit, SignatureTransferDetails[] calldata transferDetails, address owner, bytes calldata signature ) external; /// @notice Transfers multiple tokens using a signed permit message /// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition /// @notice Includes extra data provided by the caller to verify signature over /// @param permit The permit data signed over by the owner /// @param owner The owner of the tokens to transfer /// @param transferDetails Specifies the recipient and requested amount for the token transfer /// @param witness Extra data to include when checking the user signature /// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash /// @param signature The signature to verify function permitWitnessTransferFrom( PermitBatchTransferFrom memory permit, SignatureTransferDetails[] calldata transferDetails, address owner, bytes32 witness, string calldata witnessTypeString, bytes calldata signature ) external; /// @notice Invalidates the bits specified in mask for the bitmap at the word position /// @dev The wordPos is maxed at type(uint248).max /// @param wordPos A number to index the nonceBitmap at /// @param mask A bitmap masked against msg.sender's current bitmap at the word position function invalidateUnorderedNonces(uint256 wordPos, uint256 mask) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IAxelarGateway} from "./IAxelarGateway.sol"; import {IAxelarGasService} from "@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGasService.sol"; import {ICoral} from "./ICoral.sol"; import {IPermit2} from "./IPermit2.sol"; import {ISquidMulticall} from "./ISquidMulticall.sol"; /// @title Spoke /// @notice Entry point of the protocol. The Spoke.sol contract manages the state of orders, token transfers, /// and settlement. interface ISpoke is ICoral { /// @notice Order status type that tracks the state of an Order throughout its lifecycle on the Spoke. enum OrderStatus { // Order does not exist. EMPTY, // Order has been created, pending settlement. CREATED, // Order has been settled. SETTLED, // Order has been refunded. REFUNDED } /// @notice Settlement status type that tracks the settlement state of an Order throughout its lifecycle on the Spoke. enum SettlementStatus { // Order settlement does not exist. EMPTY, // Order has been filled. FILLED, // Order has been forwarded to the Hub pending source token release. FORWARDED } /// @notice Calldata format expected by the Spoke.sol contract. struct Order { // Address that will supply the fromAmount of fromToken on the fromChain. address fromAddress; // Address to receive the fillAmount of toToken on the toChain. address toAddress; // Address that will fill the Order on the toChain. address filler; // Address of the ERC20 token being supplied on the fromChain. // 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE in case of native token. address fromToken; // Address of the ERC20 token being supplied on the toChain. // 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE in case of native token. address toToken; // Expiration in UNIX for the Order to be created on the fromChain. uint256 expiry; // Amount of fromToken to be provided by the fromAddress. uint256 fromAmount; // Amount of toToken to be provided by the filler. uint256 fillAmount; // Protocol fees are taken out of the fromAmount and are calculated within the Spoke.sol // contract for single chain orders or on the Hub for cross chain orders. // The following formula determines the amount of fromToken reserved as fees: // fee = (fromAmount * feeRate) / 1000000 uint256 feeRate; // Chain ID of the chain the Order will be created on. uint256 fromChain; // Chain ID of the chain the Order will be filled on. uint256 toChain; // Keccak256 hash of the abi.encoded ISquidMulticall.Call[] calldata calls that should be provided // at the time of filling the order. bytes32 postHookHash; } /// @notice Emitted when the Spoke.sol contract is successfully initialized after contract deployment. /// @param gateway Address set as the relevant Axelar's AxelarGateway.sol contract deployment. /// @param gasService Address set as the relevant Axelar's AxelarGasService.sol contract deployment. /// @param permit2 Address set as the relevant Uniswap's Permit2.sol contract deployment. /// @param squidMulticall Address set as the relevant Squid's SquidMulticall.sol contract deployment. /// @param feeCollector Address set as the EOA that can collect fees from the protocol. /// @param hubChainName Chain name of the chain the Hub.sol contract is deployed to. /// @param hubAddress Address set as the relevant Hub.sol contract. event SpokeInitialized( IAxelarGateway indexed gateway, IAxelarGasService indexed gasService, IPermit2 indexed permit2, ISquidMulticall squidMulticall, address feeCollector, string hubChainName, string hubAddress ); /// @dev Source events /// @notice Emitted when fees are collected from the Spoke.sol contract. /// @param feeCollector Address of the EOA that collected fees. /// @param token Token for which fees were collected. /// @param amount Amount of token for which fees were collected. event FeesCollected( address indexed feeCollector, address indexed token, uint256 indexed amount ); /// @notice Emitted when an Order is created on the source chain. /// @param orderHash Keccak256 hash of the Order that was created. /// @param order Raw Order struct of the Order that was created. event OrderCreated(bytes32 indexed orderHash, Order order); /// @notice Emitted when an Order is refunded on the source chain. /// @param orderHash Keccak256 hash of the Order that was refunded. event OrderRefunded(bytes32 indexed orderHash); /// @notice Emitted when an Order has been settled and tokens released to the filler, completing /// its lifecycle. /// @param orderHash Keccak256 hash of the Order that was settled. event TokensReleased(bytes32 indexed orderHash); /// @dev Destination events /// @notice Emitted when an Order is filled on the source chain. /// @param orderHash Keccak256 hash of the Order that was filled. /// @param order Raw Order struct of the Order that was filled. event OrderFilled(bytes32 indexed orderHash, Order order); /// @notice Emitted when an Order settlement has been forwarded to the Hub for processing. /// @param orderHash Keccak256 hash of the Order that was forwarded. event SettlementForwarded(bytes32 indexed orderHash); /// @notice Thrown when zero msg.value is provided to a function that requires extra native tokens to be /// supplied to pay for gas needs. error GasRequired(); /// @notice Thrown when the order.fromAmount of the provided Order is equal to zero. error InvalidAmount(); /// @notice Thrown when an array has an incorrect length. error InvalidArrayLength(); /// @notice Thrown when the targeted chain is not equal to the order.toChain of the provided Order. error InvalidDestinationChain(); /// @notice Thrown when an invalid FillType is provided to the Axelar GMP targeting the Spoke.sol contract. error InvalidFillType(); /// @notice Thrown when the provided msg.value does not match the order.fromAmount or order.fillAmount of /// the provided Order that deals with native tokens. error InvalidNativeAmount(); /// @notice Thrown when the order.postHookHash of the provided Order does not match the keccak256 hash of /// the abi.encoded ISquidMulticall.Call[] calldata calls provided while filling an Order. error InvalidPostHookProvided(); /// @notice Thrown when an invalid cross-chain messaging provider is provided to the forwarding function. error InvalidProvider(); /// @notice Thrown when the order.filler of a provided Order does not match the provided filler when batching /// single chain settlements. error InvalidSettlementFiller(); /// @notice Thrown when the order.fromToken of a provided Order does not match the provided fromToken when /// batching single chain settlements. error InvalidSettlementSourceToken(); /// @notice Thrown when the targeted chain is not equal to the order.fromChain of the provided Order. error InvalidSourceChain(); /// @notice Thrown when not enough msg.value is provided while batch filling orders involving native tokens. error InvalidTotalNativeAmount(); /// @notice Thrown when an invalid signature is provided while executing gasless intents. error InvalidUserSignature(); /// @notice Thrown when native token is selected as the order.fromToken of a provided Order and passed to a /// function that does not allow native tokens. error NativeTokensNotAllowed(); /// @notice Thrown when the caller address is not equal to the feeCollecter address set within the initializer. error OnlyFeeCollector(); /// @notice Thrown when the caller msg.sender is not equal to the order.filler of the provided Order. error OnlyFillerCanSettle(); /// @notice Thrown when an Axelar GMP is executed from an address or chain that does not match the /// hubChainName and hubAddress set within the initializer. error OnlyTrustedAddress(); /// @notice Thrown when the orderHashToStatus of the orderHash of the provided Order is not in the // required OrderStatus.EMPTY state. error OrderAlreadyExists(); /// @notice Thrown when the settlementToStatus of the orderHash of the provided Order is not in the // required SettlementStatus.EMPTY state. error OrderAlreadySettled(); /// @notice Thrown when the current block.timestamp is greater than the order.expiry of the provided Order. error OrderExpired(); /// @notice Thrown when the current block.timestamp is not greater than the order.expiry + buffer /// when attempting to refund an order. error OrderNotExpired(); /// @notice Thrown when the settlementToStatus of the orderHash of the provided Order is not in the // required SettlementStatus.FILLED state. error OrderNotSettled(); /// @notice Thrown when the orderHashToStatus of the orderHash of the provided Order is not in the // required OrderStatus.CREATED state. error OrderStateNotCreated(); /// @notice Thrown when the order.fromToken of a provided Order is not a native token and a non-zero /// msg.value is provided. error UnexpectedNativeToken(); /// @notice Thrown when a LayerZero GMP is executed from an address that does not match the hubAddressBytes32 /// set within the initializer. error UnauthorizedOriginAddress(); /// @notice Thrown when a LayerZero GMP is executed from an inactive or unapproved chain endpoint. error UnauthorizedOriginEndpoint(); /// @notice Executes the intent on the source chain, locking the ERC20 or native tokens in the /// Spoke.sol contract, setting the OrderStatus to CREATED, and making the order eligible /// to be filled on the destination chain. /// @dev Orders are tied to the keccak256 hash of the Order therefore each Order is unique /// according to the parameters in the Order and can only be executed a single time. Using this /// method tokens will transfer from the msg.sender, but the order will belong to the /// order.fromAddress. /// @param order Order to be executed by the Spoke.sol contract in the format of the Order struct. function createOrder(Order calldata order) external payable; /// @notice Executes the intent on behalf of the Order signer gaslessly on the source chain, locking /// the ERC20 or native tokens in the Spoke.sol contract, setting the OrderStatus to CREATED, and /// making the order eligible to be filled on the destination chain. /// @dev Orders are tied to the keccak256 hash of the Order therefore each Order is unique /// according to the parameters in the Order and can only be executed a single time. Using this /// method tokens will transfer from the order.fromAddress. /// @dev The intent can be executed by the signer or a separate relayer on behalf of the signer. /// @dev This method requires the Order signer to have already approved the Spoke.sol contract to /// spend the ERC20 order.fromToken. /// @dev This method cannot be used with native tokens as it requires transferring tokens from the /// signer at the time the intent is sponsored. /// @param order Order to be executed by the Spoke.sol contract in the format of the Order struct. /// @param signature Signature calldata according to EIP-712 using eth_signTypedData_v4. function sponsorOrder(Order calldata order, bytes calldata signature) external; /// @notice Executes the intent on behalf of the Order signer gaslessly on the source chain using /// Uniswap's Permit2 contract, locking the ERC20 or native tokens in the Spoke.sol contract, setting /// the OrderStatus to CREATED, and making the order eligible to be filled on the destination chain. /// @dev Orders are tied to the keccak256 hash of the Order therefore each Order is unique /// according to the parameters in the Order and can only be executed a single time. Using this /// method tokens will transfer from the order.fromAddress. /// @dev The intent can be executed by the signer or a separate relayer on behalf of the signer. /// @dev This method requires the Order signer to have already approved the Uniswap Permit2 /// contract on the order.fromChain for order.fromAmount of ERC20 order.fromToken. /// @dev See https://docs.uniswap.org/contracts/permit2/reference/signature-transfer for more /// information about permit2 protocol requirements. /// @dev This method cannot be used with native tokens as it requires transferring tokens from the /// signer at the time the intent is sponsored. /// @param order Order to be executed by the Spoke.sol contract in the format of the Order struct. /// @param permit Permit data according to permit2 protocol. /// @param signature Signature data according to permit2 protocol. function sponsorOrderUsingPermit2( Order calldata order, IPermit2.PermitTransferFrom calldata permit, bytes calldata signature ) external; /// @notice Refunds an eligible Order, transferring the order.fromAmount of order.fromToken from /// the Spoke.sol contract to the order.fromAddress. /// @dev Orders can be instantly refunded by the order.filler if the filler decides they don't wish /// to fill the order. /// @dev Orders can be refunded by anyone as long is the block.timestamp of the target chain is /// greater than the order.expiry + 24 hours. /// @param order Order to be refunded by the Spoke.sol contract in the format of the Order struct. function refundOrder(Order calldata order) external; /// @notice Transfers collected protocol fees from the Spoke.sol contract to the feeCollector and /// sets the fee balance for the provided tokens to zero. /// @dev Fees can be collected for all ERC20 and native tokens, this method will transfer the full /// balance of the currently collected fees per token provided. /// @param tokens Array of ERC20 tokens to collect fees for. function collectFees(address[] calldata tokens) external; /// @notice Fills orders in batches on the destination chain, transferring the order.fillAmount of /// order.toToken from the order.filler to the order.toAddress, setting the SettlementStatus to /// FILLED, and all orders in the batch eligible to be forwarded to the Hub for processing. /// @dev Orders that contain post hooks (postHookHash != bytes32(0)) require SquidMulticall calls /// to be provided during fill. These extra calls will be ran by SquidMulticall after filling the /// order during the same transaction. /// @dev Only the order.filler can fill any particular order. /// @dev In the case of filling native token orders in batches, the provided msg.value must be greater /// than or equal to the total order.fillAmount of native tokens in the batch. Batches can be a mix of /// ERC20 and native tokens. /// @param orders Array of Orders to be filled by the Spoke.sol contract in the format of the Order struct. /// @param calls Array of Calls to be ran by the multicall after fill, formatted to the SquidMulticall /// Call struct. function batchFillOrder(Order[] calldata orders, ISquidMulticall.Call[][] calldata calls) external payable; /// @notice Fills an order on the destination chain, transferring the order.fillAmount of /// order.toToken from the order.filler to the order.toAddress, setting the SettlementStatus to /// FILLED, and making the order eligible to be forwarded to the Hub for processing. /// @dev Orders that contain post hooks (postHookHash != bytes32(0)) require SquidMulticall calls /// to be provided during fill. These extra calls will be ran by SquidMulticall after filling the /// order during the same transaction. /// @dev Only the order.filler can fill any particular order. /// @param order Order to be filled by the Spoke.sol contract in the format of the Order struct. /// @param calls Calls to be ran by the multicall after fill, formatted to the SquidMulticall Call struct. function fillOrder(Order calldata order, ISquidMulticall.Call[] calldata calls) external payable; /// @notice Sets the SettlementStatus of orders to FORWARDED and executes an Axelar GMP containing /// an array of eligible order hashes to be sent cross chain to the Hub for processing. /// @dev Provided orders must have the settlementToStatus set FILLED to be eligible to be forwarded. /// @dev Gas is required in the form of native tokens, therefore the msg.value must contain enough /// native token to pay for the Axelar GMP and execution costs of the calldata on the Hub. /// @dev It is recommended to forward settlements in batches, the number of orders that can be forwarded /// in a batch is dependent on the block gas limit of the particular chain. /// @param orderHashes Array of order hashes to be forwarded by the Spoke.sol contract. /// @param lzFee LayerZero-specific additional fee required to forward the settlement via LayerZero. /// @param gasLimit Execution gas limit for the Message Passing to enforce execution constraints. /// @param provider Enum indicating whether the forwarding is done through AXELAR or LAYERZERO provider. function forwardSettlements( bytes32[] calldata orderHashes, uint256 lzFee, uint128 gasLimit, Provider provider ) external payable; /// @notice Processes filled single chain orders, setting the SettlementStatus to FORWARDED and /// OrderStatus to SETTLED for eligible orders, calculates the fee amount based on the order.feeRate /// for each token in a particular batch, and transfers the total amount of order.fromAmount (minus /// the fee amount) of each order.fromToken from the Spoke.sol contract to the order.filler, and increments /// the available protocol fees for each order.fromToken according to the calculated fees for the orders /// being processed, completing the lifecycle of single chain orders. /// @dev Provided orders must have the SettlementStatus set to FILLED and OrderStatus set to CREATED /// to be eligible. /// @dev This method is only available for single chain orders and does not require an Axelar GMP. /// @dev This method is only available for a single filler therefore the order.filler of all orders in a /// batch must be equal. /// @dev This method can be used with multiple from tokens. For example, if there are 100 orders in a batch /// and of all order.fromToken there are 10 unique tokens, this function only requires the 10 unique tokens /// to be passed as the fromTokens. This will execute 10 transfers from the Spoke.sol contract to the /// order.filler for the total amount of order.fromAmount for each unique token being processed. /// @dev It is recommended to process settlements in batches, the number of orders that can be processed /// in a batch is dependent on the block gas limit of the particular chain. /// @param orders Array of single chain Orders to be processed by the Spoke.sol contract in the format of /// the Order struct. /// @param fromTokens Array of addresses for all unique order.fromToken in a particular batch. /// @param filler Address of the order.filler for all orders in the particular batch. function batchMultiTokenSingleChainSettlements( Order[] calldata orders, address[] calldata fromTokens, address filler ) external payable; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /// @title SquidMulticall /// @notice Multicall logic specific to Squid calls format. The contract specificity is mainly /// to enable ERC20 and native token amounts in calldata between two calls. /// @dev Support receiption of NFTs. interface ISquidMulticall { /// @notice Call type that enables to specific behaviours of the multicall. enum CallType { // Will simply run calldata Default, // Will update amount field in calldata with ERC20 token balance of the multicall contract. FullTokenBalance, // Will update amount field in calldata with native token balance of the multicall contract. FullNativeBalance, // Will run a safeTransferFrom to get full ERC20 token balance of the caller. CollectTokenBalance } /// @notice Calldata format expected by multicall. struct Call { // Call type, see CallType struct description. CallType callType; // Address that will be called. address target; // Native token amount that will be sent in call. uint256 value; // Calldata that will be send in call. bytes callData; // Extra data used by multicall depending on call type. // Default: unused (provide 0x) // FullTokenBalance: address of the ERC20 token to get balance of and zero indexed position // of the amount parameter to update in function call contained by calldata. // Expect format is: abi.encode(address token, uint256 amountParameterPosition) // Eg: for function swap(address tokenIn, uint amountIn, address tokenOut, uint amountOutMin,) // amountParameterPosition would be 1. // FullNativeBalance: unused (provide 0x) // CollectTokenBalance: address of the ERC20 token to collect. // Expect format is: abi.encode(address token) bytes payload; } /// Thrown when one of the calls fails. /// @param callPosition Zero indexed position of the call in the call set provided to the /// multicall. /// @param reason Revert data returned by contract called in failing call. error CallFailed(uint256 callPosition, bytes reason); /// @notice Main function of the multicall that runs the call set. /// @param calls Call set to be ran by multicall. function run(Call[] calldata calls) external payable; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; /// @title Utils /// @notice Library for general purpose functions and values. library Utils { using Address for address payable; /// @notice Arbitrary address chosen to represent native token of current network. address internal constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; bytes32 internal constant ORDER_TYPEHASH = keccak256("Order(address fromAddress,address toAddress,address filler,address fromToken,address toToken,uint256 expiry,uint256 fromAmount,uint256 fillAmount,uint256 feeRate,uint256 fromChain,uint256 toChain,bytes32 postHookHash)"); string internal constant ORDER_WITNESS_TYPE_STRING = "Order witness)Order(address fromAddress,address toAddress,address filler,address fromToken,address toToken,uint256 expiry,uint256 fromAmount,uint256 fillAmount,uint256 feeRate,uint256 fromChain,uint256 toChain,bytes32 postHookHash)TokenPermissions(address token,uint256 amount)"; uint256 internal constant FEE_DIVISOR = 1000000; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { IMessageLibManager } from "./IMessageLibManager.sol"; import { IMessagingComposer } from "./IMessagingComposer.sol"; import { IMessagingChannel } from "./IMessagingChannel.sol"; import { IMessagingContext } from "./IMessagingContext.sol"; struct MessagingParams { uint32 dstEid; bytes32 receiver; bytes message; bytes options; bool payInLzToken; } struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; } struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; } struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; } interface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext { event PacketSent(bytes encodedPayload, bytes options, address sendLibrary); event PacketVerified(Origin origin, address receiver, bytes32 payloadHash); event PacketDelivered(Origin origin, address receiver); event LzReceiveAlert( address indexed receiver, address indexed executor, Origin origin, bytes32 guid, uint256 gas, uint256 value, bytes message, bytes extraData, bytes reason ); event LzTokenSet(address token); event DelegateSet(address sender, address delegate); function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory); function send( MessagingParams calldata _params, address _refundAddress ) external payable returns (MessagingReceipt memory); function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external; function verifiable(Origin calldata _origin, address _receiver) external view returns (bool); function initializable(Origin calldata _origin, address _receiver) external view returns (bool); function lzReceive( Origin calldata _origin, address _receiver, bytes32 _guid, bytes calldata _message, bytes calldata _extraData ) external payable; // oapp can burn messages partially by calling this function with its own business logic if messages are verified in order function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external; function setLzToken(address _lzToken) external; function lzToken() external view returns (address); function nativeToken() external view returns (address); function setDelegate(address _delegate) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { Origin } from "./ILayerZeroEndpointV2.sol"; interface ILayerZeroReceiver { function allowInitializePath(Origin calldata _origin) external view returns (bool); function nextNonce(uint32 _eid, bytes32 _sender) external view returns (uint64); function lzReceive( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address _executor, bytes calldata _extraData ) external payable; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; struct SetConfigParam { uint32 eid; uint32 configType; bytes config; } interface IMessageLibManager { struct Timeout { address lib; uint256 expiry; } event LibraryRegistered(address newLib); event DefaultSendLibrarySet(uint32 eid, address newLib); event DefaultReceiveLibrarySet(uint32 eid, address newLib); event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry); event SendLibrarySet(address sender, uint32 eid, address newLib); event ReceiveLibrarySet(address receiver, uint32 eid, address newLib); event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout); function registerLibrary(address _lib) external; function isRegisteredLibrary(address _lib) external view returns (bool); function getRegisteredLibraries() external view returns (address[] memory); function setDefaultSendLibrary(uint32 _eid, address _newLib) external; function defaultSendLibrary(uint32 _eid) external view returns (address); function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _gracePeriod) external; function defaultReceiveLibrary(uint32 _eid) external view returns (address); function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external; function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry); function isSupportedEid(uint32 _eid) external view returns (bool); function isValidReceiveLibrary(address _receiver, uint32 _eid, address _lib) external view returns (bool); /// ------------------- OApp interfaces ------------------- function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external; function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib); function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool); function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external; function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault); function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _expiry) external; function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry); function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external; function getConfig( address _oapp, address _lib, uint32 _eid, uint32 _configType ) external view returns (bytes memory config); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface IMessagingChannel { event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce); event PacketNilified(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash); event PacketBurnt(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash); function eid() external view returns (uint32); // this is an emergency function if a message cannot be verified for some reasons // required to provide _nextNonce to avoid race condition function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external; function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external; function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external; function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32); function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64); function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64); function inboundPayloadHash( address _receiver, uint32 _srcEid, bytes32 _sender, uint64 _nonce ) external view returns (bytes32); function lazyInboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface IMessagingComposer { event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message); event ComposeDelivered(address from, address to, bytes32 guid, uint16 index); event LzComposeAlert( address indexed from, address indexed to, address indexed executor, bytes32 guid, uint16 index, uint256 gas, uint256 value, bytes message, bytes extraData, bytes reason ); function composeQueue( address _from, address _to, bytes32 _guid, uint16 _index ) external view returns (bytes32 messageHash); function sendCompose(address _to, bytes32 _guid, uint16 _index, bytes calldata _message) external; function lzCompose( address _from, address _to, bytes32 _guid, uint16 _index, bytes calldata _message, bytes calldata _extraData ) external payable; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface IMessagingContext { function isSendingMessage() external view returns (bool); function getSendContext() external view returns (uint32 dstEid, address sender); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { ILayerZeroEndpointV2 } from "./ILayerZeroEndpointV2.sol"; /** * @title IOAppCore */ interface IOAppCore { // Custom error messages error OnlyPeer(uint32 eid, bytes32 sender); error NoPeer(uint32 eid); error InvalidEndpointCall(); error InvalidDelegate(); // Event emitted when a peer (OApp) is set for a corresponding endpoint event PeerSet(uint32 eid, bytes32 peer); /** * @notice Retrieves the OApp version information. * @return senderVersion The version of the OAppSender.sol contract. * @return receiverVersion The version of the OAppReceiver.sol contract. */ function oAppVersion() external view returns (uint64 senderVersion, uint64 receiverVersion); /** * @notice Retrieves the LayerZero endpoint associated with the OApp. * @return iEndpoint The LayerZero endpoint as an interface. */ function endpoint() external view returns (ILayerZeroEndpointV2 iEndpoint); /** * @notice Retrieves the peer (OApp) associated with a corresponding endpoint. * @param _eid The endpoint ID. * @return peer The peer address (OApp instance) associated with the corresponding endpoint. */ function peers(uint32 _eid) external view returns (bytes32 peer); /** * @notice Sets the peer address (OApp instance) for a corresponding endpoint. * @param _eid The endpoint ID. * @param _peer The address of the peer to be associated with the corresponding endpoint. */ function setPeer(uint32 _eid, bytes32 _peer) external; /** * @notice Sets the delegate address for the OApp Core. * @param _delegate The address of the delegate to be set. */ function setDelegate(address _delegate) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { ILayerZeroReceiver, Origin } from "./ILayerZeroReceiver.sol"; interface IOAppReceiver is ILayerZeroReceiver { /** * @notice Indicates whether an address is an approved composeMsg sender to the Endpoint. * @param _origin The origin information containing the source endpoint and sender address. * - srcEid: The source chain endpoint ID. * - sender: The sender address on the src chain. * - nonce: The nonce of the message. * @param _message The lzReceive payload. * @param _sender The sender address. * @return isSender Is a valid sender. * * @dev Applications can optionally choose to implement a separate composeMsg sender that is NOT the bridging layer. * @dev The default sender IS the OAppReceiver implementer. */ function isComposeMsgSender( Origin calldata _origin, bytes calldata _message, address _sender ) external view returns (bool isSender); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; // @dev Import the 'MessagingFee' and 'MessagingReceipt' so it's exposed to OApp implementers // solhint-disable-next-line no-unused-import import { OAppSender, MessagingFee, MessagingReceipt } from "./OAppSender.sol"; // @dev Import the 'Origin' so it's exposed to OApp implementers // solhint-disable-next-line no-unused-import import { OAppReceiver, Origin } from "./OAppReceiver.sol"; import { OAppCore } from "./OAppCore.sol"; /** * @title OApp * @dev Abstract contract serving as the base for OApp implementation, combining OAppSender and OAppReceiver functionality. */ abstract contract OApp is OAppSender, OAppReceiver { /** * @dev Constructor to initialize the OApp with the provided endpoint and owner. * @param _endpoint The address of the LOCAL LayerZero endpoint. * @param _delegate The delegate capable of making OApp configurations inside of the endpoint. */ constructor(address _endpoint, address _delegate) OAppCore(_endpoint, _delegate) {} /** * @notice Retrieves the OApp version information. * @return senderVersion The version of the OAppSender.sol implementation. * @return receiverVersion The version of the OAppReceiver.sol implementation. */ function oAppVersion() public pure virtual override(OAppSender, OAppReceiver) returns (uint64 senderVersion, uint64 receiverVersion) { return (SENDER_VERSION, RECEIVER_VERSION); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IOAppCore, ILayerZeroEndpointV2 } from "./interfaces/IOAppCore.sol"; /** * @title OAppCore * @dev Abstract contract implementing the IOAppCore interface with basic OApp configurations. */ abstract contract OAppCore is IOAppCore, Ownable { // The LayerZero endpoint associated with the given OApp ILayerZeroEndpointV2 public endpoint; // Mapping to store peers associated with corresponding endpoints mapping(uint32 eid => bytes32 peer) public peers; /** * @dev Constructor to initialize the OAppCore with the provided endpoint and delegate. * @param _endpoint The address of the LOCAL Layer Zero endpoint. * @param _delegate The delegate capable of making OApp configurations inside of the endpoint. * * @dev The delegate typically should be set as the owner of the contract. */ constructor(address _endpoint, address _delegate) { endpoint = ILayerZeroEndpointV2(_endpoint); if (_delegate == address(0)) revert InvalidDelegate(); // endpoint.setDelegate(_delegate); } /** * @notice Sets the peer address (OApp instance) for a corresponding endpoint. * @param _eid The endpoint ID. * @param _peer The address of the peer to be associated with the corresponding endpoint. * * @dev Only the owner/admin of the OApp can call this function. * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp. * @dev Set this to bytes32(0) to remove the peer address. * @dev Peer is a bytes32 to accommodate non-evm chains. */ function setPeer(uint32 _eid, bytes32 _peer) public virtual onlyOwner { _setPeer(_eid, _peer); } /** * @notice Sets the peer address (OApp instance) for a corresponding endpoint. * @param _eid The endpoint ID. * @param _peer The address of the peer to be associated with the corresponding endpoint. * * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp. * @dev Set this to bytes32(0) to remove the peer address. * @dev Peer is a bytes32 to accommodate non-evm chains. */ function _setPeer(uint32 _eid, bytes32 _peer) internal virtual { peers[_eid] = _peer; emit PeerSet(_eid, _peer); } /** * @notice Internal function to get the peer address associated with a specific endpoint; reverts if NOT set. * ie. the peer is set to bytes32(0). * @param _eid The endpoint ID. * @return peer The address of the peer associated with the specified endpoint. */ function _getPeerOrRevert(uint32 _eid) internal view virtual returns (bytes32) { bytes32 peer = peers[_eid]; if (peer == bytes32(0)) revert NoPeer(_eid); return peer; } /** * @notice Sets the delegate address for the OApp. * @param _delegate The address of the delegate to be set. * * @dev Only the owner/admin of the OApp can call this function. * @dev Provides the ability for a delegate to set configs, on behalf of the OApp, directly on the Endpoint contract. */ function setDelegate(address _delegate) public onlyOwner { endpoint.setDelegate(_delegate); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { IOAppReceiver, Origin } from "./interfaces/IOAppReceiver.sol"; import { OAppCore } from "./OAppCore.sol"; /** * @title OAppReceiver * @dev Abstract contract implementing the ILayerZeroReceiver interface and extending OAppCore for OApp receivers. */ abstract contract OAppReceiver is IOAppReceiver, OAppCore { // Custom error message for when the caller is not the registered endpoint/ error OnlyEndpoint(address addr); // @dev The version of the OAppReceiver implementation. // @dev Version is bumped when changes are made to this contract. uint64 internal constant RECEIVER_VERSION = 2; /** * @notice Retrieves the OApp version information. * @return senderVersion The version of the OAppSender.sol contract. * @return receiverVersion The version of the OAppReceiver.sol contract. * * @dev Providing 0 as the default for OAppSender version. Indicates that the OAppSender is not implemented. * ie. this is a RECEIVE only OApp. * @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions. */ function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) { return (0, RECEIVER_VERSION); } /** * @notice Indicates whether an address is an approved composeMsg sender to the Endpoint. * @dev _origin The origin information containing the source endpoint and sender address. * - srcEid: The source chain endpoint ID. * - sender: The sender address on the src chain. * - nonce: The nonce of the message. * @dev _message The lzReceive payload. * @param _sender The sender address. * @return isSender Is a valid sender. * * @dev Applications can optionally choose to implement separate composeMsg senders that are NOT the bridging layer. * @dev The default sender IS the OAppReceiver implementer. */ function isComposeMsgSender( Origin calldata /*_origin*/, bytes calldata /*_message*/, address _sender ) public view virtual returns (bool) { return _sender == address(this); } /** * @notice Checks if the path initialization is allowed based on the provided origin. * @param origin The origin information containing the source endpoint and sender address. * @return Whether the path has been initialized. * * @dev This indicates to the endpoint that the OApp has enabled msgs for this particular path to be received. * @dev This defaults to assuming if a peer has been set, its initialized. * Can be overridden by the OApp if there is other logic to determine this. */ function allowInitializePath(Origin calldata origin) public view virtual returns (bool) { return peers[origin.srcEid] == origin.sender; } /** * @notice Retrieves the next nonce for a given source endpoint and sender address. * @dev _srcEid The source endpoint ID. * @dev _sender The sender address. * @return nonce The next nonce. * * @dev The path nonce starts from 1. If 0 is returned it means that there is NO nonce ordered enforcement. * @dev Is required by the off-chain executor to determine the OApp expects msg execution is ordered. * @dev This is also enforced by the OApp. * @dev By default this is NOT enabled. ie. nextNonce is hardcoded to return 0. */ function nextNonce(uint32 /*_srcEid*/, bytes32 /*_sender*/) public view virtual returns (uint64 nonce) { return 0; } /** * @dev Entry point for receiving messages or packets from the endpoint. * @param _origin The origin information containing the source endpoint and sender address. * - srcEid: The source chain endpoint ID. * - sender: The sender address on the src chain. * - nonce: The nonce of the message. * @param _guid The unique identifier for the received LayerZero message. * @param _message The payload of the received message. * @param _executor The address of the executor for the received message. * @param _extraData Additional arbitrary data provided by the corresponding executor. * * @dev Entry point for receiving msg/packet from the LayerZero endpoint. */ function lzReceive( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address _executor, bytes calldata _extraData ) public payable virtual { // Ensures that only the endpoint can attempt to lzReceive() messages to this OApp. if (address(endpoint) != msg.sender) revert OnlyEndpoint(msg.sender); // Ensure that the sender matches the expected peer for the source endpoint. if (_getPeerOrRevert(_origin.srcEid) != _origin.sender) revert OnlyPeer(_origin.srcEid, _origin.sender); // Call the internal OApp implementation of lzReceive. _lzReceive(_origin, _guid, _message, _executor, _extraData); } /** * @dev Internal function to implement lzReceive logic without needing to copy the basic parameter validation. */ function _lzReceive( Origin calldata _origin, bytes32 _guid, bytes calldata _message, address _executor, bytes calldata _extraData ) internal virtual; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { MessagingParams, MessagingFee, MessagingReceipt } from "./interfaces/ILayerZeroEndpointV2.sol"; import { OAppCore } from "./OAppCore.sol"; /** * @title OAppSender * @dev Abstract contract implementing the OAppSender functionality for sending messages to a LayerZero endpoint. */ abstract contract OAppSender is OAppCore { using SafeERC20 for IERC20; // Custom error messages error NotEnoughNative(uint256 msgValue); error LzTokenUnavailable(); // @dev The version of the OAppSender implementation. // @dev Version is bumped when changes are made to this contract. uint64 internal constant SENDER_VERSION = 1; /** * @notice Retrieves the OApp version information. * @return senderVersion The version of the OAppSender.sol contract. * @return receiverVersion The version of the OAppReceiver.sol contract. * * @dev Providing 0 as the default for OAppReceiver version. Indicates that the OAppReceiver is not implemented. * ie. this is a SEND only OApp. * @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions */ function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) { return (SENDER_VERSION, 0); } /** * @dev Internal function to interact with the LayerZero EndpointV2.quote() for fee calculation. * @param _dstEid The destination endpoint ID. * @param _message The message payload. * @param _options Additional options for the message. * @param _payInLzToken Flag indicating whether to pay the fee in LZ tokens. * @return fee The calculated MessagingFee for the message. * - nativeFee: The native fee for the message. * - lzTokenFee: The LZ token fee for the message. */ function _quote( uint32 _dstEid, bytes memory _message, bytes memory _options, bool _payInLzToken ) internal view virtual returns (MessagingFee memory fee) { return endpoint.quote( MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _payInLzToken), address(this) ); } /** * @dev Internal function to interact with the LayerZero EndpointV2.send() for sending a message. * @param _dstEid The destination endpoint ID. * @param _message The message payload. * @param _options Additional options for the message. * @param _fee The calculated LayerZero fee for the message. * - nativeFee: The native fee. * - lzTokenFee: The lzToken fee. * @param _refundAddress The address to receive any excess fee values sent to the endpoint. * @return receipt The receipt for the sent message. * - guid: The unique identifier for the sent message. * - nonce: The nonce of the sent message. * - fee: The LayerZero fee incurred for the message. */ function _lzSend( uint32 _dstEid, bytes memory _message, bytes memory _options, MessagingFee memory _fee, address _refundAddress ) internal virtual returns (MessagingReceipt memory receipt) { // @dev Push corresponding fees to the endpoint, any excess is sent back to the _refundAddress from the endpoint. uint256 messageValue = _payNative(_fee.nativeFee); if (_fee.lzTokenFee > 0) _payLzToken(_fee.lzTokenFee); return // solhint-disable-next-line check-send-result endpoint.send{ value: messageValue }( MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _fee.lzTokenFee > 0), _refundAddress ); } /** * @dev Internal function to pay the native fee associated with the message. * @param _nativeFee The native fee to be paid. * @return nativeFee The amount of native currency paid. * * @dev If the OApp needs to initiate MULTIPLE LayerZero messages in a single transaction, * this will need to be overridden because msg.value would contain multiple lzFees. * @dev Should be overridden in the event the LayerZero endpoint requires a different native currency. * @dev Some EVMs use an ERC20 as a method for paying transactions/gasFees. * @dev The endpoint is EITHER/OR, ie. it will NOT support both types of native payment at a time. */ function _payNative(uint256 _nativeFee) internal virtual returns (uint256 nativeFee) { if (msg.value != _nativeFee) revert NotEnoughNative(msg.value); return _nativeFee; } /** * @dev Internal function to pay the LZ token fee associated with the message. * @param _lzTokenFee The LZ token fee to be paid. * * @dev If the caller is trying to pay in the specified lzToken, then the lzTokenFee is passed to the endpoint. * @dev Any excess sent, is passed back to the specified _refundAddress in the _lzSend(). */ function _payLzToken(uint256 _lzTokenFee) internal virtual { // @dev Cannot cache the token because it is not immutable in the endpoint. address lzToken = endpoint.lzToken(); if (lzToken == address(0)) revert LzTokenUnavailable(); // Pay LZ token fee by sending tokens to the endpoint. IERC20(lzToken).safeTransferFrom(msg.sender, address(endpoint), _lzTokenFee); } }
// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.8.0 <0.9.0; library BytesLib { function concat( bytes memory _preBytes, bytes memory _postBytes ) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore(0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. )) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore( sc, add( and( fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00 ), and(mload(mc), mask) ) ) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1 , "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equal_nonAligned(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let endMinusWord := add(_preBytes, length) let mc := add(_preBytes, 0x20) let cc := add(_postBytes, 0x20) for { // the next line is the loop condition: // while(uint256(mc < endWord) + cb == 2) } eq(add(lt(mc, endMinusWord), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } // Only if still successful // For <1 word tail bytes if gt(success, 0) { // Get the remainder of length/32 // length % 32 = AND(length, 32 - 1) let numTailBytes := and(length, 0x1f) let mcRem := mload(mc) let ccRem := mload(cc) for { let i := 0 // the next line is the loop condition: // while(uint256(i < numTailBytes) + cb == 2) } eq(add(lt(i, numTailBytes), cb), 2) { i := add(i, 1) } { if iszero(eq(byte(i, mcRem), byte(i, ccRem))) { // unsuccess: success := 0 cb := 0 } } } } default { // unsuccess: success := 0 } } return success; } function equalStorage( bytes storage _preBytes, bytes memory _postBytes ) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for {} eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
{ "optimizer": { "enabled": true, "runs": 9999 }, "viaIR": true, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"GasRequired","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidArrayLength","type":"error"},{"inputs":[],"name":"InvalidDelegate","type":"error"},{"inputs":[],"name":"InvalidDestinationChain","type":"error"},{"inputs":[],"name":"InvalidEndpointCall","type":"error"},{"inputs":[],"name":"InvalidFillType","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidNativeAmount","type":"error"},{"inputs":[{"internalType":"uint16","name":"optionType","type":"uint16"}],"name":"InvalidOptionType","type":"error"},{"inputs":[],"name":"InvalidPostHookProvided","type":"error"},{"inputs":[],"name":"InvalidProvider","type":"error"},{"inputs":[],"name":"InvalidSettlementFiller","type":"error"},{"inputs":[],"name":"InvalidSettlementSourceToken","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[],"name":"InvalidSourceChain","type":"error"},{"inputs":[],"name":"InvalidTotalNativeAmount","type":"error"},{"inputs":[],"name":"InvalidUserSignature","type":"error"},{"inputs":[],"name":"LengthMismatch","type":"error"},{"inputs":[],"name":"LzTokenUnavailable","type":"error"},{"inputs":[],"name":"NativeTokensNotAllowed","type":"error"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"}],"name":"NoPeer","type":"error"},{"inputs":[],"name":"NotApprovedByGateway","type":"error"},{"inputs":[{"internalType":"uint256","name":"msgValue","type":"uint256"}],"name":"NotEnoughNative","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"OnlyEndpoint","type":"error"},{"inputs":[],"name":"OnlyFeeCollector","type":"error"},{"inputs":[],"name":"OnlyFillerCanSettle","type":"error"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"}],"name":"OnlyPeer","type":"error"},{"inputs":[],"name":"OnlyTrustedAddress","type":"error"},{"inputs":[],"name":"OrderAlreadyExists","type":"error"},{"inputs":[],"name":"OrderAlreadySettled","type":"error"},{"inputs":[],"name":"OrderExpired","type":"error"},{"inputs":[],"name":"OrderNotExpired","type":"error"},{"inputs":[],"name":"OrderNotSettled","type":"error"},{"inputs":[],"name":"OrderStateNotCreated","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","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":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"UnauthorizedOriginAddress","type":"error"},{"inputs":[],"name":"UnauthorizedOriginEndpoint","type":"error"},{"inputs":[],"name":"UnexpectedNativeToken","type":"error"},{"inputs":[],"name":"UntrustedChain","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroStringLength","type":"error"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"feeCollector","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeesCollected","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":"orderHash","type":"bytes32"},{"components":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"toAddress","type":"address"},{"internalType":"address","name":"filler","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"fillAmount","type":"uint256"},{"internalType":"uint256","name":"feeRate","type":"uint256"},{"internalType":"uint256","name":"fromChain","type":"uint256"},{"internalType":"uint256","name":"toChain","type":"uint256"},{"internalType":"bytes32","name":"postHookHash","type":"bytes32"}],"indexed":false,"internalType":"struct ISpoke.Order","name":"order","type":"tuple"}],"name":"OrderCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderHash","type":"bytes32"},{"components":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"toAddress","type":"address"},{"internalType":"address","name":"filler","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"fillAmount","type":"uint256"},{"internalType":"uint256","name":"feeRate","type":"uint256"},{"internalType":"uint256","name":"fromChain","type":"uint256"},{"internalType":"uint256","name":"toChain","type":"uint256"},{"internalType":"bytes32","name":"postHookHash","type":"bytes32"}],"indexed":false,"internalType":"struct ISpoke.Order","name":"order","type":"tuple"}],"name":"OrderFilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderHash","type":"bytes32"}],"name":"OrderRefunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"eid","type":"uint32"},{"indexed":false,"internalType":"bytes32","name":"peer","type":"bytes32"}],"name":"PeerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderHash","type":"bytes32"}],"name":"SettlementForwarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IAxelarGateway","name":"gateway","type":"address"},{"indexed":true,"internalType":"contract IAxelarGasService","name":"gasService","type":"address"},{"indexed":true,"internalType":"contract IPermit2","name":"permit2","type":"address"},{"indexed":false,"internalType":"contract ISquidMulticall","name":"squidMulticall","type":"address"},{"indexed":false,"internalType":"address","name":"feeCollector","type":"address"},{"indexed":false,"internalType":"string","name":"hubChainName","type":"string"},{"indexed":false,"internalType":"string","name":"hubAddress","type":"string"}],"name":"SpokeInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderHash","type":"bytes32"}],"name":"TokensReleased","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"chain","type":"string"}],"name":"TrustedAddressRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"chain","type":"string"},{"indexed":false,"internalType":"string","name":"address_","type":"string"}],"name":"TrustedAddressSet","type":"event"},{"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"addressToBytes32","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"origin","type":"tuple"}],"name":"allowInitializePath","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"toAddress","type":"address"},{"internalType":"address","name":"filler","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"fillAmount","type":"uint256"},{"internalType":"uint256","name":"feeRate","type":"uint256"},{"internalType":"uint256","name":"fromChain","type":"uint256"},{"internalType":"uint256","name":"toChain","type":"uint256"},{"internalType":"bytes32","name":"postHookHash","type":"bytes32"}],"internalType":"struct ISpoke.Order[]","name":"orders","type":"tuple[]"},{"components":[{"internalType":"enum ISquidMulticall.CallType","name":"callType","type":"uint8"},{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"bytes","name":"payload","type":"bytes"}],"internalType":"struct ISquidMulticall.Call[][]","name":"calls","type":"tuple[][]"}],"name":"batchFillOrder","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"toAddress","type":"address"},{"internalType":"address","name":"filler","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"fillAmount","type":"uint256"},{"internalType":"uint256","name":"feeRate","type":"uint256"},{"internalType":"uint256","name":"fromChain","type":"uint256"},{"internalType":"uint256","name":"toChain","type":"uint256"},{"internalType":"bytes32","name":"postHookHash","type":"bytes32"}],"internalType":"struct ISpoke.Order[]","name":"orders","type":"tuple[]"},{"internalType":"address[]","name":"fromTokens","type":"address[]"},{"internalType":"address","name":"filler","type":"address"}],"name":"batchMultiTokenSingleChainSettlements","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"chainName","outputs":[{"internalType":"string","name":"chainName_","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"collectFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"toAddress","type":"address"},{"internalType":"address","name":"filler","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"fillAmount","type":"uint256"},{"internalType":"uint256","name":"feeRate","type":"uint256"},{"internalType":"uint256","name":"fromChain","type":"uint256"},{"internalType":"uint256","name":"toChain","type":"uint256"},{"internalType":"bytes32","name":"postHookHash","type":"bytes32"}],"internalType":"struct ISpoke.Order","name":"order","type":"tuple"}],"name":"createOrder","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endpoint","outputs":[{"internalType":"contract ILayerZeroEndpointV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commandId","type":"bytes32"},{"internalType":"string","name":"sourceChain","type":"string"},{"internalType":"string","name":"sourceAddress","type":"string"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"execute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commandId","type":"bytes32"},{"internalType":"string","name":"sourceChain","type":"string"},{"internalType":"string","name":"sourceAddress","type":"string"},{"internalType":"bytes","name":"payload","type":"bytes"},{"internalType":"string","name":"tokenSymbol","type":"string"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"executeWithToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"toAddress","type":"address"},{"internalType":"address","name":"filler","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"fillAmount","type":"uint256"},{"internalType":"uint256","name":"feeRate","type":"uint256"},{"internalType":"uint256","name":"fromChain","type":"uint256"},{"internalType":"uint256","name":"toChain","type":"uint256"},{"internalType":"bytes32","name":"postHookHash","type":"bytes32"}],"internalType":"struct ISpoke.Order","name":"order","type":"tuple"},{"components":[{"internalType":"enum ISquidMulticall.CallType","name":"callType","type":"uint8"},{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"bytes","name":"payload","type":"bytes"}],"internalType":"struct ISquidMulticall.Call[]","name":"calls","type":"tuple[]"}],"name":"fillOrder","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"orderHashes","type":"bytes32[]"},{"internalType":"uint256","name":"lzFee","type":"uint256"},{"internalType":"uint128","name":"gasLimit","type":"uint128"},{"internalType":"enum ICoral.Provider","name":"provider","type":"uint8"}],"name":"forwardSettlements","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"gasService","outputs":[{"internalType":"contract IAxelarGasService","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gateway","outputs":[{"internalType":"contract IAxelarGateway","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hubAddress","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hubAddressBytes32","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hubChainName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hubEndpoint","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IAxelarGateway","name":"_axelarGateway","type":"address"},{"internalType":"contract IAxelarGasService","name":"_axelarGasService","type":"address"},{"internalType":"contract IPermit2","name":"_permit2","type":"address"},{"internalType":"contract ISquidMulticall","name":"_squidMulticall","type":"address"},{"internalType":"address","name":"_feeCollector","type":"address"},{"internalType":"string","name":"_hubChainName","type":"string"},{"internalType":"string","name":"_hubAddress","type":"string"},{"internalType":"contract ILayerZeroEndpointV2","name":"_endpoint","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_hub","type":"address"},{"internalType":"uint32","name":"_hubEndpoint","type":"uint32"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"","type":"tuple"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"address","name":"_sender","type":"address"}],"name":"isComposeMsgSender","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"chain","type":"string"},{"internalType":"string","name":"address_","type":"string"}],"name":"isTrustedAddress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"_origin","type":"tuple"},{"internalType":"bytes32","name":"_guid","type":"bytes32"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"_executor","type":"address"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"nextNonce","outputs":[{"internalType":"uint64","name":"nonce","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oAppVersion","outputs":[{"internalType":"uint64","name":"senderVersion","type":"uint64"},{"internalType":"uint64","name":"receiverVersion","type":"uint64"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"orderHashToStatus","outputs":[{"internalType":"enum ISpoke.OrderStatus","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"}],"name":"peers","outputs":[{"internalType":"bytes32","name":"peer","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permit2","outputs":[{"internalType":"contract IPermit2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"internalType":"bytes32[]","name":"orderHashes","type":"bytes32[]"},{"internalType":"uint128","name":"gasLimit","type":"uint128"},{"internalType":"bool","name":"_payInLzToken","type":"bool"}],"name":"quote","outputs":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"toAddress","type":"address"},{"internalType":"address","name":"filler","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"fillAmount","type":"uint256"},{"internalType":"uint256","name":"feeRate","type":"uint256"},{"internalType":"uint256","name":"fromChain","type":"uint256"},{"internalType":"uint256","name":"toChain","type":"uint256"},{"internalType":"bytes32","name":"postHookHash","type":"bytes32"}],"internalType":"struct ISpoke.Order","name":"order","type":"tuple"}],"name":"refundOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegate","type":"address"}],"name":"setDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"bytes32","name":"_peer","type":"bytes32"}],"name":"setPeer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"settlementToStatus","outputs":[{"internalType":"enum ISpoke.SettlementStatus","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"toAddress","type":"address"},{"internalType":"address","name":"filler","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"fillAmount","type":"uint256"},{"internalType":"uint256","name":"feeRate","type":"uint256"},{"internalType":"uint256","name":"fromChain","type":"uint256"},{"internalType":"uint256","name":"toChain","type":"uint256"},{"internalType":"bytes32","name":"postHookHash","type":"bytes32"}],"internalType":"struct ISpoke.Order","name":"order","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"sponsorOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"toAddress","type":"address"},{"internalType":"address","name":"filler","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"fillAmount","type":"uint256"},{"internalType":"uint256","name":"feeRate","type":"uint256"},{"internalType":"uint256","name":"fromChain","type":"uint256"},{"internalType":"uint256","name":"toChain","type":"uint256"},{"internalType":"bytes32","name":"postHookHash","type":"bytes32"}],"internalType":"struct ISpoke.Order","name":"order","type":"tuple"},{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ISignatureTransfer.TokenPermissions","name":"permitted","type":"tuple"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct ISignatureTransfer.PermitTransferFrom","name":"permit","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"sponsorOrderUsingPermit2","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"squidMulticall","outputs":[{"internalType":"contract ISquidMulticall","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenToCollectedFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"chain","type":"string"}],"name":"trustedAddress","outputs":[{"internalType":"string","name":"trustedAddress_","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"chain","type":"string"}],"name":"trustedAddressHash","outputs":[{"internalType":"bytes32","name":"trustedAddressHash_","type":"bytes32"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
61016060409080825234620001da576200001981620001df565b6005815260208101906453706f6b6560d81b82528251916200003b83620001df565b600183526020830192603160f81b84523315620001c25760008054336001600160a01b031980831682178455929692916001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08880a373c012a11111111111111111111111111111111111908181600154161760015560035416176003556001600455620000d08462000211565b92610120938452620000e283620003eb565b94610140958652519020918260e052519020610100958187524660a05280519160208301937f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f85528284015260608301524660808301523060a083015260a0825260c082019582871060018060401b03881117620001ae57508590525190206080523060c052615e239384620005a4853960805184615a0f015260a05184615ac4015260c051846159e0015260e05184615a5e01525183615a8401525182612286015251816122af0152f35b634e487b7160e01b81526041600452602490fd5b8451631e4fbdf760e01b815260006004820152602490fd5b600080fd5b604081019081106001600160401b03821117620001fb57604052565b634e487b7160e01b600052604160045260246000fd5b80516020919082811015620002b0575090601f8251116200024f57808251920151908083106200024057501790565b82600019910360031b1b161790565b90604051809263305a27a960e01b82528060048301528251908160248401526000935b82851062000296575050604492506000838284010152601f80199101168101030190fd5b848101820151868601604401529381019385935062000272565b6001600160401b038111620001fb576005928354926001938481811c91168015620003e0575b83821014620003ca57601f811162000393575b5081601f84116001146200032957509282939183926000946200031d575b50501b916000199060031b1c191617905560ff90565b01519250388062000307565b919083601f1981168760005284600020946000905b888383106200037857505050106200035e575b505050811b01905560ff90565b015160001960f88460031b161c1916905538808062000351565b8587015188559096019594850194879350908101906200033e565b8560005284601f846000209201871c820191601f8601881c015b828110620003bd575050620002e9565b60008155018590620003ad565b634e487b7160e01b600052602260045260246000fd5b90607f1690620002d6565b805160209081811015620004795750601f8251116200041857808251920151908083106200024057501790565b90604051809263305a27a960e01b82528060048301528251908160248401526000935b8285106200045f575050604492506000838284010152601f80199101168101030190fd5b84810182015186860160440152938101938593506200043b565b906001600160401b038211620001fb57600654926001938481811c9116801562000598575b83821014620003ca57601f81116200055e575b5081601f8411600114620004f25750928293918392600094620004e6575b50501b916000199060031b1c19161760065560ff90565b015192503880620004cf565b919083601f198116600660005284600020946000905b8883831062000543575050501062000529575b505050811b0160065560ff90565b015160001960f88460031b161c191690553880806200051b565b85870151885590960195948501948793509081019062000508565b600660005284601f84600020920160051c820191601f860160051c015b8281106200058b575050620004b1565b600081550185906200057b565b90607f16906200049e56fe6080604052600436101561001257600080fd5b60003560e01c80630630dea4146102c7578063076e9f6c146102c25780630d77797c146102bd578063116191b6146102b85780631191c72e146102b357806312261ee7146102ae57806313137d65146102a957806317442b70146102a45780631a98b2e01461029f5780631c93b03a1461029a5780631e44fb971461029557806321b4ae78146102905780632b8cb1f61461028b5780632e3d6cf9146102865780633400288b14610281578063365324411461027c578063477aedc714610277578063491606581461027257806358c0f7291461026d57806359ce62e9146102685780635e280f11146102635780636a22d8cc1461025e578063715018a61461025957806379db29c8146102545780637d25a05e1461024f57806382413eac1461024a57806382c947b71461024557806382e5f9e41461024057806384b0196e1461023b5780638da5cb5b14610236578063951f401614610231578063a32b52a71461022c578063aab59a0914610227578063b98ef27514610222578063bb0b6a531461021d578063c415b95c14610218578063c506bff414610213578063ca5eb5e11461020e578063db715f7b14610209578063f2fde38b14610204578063f69b1b29146101ff578063ff7bd03d146101fa5763ffd5982a146101f557600080fd5b612d8b565b612d45565b612d21565b612cb3565b612c75565b612be3565b612b7e565b612b57565b612b1c565b612a6b565b612403565b6123cb565b6123a3565b61237c565b61226d565b61222e565b612068565b612009565b611fe2565b611e9b565b611e29565b611e02565b611ddb565b611db4565b611c27565b611ae5565b611a16565b611708565b6116d7565b61144d565b611429565b6112b6565b6110a8565b610f9e565b610eb2565b610e90565b610d7e565b610d18565b6109ff565b610961565b6106fd565b6106b3565b610338565b9181601f840112156102fd5782359167ffffffffffffffff83116102fd576020808501948460051b0101116102fd57565b600080fd5b604435906fffffffffffffffffffffffffffffffff821682036102fd57565b600211156102fd57565b359061033682610321565b565b60806003193601126102fd576004803567ffffffffffffffff81116102fd5761036490369083016102cc565b909161036e610302565b926064359061037c82610321565b610384613e26565b341561064c5783156106235760005b84811061056b57506103bf906103b160405195869260208401612df0565b03601f19810185528461191f565b6103c881612e32565b806104eb57509091506103f26103e6600a546001600160a01b031690565b6001600160a01b031690565b803b156102fd57600060405180927f0c93e3bb00000000000000000000000000000000000000000000000000000000825281806104333389308a8501612e3c565b039134905af180156104d3576104d8575b5061045a6103e66003546001600160a01b031690565b91823b156102fd5761049d92600092836040518096819582947f1c92115f0000000000000000000000000000000000000000000000000000000084528301612e98565b03925af180156104d3576104ba575b505b6104b86001600455565b005b806104c76104cd92611896565b80610956565b386104ac565b612e8c565b806104c76104e592611896565b38610444565b806104f7600192612e32565b03610543575061051161053d9261050c613e61565b613e96565b9061052160105463ffffffff1690565b9161052a611942565b91348352602435602084015233936140bd565b506104ae565b6040517f7626db82000000000000000000000000000000000000000000000000000000008152fd5b61059461058d61057c838886612ddb565b356000526009602052604060002090565b5460ff1690565b61059d816123c1565b156105fa57806105c36105b661057c6001948987612ddb565b600260ff19825416179055565b6105ce818785612ddb565b357f69f975bd70ea51b973eb6aff3812f49adf595bd59d6f3d29840d5695cc19ba30600080a201610393565b836040517f4811daf5000000000000000000000000000000000000000000000000000000008152fd5b826040517f9d89020a000000000000000000000000000000000000000000000000000000008152fd5b826040517f03aeed96000000000000000000000000000000000000000000000000000000008152fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600411156106ae57565b610675565b346102fd5760206003193601126102fd576004356000526008602052602060ff60406000205416604051906106e7816106a4565b8152f35b6003196101809101126102fd57600490565b6101806003193601126102fd57610713366106eb565b61071b613e26565b60409081516020810190610741816107338585612f4d565b03601f19810183528261191f565b5190209161075c61058d846000526008602052604060002090565b610765816106a4565b61092d5760a082013542116109045746610120830135036108db576060820173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee806001600160a01b036107ab84613035565b161415806108d2575b6108a9576107dc6107cf866000526008602052604060002090565b600160ff19825416179055565b6107e86103e683613035565b03610860575060c08201353403610837577f181de28643611afcf1cb4c095a1ef99c157e78437294f478c978e4a56e1ca77e9161082a915b5191829182612f4d565b0390a26104b86001600455565b600490517f44e8bd2c000000000000000000000000000000000000000000000000000000008152fd5b9161082a916108a46108956103e67f181de28643611afcf1cb4c095a1ef99c157e78437294f478c978e4a56e1ca77e96613035565b60c084013590309033906157e0565b610820565b600483517fd453e7b5000000000000000000000000000000000000000000000000000000008152fd5b503415156107b4565b600490517f9284b197000000000000000000000000000000000000000000000000000000008152fd5b600490517fc56873ba000000000000000000000000000000000000000000000000000000008152fd5b600490517f966753c5000000000000000000000000000000000000000000000000000000008152fd5b60009103126102fd57565b346102fd5760006003193601126102fd5760206001600160a01b0360035416604051908152f35b9181601f840112156102fd5782359167ffffffffffffffff83116102fd5760208085019461018085020101116102fd57565b6001600160a01b038116036102fd57565b60843590610336826109ba565b6101043590610336826109ba565b6101243590610336826109ba565b3590610336826109ba565b6060806003193601126102fd5760049067ffffffffffffffff82358181116102fd57610a2e9036908501610988565b90916024359081116102fd57610a4790369086016102cc565b949060443591610a56836109ba565b83158015610d0e575b610ce657610a6c84612ee2565b95610a7688612ee2565b94610a8089612ee2565b966000936001600160a01b0393848816955b848110610ab55750505050505050610aaf906104b89636916130d1565b936143f5565b610ac0818686612f3c565b6040908151610ad781610733602082019485612f4d565b519020906001610af461058d846000526009602052604060002090565b610afd816123c1565b03610cbe5746610120610b11858a8a612f3c565b013503610c965746610140610b27858a8a612f3c565b013503610c6e578888610b4583610b3f878c8c612f3c565b01613035565b1603610c4657610b648f8b610b5f87610b3f888d8d612f3c565b6143a9565b906000198214610c1e575090610c17838f8f8f908396610bf4610c07888f948f60019d610c1197610c009260c094610bdc6105b6610bcb610bc289610baa898989612f3c565b0135610100610bba8a8a8a612f3c565b01359061306e565b620f4240900490565b986000526009602052604060002090565b610bfa8a610bf489610bee8386613093565b516130b7565b92613093565b52612f3c565b01356130c4565b610bee8386613093565b52613093565b5201610a92565b8590517fdf4c7777000000000000000000000000000000000000000000000000000000008152fd5b8490517f69fa1755000000000000000000000000000000000000000000000000000000008152fd5b8490517f9284b197000000000000000000000000000000000000000000000000000000008152fd5b8490517fb86ac1ef000000000000000000000000000000000000000000000000000000008152fd5b8490517f4811daf5000000000000000000000000000000000000000000000000000000008152fd5b6040517f9d89020a000000000000000000000000000000000000000000000000000000008152fd5b5060028710610a5f565b346102fd5760006003193601126102fd5760206001600160a01b03600b5416604051908152f35b60031960609101126102fd57600490565b9181601f840112156102fd5782359167ffffffffffffffff83116102fd57602083818601950101116102fd57565b60e06003193601126102fd57610d9336610d3f565b67ffffffffffffffff6084358181116102fd57610db4903690600401610d50565b91610dc060a4356109ba565b60c4359081116102fd57610dd8903690600401610d50565b50506001600160a01b03600154163303610e5f57610dfd610df884613129565b614596565b926020810135809403610e14576104b89350614750565b610e1e8491613129565b6040517fc26bebcc00000000000000000000000000000000000000000000000000000000815263ffffffff9190911660048201526024810191909152604490fd5b6040517f91ac5e4f000000000000000000000000000000000000000000000000000000008152336004820152602490fd5b346102fd5760006003193601126102fd57604080516001815260026020820152f35b346102fd5760c06003193601126102fd5767ffffffffffffffff6024358181116102fd57610ee4903690600401610d50565b6044358381116102fd57610efc903690600401610d50565b6064929192358581116102fd57610f17903690600401610d50565b916084359687116102fd57610f336104b8973690600401610d50565b95909460a43597600435613169565b60005b838110610f555750506000910152565b8181015183820152602001610f45565b90601f19601f602093610f8381518092818752878088019101610f42565b0116010190565b906020610f9b928181520190610f65565b90565b346102fd576000806003193601126110a55760405190807f0e2c162a1f4b5cff9fdbd6b34678a9bcb9898a0b9fbca695b112d61688d8b2ac8054610fe181612098565b80865292602092600192808416908115611075575060011461101e575b61101a8761100e8189038261191f565b60405191829182610f8a565b0390f35b815293507f6703f9a97b5b44375099a890a40c8c70a9efc4d97fa39f72811f72b1a93211625b8385106110625750505050810160200161100e8261101a3880610ffe565b8054868601840152938201938101611044565b905087965061101a9794506020935061100e95925060ff1991501682840152151560051b82010192933880610ffe565b80fd5b346102fd576101806003193601126102fd576110c3366106eb565b6110cb613e26565b60405160208101906110e1816107338585612f4d565b5190209060016110fe61058d846000526008602052604060002090565b611107816106a4565b036112665761111b6103e660408301613035565b3303611221575b46610120820135036111f757611152611145836000526008602052604060002090565b600360ff19825416179055565b606081019073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0361117d84613035565b16036111ce5761119f915060c06111966103e683613035565b91013590614941565b7fa60671d8537ed193e567f86ddf28cf35dc67073b5ad80a2d41359cfa78db0a1e600080a26104b86001600455565b6111dd6103e66111f293613035565b9060c06111e982613035565b910135916148ab565b61119f565b60046040517f9284b197000000000000000000000000000000000000000000000000000000008152fd5b61123761123160a08301356130a7565b42111590565b156111225760046040517f796c85f3000000000000000000000000000000000000000000000000000000008152fd5b60046040517fab81a57d000000000000000000000000000000000000000000000000000000008152fd5b63ffffffff8116036102fd57565b610144359061033682611290565b801515036102fd57565b346102fd5760806003193601126102fd576004356112d381611290565b60243567ffffffffffffffff81116102fd5761133c916112fa6113cf9236906004016102cc565b61139a611308939293610302565b61134460643591611318836112ac565b604098899761132e895197889260208401612df0565b03601f19810187528661191f565b61050c613e61565b61134c613272565b506113626103e66001546001600160a01b031690565b9361136c86614596565b61138361137761194f565b63ffffffff9098168852565b602087015286860152606085015215156080840152565b825180809581947fddc28c58000000000000000000000000000000000000000000000000000000008352309060048401614032565b03915afa9081156104d3576000916113fc575b508051602091820151925190815290810191909152604090f35b61141c9150823d8411611422575b611414818361191f565b8101906149c4565b386113e2565b503d61140a565b346102fd5760006003193601126102fd57602063ffffffff60105416604051908152f35b346102fd576102206003193601126102fd57611468366106eb565b60807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7c3601126102fd57610204359067ffffffffffffffff82116102fd576114b560049236908401610d50565b90916114bf613e26565b604091825160208101906114d7816107338685612f4d565b519020946114f261058d876000526008602052604060002090565b6114fb816106a4565b6116b05760a083013542116116895746610120840135036116625773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0361153f60608601613035565b161461163b5761155c6107cf876000526008602052604060002090565b611564613272565b3081529460c0840135602087015261157b846149d8565b956115916103e6600b546001600160a01b031690565b9161159b86613035565b936115a461328b565b843b156102fd5760009687936115e7928b519c8d998a9889977f137c29fe0000000000000000000000000000000000000000000000000000000089528801613409565b03925af19182156104d3577f181de28643611afcf1cb4c095a1ef99c157e78437294f478c978e4a56e1ca77e9361082a93611628575b505191829182612f4d565b806104c761163592611896565b3861161d565b83517f8dccaef7000000000000000000000000000000000000000000000000000000008152fd5b83517f9284b197000000000000000000000000000000000000000000000000000000008152fd5b83517fc56873ba000000000000000000000000000000000000000000000000000000008152fd5b83517f966753c5000000000000000000000000000000000000000000000000000000008152fd5b346102fd5760406003193601126102fd576104b86004356116f781611290565b6116ff614aea565b60243590614b2e565b6040806003193601126102fd57600467ffffffffffffffff81358181116102fd57611737903690600401610988565b90916024359081116102fd576117519036906004016102cc565b9290948215801561185d575b61183357349060005b84811061176f57005b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6117976103e66080610b3f858a8a612f3c565b146117d2575b806117cc6117c78a6117bd848b6117b76001988d8d612f3c565b9361348f565b92909136906134f2565b614b7f565b01611766565b9160e0806117e1858888612f3c565b0135821061180b57600191611803916117fb868989612f3c565b0135906130c4565b92905061179d565b8783517f27ea1575000000000000000000000000000000000000000000000000000000008152fd5b60046040517f9d89020a000000000000000000000000000000000000000000000000000000008152fd5b508383141561175d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b67ffffffffffffffff81116118aa57604052565b611867565b6040810190811067ffffffffffffffff8211176118aa57604052565b6060810190811067ffffffffffffffff8211176118aa57604052565b60a0810190811067ffffffffffffffff8211176118aa57604052565b60c0810190811067ffffffffffffffff8211176118aa57604052565b90601f601f19910116810190811067ffffffffffffffff8211176118aa57604052565b60405190610336826118af565b60405190610336826118e7565b60405190610180820182811067ffffffffffffffff8211176118aa57604052565b67ffffffffffffffff81116118aa57601f01601f191660200190565b9291926119a58261197d565b916119b3604051938461191f565b8294818452818301116102fd578281602093846000960137010152565b9080601f830112156102fd57816020610f9b93359101611999565b60206003198201126102fd576004359067ffffffffffffffff82116102fd57610f9b916004016119d0565b346102fd57611a2c611a27366119eb565b615235565b60405190600082825491611a3f83612098565b9283835260209460019186600182169182600014611ac2575050600114611a83575b5050611a6f9250038361191f565b61101a604051928284938452830190610f65565b85925060005281600020906000915b858310611aaa575050611a6f93508201013880611a61565b80548389018501528794508693909201918101611a92565b91509350611a6f95925060ff1991501682840152151560051b8201013880611a61565b346102fd5760806003193601126102fd57600467ffffffffffffffff6024358181116102fd57611b189036908401610d50565b916044358181116102fd57611b309036908601610d50565b916064359081116102fd57611b489036908701610d50565b94909382602083611b5a368a8a611999565b8281519101208460008c611bac6001600160a01b0360035416948c604051998a98899788967f5f6970c300000000000000000000000000000000000000000000000000000000885280359088016135a3565b03925af19081156104d357600091611bf8575b5015611bcf576104b89650615277565b866040517f500c44b4000000000000000000000000000000000000000000000000000000008152fd5b611c1a915060203d602011611c20575b611c12818361191f565b810190613133565b38611bbf565b503d611c08565b346102fd5760206003193601126102fd5760043567ffffffffffffffff81116102fd57611c589036906004016102cc565b906001600160a01b0390600d9082600d54163303611d8a5783156118335760005b848110611c8257005b80611cb4611c9b611c966001948987612ddb565b613035565b6001600160a01b03166000526007602052604060002090565b5480611d04575b84546001600160a01b03168680611cd6611c96868c8a612ddb565b1691167f9bcb6d1f38f6800906185471a11ede9a8e16200853225aa62558db6076490f2d600080a401611c79565b6000611d17611c9b611c96858b89612ddb565b5573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee86611d3c611c96858b89612ddb565b1603611d6457611d5f81611d5a6103e688546001600160a01b031690565b614941565b611cbb565b611d5f81611d796103e6611c96868c8a612ddb565b87546001600160a01b0316906148ab565b60046040517f91034599000000000000000000000000000000000000000000000000000000008152fd5b346102fd5760006003193601126102fd5760206001600160a01b03600c5416604051908152f35b346102fd5760006003193601126102fd5760206001600160a01b0360015416604051908152f35b346102fd5760006003193601126102fd5760206001600160a01b03600a5416604051908152f35b346102fd576000806003193601126110a557611e43614aea565b806001600160a01b0381547fffffffffffffffffffffffff000000000000000000000000000000000000000081168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b346102fd576101a06003193601126102fd57611eb6366106eb565b6101843567ffffffffffffffff81116102fd57611ed7903690600401610d50565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b036060850135611f02816109ba565b1614611fb857611f7791611f7391611f6d853592611f1f846109ba565b6042611f2a886149d8565b611f326159d6565b90604051917f190100000000000000000000000000000000000000000000000000000000000083526002830152602282015220923691611999565b9161532a565b1590565b611f8e5780611f886104b892613035565b906141b2565b60046040517fe3fb657c000000000000000000000000000000000000000000000000000000008152fd5b60046040517f8dccaef7000000000000000000000000000000000000000000000000000000008152fd5b346102fd5760406003193601126102fd57611ffe600435611290565b602060405160008152f35b346102fd5760a06003193601126102fd5761202336610d3f565b5060643567ffffffffffffffff81116102fd57612044903690600401610d50565b50506020608435612054816109ba565b604051906001600160a01b03309116148152f35b346102fd5760206003193601126102fd576020600435612087816109ba565b6001600160a01b0360405191168152f35b90600182811c921680156120e1575b60208310146120b257565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b91607f16916120a7565b600e54600092916120fb82612098565b8082529160209060019081811690811561217a575060011461211e575b50505050565b92939450600e6000527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd926000935b858510612167575050506020925001019038808080612118565b805485850184015293820193810161214d565b915050602094955060ff1991509291921683830152151560051b01019038808080612118565b600f54600092916121b082612098565b8082529160209060019081811690811561217a57506001146121d25750505050565b92939450600f6000527f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac802926000935b85851061221b575050506020925001019038808080612118565b8054858501840152938201938101612201565b346102fd5760006003193601126102fd5761101a60405161225981612252816120eb565b038261191f565b604051918291602083526020830190610f65565b346102fd5760006003193601126102fd5761232b6122aa7f0000000000000000000000000000000000000000000000000000000000000000615b26565b6122d37f0000000000000000000000000000000000000000000000000000000000000000615c40565b906122dc612f13565b906040519384937f0f00000000000000000000000000000000000000000000000000000000000000855261231d60209360e0602088015260e0870190610f65565b908582036040870152610f65565b466060850152306080850152600060a085015283810360c08501526020808451928381520193019160005b82811061236557505050500390f35b835185528695509381019392810192600101612356565b346102fd5760006003193601126102fd5760206001600160a01b0360005416604051908152f35b346102fd5760006003193601126102fd576020601154604051908152f35b600311156106ae57565b346102fd5760206003193601126102fd57600435600052600960205260ff6040600020541660405160038210156106ae576020918152f35b6101a06003193601126102fd57612419366106eb565b610184359067ffffffffffffffff82116102fd5761243c600492369084016102cc565b608083929301359361244d856109ba565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee92836001600160a01b038097161480612a43575b612a1a576124859036906134f2565b9161248e613e26565b6040938451906020820182612549878381516001600160a01b03168152610180810192916020818101516001600160a01b0316908301526040818101516001600160a01b0316908301526060818101516001600160a01b0316908301526080818101516001600160a01b03169083015260a081015160a083015260c081015160c083015260e081015160e083015261010080820151908301526101208082015190830152610140808201519083015261016080910151910152565b039261255d601f199485810183528261191f565b5190209761257861058d8a6000526009602052604060002090565b612581816123c1565b6129f2578686019161259d6103e684516001600160a01b031690565b33036129ca5761014087015146036129a2576125c66107cf8b6000526009602052604060002090565b60808701916125dc83516001600160a01b031690565b169081036127f65750505061016084018051909190156127a157855161261860208201928261260c878c8761510b565b0390810183528261191f565b519020905103612779576126376103e6600c546001600160a01b031690565b60e084015195813b156102fd5761267e966000948751988995869485937ff87ef800000000000000000000000000000000000000000000000000000000008552840161510b565b03925af19182156104d3577f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b79361082a93612766575b505b519182918281516001600160a01b03168152610180810192916020818101516001600160a01b0316908301526040818101516001600160a01b0316908301526060818101516001600160a01b0316908301526080818101516001600160a01b03169083015260a081015160a083015260c081015160c083015260e081015160e083015261010080820151908301526101208082015190830152610140808201519083015261016080910151910152565b806104c761277392611896565b386126b4565b5082517f332c0963000000000000000000000000000000000000000000000000000000008152fd5b505050507f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b7925061082a916127f16127e66103e660208501516001600160a01b031690565b60e084015190614941565b6126b6565b90919261016087019182511515600014612944575087516020810191612822908261260c898e8761510b565b51902090510361291c57906128556128476103e661287694516001600160a01b031690565b91516001600160a01b031690565b61286a6103e6600c546001600160a01b031690565b9060e0870151926157e0565b61288b6103e6600c546001600160a01b031690565b803b156102fd576128cd95600080948751988995869485937ff87ef800000000000000000000000000000000000000000000000000000000008552840161510b565b03925af19182156104d3577f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b79361082a93612909575b506126b6565b806104c761291692611896565b38612903565b8386517f332c0963000000000000000000000000000000000000000000000000000000008152fd5b93517f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b7995061082a9896506127f195506001600160a01b03169250612987915050565b60208501516001600160a01b03165b9060e0860151926157e0565b8588517fb86ac1ef000000000000000000000000000000000000000000000000000000008152fd5b8588517fa4e189a6000000000000000000000000000000000000000000000000000000008152fd5b8487517f4747436c000000000000000000000000000000000000000000000000000000008152fd5b506040517f44e8bd2c000000000000000000000000000000000000000000000000000000008152fd5b5060e0810135341415612476565b60643590610336826109ba565b60e43590610336826109ba565b346102fd576101606003193601126102fd57600435612a89816109ba565b60243590612a96826109ba565b60443591612aa3836109ba565b612aab612a51565b92612ab46109cb565b67ffffffffffffffff949060a4358681116102fd57612ad79036906004016119d0565b60c4359687116102fd57612af26104b89736906004016119d0565b91612afb612a5e565b93612b046109d8565b95612b0d6109e6565b97612b1661129e565b996135d9565b346102fd5760206003193601126102fd5763ffffffff600435612b3e81611290565b1660005260026020526020604060002054604051908152f35b346102fd5760006003193601126102fd5760206001600160a01b03600d5416604051908152f35b346102fd5760406003193601126102fd5767ffffffffffffffff6004358181116102fd57612bb0903690600401610d50565b6024929192359182116102fd57602092612bd1612bd9933690600401610d50565b929091613ddf565b6040519015158152f35b346102fd57600060206003193601126110a557600435612c02816109ba565b612c0a614aea565b816001600160a01b03806001541692833b15612c71576024908360405195869485937fca5eb5e10000000000000000000000000000000000000000000000000000000085521660048401525af180156104d357612c65575080f35b612c6e90611896565b80f35b8280fd5b346102fd5760206003193601126102fd576001600160a01b03600435612c9a816109ba565b1660005260076020526020604060002054604051908152f35b346102fd5760206003193601126102fd57600435612cd0816109ba565b612cd8614aea565b6001600160a01b03811615612cf0576104b8906152ca565b60246040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260006004820152fd5b346102fd5760006003193601126102fd5761101a60405161225981612252816121a0565b346102fd5760606003193601126102fd576020612d6136610d3f565b63ffffffff8135612d7181611290565b166000526002825260406000205482604051920135148152f35b346102fd576020612da3612d9e366119eb565b6155ab565b54604051908152f35b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9190811015612deb5760051b0190565b612dac565b602081528260208201527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83116102fd5760409260051b809284830137010190565b600211156106ae57565b9190612e856080929594956001600160a01b03809316855260a06020860152612e77612e6a60a087016120eb565b86810360408801526121a0565b908582036060870152610f65565b9416910152565b6040513d6000823e3d90fd5b610f9b9160608252612ebc612eaf606084016120eb565b83810360208501526121a0565b916040818403910152610f65565b67ffffffffffffffff81116118aa5760051b60200190565b90612eec82612eca565b612ef9604051918261191f565b828152601f19612f098294612eca565b0190602036910137565b6040516020810181811067ffffffffffffffff8211176118aa5760405260008152906000368137565b9190811015612deb57610180020190565b61018081019291612f6e82612f61836109f4565b6001600160a01b03169052565b612f8d612f7d602083016109f4565b6001600160a01b03166020840152565b612fac612f9c604083016109f4565b6001600160a01b03166040840152565b612fcb612fbb606083016109f4565b6001600160a01b03166060840152565b612fea612fda608083016109f4565b6001600160a01b03166080840152565b60a081013560a083015260c081013560c083015260e081013560e083015261010080820135908301526101208082013590830152610140808201359083015261016080910135910152565b35610f9b816109ba565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8181029291811591840414171561308157565b61303f565b805115612deb5760200190565b8051821015612deb5760209160051b010190565b9062015180820180921161308157565b9190820180921161308157565b9190820391821161308157565b92916130dc82612eca565b916130ea604051938461191f565b829481845260208094019160051b81019283116102fd57905b8282106131105750505050565b838091833561311e816109ba565b815201910190613103565b35610f9b81611290565b908160209103126102fd5751610f9b816112ac565b601f8260209493601f19938186528686013760008582860101520116010190565b9260209861320892986131866131e09c95986000989a3691611999565b8b8151910120926131f46001600160a01b03600354169a6040519e8f9d8e9c8d9b7f1876eed9000000000000000000000000000000000000000000000000000000008d5260048d015260c060248d015260c48c0191613148565b9060031993848b84030160448c0152613148565b936064880152868403016084870152613148565b9060a483015203925af19081156104d357600091613253575b501561322957565b60046040517f500c44b4000000000000000000000000000000000000000000000000000000008152fd5b61326c915060203d602011611c2057611c12818361191f565b38613221565b6040519061327f826118af565b60006020838281520152565b60405190610140820182811067ffffffffffffffff8211176118aa5760405261011582527f746f6b656e2c75696e7432353620616d6f756e74290000000000000000000000610120837f4f72646572207769746e657373294f7264657228616464726573732066726f6d60208201527f416464726573732c6164647265737320746f416464726573732c61646472657360408201527f732066696c6c65722c616464726573732066726f6d546f6b656e2c616464726560608201527f737320746f546f6b656e2c75696e74323536206578706972792c75696e74323560808201527f362066726f6d416d6f756e742c75696e743235362066696c6c416d6f756e742c60a08201527f75696e7432353620666565526174652c75696e743235362066726f6d4368616960c08201527f6e2c75696e7432353620746f436861696e2c6279746573333220706f7374486f60e08201527f6f6b4861736829546f6b656e5065726d697373696f6e732861646472657373206101008201520152565b949290610f9b96949161346c613480946020610140946101843561342c816109ba565b6001600160a01b039081168c526101a435838d01526101c43560408d01526101e43560608d01528151811660808d015291015160a08b01521660c0890152565b60e087015280610100870152850190610f65565b92610120818503910152613148565b9190811015612deb5760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1813603018212156102fd57019081359167ffffffffffffffff83116102fd576020018260051b360381136102fd579190565b9190826101809103126102fd5761350761195c565b91613511816109f4565b835261351f602082016109f4565b6020840152613530604082016109f4565b6040840152613541606082016109f4565b6060840152613552608082016109f4565b608084015260a081013560a084015260c081013560c084015260e081013560e08401526101008082013590840152610120808201359084015261014080820135908401526101608091013590830152565b96959490606094926135d4946135c6928a52608060208b015260808a0191613148565b918783036040890152613148565b930152565b99979593919896949290987ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00998a549b60ff8d60401c16159c8d67ffffffffffffffff821680159182613794575b50600114908161378a575b159081613781575b50613757576136759c60018f927fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000161790556136fb57613ae3565b61367b57565b6136c77ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a007fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff8154169055565b604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29080602081015b0390a1565b6137527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00680100000000000000007fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff825416179055565b613ae3565b60046040517ff92ee8a9000000000000000000000000000000000000000000000000000000008152fd5b9050153861363a565b303b159150613632565b91508f613627565b601f81116137a8575050565b600090600e6000527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd906020601f850160051c83019410613804575b601f0160051c01915b8281106137f957505050565b8181556001016137ed565b90925082906137e4565b601f811161381a575050565b600090600f6000527f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac802906020601f850160051c83019410613876575b601f0160051c01915b82811061386b57505050565b81815560010161385f565b9092508290613856565b90601f811161388e57505050565b6000916000526020600020906020601f850160051c830194106138cc575b601f0160051c01915b8281106138c157505050565b8181556001016138b5565b90925082906138ac565b90815167ffffffffffffffff81116118aa576138fc816138f7600e54612098565b61379c565b602080601f831160011461393e5750819061392e9394600092613933575b50506000198260011b9260031b1c19161790565b600e55565b01519050388061391a565b90601f19831694613971600e6000527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd90565b926000905b8782106139ae575050836001959610613995575b505050811b01600e55565b015160001960f88460031b161c1916905538808061398a565b80600185968294968601518155019501930190613976565b90815167ffffffffffffffff81116118aa576139ec816139e7600f54612098565b61380e565b602080601f8311600114613a2257508190613a1d93946000926139335750506000198260011b9260031b1c19161790565b600f55565b90601f19831694613a55600f6000527f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac80290565b926000905b878210613a92575050836001959610613a79575b505050811b01600f55565b015160001960f88460031b161c19169055388080613a6e565b80600185968294968601518155019501930190613a5a565b90610f9b926001600160a01b03809216835216602082015260806040820152613ad5608082016120eb565b9060608183039101526121a0565b92613ba5613c2497969593613b71613bd994613b3d8d9c9f9d98613b09613c0d9a613e06565b6001600160a01b03167fffffffffffffffffffffffff00000000000000000000000000000000000000006003541617600355565b6001600160a01b03167fffffffffffffffffffffffff0000000000000000000000000000000000000000600a541617600a55565b6001600160a01b03167fffffffffffffffffffffffff0000000000000000000000000000000000000000600b541617600b55565b6001600160a01b03167fffffffffffffffffffffffff0000000000000000000000000000000000000000600c541617600c55565b6001600160a01b03167fffffffffffffffffffffffff0000000000000000000000000000000000000000600d541617600d55565b613c16816138d6565b613c1f826139c6565b615431565b6001600160a01b0393848116907311111111111111111111111111111111111111118203613ce6575b5050505050613c646003546001600160a01b031690565b600a546001600160a01b0316917f66b86e9a862484192b40f4e2dc828c11d9e09ca77f9d2c226a96e743f99e4ec8613ca4600b546001600160a01b031690565b91613cb7600c546001600160a01b031690565b92613ce1613ccd600d546001600160a01b031690565b838060405195869516991697169583613aaa565b0390a4565b613d1e906001600160a01b03167fffffffffffffffffffffffff00000000000000000000000000000000000000006001541617600155565b803b156102fd576040517fca5eb5e10000000000000000000000000000000000000000000000000000000081526001600160a01b039290921660048301526000908290602490829084905af180156104d357613dc293613dbd928692613dcc575b50613db58463ffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000006010541617601055565b168092614b2e565b601155565b3880808080613c4d565b806104c7613dd992611896565b38613d7f565b613df2613e0193612d9e93953691611999565b60208151910120933691611999565b541490565b613e0e614aea565b6001600160a01b03811615612cf057610336906152ca565b600260045414613e37576002600455565b60046040517f3ee5aeb5000000000000000000000000000000000000000000000000000000008152fd5b6040517e03000000000000000000000000000000000000000000000000000000000000602082015260028152610f9b816118af565b9061ffff91600383613ea7836155ed565b1603613f5d577fffffffffffffffffffffffffffffffff000000000000000000000000000000006040519260801b16602083015260108252613ee8826118af565b600383613ef4836155ed565b1603613f5d578151838111613f2557831660010192831161308157610733610f9b926040519485936020850161565b565b604490604051907f6dfcc650000000000000000000000000000000000000000000000000000000008252601060048301526024820152fd5b82613f696024926155ed565b6040517f3a51740d00000000000000000000000000000000000000000000000000000000815291166004820152fd5b60405190613fa5826118cb565b8160008152600060208201526040613fbb613272565b910152565b91908260409103126102fd57604051613fd8816118af565b6020808294805184520151910152565b6080818303126102fd5760405191613fff836118cb565b81518352602082015167ffffffffffffffff811681036102fd57602084015261402a91604001613fc0565b604082015290565b906001600160a01b036020919493946040845263ffffffff815116604085015282810151606085015260806140ac614078604084015160a08489015260e0880190610f65565b60608401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08883030160a0890152610f65565b910151151560c08501529416910152565b60809361412f61416496946140d0613f98565b5060206140dd84516156e0565b9301908151806141a3575b506140fe6103e66001546001600160a01b031690565b9561410886614596565b925115159261411861137761194f565b602087015260408601526060850152151586840152565b6040518096819582947f2637a45000000000000000000000000000000000000000000000000000000000845260048401614032565b03925af19081156104d35760009161417a575090565b610f9b915060803d60801161419c575b614194818361191f565b810190613fe8565b503d61418a565b6141ac9061571a565b386140e8565b6141ba613e26565b6040805160208101906141d1816107338685612f4d565b519020926141ec61058d856000526008602052604060002090565b6141f5816106a4565b6143805760a0830135421161435757466101208401350361432e576060830173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee806001600160a01b0361423b84613035565b16141580614325575b6142fc5761425f6107cf876000526008602052604060002090565b61426b6103e683613035565b036142b957505060c0820135340361083757517f181de28643611afcf1cb4c095a1ef99c157e78437294f478c978e4a56e1ca77e9181906142ac9082612f4d565b0390a26103366001600455565b916108a47f181de28643611afcf1cb4c095a1ef99c157e78437294f478c978e4a56e1ca77e94926142ef6103e66142ac96613035565b60c08501359130916157e0565b600484517fd453e7b5000000000000000000000000000000000000000000000000000000008152fd5b50341515614244565b600482517f9284b197000000000000000000000000000000000000000000000000000000008152fd5b600482517fc56873ba000000000000000000000000000000000000000000000000000000008152fd5b600482517f966753c5000000000000000000000000000000000000000000000000000000008152fd5b909160005b8181106143bf575050505060001990565b6143ca818386612ddb565b356143d4816109ba565b6001600160a01b038085169116146143ee576001016143ae565b9250505090565b9392949190614402613e26565b845115801561458a575b801561457e575b8015614573575b6118335760005b85518110156144a2576144348187613093565b5190600161444f61058d846000526008602052604060002090565b614458816106a4565b0361126657816144776105b66001946000526008602052604060002090565b7fd48052bf92f3eec93ecdeeec72ea80e1071c926cb4d6e5a37ee71be8a0ce9a10600080a201614421565b50919350919360005b855181101561456357806144c160019284613093565b516144ea6144e2611c9b6144d5858c613093565b516001600160a01b031690565b9182546130b7565b905573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6145116103e66144d5848b613093565b03614539576145336145238287613093565b516001600160a01b038616614941565b016144ab565b61455e61454c6103e66144d5848b613093565b856145578489613093565b51916148ab565b614533565b5050505090506103366001600455565b50600284511061441a565b50855184511415614413565b5081518451141561440c565b63ffffffff168060005260026020526040600020549081156145b6575090565b602490604051907ff6ff4fb70000000000000000000000000000000000000000000000000000000082526004820152fd5b9080601f830112156102fd57602090823561460181612eca565b9361460f604051958661191f565b81855260208086019260051b8201019283116102fd57602001905b828210614638575050505090565b8135815290830190830161462a565b9080601f830112156102fd57602090823561466181612eca565b9361466f604051958661191f565b81855260208086019260051b8201019283116102fd57602001905b828210614698575050505090565b8135815290830190830161468a565b9080601f830112156102fd57816020610f9b933591016130d1565b91909160c0818403126102fd576146d88161032b565b9267ffffffffffffffff60208301358181116102fd57826146fa9185016145e7565b93614707604085016109f4565b9360608101358381116102fd5784614720918301614647565b9360808201358481116102fd5781614739918401614647565b9360a08301359081116102fd57610f9b92016146a7565b9190916011546020820135036148815761476990613129565b63ffffffff61478961478060105463ffffffff1690565b63ffffffff1690565b91160361485757816147a5916001600160a01b039301906146c2565b93949195909216906147b681612e32565b8061480e57506001835114801590614802575b80156147f6575b611833576147f06144d56147e96147e961033698613086565b5194613086565b9361583d565b506001825114156147d0565b506001855114156147c9565b8061481f6001929794959697612e32565b0361482d57610336946143f5565b60046040517f43013282000000000000000000000000000000000000000000000000000000008152fd5b60046040517fc6705675000000000000000000000000000000000000000000000000000000008152fd5b60046040517f5c49dc24000000000000000000000000000000000000000000000000000000008152fd5b916001600160a01b03604051927fa9059cbb000000000000000000000000000000000000000000000000000000006020850152166024830152604482015260448152608081019181831067ffffffffffffffff8411176118aa576103369260405261594a565b3d1561493c573d906149228261197d565b91614930604051938461191f565b82523d6000602084013e565b606090565b8147106149945760008080936001600160a01b038294165af1614962614911565b501561496a57565b60046040517f1425ea42000000000000000000000000000000000000000000000000000000008152fd5b60246040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152fd5b906040828203126102fd57610f9b91613fc0565b80356149e3816109ba565b614ae46020830135916149f5836109ba565b610733614a0460408601613035565b614a1060608701613035565b614a1c60808801613035565b9160405196879560208701998a6101608201359661014083013596610120840135966101008501359660e08601359660a060c0880135970135959895929c9b9a979490916101809a97946040936101a08c019f7fa85cf3e3ad772b6de109a440bbce9afa8bf3ad775604b14049d27ae5650d3d3a8d528c6001600160a01b0396878096818096166020850152169101521660608c01521660808a01521660a088015260c087015260e08601526101008501526101208401526101408301526101608201520152565b51902090565b6001600160a01b03600054163303614afe57565b60246040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152fd5b63ffffffff1660008181526002602090815260409182902084905581519283528201929092527f238399d427b947898edb290f5ff0f9109849b1c3ba196a42e35f00c50a54b98b91819081016136f6565b614b87613e26565b6040908151936020850185614c42848381516001600160a01b03168152610180810192916020818101516001600160a01b0316908301526040818101516001600160a01b0316908301526060818101516001600160a01b0316908301526080818101516001600160a01b03169083015260a081015160a083015260c081015160c083015260e081015160e083015261010080820151908301526101208082015190830152610140808201519083015261016080910151910152565b0395614c56601f199788810183528261191f565b51902094614c7161058d876000526009602052604060002090565b614c7a816123c1565b61509257838301614c956103e682516001600160a01b031690565b330361506957610140840151460361504057614cbe6107cf886000526009602052604060002090565b608084016001600160a01b03614cdb82516001600160a01b031690565b1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103614eda575050506101608301805190919015614e96578451614d1f60208201928261260c878b8761510b565b519020905103614e6d57614d3e6103e6600c546001600160a01b031690565b9060e083015191803b156102fd57614d879560009386518098819582947ff87ef8000000000000000000000000000000000000000000000000000000000084526004840161510b565b03925af19182156104d3577f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b7936142ac936127665750519182918281516001600160a01b03168152610180810192916020818101516001600160a01b0316908301526040818101516001600160a01b0316908301526060818101516001600160a01b0316908301526080818101516001600160a01b03169083015260a081015160a083015260c081015160c083015260e081015160e083015261010080820151908301526101208082015190830152610140808201519083015261016080910151910152565b600483517f332c0963000000000000000000000000000000000000000000000000000000008152fd5b5050507f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b792506142ac916127f16127e66103e660208501516001600160a01b031690565b90919261016086989598019182511515600014614fff57508651614f0860208201928261260c8c8a8761510b565b519020905103614fd65790614f2d6128476103e6614f4294516001600160a01b031690565b6129966103e6600c546001600160a01b031690565b614f576103e6600c546001600160a01b031690565b93843b156102fd57614f9b946000928386518098819582947ff87ef8000000000000000000000000000000000000000000000000000000000084526004840161510b565b03925af19182156104d3577f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b7936142ac9361290957506126b6565b600485517f332c0963000000000000000000000000000000000000000000000000000000008152fd5b925050507f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b795506142ac9492506129876127f192516001600160a01b031690565b600485517fb86ac1ef000000000000000000000000000000000000000000000000000000008152fd5b600485517fa4e189a6000000000000000000000000000000000000000000000000000000008152fd5b600484517f4747436c000000000000000000000000000000000000000000000000000000008152fd5b90357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1823603018112156102fd57016020813591019167ffffffffffffffff82116102fd5781360383136102fd57565b9160208181850182865252604093604081019460408460051b83010195856000935b86851061513f57505050505050505090565b90919293949596977fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc082820301845288357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61843603018112156102fd57830190813560a060048210156102fd576001938a9361520561522393856151c388976106a4565b83526001600160a01b03868501356151da816109ba565b16868401528b8401358c840152606090806151f7838701876150bb565b929093860152840191613148565b91615215608091828101906150bb565b929091818503910152613148565b9a01940195019392969594919061512d565b604051614ae48161073360208201947fa5b4aa1bcb538076d57d083e3004c6907e2eba42d84c21922d441967a02b472f86526040808401526060830190610f65565b90615286939291959495613ddf565b156152a057816147a5916001600160a01b039301906146c2565b60046040517fca37de93000000000000000000000000000000000000000000000000000000008152fd5b600054906001600160a01b0380911691827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b6153348383615aea565b50615341819592956106a4565b1593846153f6575b508315615357575b50505090565b60009293509082916040516153a98161073360208201947f1626ba7e00000000000000000000000000000000000000000000000000000000998a87526024840152604060448401526064830190610f65565b51915afa906153b6614911565b826153e8575b826153cc575b5050388080615351565b9091506020818051810103126102fd57602001511438806153c2565b9150602082511015916153bc565b6001600160a01b03838116911614935038615349565b9091615423610f9b93604084526040840190610f65565b916020818403910152610f65565b9190825115615581578051156155815761544a83615235565b9281519367ffffffffffffffff85116118aa576154718561546b8354612098565b83613880565b602080601f87116001146154f25750857fdb6b260ea45f7fe513e1d3b8c21017a29e3a41610e95aefb8862b81c69aec61c95966154c3926000916154e7575b506000198260011b9260031b1c19161790565b90555b6154cf816155ab565b8251602084012090556136f66040519283928361540c565b9050850151386154b0565b90601f19871661550784600052602060002090565b926000905b8282106155695750509187917fdb6b260ea45f7fe513e1d3b8c21017a29e3a41610e95aefb8862b81c69aec61c979860019410615550575b5050811b0190556154c6565b86015160001960f88460031b161c191690553880615544565b80600185968294968b0151815501950193019061550c565b60046040517fdeba1689000000000000000000000000000000000000000000000000000000008152fd5b604051614ae48161073360208201947f5f58fea7d48d37d5d1cc2546dfcc3d3cbfe8d758d5ca19c44087f52e15a1050586526040808401526060830190610f65565b60028151106155fd576002015190565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f746f55696e7431365f6f75744f66426f756e64730000000000000000000000006044820152fd5b602090615672600495949382815194859201610f42565b01907fffff0000000000000000000000000000000000000000000000000000000000007f01000000000000000000000000000000000000000000000000000000000000009182845260f01b16600183015260038201526156db8251809360208685019101610f42565b010190565b8034036156ea5790565b60246040517f9f704120000000000000000000000000000000000000000000000000000000008152346004820152fd5b6001600160a01b03908160015416916040517fe4fe1d94000000000000000000000000000000000000000000000000000000008152602081600481875afa9081156104d3576000916157a5575b501691821561577b576103369233906157e0565b60046040517f5373352a000000000000000000000000000000000000000000000000000000008152fd5b90506020813d6020116157d8575b816157c06020938361191f565b810103126102fd57516157d2816109ba565b38615767565b3d91506157b3565b909261033693604051937f23b872dd0000000000000000000000000000000000000000000000000000000060208601526001600160a01b038092166024860152166044840152606483015260648252615838826118e7565b61594a565b929390949161584a613e26565b8351156118335760009560005b85518110156158d75761586a8187613093565b5190600161588561058d846000526008602052604060002090565b61588e816106a4565b0361126657816158ad6105b66001946000526008602052604060002090565b7fd48052bf92f3eec93ecdeeec72ea80e1071c926cb4d6e5a37ee71be8a0ce9a108a80a201615857565b509295509250926158fe6144e2856001600160a01b03166000526007602052604060002090565b90556001600160a01b0392831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee810361593b57506159319216614941565b6103366001600455565b61594593506148ab565b615931565b6000806001600160a01b0361597493169360208151910182865af161596d614911565b9083615d84565b80519081151591826159bb575b505061598a5750565b602490604051907f5274afe70000000000000000000000000000000000000000000000000000000082526004820152fd5b6159ce9250602080918301019101613133565b153880615981565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016301480615ac1575b15615a31577f000000000000000000000000000000000000000000000000000000000000000090565b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527f000000000000000000000000000000000000000000000000000000000000000060408201527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260a08152614ae481611903565b507f00000000000000000000000000000000000000000000000000000000000000004614615a08565b8151919060418303615b1b57615b1492506020820151906060604084015193015160001a90615d00565b9192909190565b505060009160029190565b60ff8114615b7c5760ff811690601f8211615b525760405191615b48836118af565b8252602082015290565b60046040517fb3512b0c000000000000000000000000000000000000000000000000000000008152fd5b50604051600554816000615b8f83612098565b80835292602090600190818116908115615c1b5750600114615bba575b5050610f9b9250038261191f565b91509260056000527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0936000925b828410615c035750610f9b9450505081016020013880615bac565b85548785018301529485019486945092810192615be8565b905060209350610f9b95925060ff1991501682840152151560051b8201013880615bac565b60ff8114615c625760ff811690601f8211615b525760405191615b48836118af565b50604051600654816000615c7583612098565b80835292602090600190818116908115615c1b5750600114615c9f575050610f9b9250038261191f565b91509260066000527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f936000925b828410615ce85750610f9b9450505081016020013880615bac565b85548785018301529485019486945092810192615ccd565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411615d7857926020929160ff608095604051948552168484015260408301526060820152600092839182805260015afa156104d35780516001600160a01b03811615615d6f57918190565b50809160019190565b50505060009160039190565b90615d99575080511561496a57805190602001fd5b81511580615de4575b615daa575090565b6024906001600160a01b03604051917f9996b315000000000000000000000000000000000000000000000000000000008352166004820152fd5b50803b15615da256fea2646970667358221220d7cc3795083b4b25b61f11142c6e0c2ccba56dd497bce2e0ca9ed4f05acfb03364736f6c63430008170033
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c80630630dea4146102c7578063076e9f6c146102c25780630d77797c146102bd578063116191b6146102b85780631191c72e146102b357806312261ee7146102ae57806313137d65146102a957806317442b70146102a45780631a98b2e01461029f5780631c93b03a1461029a5780631e44fb971461029557806321b4ae78146102905780632b8cb1f61461028b5780632e3d6cf9146102865780633400288b14610281578063365324411461027c578063477aedc714610277578063491606581461027257806358c0f7291461026d57806359ce62e9146102685780635e280f11146102635780636a22d8cc1461025e578063715018a61461025957806379db29c8146102545780637d25a05e1461024f57806382413eac1461024a57806382c947b71461024557806382e5f9e41461024057806384b0196e1461023b5780638da5cb5b14610236578063951f401614610231578063a32b52a71461022c578063aab59a0914610227578063b98ef27514610222578063bb0b6a531461021d578063c415b95c14610218578063c506bff414610213578063ca5eb5e11461020e578063db715f7b14610209578063f2fde38b14610204578063f69b1b29146101ff578063ff7bd03d146101fa5763ffd5982a146101f557600080fd5b612d8b565b612d45565b612d21565b612cb3565b612c75565b612be3565b612b7e565b612b57565b612b1c565b612a6b565b612403565b6123cb565b6123a3565b61237c565b61226d565b61222e565b612068565b612009565b611fe2565b611e9b565b611e29565b611e02565b611ddb565b611db4565b611c27565b611ae5565b611a16565b611708565b6116d7565b61144d565b611429565b6112b6565b6110a8565b610f9e565b610eb2565b610e90565b610d7e565b610d18565b6109ff565b610961565b6106fd565b6106b3565b610338565b9181601f840112156102fd5782359167ffffffffffffffff83116102fd576020808501948460051b0101116102fd57565b600080fd5b604435906fffffffffffffffffffffffffffffffff821682036102fd57565b600211156102fd57565b359061033682610321565b565b60806003193601126102fd576004803567ffffffffffffffff81116102fd5761036490369083016102cc565b909161036e610302565b926064359061037c82610321565b610384613e26565b341561064c5783156106235760005b84811061056b57506103bf906103b160405195869260208401612df0565b03601f19810185528461191f565b6103c881612e32565b806104eb57509091506103f26103e6600a546001600160a01b031690565b6001600160a01b031690565b803b156102fd57600060405180927f0c93e3bb00000000000000000000000000000000000000000000000000000000825281806104333389308a8501612e3c565b039134905af180156104d3576104d8575b5061045a6103e66003546001600160a01b031690565b91823b156102fd5761049d92600092836040518096819582947f1c92115f0000000000000000000000000000000000000000000000000000000084528301612e98565b03925af180156104d3576104ba575b505b6104b86001600455565b005b806104c76104cd92611896565b80610956565b386104ac565b612e8c565b806104c76104e592611896565b38610444565b806104f7600192612e32565b03610543575061051161053d9261050c613e61565b613e96565b9061052160105463ffffffff1690565b9161052a611942565b91348352602435602084015233936140bd565b506104ae565b6040517f7626db82000000000000000000000000000000000000000000000000000000008152fd5b61059461058d61057c838886612ddb565b356000526009602052604060002090565b5460ff1690565b61059d816123c1565b156105fa57806105c36105b661057c6001948987612ddb565b600260ff19825416179055565b6105ce818785612ddb565b357f69f975bd70ea51b973eb6aff3812f49adf595bd59d6f3d29840d5695cc19ba30600080a201610393565b836040517f4811daf5000000000000000000000000000000000000000000000000000000008152fd5b826040517f9d89020a000000000000000000000000000000000000000000000000000000008152fd5b826040517f03aeed96000000000000000000000000000000000000000000000000000000008152fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600411156106ae57565b610675565b346102fd5760206003193601126102fd576004356000526008602052602060ff60406000205416604051906106e7816106a4565b8152f35b6003196101809101126102fd57600490565b6101806003193601126102fd57610713366106eb565b61071b613e26565b60409081516020810190610741816107338585612f4d565b03601f19810183528261191f565b5190209161075c61058d846000526008602052604060002090565b610765816106a4565b61092d5760a082013542116109045746610120830135036108db576060820173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee806001600160a01b036107ab84613035565b161415806108d2575b6108a9576107dc6107cf866000526008602052604060002090565b600160ff19825416179055565b6107e86103e683613035565b03610860575060c08201353403610837577f181de28643611afcf1cb4c095a1ef99c157e78437294f478c978e4a56e1ca77e9161082a915b5191829182612f4d565b0390a26104b86001600455565b600490517f44e8bd2c000000000000000000000000000000000000000000000000000000008152fd5b9161082a916108a46108956103e67f181de28643611afcf1cb4c095a1ef99c157e78437294f478c978e4a56e1ca77e96613035565b60c084013590309033906157e0565b610820565b600483517fd453e7b5000000000000000000000000000000000000000000000000000000008152fd5b503415156107b4565b600490517f9284b197000000000000000000000000000000000000000000000000000000008152fd5b600490517fc56873ba000000000000000000000000000000000000000000000000000000008152fd5b600490517f966753c5000000000000000000000000000000000000000000000000000000008152fd5b60009103126102fd57565b346102fd5760006003193601126102fd5760206001600160a01b0360035416604051908152f35b9181601f840112156102fd5782359167ffffffffffffffff83116102fd5760208085019461018085020101116102fd57565b6001600160a01b038116036102fd57565b60843590610336826109ba565b6101043590610336826109ba565b6101243590610336826109ba565b3590610336826109ba565b6060806003193601126102fd5760049067ffffffffffffffff82358181116102fd57610a2e9036908501610988565b90916024359081116102fd57610a4790369086016102cc565b949060443591610a56836109ba565b83158015610d0e575b610ce657610a6c84612ee2565b95610a7688612ee2565b94610a8089612ee2565b966000936001600160a01b0393848816955b848110610ab55750505050505050610aaf906104b89636916130d1565b936143f5565b610ac0818686612f3c565b6040908151610ad781610733602082019485612f4d565b519020906001610af461058d846000526009602052604060002090565b610afd816123c1565b03610cbe5746610120610b11858a8a612f3c565b013503610c965746610140610b27858a8a612f3c565b013503610c6e578888610b4583610b3f878c8c612f3c565b01613035565b1603610c4657610b648f8b610b5f87610b3f888d8d612f3c565b6143a9565b906000198214610c1e575090610c17838f8f8f908396610bf4610c07888f948f60019d610c1197610c009260c094610bdc6105b6610bcb610bc289610baa898989612f3c565b0135610100610bba8a8a8a612f3c565b01359061306e565b620f4240900490565b986000526009602052604060002090565b610bfa8a610bf489610bee8386613093565b516130b7565b92613093565b52612f3c565b01356130c4565b610bee8386613093565b52613093565b5201610a92565b8590517fdf4c7777000000000000000000000000000000000000000000000000000000008152fd5b8490517f69fa1755000000000000000000000000000000000000000000000000000000008152fd5b8490517f9284b197000000000000000000000000000000000000000000000000000000008152fd5b8490517fb86ac1ef000000000000000000000000000000000000000000000000000000008152fd5b8490517f4811daf5000000000000000000000000000000000000000000000000000000008152fd5b6040517f9d89020a000000000000000000000000000000000000000000000000000000008152fd5b5060028710610a5f565b346102fd5760006003193601126102fd5760206001600160a01b03600b5416604051908152f35b60031960609101126102fd57600490565b9181601f840112156102fd5782359167ffffffffffffffff83116102fd57602083818601950101116102fd57565b60e06003193601126102fd57610d9336610d3f565b67ffffffffffffffff6084358181116102fd57610db4903690600401610d50565b91610dc060a4356109ba565b60c4359081116102fd57610dd8903690600401610d50565b50506001600160a01b03600154163303610e5f57610dfd610df884613129565b614596565b926020810135809403610e14576104b89350614750565b610e1e8491613129565b6040517fc26bebcc00000000000000000000000000000000000000000000000000000000815263ffffffff9190911660048201526024810191909152604490fd5b6040517f91ac5e4f000000000000000000000000000000000000000000000000000000008152336004820152602490fd5b346102fd5760006003193601126102fd57604080516001815260026020820152f35b346102fd5760c06003193601126102fd5767ffffffffffffffff6024358181116102fd57610ee4903690600401610d50565b6044358381116102fd57610efc903690600401610d50565b6064929192358581116102fd57610f17903690600401610d50565b916084359687116102fd57610f336104b8973690600401610d50565b95909460a43597600435613169565b60005b838110610f555750506000910152565b8181015183820152602001610f45565b90601f19601f602093610f8381518092818752878088019101610f42565b0116010190565b906020610f9b928181520190610f65565b90565b346102fd576000806003193601126110a55760405190807f0e2c162a1f4b5cff9fdbd6b34678a9bcb9898a0b9fbca695b112d61688d8b2ac8054610fe181612098565b80865292602092600192808416908115611075575060011461101e575b61101a8761100e8189038261191f565b60405191829182610f8a565b0390f35b815293507f6703f9a97b5b44375099a890a40c8c70a9efc4d97fa39f72811f72b1a93211625b8385106110625750505050810160200161100e8261101a3880610ffe565b8054868601840152938201938101611044565b905087965061101a9794506020935061100e95925060ff1991501682840152151560051b82010192933880610ffe565b80fd5b346102fd576101806003193601126102fd576110c3366106eb565b6110cb613e26565b60405160208101906110e1816107338585612f4d565b5190209060016110fe61058d846000526008602052604060002090565b611107816106a4565b036112665761111b6103e660408301613035565b3303611221575b46610120820135036111f757611152611145836000526008602052604060002090565b600360ff19825416179055565b606081019073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0361117d84613035565b16036111ce5761119f915060c06111966103e683613035565b91013590614941565b7fa60671d8537ed193e567f86ddf28cf35dc67073b5ad80a2d41359cfa78db0a1e600080a26104b86001600455565b6111dd6103e66111f293613035565b9060c06111e982613035565b910135916148ab565b61119f565b60046040517f9284b197000000000000000000000000000000000000000000000000000000008152fd5b61123761123160a08301356130a7565b42111590565b156111225760046040517f796c85f3000000000000000000000000000000000000000000000000000000008152fd5b60046040517fab81a57d000000000000000000000000000000000000000000000000000000008152fd5b63ffffffff8116036102fd57565b610144359061033682611290565b801515036102fd57565b346102fd5760806003193601126102fd576004356112d381611290565b60243567ffffffffffffffff81116102fd5761133c916112fa6113cf9236906004016102cc565b61139a611308939293610302565b61134460643591611318836112ac565b604098899761132e895197889260208401612df0565b03601f19810187528661191f565b61050c613e61565b61134c613272565b506113626103e66001546001600160a01b031690565b9361136c86614596565b61138361137761194f565b63ffffffff9098168852565b602087015286860152606085015215156080840152565b825180809581947fddc28c58000000000000000000000000000000000000000000000000000000008352309060048401614032565b03915afa9081156104d3576000916113fc575b508051602091820151925190815290810191909152604090f35b61141c9150823d8411611422575b611414818361191f565b8101906149c4565b386113e2565b503d61140a565b346102fd5760006003193601126102fd57602063ffffffff60105416604051908152f35b346102fd576102206003193601126102fd57611468366106eb565b60807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7c3601126102fd57610204359067ffffffffffffffff82116102fd576114b560049236908401610d50565b90916114bf613e26565b604091825160208101906114d7816107338685612f4d565b519020946114f261058d876000526008602052604060002090565b6114fb816106a4565b6116b05760a083013542116116895746610120840135036116625773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0361153f60608601613035565b161461163b5761155c6107cf876000526008602052604060002090565b611564613272565b3081529460c0840135602087015261157b846149d8565b956115916103e6600b546001600160a01b031690565b9161159b86613035565b936115a461328b565b843b156102fd5760009687936115e7928b519c8d998a9889977f137c29fe0000000000000000000000000000000000000000000000000000000089528801613409565b03925af19182156104d3577f181de28643611afcf1cb4c095a1ef99c157e78437294f478c978e4a56e1ca77e9361082a93611628575b505191829182612f4d565b806104c761163592611896565b3861161d565b83517f8dccaef7000000000000000000000000000000000000000000000000000000008152fd5b83517f9284b197000000000000000000000000000000000000000000000000000000008152fd5b83517fc56873ba000000000000000000000000000000000000000000000000000000008152fd5b83517f966753c5000000000000000000000000000000000000000000000000000000008152fd5b346102fd5760406003193601126102fd576104b86004356116f781611290565b6116ff614aea565b60243590614b2e565b6040806003193601126102fd57600467ffffffffffffffff81358181116102fd57611737903690600401610988565b90916024359081116102fd576117519036906004016102cc565b9290948215801561185d575b61183357349060005b84811061176f57005b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6117976103e66080610b3f858a8a612f3c565b146117d2575b806117cc6117c78a6117bd848b6117b76001988d8d612f3c565b9361348f565b92909136906134f2565b614b7f565b01611766565b9160e0806117e1858888612f3c565b0135821061180b57600191611803916117fb868989612f3c565b0135906130c4565b92905061179d565b8783517f27ea1575000000000000000000000000000000000000000000000000000000008152fd5b60046040517f9d89020a000000000000000000000000000000000000000000000000000000008152fd5b508383141561175d565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b67ffffffffffffffff81116118aa57604052565b611867565b6040810190811067ffffffffffffffff8211176118aa57604052565b6060810190811067ffffffffffffffff8211176118aa57604052565b60a0810190811067ffffffffffffffff8211176118aa57604052565b60c0810190811067ffffffffffffffff8211176118aa57604052565b90601f601f19910116810190811067ffffffffffffffff8211176118aa57604052565b60405190610336826118af565b60405190610336826118e7565b60405190610180820182811067ffffffffffffffff8211176118aa57604052565b67ffffffffffffffff81116118aa57601f01601f191660200190565b9291926119a58261197d565b916119b3604051938461191f565b8294818452818301116102fd578281602093846000960137010152565b9080601f830112156102fd57816020610f9b93359101611999565b60206003198201126102fd576004359067ffffffffffffffff82116102fd57610f9b916004016119d0565b346102fd57611a2c611a27366119eb565b615235565b60405190600082825491611a3f83612098565b9283835260209460019186600182169182600014611ac2575050600114611a83575b5050611a6f9250038361191f565b61101a604051928284938452830190610f65565b85925060005281600020906000915b858310611aaa575050611a6f93508201013880611a61565b80548389018501528794508693909201918101611a92565b91509350611a6f95925060ff1991501682840152151560051b8201013880611a61565b346102fd5760806003193601126102fd57600467ffffffffffffffff6024358181116102fd57611b189036908401610d50565b916044358181116102fd57611b309036908601610d50565b916064359081116102fd57611b489036908701610d50565b94909382602083611b5a368a8a611999565b8281519101208460008c611bac6001600160a01b0360035416948c604051998a98899788967f5f6970c300000000000000000000000000000000000000000000000000000000885280359088016135a3565b03925af19081156104d357600091611bf8575b5015611bcf576104b89650615277565b866040517f500c44b4000000000000000000000000000000000000000000000000000000008152fd5b611c1a915060203d602011611c20575b611c12818361191f565b810190613133565b38611bbf565b503d611c08565b346102fd5760206003193601126102fd5760043567ffffffffffffffff81116102fd57611c589036906004016102cc565b906001600160a01b0390600d9082600d54163303611d8a5783156118335760005b848110611c8257005b80611cb4611c9b611c966001948987612ddb565b613035565b6001600160a01b03166000526007602052604060002090565b5480611d04575b84546001600160a01b03168680611cd6611c96868c8a612ddb565b1691167f9bcb6d1f38f6800906185471a11ede9a8e16200853225aa62558db6076490f2d600080a401611c79565b6000611d17611c9b611c96858b89612ddb565b5573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee86611d3c611c96858b89612ddb565b1603611d6457611d5f81611d5a6103e688546001600160a01b031690565b614941565b611cbb565b611d5f81611d796103e6611c96868c8a612ddb565b87546001600160a01b0316906148ab565b60046040517f91034599000000000000000000000000000000000000000000000000000000008152fd5b346102fd5760006003193601126102fd5760206001600160a01b03600c5416604051908152f35b346102fd5760006003193601126102fd5760206001600160a01b0360015416604051908152f35b346102fd5760006003193601126102fd5760206001600160a01b03600a5416604051908152f35b346102fd576000806003193601126110a557611e43614aea565b806001600160a01b0381547fffffffffffffffffffffffff000000000000000000000000000000000000000081168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b346102fd576101a06003193601126102fd57611eb6366106eb565b6101843567ffffffffffffffff81116102fd57611ed7903690600401610d50565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b036060850135611f02816109ba565b1614611fb857611f7791611f7391611f6d853592611f1f846109ba565b6042611f2a886149d8565b611f326159d6565b90604051917f190100000000000000000000000000000000000000000000000000000000000083526002830152602282015220923691611999565b9161532a565b1590565b611f8e5780611f886104b892613035565b906141b2565b60046040517fe3fb657c000000000000000000000000000000000000000000000000000000008152fd5b60046040517f8dccaef7000000000000000000000000000000000000000000000000000000008152fd5b346102fd5760406003193601126102fd57611ffe600435611290565b602060405160008152f35b346102fd5760a06003193601126102fd5761202336610d3f565b5060643567ffffffffffffffff81116102fd57612044903690600401610d50565b50506020608435612054816109ba565b604051906001600160a01b03309116148152f35b346102fd5760206003193601126102fd576020600435612087816109ba565b6001600160a01b0360405191168152f35b90600182811c921680156120e1575b60208310146120b257565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b91607f16916120a7565b600e54600092916120fb82612098565b8082529160209060019081811690811561217a575060011461211e575b50505050565b92939450600e6000527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd926000935b858510612167575050506020925001019038808080612118565b805485850184015293820193810161214d565b915050602094955060ff1991509291921683830152151560051b01019038808080612118565b600f54600092916121b082612098565b8082529160209060019081811690811561217a57506001146121d25750505050565b92939450600f6000527f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac802926000935b85851061221b575050506020925001019038808080612118565b8054858501840152938201938101612201565b346102fd5760006003193601126102fd5761101a60405161225981612252816120eb565b038261191f565b604051918291602083526020830190610f65565b346102fd5760006003193601126102fd5761232b6122aa7f53706f6b65000000000000000000000000000000000000000000000000000005615b26565b6122d37f3100000000000000000000000000000000000000000000000000000000000001615c40565b906122dc612f13565b906040519384937f0f00000000000000000000000000000000000000000000000000000000000000855261231d60209360e0602088015260e0870190610f65565b908582036040870152610f65565b466060850152306080850152600060a085015283810360c08501526020808451928381520193019160005b82811061236557505050500390f35b835185528695509381019392810192600101612356565b346102fd5760006003193601126102fd5760206001600160a01b0360005416604051908152f35b346102fd5760006003193601126102fd576020601154604051908152f35b600311156106ae57565b346102fd5760206003193601126102fd57600435600052600960205260ff6040600020541660405160038210156106ae576020918152f35b6101a06003193601126102fd57612419366106eb565b610184359067ffffffffffffffff82116102fd5761243c600492369084016102cc565b608083929301359361244d856109ba565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee92836001600160a01b038097161480612a43575b612a1a576124859036906134f2565b9161248e613e26565b6040938451906020820182612549878381516001600160a01b03168152610180810192916020818101516001600160a01b0316908301526040818101516001600160a01b0316908301526060818101516001600160a01b0316908301526080818101516001600160a01b03169083015260a081015160a083015260c081015160c083015260e081015160e083015261010080820151908301526101208082015190830152610140808201519083015261016080910151910152565b039261255d601f199485810183528261191f565b5190209761257861058d8a6000526009602052604060002090565b612581816123c1565b6129f2578686019161259d6103e684516001600160a01b031690565b33036129ca5761014087015146036129a2576125c66107cf8b6000526009602052604060002090565b60808701916125dc83516001600160a01b031690565b169081036127f65750505061016084018051909190156127a157855161261860208201928261260c878c8761510b565b0390810183528261191f565b519020905103612779576126376103e6600c546001600160a01b031690565b60e084015195813b156102fd5761267e966000948751988995869485937ff87ef800000000000000000000000000000000000000000000000000000000008552840161510b565b03925af19182156104d3577f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b79361082a93612766575b505b519182918281516001600160a01b03168152610180810192916020818101516001600160a01b0316908301526040818101516001600160a01b0316908301526060818101516001600160a01b0316908301526080818101516001600160a01b03169083015260a081015160a083015260c081015160c083015260e081015160e083015261010080820151908301526101208082015190830152610140808201519083015261016080910151910152565b806104c761277392611896565b386126b4565b5082517f332c0963000000000000000000000000000000000000000000000000000000008152fd5b505050507f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b7925061082a916127f16127e66103e660208501516001600160a01b031690565b60e084015190614941565b6126b6565b90919261016087019182511515600014612944575087516020810191612822908261260c898e8761510b565b51902090510361291c57906128556128476103e661287694516001600160a01b031690565b91516001600160a01b031690565b61286a6103e6600c546001600160a01b031690565b9060e0870151926157e0565b61288b6103e6600c546001600160a01b031690565b803b156102fd576128cd95600080948751988995869485937ff87ef800000000000000000000000000000000000000000000000000000000008552840161510b565b03925af19182156104d3577f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b79361082a93612909575b506126b6565b806104c761291692611896565b38612903565b8386517f332c0963000000000000000000000000000000000000000000000000000000008152fd5b93517f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b7995061082a9896506127f195506001600160a01b03169250612987915050565b60208501516001600160a01b03165b9060e0860151926157e0565b8588517fb86ac1ef000000000000000000000000000000000000000000000000000000008152fd5b8588517fa4e189a6000000000000000000000000000000000000000000000000000000008152fd5b8487517f4747436c000000000000000000000000000000000000000000000000000000008152fd5b506040517f44e8bd2c000000000000000000000000000000000000000000000000000000008152fd5b5060e0810135341415612476565b60643590610336826109ba565b60e43590610336826109ba565b346102fd576101606003193601126102fd57600435612a89816109ba565b60243590612a96826109ba565b60443591612aa3836109ba565b612aab612a51565b92612ab46109cb565b67ffffffffffffffff949060a4358681116102fd57612ad79036906004016119d0565b60c4359687116102fd57612af26104b89736906004016119d0565b91612afb612a5e565b93612b046109d8565b95612b0d6109e6565b97612b1661129e565b996135d9565b346102fd5760206003193601126102fd5763ffffffff600435612b3e81611290565b1660005260026020526020604060002054604051908152f35b346102fd5760006003193601126102fd5760206001600160a01b03600d5416604051908152f35b346102fd5760406003193601126102fd5767ffffffffffffffff6004358181116102fd57612bb0903690600401610d50565b6024929192359182116102fd57602092612bd1612bd9933690600401610d50565b929091613ddf565b6040519015158152f35b346102fd57600060206003193601126110a557600435612c02816109ba565b612c0a614aea565b816001600160a01b03806001541692833b15612c71576024908360405195869485937fca5eb5e10000000000000000000000000000000000000000000000000000000085521660048401525af180156104d357612c65575080f35b612c6e90611896565b80f35b8280fd5b346102fd5760206003193601126102fd576001600160a01b03600435612c9a816109ba565b1660005260076020526020604060002054604051908152f35b346102fd5760206003193601126102fd57600435612cd0816109ba565b612cd8614aea565b6001600160a01b03811615612cf0576104b8906152ca565b60246040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260006004820152fd5b346102fd5760006003193601126102fd5761101a60405161225981612252816121a0565b346102fd5760606003193601126102fd576020612d6136610d3f565b63ffffffff8135612d7181611290565b166000526002825260406000205482604051920135148152f35b346102fd576020612da3612d9e366119eb565b6155ab565b54604051908152f35b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9190811015612deb5760051b0190565b612dac565b602081528260208201527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83116102fd5760409260051b809284830137010190565b600211156106ae57565b9190612e856080929594956001600160a01b03809316855260a06020860152612e77612e6a60a087016120eb565b86810360408801526121a0565b908582036060870152610f65565b9416910152565b6040513d6000823e3d90fd5b610f9b9160608252612ebc612eaf606084016120eb565b83810360208501526121a0565b916040818403910152610f65565b67ffffffffffffffff81116118aa5760051b60200190565b90612eec82612eca565b612ef9604051918261191f565b828152601f19612f098294612eca565b0190602036910137565b6040516020810181811067ffffffffffffffff8211176118aa5760405260008152906000368137565b9190811015612deb57610180020190565b61018081019291612f6e82612f61836109f4565b6001600160a01b03169052565b612f8d612f7d602083016109f4565b6001600160a01b03166020840152565b612fac612f9c604083016109f4565b6001600160a01b03166040840152565b612fcb612fbb606083016109f4565b6001600160a01b03166060840152565b612fea612fda608083016109f4565b6001600160a01b03166080840152565b60a081013560a083015260c081013560c083015260e081013560e083015261010080820135908301526101208082013590830152610140808201359083015261016080910135910152565b35610f9b816109ba565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8181029291811591840414171561308157565b61303f565b805115612deb5760200190565b8051821015612deb5760209160051b010190565b9062015180820180921161308157565b9190820180921161308157565b9190820391821161308157565b92916130dc82612eca565b916130ea604051938461191f565b829481845260208094019160051b81019283116102fd57905b8282106131105750505050565b838091833561311e816109ba565b815201910190613103565b35610f9b81611290565b908160209103126102fd5751610f9b816112ac565b601f8260209493601f19938186528686013760008582860101520116010190565b9260209861320892986131866131e09c95986000989a3691611999565b8b8151910120926131f46001600160a01b03600354169a6040519e8f9d8e9c8d9b7f1876eed9000000000000000000000000000000000000000000000000000000008d5260048d015260c060248d015260c48c0191613148565b9060031993848b84030160448c0152613148565b936064880152868403016084870152613148565b9060a483015203925af19081156104d357600091613253575b501561322957565b60046040517f500c44b4000000000000000000000000000000000000000000000000000000008152fd5b61326c915060203d602011611c2057611c12818361191f565b38613221565b6040519061327f826118af565b60006020838281520152565b60405190610140820182811067ffffffffffffffff8211176118aa5760405261011582527f746f6b656e2c75696e7432353620616d6f756e74290000000000000000000000610120837f4f72646572207769746e657373294f7264657228616464726573732066726f6d60208201527f416464726573732c6164647265737320746f416464726573732c61646472657360408201527f732066696c6c65722c616464726573732066726f6d546f6b656e2c616464726560608201527f737320746f546f6b656e2c75696e74323536206578706972792c75696e74323560808201527f362066726f6d416d6f756e742c75696e743235362066696c6c416d6f756e742c60a08201527f75696e7432353620666565526174652c75696e743235362066726f6d4368616960c08201527f6e2c75696e7432353620746f436861696e2c6279746573333220706f7374486f60e08201527f6f6b4861736829546f6b656e5065726d697373696f6e732861646472657373206101008201520152565b949290610f9b96949161346c613480946020610140946101843561342c816109ba565b6001600160a01b039081168c526101a435838d01526101c43560408d01526101e43560608d01528151811660808d015291015160a08b01521660c0890152565b60e087015280610100870152850190610f65565b92610120818503910152613148565b9190811015612deb5760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1813603018212156102fd57019081359167ffffffffffffffff83116102fd576020018260051b360381136102fd579190565b9190826101809103126102fd5761350761195c565b91613511816109f4565b835261351f602082016109f4565b6020840152613530604082016109f4565b6040840152613541606082016109f4565b6060840152613552608082016109f4565b608084015260a081013560a084015260c081013560c084015260e081013560e08401526101008082013590840152610120808201359084015261014080820135908401526101608091013590830152565b96959490606094926135d4946135c6928a52608060208b015260808a0191613148565b918783036040890152613148565b930152565b99979593919896949290987ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00998a549b60ff8d60401c16159c8d67ffffffffffffffff821680159182613794575b50600114908161378a575b159081613781575b50613757576136759c60018f927fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000161790556136fb57613ae3565b61367b57565b6136c77ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a007fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff8154169055565b604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29080602081015b0390a1565b6137527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00680100000000000000007fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff825416179055565b613ae3565b60046040517ff92ee8a9000000000000000000000000000000000000000000000000000000008152fd5b9050153861363a565b303b159150613632565b91508f613627565b601f81116137a8575050565b600090600e6000527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd906020601f850160051c83019410613804575b601f0160051c01915b8281106137f957505050565b8181556001016137ed565b90925082906137e4565b601f811161381a575050565b600090600f6000527f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac802906020601f850160051c83019410613876575b601f0160051c01915b82811061386b57505050565b81815560010161385f565b9092508290613856565b90601f811161388e57505050565b6000916000526020600020906020601f850160051c830194106138cc575b601f0160051c01915b8281106138c157505050565b8181556001016138b5565b90925082906138ac565b90815167ffffffffffffffff81116118aa576138fc816138f7600e54612098565b61379c565b602080601f831160011461393e5750819061392e9394600092613933575b50506000198260011b9260031b1c19161790565b600e55565b01519050388061391a565b90601f19831694613971600e6000527fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd90565b926000905b8782106139ae575050836001959610613995575b505050811b01600e55565b015160001960f88460031b161c1916905538808061398a565b80600185968294968601518155019501930190613976565b90815167ffffffffffffffff81116118aa576139ec816139e7600f54612098565b61380e565b602080601f8311600114613a2257508190613a1d93946000926139335750506000198260011b9260031b1c19161790565b600f55565b90601f19831694613a55600f6000527f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac80290565b926000905b878210613a92575050836001959610613a79575b505050811b01600f55565b015160001960f88460031b161c19169055388080613a6e565b80600185968294968601518155019501930190613a5a565b90610f9b926001600160a01b03809216835216602082015260806040820152613ad5608082016120eb565b9060608183039101526121a0565b92613ba5613c2497969593613b71613bd994613b3d8d9c9f9d98613b09613c0d9a613e06565b6001600160a01b03167fffffffffffffffffffffffff00000000000000000000000000000000000000006003541617600355565b6001600160a01b03167fffffffffffffffffffffffff0000000000000000000000000000000000000000600a541617600a55565b6001600160a01b03167fffffffffffffffffffffffff0000000000000000000000000000000000000000600b541617600b55565b6001600160a01b03167fffffffffffffffffffffffff0000000000000000000000000000000000000000600c541617600c55565b6001600160a01b03167fffffffffffffffffffffffff0000000000000000000000000000000000000000600d541617600d55565b613c16816138d6565b613c1f826139c6565b615431565b6001600160a01b0393848116907311111111111111111111111111111111111111118203613ce6575b5050505050613c646003546001600160a01b031690565b600a546001600160a01b0316917f66b86e9a862484192b40f4e2dc828c11d9e09ca77f9d2c226a96e743f99e4ec8613ca4600b546001600160a01b031690565b91613cb7600c546001600160a01b031690565b92613ce1613ccd600d546001600160a01b031690565b838060405195869516991697169583613aaa565b0390a4565b613d1e906001600160a01b03167fffffffffffffffffffffffff00000000000000000000000000000000000000006001541617600155565b803b156102fd576040517fca5eb5e10000000000000000000000000000000000000000000000000000000081526001600160a01b039290921660048301526000908290602490829084905af180156104d357613dc293613dbd928692613dcc575b50613db58463ffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000006010541617601055565b168092614b2e565b601155565b3880808080613c4d565b806104c7613dd992611896565b38613d7f565b613df2613e0193612d9e93953691611999565b60208151910120933691611999565b541490565b613e0e614aea565b6001600160a01b03811615612cf057610336906152ca565b600260045414613e37576002600455565b60046040517f3ee5aeb5000000000000000000000000000000000000000000000000000000008152fd5b6040517e03000000000000000000000000000000000000000000000000000000000000602082015260028152610f9b816118af565b9061ffff91600383613ea7836155ed565b1603613f5d577fffffffffffffffffffffffffffffffff000000000000000000000000000000006040519260801b16602083015260108252613ee8826118af565b600383613ef4836155ed565b1603613f5d578151838111613f2557831660010192831161308157610733610f9b926040519485936020850161565b565b604490604051907f6dfcc650000000000000000000000000000000000000000000000000000000008252601060048301526024820152fd5b82613f696024926155ed565b6040517f3a51740d00000000000000000000000000000000000000000000000000000000815291166004820152fd5b60405190613fa5826118cb565b8160008152600060208201526040613fbb613272565b910152565b91908260409103126102fd57604051613fd8816118af565b6020808294805184520151910152565b6080818303126102fd5760405191613fff836118cb565b81518352602082015167ffffffffffffffff811681036102fd57602084015261402a91604001613fc0565b604082015290565b906001600160a01b036020919493946040845263ffffffff815116604085015282810151606085015260806140ac614078604084015160a08489015260e0880190610f65565b60608401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08883030160a0890152610f65565b910151151560c08501529416910152565b60809361412f61416496946140d0613f98565b5060206140dd84516156e0565b9301908151806141a3575b506140fe6103e66001546001600160a01b031690565b9561410886614596565b925115159261411861137761194f565b602087015260408601526060850152151586840152565b6040518096819582947f2637a45000000000000000000000000000000000000000000000000000000000845260048401614032565b03925af19081156104d35760009161417a575090565b610f9b915060803d60801161419c575b614194818361191f565b810190613fe8565b503d61418a565b6141ac9061571a565b386140e8565b6141ba613e26565b6040805160208101906141d1816107338685612f4d565b519020926141ec61058d856000526008602052604060002090565b6141f5816106a4565b6143805760a0830135421161435757466101208401350361432e576060830173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee806001600160a01b0361423b84613035565b16141580614325575b6142fc5761425f6107cf876000526008602052604060002090565b61426b6103e683613035565b036142b957505060c0820135340361083757517f181de28643611afcf1cb4c095a1ef99c157e78437294f478c978e4a56e1ca77e9181906142ac9082612f4d565b0390a26103366001600455565b916108a47f181de28643611afcf1cb4c095a1ef99c157e78437294f478c978e4a56e1ca77e94926142ef6103e66142ac96613035565b60c08501359130916157e0565b600484517fd453e7b5000000000000000000000000000000000000000000000000000000008152fd5b50341515614244565b600482517f9284b197000000000000000000000000000000000000000000000000000000008152fd5b600482517fc56873ba000000000000000000000000000000000000000000000000000000008152fd5b600482517f966753c5000000000000000000000000000000000000000000000000000000008152fd5b909160005b8181106143bf575050505060001990565b6143ca818386612ddb565b356143d4816109ba565b6001600160a01b038085169116146143ee576001016143ae565b9250505090565b9392949190614402613e26565b845115801561458a575b801561457e575b8015614573575b6118335760005b85518110156144a2576144348187613093565b5190600161444f61058d846000526008602052604060002090565b614458816106a4565b0361126657816144776105b66001946000526008602052604060002090565b7fd48052bf92f3eec93ecdeeec72ea80e1071c926cb4d6e5a37ee71be8a0ce9a10600080a201614421565b50919350919360005b855181101561456357806144c160019284613093565b516144ea6144e2611c9b6144d5858c613093565b516001600160a01b031690565b9182546130b7565b905573eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6145116103e66144d5848b613093565b03614539576145336145238287613093565b516001600160a01b038616614941565b016144ab565b61455e61454c6103e66144d5848b613093565b856145578489613093565b51916148ab565b614533565b5050505090506103366001600455565b50600284511061441a565b50855184511415614413565b5081518451141561440c565b63ffffffff168060005260026020526040600020549081156145b6575090565b602490604051907ff6ff4fb70000000000000000000000000000000000000000000000000000000082526004820152fd5b9080601f830112156102fd57602090823561460181612eca565b9361460f604051958661191f565b81855260208086019260051b8201019283116102fd57602001905b828210614638575050505090565b8135815290830190830161462a565b9080601f830112156102fd57602090823561466181612eca565b9361466f604051958661191f565b81855260208086019260051b8201019283116102fd57602001905b828210614698575050505090565b8135815290830190830161468a565b9080601f830112156102fd57816020610f9b933591016130d1565b91909160c0818403126102fd576146d88161032b565b9267ffffffffffffffff60208301358181116102fd57826146fa9185016145e7565b93614707604085016109f4565b9360608101358381116102fd5784614720918301614647565b9360808201358481116102fd5781614739918401614647565b9360a08301359081116102fd57610f9b92016146a7565b9190916011546020820135036148815761476990613129565b63ffffffff61478961478060105463ffffffff1690565b63ffffffff1690565b91160361485757816147a5916001600160a01b039301906146c2565b93949195909216906147b681612e32565b8061480e57506001835114801590614802575b80156147f6575b611833576147f06144d56147e96147e961033698613086565b5194613086565b9361583d565b506001825114156147d0565b506001855114156147c9565b8061481f6001929794959697612e32565b0361482d57610336946143f5565b60046040517f43013282000000000000000000000000000000000000000000000000000000008152fd5b60046040517fc6705675000000000000000000000000000000000000000000000000000000008152fd5b60046040517f5c49dc24000000000000000000000000000000000000000000000000000000008152fd5b916001600160a01b03604051927fa9059cbb000000000000000000000000000000000000000000000000000000006020850152166024830152604482015260448152608081019181831067ffffffffffffffff8411176118aa576103369260405261594a565b3d1561493c573d906149228261197d565b91614930604051938461191f565b82523d6000602084013e565b606090565b8147106149945760008080936001600160a01b038294165af1614962614911565b501561496a57565b60046040517f1425ea42000000000000000000000000000000000000000000000000000000008152fd5b60246040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152fd5b906040828203126102fd57610f9b91613fc0565b80356149e3816109ba565b614ae46020830135916149f5836109ba565b610733614a0460408601613035565b614a1060608701613035565b614a1c60808801613035565b9160405196879560208701998a6101608201359661014083013596610120840135966101008501359660e08601359660a060c0880135970135959895929c9b9a979490916101809a97946040936101a08c019f7fa85cf3e3ad772b6de109a440bbce9afa8bf3ad775604b14049d27ae5650d3d3a8d528c6001600160a01b0396878096818096166020850152169101521660608c01521660808a01521660a088015260c087015260e08601526101008501526101208401526101408301526101608201520152565b51902090565b6001600160a01b03600054163303614afe57565b60246040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152fd5b63ffffffff1660008181526002602090815260409182902084905581519283528201929092527f238399d427b947898edb290f5ff0f9109849b1c3ba196a42e35f00c50a54b98b91819081016136f6565b614b87613e26565b6040908151936020850185614c42848381516001600160a01b03168152610180810192916020818101516001600160a01b0316908301526040818101516001600160a01b0316908301526060818101516001600160a01b0316908301526080818101516001600160a01b03169083015260a081015160a083015260c081015160c083015260e081015160e083015261010080820151908301526101208082015190830152610140808201519083015261016080910151910152565b0395614c56601f199788810183528261191f565b51902094614c7161058d876000526009602052604060002090565b614c7a816123c1565b61509257838301614c956103e682516001600160a01b031690565b330361506957610140840151460361504057614cbe6107cf886000526009602052604060002090565b608084016001600160a01b03614cdb82516001600160a01b031690565b1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103614eda575050506101608301805190919015614e96578451614d1f60208201928261260c878b8761510b565b519020905103614e6d57614d3e6103e6600c546001600160a01b031690565b9060e083015191803b156102fd57614d879560009386518098819582947ff87ef8000000000000000000000000000000000000000000000000000000000084526004840161510b565b03925af19182156104d3577f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b7936142ac936127665750519182918281516001600160a01b03168152610180810192916020818101516001600160a01b0316908301526040818101516001600160a01b0316908301526060818101516001600160a01b0316908301526080818101516001600160a01b03169083015260a081015160a083015260c081015160c083015260e081015160e083015261010080820151908301526101208082015190830152610140808201519083015261016080910151910152565b600483517f332c0963000000000000000000000000000000000000000000000000000000008152fd5b5050507f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b792506142ac916127f16127e66103e660208501516001600160a01b031690565b90919261016086989598019182511515600014614fff57508651614f0860208201928261260c8c8a8761510b565b519020905103614fd65790614f2d6128476103e6614f4294516001600160a01b031690565b6129966103e6600c546001600160a01b031690565b614f576103e6600c546001600160a01b031690565b93843b156102fd57614f9b946000928386518098819582947ff87ef8000000000000000000000000000000000000000000000000000000000084526004840161510b565b03925af19182156104d3577f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b7936142ac9361290957506126b6565b600485517f332c0963000000000000000000000000000000000000000000000000000000008152fd5b925050507f6955fd9b2a7639a9baac024897cad7007b45ffa74cbfe9582d58401ff6b977b795506142ac9492506129876127f192516001600160a01b031690565b600485517fb86ac1ef000000000000000000000000000000000000000000000000000000008152fd5b600485517fa4e189a6000000000000000000000000000000000000000000000000000000008152fd5b600484517f4747436c000000000000000000000000000000000000000000000000000000008152fd5b90357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1823603018112156102fd57016020813591019167ffffffffffffffff82116102fd5781360383136102fd57565b9160208181850182865252604093604081019460408460051b83010195856000935b86851061513f57505050505050505090565b90919293949596977fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc082820301845288357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61843603018112156102fd57830190813560a060048210156102fd576001938a9361520561522393856151c388976106a4565b83526001600160a01b03868501356151da816109ba565b16868401528b8401358c840152606090806151f7838701876150bb565b929093860152840191613148565b91615215608091828101906150bb565b929091818503910152613148565b9a01940195019392969594919061512d565b604051614ae48161073360208201947fa5b4aa1bcb538076d57d083e3004c6907e2eba42d84c21922d441967a02b472f86526040808401526060830190610f65565b90615286939291959495613ddf565b156152a057816147a5916001600160a01b039301906146c2565b60046040517fca37de93000000000000000000000000000000000000000000000000000000008152fd5b600054906001600160a01b0380911691827fffffffffffffffffffffffff0000000000000000000000000000000000000000821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b6153348383615aea565b50615341819592956106a4565b1593846153f6575b508315615357575b50505090565b60009293509082916040516153a98161073360208201947f1626ba7e00000000000000000000000000000000000000000000000000000000998a87526024840152604060448401526064830190610f65565b51915afa906153b6614911565b826153e8575b826153cc575b5050388080615351565b9091506020818051810103126102fd57602001511438806153c2565b9150602082511015916153bc565b6001600160a01b03838116911614935038615349565b9091615423610f9b93604084526040840190610f65565b916020818403910152610f65565b9190825115615581578051156155815761544a83615235565b9281519367ffffffffffffffff85116118aa576154718561546b8354612098565b83613880565b602080601f87116001146154f25750857fdb6b260ea45f7fe513e1d3b8c21017a29e3a41610e95aefb8862b81c69aec61c95966154c3926000916154e7575b506000198260011b9260031b1c19161790565b90555b6154cf816155ab565b8251602084012090556136f66040519283928361540c565b9050850151386154b0565b90601f19871661550784600052602060002090565b926000905b8282106155695750509187917fdb6b260ea45f7fe513e1d3b8c21017a29e3a41610e95aefb8862b81c69aec61c979860019410615550575b5050811b0190556154c6565b86015160001960f88460031b161c191690553880615544565b80600185968294968b0151815501950193019061550c565b60046040517fdeba1689000000000000000000000000000000000000000000000000000000008152fd5b604051614ae48161073360208201947f5f58fea7d48d37d5d1cc2546dfcc3d3cbfe8d758d5ca19c44087f52e15a1050586526040808401526060830190610f65565b60028151106155fd576002015190565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f746f55696e7431365f6f75744f66426f756e64730000000000000000000000006044820152fd5b602090615672600495949382815194859201610f42565b01907fffff0000000000000000000000000000000000000000000000000000000000007f01000000000000000000000000000000000000000000000000000000000000009182845260f01b16600183015260038201526156db8251809360208685019101610f42565b010190565b8034036156ea5790565b60246040517f9f704120000000000000000000000000000000000000000000000000000000008152346004820152fd5b6001600160a01b03908160015416916040517fe4fe1d94000000000000000000000000000000000000000000000000000000008152602081600481875afa9081156104d3576000916157a5575b501691821561577b576103369233906157e0565b60046040517f5373352a000000000000000000000000000000000000000000000000000000008152fd5b90506020813d6020116157d8575b816157c06020938361191f565b810103126102fd57516157d2816109ba565b38615767565b3d91506157b3565b909261033693604051937f23b872dd0000000000000000000000000000000000000000000000000000000060208601526001600160a01b038092166024860152166044840152606483015260648252615838826118e7565b61594a565b929390949161584a613e26565b8351156118335760009560005b85518110156158d75761586a8187613093565b5190600161588561058d846000526008602052604060002090565b61588e816106a4565b0361126657816158ad6105b66001946000526008602052604060002090565b7fd48052bf92f3eec93ecdeeec72ea80e1071c926cb4d6e5a37ee71be8a0ce9a108a80a201615857565b509295509250926158fe6144e2856001600160a01b03166000526007602052604060002090565b90556001600160a01b0392831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee810361593b57506159319216614941565b6103366001600455565b61594593506148ab565b615931565b6000806001600160a01b0361597493169360208151910182865af161596d614911565b9083615d84565b80519081151591826159bb575b505061598a5750565b602490604051907f5274afe70000000000000000000000000000000000000000000000000000000082526004820152fd5b6159ce9250602080918301019101613133565b153880615981565b6001600160a01b037f000000000000000000000000df4ffda22270c12d0b5b3788f1669d709476111e16301480615ac1575b15615a31577f6679faa734fcf641a913e19dc94fd7ae85dd804a7492d6e5fbc9a2c4fc5a3d3390565b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527fa3af52f5a19c476683ea78df83de176413a7ee276eff3239668570b1587f33b660408201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260a08152614ae481611903565b507f00000000000000000000000000000000000000000000000000000000000000014614615a08565b8151919060418303615b1b57615b1492506020820151906060604084015193015160001a90615d00565b9192909190565b505060009160029190565b60ff8114615b7c5760ff811690601f8211615b525760405191615b48836118af565b8252602082015290565b60046040517fb3512b0c000000000000000000000000000000000000000000000000000000008152fd5b50604051600554816000615b8f83612098565b80835292602090600190818116908115615c1b5750600114615bba575b5050610f9b9250038261191f565b91509260056000527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0936000925b828410615c035750610f9b9450505081016020013880615bac565b85548785018301529485019486945092810192615be8565b905060209350610f9b95925060ff1991501682840152151560051b8201013880615bac565b60ff8114615c625760ff811690601f8211615b525760405191615b48836118af565b50604051600654816000615c7583612098565b80835292602090600190818116908115615c1b5750600114615c9f575050610f9b9250038261191f565b91509260066000527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f936000925b828410615ce85750610f9b9450505081016020013880615bac565b85548785018301529485019486945092810192615ccd565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411615d7857926020929160ff608095604051948552168484015260408301526060820152600092839182805260015afa156104d35780516001600160a01b03811615615d6f57918190565b50809160019190565b50505060009160039190565b90615d99575080511561496a57805190602001fd5b81511580615de4575b615daa575090565b6024906001600160a01b03604051917f9996b315000000000000000000000000000000000000000000000000000000008352166004820152fd5b50803b15615da256fea2646970667358221220d7cc3795083b4b25b61f11142c6e0c2ccba56dd497bce2e0ca9ed4f05acfb03364736f6c63430008170033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
BASE | 18.00% | $0.999805 | 17,827.4897 | $17,824.01 | |
BASE | 11.57% | $2,481.9 | 4.6174 | $11,460.03 | |
BASE | 2.67% | $2,483.5 | 1.0659 | $2,647.18 | |
ETH | 16.68% | $2,483.09 | 6.6542 | $16,522.87 | |
ETH | 6.69% | $0.99979 | 6,626.9214 | $6,625.53 | |
ETH | 0.77% | $1 | 760.1973 | $760.96 | |
ETH | <0.01% | $2,483.09 | 0.00163021 | $4.05 | |
ARB | 10.77% | $1 | 10,660.3673 | $10,671.03 | |
ARB | 2.65% | $0.999793 | 2,626.0297 | $2,625.49 | |
ARB | 1.54% | $2,481.82 | 0.6151 | $1,526.59 | |
ARB | 0.03% | $2,483.23 | 0.0112 | $27.87 | |
POL | 9.49% | $0.999794 | 9,399.4222 | $9,397.49 | |
POL | 0.57% | $1 | 566.895 | $567.46 | |
POL | 0.16% | $2,476.74 | 0.0626 | $155.02 | |
BSC | 6.24% | $1 | 6,172.6559 | $6,178.83 | |
BSC | 1.47% | $643.54 | 2.2647 | $1,457.39 | |
BSC | 1.11% | $1 | 1,097.331 | $1,097.34 | |
BSC | 0.09% | $2,476.74 | 0.037 | $91.58 | |
BSC | <0.01% | $1.08 | 1.4663 | $1.59 | |
AVAX | 5.73% | $0.999883 | 5,679.4688 | $5,678.8 | |
AVAX | 1.43% | $1 | 1,419.0535 | $1,420.05 | |
AVAX | <0.01% | $19.71 | 0.0743 | $1.47 | |
OP | 1.91% | $0.999805 | 1,887.5599 | $1,887.19 | |
OP | 0.15% | $2,481.88 | 0.058 | $143.97 | |
OP | <0.01% | $1 | 5.392 | $5.4 | |
OP | <0.01% | $2,483.5 | 0.00114398 | $2.84 | |
LINEA | 0.10% | $2,481.37 | 0.039 | $96.8 | |
LINEA | <0.01% | $2,477.92 | 0.0018795 | $4.66 | |
LINEA | <0.01% | $1 | 3.8904 | $3.89 | |
BERA | 0.10% | $2,485.64 | 0.0401 | $99.71 | |
BERA | <0.01% | $1.01 | 0.2394 | $0.2408 | |
BERA | <0.01% | $2.23 | 0.00980546 | $0.021885 | |
CELO | 0.03% | $1 | 25.3735 | $25.37 | |
CELO | 0.02% | $1 | 15.2898 | $15.31 | |
CELO | <0.01% | $0.301306 | 10.2963 | $3.1 | |
SONIC | <0.01% | $0.374 | 10.6673 | $3.99 | |
GNO | <0.01% | $1 | 0.9991 | $1 | |
GNO | <0.01% | $0.99989 | 0.4113 | $0.411275 | |
BLAST | <0.01% | $2,481.9 | 0.00039705 | $0.985448 | |
BLAST | <0.01% | $2,480.41 | 0.0000711 | $0.1763 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.