Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
(+1 Pending)
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0xd7c6bcf0a8c0d6eac11f7138ab0f681ffb894b72bc0caefc5211978c4a3edaed | Create Order | (pending) | 33 mins ago | IN | 0 ETH | (Pending) |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
DlnSource
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 9999 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.17; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@debridge-finance/debridge-contracts-v1/contracts/interfaces/ICallProxy.sol"; import "../libraries/SafeCast.sol"; import "./DlnBase.sol"; import "../interfaces/IDlnSource.sol"; contract DlnSource is DlnBase, ReentrancyGuardUpgradeable, IDlnSource { using SafeERC20Upgradeable for IERC20Upgradeable; using SafeCast for uint256; using BytesLib for bytes; /* ========== STATE VARIABLES ========== */ /// @dev A fixed fee specified in the native asset. uint88 public globalFixedNativeFee; /// @dev Transfer fee expressed in Basis Points (BPS). uint16 public globalTransferFeeBps; /// @dev Maps each chainId to the address of the `dlnDestination` contract on the respective chain. mapping(uint256 => bytes) public dlnDestinationAddresses; /// @dev Maps each order ID (derived using `getOrderId`) to its state and collected processing fee. /// This fee will be returned if an order is canceled. mapping(bytes32 => GiveOrderState) public giveOrders; /// @dev Tracks the additional amounts for an order's give part during the unlock or cancel operations. mapping(bytes32 => uint256) public givePatches; /// @dev Allocates a unique nonce for each order maker to ensure order uniqueness. mapping(address => uint256) public masterNonce; /// @dev Keeps track of the protocol fees collected from orders. mapping(address => uint256) public collectedFee; /// @dev Keeps track of orders with unexpected statuses during unlock claims. /// Maps an order ID to the claim beneficiary address. mapping(bytes32 => address) public unexpectedOrderStatusForClaim; /// @dev Keeps track of orders with unexpected statuses during cancel claims. /// Maps an order ID to the cancel beneficiary address. mapping(bytes32 => address) public unexpectedOrderStatusForCancel; /// @dev Records the amount of ETH owed to affiliate beneficiaries (used in cases where sending ETH failed). /// Maps an affiliate beneficiary's address to the owed ETH amount. mapping(address => uint256) public unclaimedAffiliateETHFees; /* ========== ENUMS ========== */ /** * @dev Enum defining the status of an order in give chain. * - `NotSet`: Indicates that the order does not exist (0). * - `Created`: Indicates that the order has been created (1). * - `ClaimedUnlock`: Indicates that the order has been fully unlocked (2). * - `ClaimedCancel`: Indicates that the order has been canceled (3). */ enum OrderGiveStatus { NotSet, // 0 Created, // 1 ClaimedUnlock, // 2 ClaimedCancel // 3 } /* ========== STRUCTS ========== */ /** * @dev Struct representing the state of order in "give" chain. * * - `status`: Indicates the status of the "give" part of the order, including whether it's created, claimed, or canceled. * - `giveTokenAddress`: The address of the ERC-20 token (or native blockchain token) involved in the "give" part of the order. * - `nativeFixFee`: A fixed fee that was paid by the maker when creating the order. * - `takeChainId`: The chain ID where the "take" part of the order is intended to be fulfilled. * - `percentFee`: A fee represented as a percentage of the total amount involved in the "give" part of the order. * - `giveAmount`: The amount of tokens involved in the "give" part of the order. * - `affiliateBeneficiary`: The address designated to receive affiliate rewards, if applicable. * - `affiliateAmount`: The amount of tokens allocated for affiliate rewards. */ struct GiveOrderState { OrderGiveStatus status; uint160 giveTokenAddress; // stot optimisation used uint160 instead address uint88 nativeFixFee; uint48 takeChainId; uint208 percentFee; uint256 giveAmount; address affiliateBeneficiary; uint256 affiliateAmount; } /* ========== EVENTS ========== */ event CreatedOrder( DlnOrderLib.Order order, bytes32 orderId, bytes affiliateFee, uint256 nativeFixFee, uint256 percentFee, uint32 referralCode, bytes metadata ); event IncreasedGiveAmount(bytes32 orderId, uint256 orderGiveFinalAmount, uint256 finalPercentFee); event AffiliateFeePaid( bytes32 _orderId, address beneficiary, uint256 affiliateFee, address giveTokenAddress ); event ClaimedUnlock( bytes32 orderId, address beneficiary, uint256 giveAmount, address giveTokenAddress ); event UnexpectedOrderStatusForClaim(bytes32 orderId, OrderGiveStatus status, address beneficiary); event CriticalMismatchChainId(bytes32 orderId, address beneficiary, uint256 takeChainId, uint256 submissionChainIdFrom); event ClaimedOrderCancel( bytes32 orderId, address beneficiary, uint256 paidAmount, address giveTokenAddress ); event UnexpectedOrderStatusForCancel(bytes32 orderId, OrderGiveStatus status, address beneficiary); event SetDlnDestinationAddress(uint256 chainIdTo, bytes dlnDestinationAddress, DlnOrderLib.ChainEngine chainEngine); event WithdrawnFee(address tokenAddress, uint256 amount, address beneficiary); event GlobalFixedNativeFeeUpdated(uint88 oldGlobalFixedNativeFee, uint88 newGlobalFixedNativeFee); event GlobalTransferFeeBpsUpdated(uint16 oldGlobalTransferFeeBps, uint16 newGlobalTransferFeeBps); /* ========== ERRORS ========== */ error WrongFixedFee(uint256 received, uint256 actual); error WrongAffiliateFeeLength(); error MismatchNativeGiveAmount(); error CriticalMismatchTakeChainId(bytes32 orderId, uint48 takeChainId, uint256 submissionsChainIdFrom); /* ========== CONSTRUCTOR ========== */ function initialize( IDeBridgeGate _deBridgeGate, uint88 _globalFixedNativeFee, uint16 _globalTransferFeeBps ) public initializer { _setFixedNativeFee(_globalFixedNativeFee); _setTransferFeeBps(_globalTransferFeeBps); __DlnBase_init(_deBridgeGate); __ReentrancyGuard_init(); } /* ========== PUBLIC METHODS ========== */ /** * @inheritdoc IDlnSource */ function createOrder( DlnOrderLib.OrderCreation calldata _orderCreation, bytes calldata _affiliateFee, uint32 _referralCode, bytes calldata _permitEnvelope ) external payable nonReentrant whenNotPaused returns (bytes32) { return _createSaltedOrder( _orderCreation, uint64(masterNonce[tx.origin]++), _affiliateFee, _referralCode, _permitEnvelope, bytes("") ); } /** * @inheritdoc IDlnSource */ function createSaltedOrder( DlnOrderLib.OrderCreation calldata _orderCreation, uint64 _salt, bytes calldata _affiliateFee, uint32 _referralCode, bytes calldata _permitEnvelope, bytes memory _metadata ) external payable nonReentrant whenNotPaused returns (bytes32) { return _createSaltedOrder( _orderCreation, _salt, _affiliateFee, _referralCode, _permitEnvelope, _metadata ); } function _createSaltedOrder( DlnOrderLib.OrderCreation calldata _orderCreation, uint64 _salt, bytes calldata _affiliateFee, uint32 _referralCode, bytes calldata _permitEnvelope, bytes memory _metadata ) internal returns (bytes32) { uint256 affiliateAmount; if (_affiliateFee.length > 0) { if (_affiliateFee.length != 52) revert WrongAffiliateFeeLength(); affiliateAmount = BytesLib.toUint256(_affiliateFee, 20); } DlnOrderLib.Order memory _order = validateCreationOrder(_orderCreation, tx.origin, _salt); // take tokens from the user's wallet _pullTokens(_orderCreation, _order, _permitEnvelope); // reduce giveAmount on (percentFee + affiliateFee) uint256 percentFee = (globalTransferFeeBps * _order.giveAmount) / BPS_DENOMINATOR; _order.giveAmount -= percentFee + affiliateAmount; bytes32 orderId = getOrderId(_order); { GiveOrderState storage orderState = giveOrders[orderId]; if (orderState.status != OrderGiveStatus.NotSet) revert IncorrectOrderStatus(); orderState.status = OrderGiveStatus.Created; orderState.giveTokenAddress = uint160(_orderCreation.giveTokenAddress); orderState.nativeFixFee = globalFixedNativeFee; orderState.takeChainId = _order.takeChainId.toUint48(); orderState.percentFee = percentFee.toUint208(); orderState.giveAmount = _order.giveAmount; // save affiliate_fee to storage if (affiliateAmount > 0) { address affiliateBeneficiary = BytesLib.toAddress(_affiliateFee, 0); if (affiliateAmount > 0 && affiliateBeneficiary == address(0)) revert ZeroAddress(); orderState.affiliateAmount = affiliateAmount; orderState.affiliateBeneficiary = affiliateBeneficiary; } } emit CreatedOrder( _order, orderId, _affiliateFee, globalFixedNativeFee, percentFee, _referralCode, _metadata ); return orderId; } /** * @dev Processes a batch of unlock orders originating from the order's take chain. * @param _orderIds An array containing the IDs of the orders to be unlocked. * @param _beneficiary The address that will receive the assets from the unlocked orders. * # Restrictions * This function can only be called through the debridge's external call mechanism, * ensuring it's invoked by a validated native sender. */ function claimBatchUnlock(bytes32[] memory _orderIds, address _beneficiary) external nonReentrant whenNotPaused { uint256 submissionChainIdFrom = _onlyDlnDestinationAddress(); uint256 length = _orderIds.length; for (uint256 i; i < length; ++i) { _claimUnlock(_orderIds[i], _beneficiary, submissionChainIdFrom); } } /** * @dev Processes a single unlock order that originates from the order's take chain. * @param _orderId The ID of the order to be unlocked. * @param _beneficiary The address that will receive the assets from the unlocked order. * # Restrictions * This function can only be invoked through the debridge's external call mechanism, * ensuring it's called by a validated native sender. */ function claimUnlock(bytes32 _orderId, address _beneficiary) external nonReentrant whenNotPaused { uint256 submissionChainIdFrom = _onlyDlnDestinationAddress(); _claimUnlock(_orderId, _beneficiary, submissionChainIdFrom); } /** * @dev Processes a batch of cancel orders originating from the order's take chain. * * This function handles multiple order cancellations at once. It processes each order in the batch to * ensure that the designated beneficiaries receive their refunds. * * @param _orderIds Array of IDs of the orders to be canceled. * @param _beneficiary The address that will receive the refunds from the canceled orders. * * # Restrictions * This function can only be invoked through the debridge's external call mechanism, * ensuring it's called by a validated native sender. */ function claimBatchCancel(bytes32[] memory _orderIds, address _beneficiary) external nonReentrant whenNotPaused { uint256 submissionChainIdFrom = _onlyDlnDestinationAddress(); uint256 length = _orderIds.length; for (uint256 i; i < length; ++i) { _claimCancel(_orderIds[i], _beneficiary, submissionChainIdFrom); } } /** * @dev Processes the cancellation of an order originating from the order's take chain. * * This function manages the cancellation of a specific order, ensuring that the designated * beneficiary receives the full refund for the canceled order. * * @param _orderId ID of the order to be canceled. * @param _beneficiary The address that will receive the refund from the canceled order. * * # Restrictions * This function can only be invoked through the debridge's external call mechanism, * ensuring it's called by a validated native sender. */ function claimCancel(bytes32 _orderId, address _beneficiary) external nonReentrant whenNotPaused { uint256 submissionChainIdFrom = _onlyDlnDestinationAddress(); _claimCancel(_orderId, _beneficiary, submissionChainIdFrom); } /** * @dev Modifies an order's give offer. * * This function allows increasing the value of the 'giveAmount' of an order, potentially * making the order more appealing. The additional amount remains in the contract and is * retrievable through the `claimUnlock` or `claimCancel` functions. * If a patch was previously made, then the new patch can only increase patch amount * * @param _order Full order information * @param _addGiveAmount Amount to be added to the give offer, which can be utilized in * the `claimUnlock` and `claimCancel` methods. * @param _permitEnvelope Contains the permit to approve the spender, encapsulating amount, * deadline, and a signature. * * # Restrictions * Only the `givePatchAuthoritySrc` can invoke this function. */ function patchOrderGive( DlnOrderLib.Order memory _order, uint256 _addGiveAmount, bytes calldata _permitEnvelope ) external payable nonReentrant whenNotPaused { bytes32 orderId = getOrderId(_order); if (_order.givePatchAuthoritySrc.toAddress() != msg.sender) revert Unauthorized(); if (_addGiveAmount == 0) revert WrongArgument(); GiveOrderState storage orderState = giveOrders[orderId]; if (orderState.status != OrderGiveStatus.Created) revert IncorrectOrderStatus(); address giveTokenAddress = _order.giveTokenAddress.toAddress(); if (giveTokenAddress == address(0)) { if (msg.value != _addGiveAmount) revert MismatchNativeGiveAmount(); } else { _executePermit(giveTokenAddress, _permitEnvelope); _safeTransferFrom( giveTokenAddress, msg.sender, address(this), _addGiveAmount ); } uint256 percentFee = (globalTransferFeeBps * _addGiveAmount) / BPS_DENOMINATOR; orderState.percentFee += percentFee.toUint208(); givePatches[orderId] += _addGiveAmount - percentFee; emit IncreasedGiveAmount(orderId, _order.giveAmount + givePatches[orderId], orderState.percentFee); } /* ========== ADMIN METHODS ========== */ /** * @dev Sets the DLN destination contract address for another chain. * @param _chainIdTo The destination chain ID. * @param _dlnDestinationAddress The address of the contract on the destination chain. * @param _chainEngine The engine type of the destination chain. */ function setDlnDestinationAddress( uint256 _chainIdTo, bytes memory _dlnDestinationAddress, DlnOrderLib.ChainEngine _chainEngine ) external onlyAdmin { if(_chainEngine == DlnOrderLib.ChainEngine.UNDEFINED) revert WrongArgument(); dlnDestinationAddresses[_chainIdTo] = _dlnDestinationAddress; chainEngines[_chainIdTo] = _chainEngine; emit SetDlnDestinationAddress(_chainIdTo, _dlnDestinationAddress, _chainEngine); } /** * @dev Withdraws the collected fees. * @param _tokens An array of token addresses for withdrawal. * @param _beneficiary The address that will receive the withdrawn tokens. */ function withdrawFee(address[] memory _tokens, address _beneficiary) external nonReentrant onlyAdmin { uint256 length = _tokens.length; for (uint256 i; i < length; ++i) { address token = _tokens[i]; uint256 feeAmount = collectedFee[token]; _safeTransferEthOrToken(token, _beneficiary, feeAmount); collectedFee[token] = 0; emit WithdrawnFee(token, feeAmount, _beneficiary); } } /** * @dev Updates the settings for fixed fee in native asset and transfer fee. * @param _globalFixedNativeFee The fixed fee in the native asset. * @param _globalTransferFeeBps The transfer fee in basis points. */ function updateGlobalFee( uint88 _globalFixedNativeFee, uint16 _globalTransferFeeBps ) external onlyAdmin { _setFixedNativeFee(_globalFixedNativeFee); _setTransferFeeBps(_globalTransferFeeBps); } /* ========== VIEW ========== */ /** * @dev Validates the creation of an order. Throws an exception if incorrect parameters are passed. * @param _orderCreation Details of the order to be validated. * @param _signer EOA (Externally Owned Account) address that will sign the transaction. * @return order Returns the validated order details. */ function validateCreationOrder(DlnOrderLib.OrderCreation memory _orderCreation, address _signer) public view returns (DlnOrderLib.Order memory order) { return validateCreationOrder(_orderCreation, _signer, uint64(masterNonce[_signer])); } function validateCreationOrder(DlnOrderLib.OrderCreation memory _orderCreation, address _signer, uint64 _salt) public view returns (DlnOrderLib.Order memory order) { uint256 dstAddressLength = dlnDestinationAddresses[_orderCreation.takeChainId].length; if (dstAddressLength == 0) revert NotSupportedDstChain(); if ( _orderCreation.takeTokenAddress.length != dstAddressLength || _orderCreation.receiverDst.length != dstAddressLength || _orderCreation.orderAuthorityAddressDst.length != dstAddressLength || (_orderCreation.allowedTakerDst.length > 0 && _orderCreation.allowedTakerDst.length != dstAddressLength) || (_orderCreation.allowedCancelBeneficiarySrc.length > 0 && _orderCreation.allowedCancelBeneficiarySrc.length != EVM_ADDRESS_LENGTH) ) revert WrongAddressLength(); order.giveChainId = getChainId(); order.makerOrderNonce = _salt; order.makerSrc = abi.encodePacked(_signer); order.giveTokenAddress = abi.encodePacked(_orderCreation.giveTokenAddress); order.giveAmount = _orderCreation.giveAmount; order.takeTokenAddress = _orderCreation.takeTokenAddress; order.takeAmount = _orderCreation.takeAmount; order.takeChainId = _orderCreation.takeChainId; order.receiverDst = _orderCreation.receiverDst; order.givePatchAuthoritySrc = abi.encodePacked(_orderCreation.givePatchAuthoritySrc); order.orderAuthorityAddressDst = _orderCreation.orderAuthorityAddressDst; order.allowedTakerDst = _orderCreation.allowedTakerDst; order.externalCall = _orderCreation.externalCall; order.allowedCancelBeneficiarySrc = _orderCreation.allowedCancelBeneficiarySrc; } /* ========== INTERNAL ========== */ function _pullTokens(DlnOrderLib.OrderCreation calldata _orderCreation, DlnOrderLib.Order memory _order, bytes calldata _permitEnvelope) internal { if (_orderCreation.giveTokenAddress == address(0)) { if (msg.value != _order.giveAmount + globalFixedNativeFee) revert MismatchNativeGiveAmount(); } else { if (msg.value != globalFixedNativeFee) revert WrongFixedFee(msg.value, globalFixedNativeFee); _executePermit(_orderCreation.giveTokenAddress, _permitEnvelope); _safeTransferFrom( _orderCreation.giveTokenAddress, msg.sender, address(this), _order.giveAmount ); } } /** * @dev Claims an unlock order that originated from the take chain. * @param _orderId The ID of the order to be unlocked. * @param _beneficiary Address that will receive the rewards. * @param _submissionChainIdFrom The chain ID of the submission sourced from the deBridgeCallProxy. */ function _claimUnlock(bytes32 _orderId, address _beneficiary, uint256 _submissionChainIdFrom) internal { GiveOrderState storage orderState = giveOrders[_orderId]; if (orderState.status != OrderGiveStatus.Created) { unexpectedOrderStatusForClaim[_orderId] = _beneficiary; emit UnexpectedOrderStatusForClaim(_orderId, orderState.status, _beneficiary); return; } // a circuit breaker in case DlnDestination has been compromised and is sending claim_unlock commands on behalf // of another chain if (orderState.takeChainId != _submissionChainIdFrom) { emit CriticalMismatchChainId(_orderId, _beneficiary, orderState.takeChainId, _submissionChainIdFrom); return; } uint256 amountToPay = orderState.giveAmount + givePatches[_orderId]; orderState.status = OrderGiveStatus.ClaimedUnlock; address giveTokenAddress = address(orderState.giveTokenAddress); _safeTransferEthOrToken(giveTokenAddress, _beneficiary, amountToPay); // send affiliateFee to affiliateFee beneficiary if (orderState.affiliateAmount > 0) { bool success; if (giveTokenAddress == address(0)) { (success, ) = orderState.affiliateBeneficiary.call{value: orderState.affiliateAmount, gas: 2300}(new bytes(0)); if (!success) { unclaimedAffiliateETHFees[orderState.affiliateBeneficiary] += orderState.affiliateAmount; } } else { IERC20Upgradeable(giveTokenAddress).safeTransfer( orderState.affiliateBeneficiary, orderState.affiliateAmount ); success = true; } if (success) { emit AffiliateFeePaid( _orderId, orderState.affiliateBeneficiary, orderState.affiliateAmount, giveTokenAddress ); } } emit ClaimedUnlock( _orderId, _beneficiary, amountToPay, giveTokenAddress ); // Collected fee collectedFee[giveTokenAddress] += orderState.percentFee; collectedFee[address(0)] += orderState.nativeFixFee; } /** * @dev Claims a cancel order that originated from the take chain. * @param _orderId The ID of the order to be canceled. * @param _beneficiary Address that will receive the full refund. * @param _submissionChainIdFrom The chain ID of the submission sourced from the deBridgeCallProxy. */ function _claimCancel(bytes32 _orderId, address _beneficiary, uint256 _submissionChainIdFrom) internal { GiveOrderState storage orderState = giveOrders[_orderId]; if (orderState.takeChainId != _submissionChainIdFrom) { revert CriticalMismatchTakeChainId(_orderId, orderState.takeChainId, _submissionChainIdFrom); } uint256 amountToPay = orderState.giveAmount + orderState.percentFee + orderState.affiliateAmount + givePatches[_orderId]; if (orderState.status == OrderGiveStatus.Created) { orderState.status = OrderGiveStatus.ClaimedCancel; address giveTokenAddress = address(orderState.giveTokenAddress); _safeTransferEthOrToken(giveTokenAddress, _beneficiary, amountToPay); _safeTransferETH(_beneficiary, orderState.nativeFixFee); emit ClaimedOrderCancel( _orderId, _beneficiary, amountToPay, giveTokenAddress ); } else { unexpectedOrderStatusForCancel[_orderId] = _beneficiary; emit UnexpectedOrderStatusForCancel(_orderId, orderState.status, _beneficiary); } } function _setFixedNativeFee(uint88 _globalFixedNativeFee) internal { uint88 oldGlobalFixedNativeFee = globalFixedNativeFee; if (oldGlobalFixedNativeFee != _globalFixedNativeFee) { globalFixedNativeFee = _globalFixedNativeFee; emit GlobalFixedNativeFeeUpdated(oldGlobalFixedNativeFee, _globalFixedNativeFee); } } function _setTransferFeeBps(uint16 _globalTransferFeeBps) internal { uint16 oldGlobalTransferFeeBps = globalTransferFeeBps; if (oldGlobalTransferFeeBps != _globalTransferFeeBps) { globalTransferFeeBps = _globalTransferFeeBps; emit GlobalTransferFeeBpsUpdated(oldGlobalTransferFeeBps, _globalTransferFeeBps); } } /// @dev Check that method was called by correct dlnDestinationAddresses from the take chain function _onlyDlnDestinationAddress() internal view returns (uint256 submissionChainIdFrom) { ICallProxy callProxy = ICallProxy(deBridgeGate.callProxy()); if (address(callProxy) != msg.sender) revert CallProxyBadRole(); bytes memory nativeSender = callProxy.submissionNativeSender(); submissionChainIdFrom = callProxy.submissionChainIdFrom(); if (keccak256(dlnDestinationAddresses[submissionChainIdFrom]) != keccak256(nativeSender)) { revert NativeSenderBadRole(nativeSender, submissionChainIdFrom); } return submissionChainIdFrom; } /* ========== Version Control ========== */ /// @dev Get this contract's version function version() external pure returns (string memory) { return "1.3.0"; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; interface ICallProxy { /// @dev Chain from which the current submission is received function submissionChainIdFrom() external view returns (uint256); /// @dev Native sender of the current submission function submissionNativeSender() external view returns (bytes memory); /// @dev Used for calls where native asset transfer is involved. /// @param _reserveAddress Receiver of the tokens if the call to _receiver fails /// @param _receiver Contract to be called /// @param _data Call data /// @param _flags Flags to change certain behavior of this function, see Flags library for more details /// @param _nativeSender Native sender /// @param _chainIdFrom Id of a chain that originated the request function call( address _reserveAddress, address _receiver, bytes memory _data, uint256 _flags, bytes memory _nativeSender, uint256 _chainIdFrom ) external payable returns (bool); /// @dev Used for calls where ERC20 transfer is involved. /// @param _token Asset address /// @param _reserveAddress Receiver of the tokens if the call to _receiver fails /// @param _receiver Contract to be called /// @param _data Call data /// @param _flags Flags to change certain behavior of this function, see Flags library for more details /// @param _nativeSender Native sender /// @param _chainIdFrom Id of a chain that originated the request function callERC20( address _token, address _reserveAddress, address _receiver, bytes memory _data, uint256 _flags, bytes memory _nativeSender, uint256 _chainIdFrom ) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; interface IDeBridgeGate { /* ========== STRUCTS ========== */ struct TokenInfo { uint256 nativeChainId; bytes nativeAddress; } struct DebridgeInfo { uint256 chainId; // native chain id uint256 maxAmount; // maximum amount to transfer uint256 balance; // total locked assets uint256 lockedInStrategies; // total locked assets in strategy (AAVE, Compound, etc) address tokenAddress; // asset address on the current chain uint16 minReservesBps; // minimal hot reserves in basis points (1/10000) bool exist; } struct DebridgeFeeInfo { uint256 collectedFees; // total collected fees uint256 withdrawnFees; // fees that already withdrawn mapping(uint256 => uint256) getChainFee; // whether the chain for the asset is supported } struct ChainSupportInfo { uint256 fixedNativeFee; // transfer fixed fee bool isSupported; // whether the chain for the asset is supported uint16 transferFeeBps; // transfer fee rate nominated in basis points (1/10000) of transferred amount } struct DiscountInfo { uint16 discountFixBps; // fix discount in BPS uint16 discountTransferBps; // transfer % discount in BPS } /// @param executionFee Fee paid to the transaction executor. /// @param fallbackAddress Receiver of the tokens if the call fails. struct SubmissionAutoParamsTo { uint256 executionFee; uint256 flags; bytes fallbackAddress; bytes data; } /// @param executionFee Fee paid to the transaction executor. /// @param fallbackAddress Receiver of the tokens if the call fails. struct SubmissionAutoParamsFrom { uint256 executionFee; uint256 flags; address fallbackAddress; bytes data; bytes nativeSender; } struct FeeParams { uint256 receivedAmount; uint256 fixFee; uint256 transferFee; bool useAssetFee; bool isNativeToken; } /* ========== PUBLIC VARS GETTERS ========== */ /// @dev Returns whether the transfer with the submissionId was claimed. /// submissionId is generated in getSubmissionIdFrom function isSubmissionUsed(bytes32 submissionId) view external returns (bool); /// @dev Returns native token info by wrapped token address function getNativeInfo(address token) view external returns ( uint256 nativeChainId, bytes memory nativeAddress); /// @dev Returns address of the proxy to execute user's calls. function callProxy() external view returns (address); /// @dev Fallback fixed fee in native asset, used if a chain fixed fee is set to 0 function globalFixedNativeFee() external view returns (uint256); /// @dev Fallback transfer fee in BPS, used if a chain transfer fee is set to 0 function globalTransferFeeBps() external view returns (uint16); /* ========== FUNCTIONS ========== */ /// @dev Submits the message to the deBridge infrastructure to be broadcasted to another supported blockchain (identified by _dstChainId) /// with the instructions to call the _targetContractAddress contract using the given _targetContractCalldata /// @notice NO ASSETS ARE BROADCASTED ALONG WITH THIS MESSAGE /// @notice DeBridgeGate only accepts submissions with msg.value (native ether) covering a small protocol fee /// (defined in the globalFixedNativeFee property). Any excess amount of ether passed to this function is /// included in the message as the execution fee - the amount deBridgeGate would give as an incentive to /// a third party in return for successful claim transaction execution on the destination chain. /// @notice DeBridgeGate accepts a set of flags that control the behaviour of the execution. This simple method /// sets the default set of flags: REVERT_IF_EXTERNAL_FAIL, PROXY_WITH_SENDER /// @param _dstChainId ID of the destination chain. /// @param _targetContractAddress A contract address to be called on the destination chain /// @param _targetContractCalldata Calldata to execute against the target contract on the destination chain function sendMessage( uint256 _dstChainId, bytes memory _targetContractAddress, bytes memory _targetContractCalldata ) external payable returns (bytes32 submissionId); /// @dev Submits the message to the deBridge infrastructure to be broadcasted to another supported blockchain (identified by _dstChainId) /// with the instructions to call the _targetContractAddress contract using the given _targetContractCalldata /// @notice NO ASSETS ARE BROADCASTED ALONG WITH THIS MESSAGE /// @notice DeBridgeGate only accepts submissions with msg.value (native ether) covering a small protocol fee /// (defined in the globalFixedNativeFee property). Any excess amount of ether passed to this function is /// included in the message as the execution fee - the amount deBridgeGate would give as an incentive to /// a third party in return for successful claim transaction execution on the destination chain. /// @notice DeBridgeGate accepts a set of flags that control the behaviour of the execution. This simple method /// sets the default set of flags: REVERT_IF_EXTERNAL_FAIL, PROXY_WITH_SENDER /// @param _dstChainId ID of the destination chain. /// @param _targetContractAddress A contract address to be called on the destination chain /// @param _targetContractCalldata Calldata to execute against the target contract on the destination chain /// @param _flags A bitmask of toggles listed in the Flags library /// @param _referralCode Referral code to identify this submission function sendMessage( uint256 _dstChainId, bytes memory _targetContractAddress, bytes memory _targetContractCalldata, uint256 _flags, uint32 _referralCode ) external payable returns (bytes32 submissionId); /// @dev This method is used for the transfer of assets [from the native chain](https://docs.debridge.finance/the-core-protocol/transfers#transfer-from-native-chain). /// It locks an asset in the smart contract in the native chain and enables minting of deAsset on the secondary chain. /// @param _tokenAddress Asset identifier. /// @param _amount Amount to be transferred (note: the fee can be applied). /// @param _chainIdTo Chain id of the target chain. /// @param _receiver Receiver address. /// @param _permitEnvelope Permit for approving the spender by signature. bytes (amount + deadline + signature) /// @param _useAssetFee use assets fee for pay protocol fix (work only for specials token) /// @param _referralCode Referral code /// @param _autoParams Auto params for external call in target network function send( address _tokenAddress, uint256 _amount, uint256 _chainIdTo, bytes memory _receiver, bytes memory _permitEnvelope, bool _useAssetFee, uint32 _referralCode, bytes calldata _autoParams ) external payable returns (bytes32 submissionId) ; /// @dev Is used for transfers [into the native chain](https://docs.debridge.finance/the-core-protocol/transfers#transfer-from-secondary-chain-to-native-chain) /// to unlock the designated amount of asset from collateral and transfer it to the receiver. /// @param _debridgeId Asset identifier. /// @param _amount Amount of the transferred asset (note: the fee can be applied). /// @param _chainIdFrom Chain where submission was sent /// @param _receiver Receiver address. /// @param _nonce Submission id. /// @param _signatures Validators signatures to confirm /// @param _autoParams Auto params for external call function claim( bytes32 _debridgeId, uint256 _amount, uint256 _chainIdFrom, address _receiver, uint256 _nonce, bytes calldata _signatures, bytes calldata _autoParams ) external; /// @dev Withdraw collected fees to feeProxy /// @param _debridgeId Asset identifier. function withdrawFee(bytes32 _debridgeId) external; /// @dev Returns asset fixed fee value for specified debridge and chainId. /// @param _debridgeId Asset identifier. /// @param _chainId Chain id. function getDebridgeChainAssetFixedFee( bytes32 _debridgeId, uint256 _chainId ) external view returns (uint256); /* ========== EVENTS ========== */ /// @dev Emitted once the tokens are sent from the original(native) chain to the other chain; the transfer tokens /// are expected to be claimed by the users. event Sent( bytes32 submissionId, bytes32 indexed debridgeId, uint256 amount, bytes receiver, uint256 nonce, uint256 indexed chainIdTo, uint32 referralCode, FeeParams feeParams, bytes autoParams, address nativeSender // bool isNativeToken //added to feeParams ); /// @dev Emitted once the tokens are transferred and withdrawn on a target chain event Claimed( bytes32 submissionId, bytes32 indexed debridgeId, uint256 amount, address indexed receiver, uint256 nonce, uint256 indexed chainIdFrom, bytes autoParams, bool isNativeToken ); /// @dev Emitted when new asset support is added. event PairAdded( bytes32 debridgeId, address tokenAddress, bytes nativeAddress, uint256 indexed nativeChainId, uint256 maxAmount, uint16 minReservesBps ); event MonitoringSendEvent( bytes32 submissionId, uint256 nonce, uint256 lockedOrMintedAmount, uint256 totalSupply ); event MonitoringClaimEvent( bytes32 submissionId, uint256 lockedOrMintedAmount, uint256 totalSupply ); /// @dev Emitted when the asset is allowed/disallowed to be transferred to the chain. event ChainSupportUpdated(uint256 chainId, bool isSupported, bool isChainFrom); /// @dev Emitted when the supported chains are updated. event ChainsSupportUpdated( uint256 chainIds, ChainSupportInfo chainSupportInfo, bool isChainFrom); /// @dev Emitted when the new call proxy is set. event CallProxyUpdated(address callProxy); /// @dev Emitted when the transfer request is executed. event AutoRequestExecuted( bytes32 submissionId, bool indexed success, address callProxy ); /// @dev Emitted when a submission is blocked. event Blocked(bytes32 submissionId); /// @dev Emitted when a submission is unblocked. event Unblocked(bytes32 submissionId); /// @dev Emitted when fee is withdrawn. event WithdrawnFee(bytes32 debridgeId, uint256 fee); /// @dev Emitted when globalFixedNativeFee and globalTransferFeeBps are updated. event FixedNativeFeeUpdated( uint256 globalFixedNativeFee, uint256 globalTransferFeeBps); /// @dev Emitted when globalFixedNativeFee is updated by feeContractUpdater event FixedNativeFeeAutoUpdated(uint256 globalFixedNativeFee); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.7; library SignatureUtil { /* ========== ERRORS ========== */ error WrongArgumentLength(); error SignatureInvalidLength(); error SignatureInvalidV(); /// @dev Prepares raw msg that was signed by the oracle. /// @param _submissionId Submission identifier. function getUnsignedMsg(bytes32 _submissionId) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _submissionId)); } /// @dev Splits signature bytes to r,s,v components. /// @param _signature Signature bytes in format r+s+v. function splitSignature(bytes memory _signature) internal pure returns ( bytes32 r, bytes32 s, uint8 v ) { if (_signature.length != 65) revert SignatureInvalidLength(); return parseSignature(_signature, 0); } function parseSignature(bytes memory _signatures, uint256 offset) internal pure returns ( bytes32 r, bytes32 s, uint8 v ) { assembly { r := mload(add(_signatures, add(32, offset))) s := mload(add(_signatures, add(64, offset))) v := and(mload(add(_signatures, add(65, offset))), 0xff) } if (v < 27) v += 27; if (v != 27 && v != 28) revert SignatureInvalidV(); } function toUint256(bytes memory _bytes, uint256 _offset) internal pure returns (uint256 result) { if (_bytes.length < _offset + 32) revert WrongArgumentLength(); assembly { result := mload(add(add(_bytes, 0x20), _offset)) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(account), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/draft-IERC20PermitUpgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = MathUpgradeable.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.17; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@debridge-finance/debridge-contracts-v1/contracts/interfaces/IDeBridgeGate.sol"; import "@debridge-finance/debridge-contracts-v1/contracts/libraries/SignatureUtil.sol"; import "../interfaces/IERC20Permit.sol"; import "../libraries/BytesLib.sol"; import "../libraries/DlnOrderLib.sol"; abstract contract DlnBase is Initializable, AccessControlUpgradeable, PausableUpgradeable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address payable; using SignatureUtil for bytes; /* ========== CONSTANTS ========== */ /// @dev Basis points or bps, set to 10 000 (equal to 1/10000). Used to express relative values (fees) uint256 public constant BPS_DENOMINATOR = 10000; /// @dev Role allowed to stop transfers bytes32 public constant GOVMONITORING_ROLE = keccak256("GOVMONITORING_ROLE"); uint256 public constant MAX_ADDRESS_LENGTH = 255; uint256 public constant EVM_ADDRESS_LENGTH = 20; uint256 public constant SOLANA_ADDRESS_LENGTH = 32; /* ========== STATE VARIABLES ========== */ // @dev Maps chainId => type of chain engine mapping(uint256 => DlnOrderLib.ChainEngine) public chainEngines; IDeBridgeGate public deBridgeGate; /* ========== ERRORS ========== */ error AdminBadRole(); error CallProxyBadRole(); error GovMonitoringBadRole(); error NativeSenderBadRole(bytes nativeSender, uint256 chainIdFrom); error MismatchedTransferAmount(); error MismatchedOrderId(); error WrongAddressLength(); error ZeroAddress(); error NotSupportedDstChain(); error EthTransferFailed(); error Unauthorized(); error IncorrectOrderStatus(); error WrongChain(); error WrongArgument(); error UnknownEngine(); /* ========== EVENTS ========== */ /* ========== MODIFIERS ========== */ modifier onlyAdmin() { if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) revert AdminBadRole(); _; } modifier onlyGovMonitoring() { if (!hasRole(GOVMONITORING_ROLE, msg.sender)) revert GovMonitoringBadRole(); _; } /* ========== CONSTRUCTOR ========== */ /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function __DlnBase_init(IDeBridgeGate _deBridgeGate) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); __Pausable_init_unchained(); __DlnBase_init_unchained(_deBridgeGate); } function __DlnBase_init_unchained(IDeBridgeGate _deBridgeGate) internal initializer { deBridgeGate = _deBridgeGate; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } /* ========== ADMIN METHODS ========== */ /// @dev Stop all protocol. function pause() external onlyGovMonitoring { _pause(); } /// @dev Unlock protocol. function unpause() external onlyAdmin { _unpause(); } /* ========== INTERNAL ========== */ function _executePermit(address _tokenAddress, bytes memory _permitEnvelope) internal { if (_permitEnvelope.length > 0) { uint256 permitAmount = BytesLib.toUint256(_permitEnvelope, 0); uint256 deadline = BytesLib.toUint256(_permitEnvelope, 32); (bytes32 r, bytes32 s, uint8 v) = _permitEnvelope.parseSignature(64); IERC20Permit(_tokenAddress).permit( msg.sender, address(this), permitAmount, deadline, v, r, s ); } } /// @dev Safe transfer tokens and check that receiver will receive exact amount (check only if to != from) function _safeTransferFrom( address _tokenAddress, address _from, address _to, uint256 _amount ) internal { IERC20Upgradeable token = IERC20Upgradeable(_tokenAddress); uint256 balanceBefore = token.balanceOf(_to); token.safeTransferFrom(_from, _to, _amount); // Received real amount uint256 receivedAmount = token.balanceOf(_to) - balanceBefore; if (_from != _to && _amount != receivedAmount) revert MismatchedTransferAmount(); } /* * @dev transfer ETH to an address, revert if it fails. * @param to recipient of the transfer * @param value the amount to send */ function _safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); if (!success) revert EthTransferFailed(); } /// @dev Transfer ETH or token /// @param tokenAddress address(0) to transfer ETH /// @param to recipient of the transfer /// @param value the amount to send function _safeTransferEthOrToken(address tokenAddress, address to, uint256 value) internal { if (tokenAddress == address(0)) { _safeTransferETH(to, value); } else { IERC20Upgradeable(tokenAddress).safeTransfer(to, value); } } function _encodeOrder(DlnOrderLib.Order memory _order) internal pure returns (bytes memory encoded) { { if ( _order.makerSrc.length > MAX_ADDRESS_LENGTH || _order.giveTokenAddress.length > MAX_ADDRESS_LENGTH || _order.takeTokenAddress.length > MAX_ADDRESS_LENGTH || _order.receiverDst.length > MAX_ADDRESS_LENGTH || _order.givePatchAuthoritySrc.length > MAX_ADDRESS_LENGTH || _order.allowedTakerDst.length > MAX_ADDRESS_LENGTH || _order.allowedCancelBeneficiarySrc.length > MAX_ADDRESS_LENGTH ) revert WrongAddressLength(); } // | Bytes | Bits | Field | // | ----- | ---- | ---------------------------------------------------- | // | 8 | 64 | Nonce // | 1 | 8 | Maker Src Address Size (!=0) | // | N | 8*N | Maker Src Address | // | 32 | 256 | Give Chain Id | // | 1 | 8 | Give Token Address Size (!=0) | // | N | 8*N | Give Token Address | // | 32 | 256 | Give Amount | // | 32 | 256 | Take Chain Id | // | 1 | 8 | Take Token Address Size (!=0) | // | N | 8*N | Take Token Address | // | 32 | 256 | Take Amount | | // | 1 | 8 | Receiver Dst Address Size (!=0) | // | N | 8*N | Receiver Dst Address | // | 1 | 8 | Give Patch Authority Address Size (!=0) | // | N | 8*N | Give Patch Authority Address | // | 1 | 8 | Order Authority Address Dst Size (!=0) | // | N | 8*N | Order Authority Address Dst | // | 1 | 8 | Allowed Taker Dst Address Size | // | N | 8*N | * Allowed Taker Address Dst | // | 1 | 8 | Allowed Cancel Beneficiary Src Address Size | // | N | 8*N | * Allowed Cancel Beneficiary Address Src | // | 1 | 8 | Is External Call Presented 0x0 - Not, != 0x0 - Yes | // | 32 | 256 | * External Call Envelope Hash encoded = abi.encodePacked( _order.makerOrderNonce, (uint8)(_order.makerSrc.length), _order.makerSrc ); { encoded = abi.encodePacked( encoded, _order.giveChainId, (uint8)(_order.giveTokenAddress.length), _order.giveTokenAddress, _order.giveAmount, _order.takeChainId ); } //Avoid stack to deep { encoded = abi.encodePacked( encoded, (uint8)(_order.takeTokenAddress.length), _order.takeTokenAddress, _order.takeAmount, (uint8)(_order.receiverDst.length), _order.receiverDst ); } { encoded = abi.encodePacked( encoded, (uint8)(_order.givePatchAuthoritySrc.length), _order.givePatchAuthoritySrc, (uint8)(_order.orderAuthorityAddressDst.length), _order.orderAuthorityAddressDst ); } { encoded = abi.encodePacked( encoded, (uint8)(_order.allowedTakerDst.length), _order.allowedTakerDst, (uint8)(_order.allowedCancelBeneficiarySrc.length), _order.allowedCancelBeneficiarySrc, _order.externalCall.length > 0 ); } if (_order.externalCall.length > 0) { encoded = abi.encodePacked( encoded, keccak256(_order.externalCall) ); } return encoded; } // ============ VIEWS ============ function getOrderId(DlnOrderLib.Order memory _order) public pure returns (bytes32) { return keccak256(_encodeOrder(_order)); } /// @dev Get current chain id function getChainId() public view virtual returns (uint256 cid) { assembly { cid := chainid() } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import "../libraries/DlnOrderLib.sol"; interface IDlnSource { /** * @notice This function returns the global fixed fee in the native asset of the protocol. * @dev This fee is denominated in the native asset (like Ether in Ethereum). * @return uint88 This return value represents the global fixed fee in the native asset. */ function globalFixedNativeFee() external returns (uint88); /** * @notice This function provides the global transfer fee, expressed in Basis Points (BPS). * @dev It retrieves a global fee which is applied to order.giveAmount. The fee is represented in Basis Points (BPS), where 1 BPS equals 0.01%. * @return uint16 The return value represents the global transfer fee in BPS. */ function globalTransferFeeBps() external returns (uint16); /** * @dev Places a new order with pseudo-random orderId onto the DLN * @notice deprecated * @param _orderCreation a structured parameter from the DlnOrderLib.OrderCreation library, containing all the necessary information required for creating a new order. * @param _affiliateFee a bytes parameter specifying the affiliate fee that will be rewarded to the beneficiary. It includes the beneficiary's details and the affiliate amount. * @param _referralCode a 32-bit unsigned integer containing the referral code. This code is traced back to the referral source or person that facilitated this order. This code is also emitted in an event for tracking purposes. * @param _permitEnvelope a bytes parameter that is used to approve the spender through a signature. It contains the amount, the deadline, and the signature. * @return bytes32 identifier (orderId) of a newly placed order */ function createOrder( DlnOrderLib.OrderCreation calldata _orderCreation, bytes calldata _affiliateFee, uint32 _referralCode, bytes calldata _permitEnvelope ) external payable returns (bytes32); /** * @dev Places a new order with deterministic orderId onto the DLN * @param _orderCreation a structured parameter from the DlnOrderLib.OrderCreation library, containing all the necessary information required for creating a new order. * @param _salt an input source of randomness for getting a deterministic identifier of an order (orderId) * @param _affiliateFee a bytes parameter specifying the affiliate fee that will be rewarded to the beneficiary. It includes the beneficiary's details and the affiliate amount. * @param _referralCode a 32-bit unsigned integer containing the referral code. This code is traced back to the referral source or person that facilitated this order. This code is also emitted in an event for tracking purposes. * @param _permitEnvelope a bytes parameter that is used to approve the spender through a signature. It contains the amount, the deadline, and the signature. * @param _metadata an arbitrary data to be tied together with the order for future off-chain analysis * @return bytes32 identifier (orderId) of a newly placed order */ function createSaltedOrder( DlnOrderLib.OrderCreation calldata _orderCreation, uint64 _salt, bytes calldata _affiliateFee, uint32 _referralCode, bytes calldata _permitEnvelope, bytes calldata _metadata ) external payable returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; }
// 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 toAddress(bytes memory _bytes) internal pure returns (address) { require(_bytes.length == 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), 0)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1 , "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage( bytes storage _preBytes, bytes memory _postBytes ) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for {} eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; library DlnOrderLib { /* ========== ENUMS ========== */ /** * @dev Enum defining the supported blockchain engines. * - `UNDEFINED`: Represents an undefined or unknown blockchain engine (0). * - `EVM`: Represents the Ethereum Virtual Machine (EVM) blockchain engine (1). * - `SOLANA`: Represents the Solana blockchain engine (2). */ enum ChainEngine { UNDEFINED, // 0 EVM, // 1 SOLANA // 2 } /* ========== STRUCTS ========== */ /// @dev Struct representing the creation parameters for creating an order on the (EVM) chain. struct OrderCreation { /// Address of the ERC-20 token that the maker is offering as part of this order. /// Use the zero address to indicate that the maker is offering a native blockchain token (such as Ether, Matic, etc.). address giveTokenAddress; /// Amount of tokens the maker is offering. uint256 giveAmount; /// Address of the ERC-20 token that the maker is willing to accept on the destination chain. bytes takeTokenAddress; /// Amount of tokens the maker is willing to accept on the destination chain. uint256 takeAmount; // the ID of the chain where an order should be fulfilled. uint256 takeChainId; /// Address on the destination chain where funds should be sent upon order fulfillment. bytes receiverDst; /// Address on the source (current) chain authorized to patch the order by adding more input tokens, making it more attractive to takers. address givePatchAuthoritySrc; /// Address on the destination chain authorized to patch the order by reducing the take amount, making it more attractive to takers, /// and can also cancel the order in the take chain. bytes orderAuthorityAddressDst; // An optional address restricting anyone in the open market from fulfilling // this order but the given address. This can be useful if you are creating a order // for a specific taker. By default, set to empty bytes array (0x) bytes allowedTakerDst; /// An optional external call data payload. bytes externalCall; // An optional address on the source (current) chain where the given input tokens // would be transferred to in case order cancellation is initiated by the orderAuthorityAddressDst // on the destination chain. This property can be safely set to an empty bytes array (0x): // in this case, tokens would be transferred to the arbitrary address specified // by the orderAuthorityAddressDst upon order cancellation bytes allowedCancelBeneficiarySrc; } /// @dev Struct representing an order. struct Order { /// Nonce for each maker. uint64 makerOrderNonce; /// Order maker address (EOA signer for EVM) in the source chain. bytes makerSrc; /// Chain ID where the order's was created. uint256 giveChainId; /// Address of the ERC-20 token that the maker is offering as part of this order. /// Use the zero address to indicate that the maker is offering a native blockchain token (such as Ether, Matic, etc.). bytes giveTokenAddress; /// Amount of tokens the maker is offering. uint256 giveAmount; // the ID of the chain where an order should be fulfilled. uint256 takeChainId; /// Address of the ERC-20 token that the maker is willing to accept on the destination chain. bytes takeTokenAddress; /// Amount of tokens the maker is willing to accept on the destination chain. uint256 takeAmount; /// Address on the destination chain where funds should be sent upon order fulfillment. bytes receiverDst; /// Address on the source (current) chain authorized to patch the order by adding more input tokens, making it more attractive to takers. bytes givePatchAuthoritySrc; /// Address on the destination chain authorized to patch the order by reducing the take amount, making it more attractive to takers, /// and can also cancel the order in the take chain. bytes orderAuthorityAddressDst; // An optional address restricting anyone in the open market from fulfilling // this order but the given address. This can be useful if you are creating a order // for a specific taker. By default, set to empty bytes array (0x) bytes allowedTakerDst; // An optional address on the source (current) chain where the given input tokens // would be transferred to in case order cancellation is initiated by the orderAuthorityAddressDst // on the destination chain. This property can be safely set to an empty bytes array (0x): // in this case, tokens would be transferred to the arbitrary address specified // by the orderAuthorityAddressDst upon order cancellation bytes allowedCancelBeneficiarySrc; /// An optional external call data payload. bytes externalCall; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
{ "optimizer": { "enabled": true, "runs": 9999 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"name":"AdminBadRole","type":"error"},{"inputs":[],"name":"CallProxyBadRole","type":"error"},{"inputs":[{"internalType":"bytes32","name":"orderId","type":"bytes32"},{"internalType":"uint48","name":"takeChainId","type":"uint48"},{"internalType":"uint256","name":"submissionsChainIdFrom","type":"uint256"}],"name":"CriticalMismatchTakeChainId","type":"error"},{"inputs":[],"name":"EthTransferFailed","type":"error"},{"inputs":[],"name":"GovMonitoringBadRole","type":"error"},{"inputs":[],"name":"IncorrectOrderStatus","type":"error"},{"inputs":[],"name":"MismatchNativeGiveAmount","type":"error"},{"inputs":[],"name":"MismatchedOrderId","type":"error"},{"inputs":[],"name":"MismatchedTransferAmount","type":"error"},{"inputs":[{"internalType":"bytes","name":"nativeSender","type":"bytes"},{"internalType":"uint256","name":"chainIdFrom","type":"uint256"}],"name":"NativeSenderBadRole","type":"error"},{"inputs":[],"name":"NotSupportedDstChain","type":"error"},{"inputs":[],"name":"SignatureInvalidV","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"UnknownEngine","type":"error"},{"inputs":[],"name":"WrongAddressLength","type":"error"},{"inputs":[],"name":"WrongAffiliateFeeLength","type":"error"},{"inputs":[],"name":"WrongArgument","type":"error"},{"inputs":[],"name":"WrongChain","type":"error"},{"inputs":[{"internalType":"uint256","name":"received","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"WrongFixedFee","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"_orderId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"affiliateFee","type":"uint256"},{"indexed":false,"internalType":"address","name":"giveTokenAddress","type":"address"}],"name":"AffiliateFeePaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"paidAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"giveTokenAddress","type":"address"}],"name":"ClaimedOrderCancel","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"giveAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"giveTokenAddress","type":"address"}],"name":"ClaimedUnlock","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint64","name":"makerOrderNonce","type":"uint64"},{"internalType":"bytes","name":"makerSrc","type":"bytes"},{"internalType":"uint256","name":"giveChainId","type":"uint256"},{"internalType":"bytes","name":"giveTokenAddress","type":"bytes"},{"internalType":"uint256","name":"giveAmount","type":"uint256"},{"internalType":"uint256","name":"takeChainId","type":"uint256"},{"internalType":"bytes","name":"takeTokenAddress","type":"bytes"},{"internalType":"uint256","name":"takeAmount","type":"uint256"},{"internalType":"bytes","name":"receiverDst","type":"bytes"},{"internalType":"bytes","name":"givePatchAuthoritySrc","type":"bytes"},{"internalType":"bytes","name":"orderAuthorityAddressDst","type":"bytes"},{"internalType":"bytes","name":"allowedTakerDst","type":"bytes"},{"internalType":"bytes","name":"allowedCancelBeneficiarySrc","type":"bytes"},{"internalType":"bytes","name":"externalCall","type":"bytes"}],"indexed":false,"internalType":"struct DlnOrderLib.Order","name":"order","type":"tuple"},{"indexed":false,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"affiliateFee","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"nativeFixFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"percentFee","type":"uint256"},{"indexed":false,"internalType":"uint32","name":"referralCode","type":"uint32"},{"indexed":false,"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"CreatedOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"takeChainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"submissionChainIdFrom","type":"uint256"}],"name":"CriticalMismatchChainId","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint88","name":"oldGlobalFixedNativeFee","type":"uint88"},{"indexed":false,"internalType":"uint88","name":"newGlobalFixedNativeFee","type":"uint88"}],"name":"GlobalFixedNativeFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"oldGlobalTransferFeeBps","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"newGlobalTransferFeeBps","type":"uint16"}],"name":"GlobalTransferFeeBpsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"orderGiveFinalAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"finalPercentFee","type":"uint256"}],"name":"IncreasedGiveAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chainIdTo","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"dlnDestinationAddress","type":"bytes"},{"indexed":false,"internalType":"enum DlnOrderLib.ChainEngine","name":"chainEngine","type":"uint8"}],"name":"SetDlnDestinationAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":false,"internalType":"enum DlnSource.OrderGiveStatus","name":"status","type":"uint8"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"}],"name":"UnexpectedOrderStatusForCancel","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":false,"internalType":"enum DlnSource.OrderGiveStatus","name":"status","type":"uint8"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"}],"name":"UnexpectedOrderStatusForClaim","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"}],"name":"WithdrawnFee","type":"event"},{"inputs":[],"name":"BPS_DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EVM_ADDRESS_LENGTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GOVMONITORING_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_ADDRESS_LENGTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SOLANA_ADDRESS_LENGTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"chainEngines","outputs":[{"internalType":"enum DlnOrderLib.ChainEngine","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"_orderIds","type":"bytes32[]"},{"internalType":"address","name":"_beneficiary","type":"address"}],"name":"claimBatchCancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"_orderIds","type":"bytes32[]"},{"internalType":"address","name":"_beneficiary","type":"address"}],"name":"claimBatchUnlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_orderId","type":"bytes32"},{"internalType":"address","name":"_beneficiary","type":"address"}],"name":"claimCancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_orderId","type":"bytes32"},{"internalType":"address","name":"_beneficiary","type":"address"}],"name":"claimUnlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"collectedFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"giveTokenAddress","type":"address"},{"internalType":"uint256","name":"giveAmount","type":"uint256"},{"internalType":"bytes","name":"takeTokenAddress","type":"bytes"},{"internalType":"uint256","name":"takeAmount","type":"uint256"},{"internalType":"uint256","name":"takeChainId","type":"uint256"},{"internalType":"bytes","name":"receiverDst","type":"bytes"},{"internalType":"address","name":"givePatchAuthoritySrc","type":"address"},{"internalType":"bytes","name":"orderAuthorityAddressDst","type":"bytes"},{"internalType":"bytes","name":"allowedTakerDst","type":"bytes"},{"internalType":"bytes","name":"externalCall","type":"bytes"},{"internalType":"bytes","name":"allowedCancelBeneficiarySrc","type":"bytes"}],"internalType":"struct DlnOrderLib.OrderCreation","name":"_orderCreation","type":"tuple"},{"internalType":"bytes","name":"_affiliateFee","type":"bytes"},{"internalType":"uint32","name":"_referralCode","type":"uint32"},{"internalType":"bytes","name":"_permitEnvelope","type":"bytes"}],"name":"createOrder","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"giveTokenAddress","type":"address"},{"internalType":"uint256","name":"giveAmount","type":"uint256"},{"internalType":"bytes","name":"takeTokenAddress","type":"bytes"},{"internalType":"uint256","name":"takeAmount","type":"uint256"},{"internalType":"uint256","name":"takeChainId","type":"uint256"},{"internalType":"bytes","name":"receiverDst","type":"bytes"},{"internalType":"address","name":"givePatchAuthoritySrc","type":"address"},{"internalType":"bytes","name":"orderAuthorityAddressDst","type":"bytes"},{"internalType":"bytes","name":"allowedTakerDst","type":"bytes"},{"internalType":"bytes","name":"externalCall","type":"bytes"},{"internalType":"bytes","name":"allowedCancelBeneficiarySrc","type":"bytes"}],"internalType":"struct DlnOrderLib.OrderCreation","name":"_orderCreation","type":"tuple"},{"internalType":"uint64","name":"_salt","type":"uint64"},{"internalType":"bytes","name":"_affiliateFee","type":"bytes"},{"internalType":"uint32","name":"_referralCode","type":"uint32"},{"internalType":"bytes","name":"_permitEnvelope","type":"bytes"},{"internalType":"bytes","name":"_metadata","type":"bytes"}],"name":"createSaltedOrder","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"deBridgeGate","outputs":[{"internalType":"contract IDeBridgeGate","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"dlnDestinationAddresses","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getChainId","outputs":[{"internalType":"uint256","name":"cid","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint64","name":"makerOrderNonce","type":"uint64"},{"internalType":"bytes","name":"makerSrc","type":"bytes"},{"internalType":"uint256","name":"giveChainId","type":"uint256"},{"internalType":"bytes","name":"giveTokenAddress","type":"bytes"},{"internalType":"uint256","name":"giveAmount","type":"uint256"},{"internalType":"uint256","name":"takeChainId","type":"uint256"},{"internalType":"bytes","name":"takeTokenAddress","type":"bytes"},{"internalType":"uint256","name":"takeAmount","type":"uint256"},{"internalType":"bytes","name":"receiverDst","type":"bytes"},{"internalType":"bytes","name":"givePatchAuthoritySrc","type":"bytes"},{"internalType":"bytes","name":"orderAuthorityAddressDst","type":"bytes"},{"internalType":"bytes","name":"allowedTakerDst","type":"bytes"},{"internalType":"bytes","name":"allowedCancelBeneficiarySrc","type":"bytes"},{"internalType":"bytes","name":"externalCall","type":"bytes"}],"internalType":"struct DlnOrderLib.Order","name":"_order","type":"tuple"}],"name":"getOrderId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"giveOrders","outputs":[{"internalType":"enum DlnSource.OrderGiveStatus","name":"status","type":"uint8"},{"internalType":"uint160","name":"giveTokenAddress","type":"uint160"},{"internalType":"uint88","name":"nativeFixFee","type":"uint88"},{"internalType":"uint48","name":"takeChainId","type":"uint48"},{"internalType":"uint208","name":"percentFee","type":"uint208"},{"internalType":"uint256","name":"giveAmount","type":"uint256"},{"internalType":"address","name":"affiliateBeneficiary","type":"address"},{"internalType":"uint256","name":"affiliateAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"givePatches","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalFixedNativeFee","outputs":[{"internalType":"uint88","name":"","type":"uint88"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalTransferFeeBps","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IDeBridgeGate","name":"_deBridgeGate","type":"address"},{"internalType":"uint88","name":"_globalFixedNativeFee","type":"uint88"},{"internalType":"uint16","name":"_globalTransferFeeBps","type":"uint16"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"masterNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint64","name":"makerOrderNonce","type":"uint64"},{"internalType":"bytes","name":"makerSrc","type":"bytes"},{"internalType":"uint256","name":"giveChainId","type":"uint256"},{"internalType":"bytes","name":"giveTokenAddress","type":"bytes"},{"internalType":"uint256","name":"giveAmount","type":"uint256"},{"internalType":"uint256","name":"takeChainId","type":"uint256"},{"internalType":"bytes","name":"takeTokenAddress","type":"bytes"},{"internalType":"uint256","name":"takeAmount","type":"uint256"},{"internalType":"bytes","name":"receiverDst","type":"bytes"},{"internalType":"bytes","name":"givePatchAuthoritySrc","type":"bytes"},{"internalType":"bytes","name":"orderAuthorityAddressDst","type":"bytes"},{"internalType":"bytes","name":"allowedTakerDst","type":"bytes"},{"internalType":"bytes","name":"allowedCancelBeneficiarySrc","type":"bytes"},{"internalType":"bytes","name":"externalCall","type":"bytes"}],"internalType":"struct DlnOrderLib.Order","name":"_order","type":"tuple"},{"internalType":"uint256","name":"_addGiveAmount","type":"uint256"},{"internalType":"bytes","name":"_permitEnvelope","type":"bytes"}],"name":"patchOrderGive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_chainIdTo","type":"uint256"},{"internalType":"bytes","name":"_dlnDestinationAddress","type":"bytes"},{"internalType":"enum DlnOrderLib.ChainEngine","name":"_chainEngine","type":"uint8"}],"name":"setDlnDestinationAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"unclaimedAffiliateETHFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"unexpectedOrderStatusForCancel","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"unexpectedOrderStatusForClaim","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint88","name":"_globalFixedNativeFee","type":"uint88"},{"internalType":"uint16","name":"_globalTransferFeeBps","type":"uint16"}],"name":"updateGlobalFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"giveTokenAddress","type":"address"},{"internalType":"uint256","name":"giveAmount","type":"uint256"},{"internalType":"bytes","name":"takeTokenAddress","type":"bytes"},{"internalType":"uint256","name":"takeAmount","type":"uint256"},{"internalType":"uint256","name":"takeChainId","type":"uint256"},{"internalType":"bytes","name":"receiverDst","type":"bytes"},{"internalType":"address","name":"givePatchAuthoritySrc","type":"address"},{"internalType":"bytes","name":"orderAuthorityAddressDst","type":"bytes"},{"internalType":"bytes","name":"allowedTakerDst","type":"bytes"},{"internalType":"bytes","name":"externalCall","type":"bytes"},{"internalType":"bytes","name":"allowedCancelBeneficiarySrc","type":"bytes"}],"internalType":"struct DlnOrderLib.OrderCreation","name":"_orderCreation","type":"tuple"},{"internalType":"address","name":"_signer","type":"address"},{"internalType":"uint64","name":"_salt","type":"uint64"}],"name":"validateCreationOrder","outputs":[{"components":[{"internalType":"uint64","name":"makerOrderNonce","type":"uint64"},{"internalType":"bytes","name":"makerSrc","type":"bytes"},{"internalType":"uint256","name":"giveChainId","type":"uint256"},{"internalType":"bytes","name":"giveTokenAddress","type":"bytes"},{"internalType":"uint256","name":"giveAmount","type":"uint256"},{"internalType":"uint256","name":"takeChainId","type":"uint256"},{"internalType":"bytes","name":"takeTokenAddress","type":"bytes"},{"internalType":"uint256","name":"takeAmount","type":"uint256"},{"internalType":"bytes","name":"receiverDst","type":"bytes"},{"internalType":"bytes","name":"givePatchAuthoritySrc","type":"bytes"},{"internalType":"bytes","name":"orderAuthorityAddressDst","type":"bytes"},{"internalType":"bytes","name":"allowedTakerDst","type":"bytes"},{"internalType":"bytes","name":"allowedCancelBeneficiarySrc","type":"bytes"},{"internalType":"bytes","name":"externalCall","type":"bytes"}],"internalType":"struct DlnOrderLib.Order","name":"order","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"giveTokenAddress","type":"address"},{"internalType":"uint256","name":"giveAmount","type":"uint256"},{"internalType":"bytes","name":"takeTokenAddress","type":"bytes"},{"internalType":"uint256","name":"takeAmount","type":"uint256"},{"internalType":"uint256","name":"takeChainId","type":"uint256"},{"internalType":"bytes","name":"receiverDst","type":"bytes"},{"internalType":"address","name":"givePatchAuthoritySrc","type":"address"},{"internalType":"bytes","name":"orderAuthorityAddressDst","type":"bytes"},{"internalType":"bytes","name":"allowedTakerDst","type":"bytes"},{"internalType":"bytes","name":"externalCall","type":"bytes"},{"internalType":"bytes","name":"allowedCancelBeneficiarySrc","type":"bytes"}],"internalType":"struct DlnOrderLib.OrderCreation","name":"_orderCreation","type":"tuple"},{"internalType":"address","name":"_signer","type":"address"}],"name":"validateCreationOrder","outputs":[{"components":[{"internalType":"uint64","name":"makerOrderNonce","type":"uint64"},{"internalType":"bytes","name":"makerSrc","type":"bytes"},{"internalType":"uint256","name":"giveChainId","type":"uint256"},{"internalType":"bytes","name":"giveTokenAddress","type":"bytes"},{"internalType":"uint256","name":"giveAmount","type":"uint256"},{"internalType":"uint256","name":"takeChainId","type":"uint256"},{"internalType":"bytes","name":"takeTokenAddress","type":"bytes"},{"internalType":"uint256","name":"takeAmount","type":"uint256"},{"internalType":"bytes","name":"receiverDst","type":"bytes"},{"internalType":"bytes","name":"givePatchAuthoritySrc","type":"bytes"},{"internalType":"bytes","name":"orderAuthorityAddressDst","type":"bytes"},{"internalType":"bytes","name":"allowedTakerDst","type":"bytes"},{"internalType":"bytes","name":"allowedCancelBeneficiarySrc","type":"bytes"},{"internalType":"bytes","name":"externalCall","type":"bytes"}],"internalType":"struct DlnOrderLib.Order","name":"order","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"address","name":"_beneficiary","type":"address"}],"name":"withdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506200001c62000022565b620000e4565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000e2576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61541880620000f46000396000f3fe6080604052600436106102db5760003560e01c80636ac89fa211610184578063b9303701116100d6578063df21dc1d1161008a578063fa82f30911610064578063fa82f3091461098c578063faeb8113146109a1578063fbe16ca7146109d857600080fd5b8063df21dc1d14610933578063e1a4521814610961578063f6ef28b41461097757600080fd5b8063d48b0146116100bb578063d48b0146146108bf578063d547741f146108df578063da615052146108ff57600080fd5b8063b93037011461088c578063ca777fbf1461089f57600080fd5b8063924a062c11610138578063a7c5f50411610112578063a7c5f5041461075e578063b2a453f8146107ad578063b5bbf6e11461087957600080fd5b8063924a062c146106ec5780639dd1aeac1461070c578063a217fddf1461074957600080fd5b80637716d26f116101695780637716d26f146106715780638456cb591461069157806391d14854146106a657600080fd5b80636ac89fa2146106235780636fba7f711461064357600080fd5b806335087f0a1161023d57806354fd4d50116101f15780635c975abb116101cb5780635c975abb146105cb5780635f1f3af7146105e35780636abd4ea71461060357600080fd5b806354fd4d50146105285780635886d8d21461056e5780635c8371981461058e57600080fd5b80633f4ba83a116102225780633f4ba83a146104d35780633fe00dd7146104e857806350e955911461050857600080fd5b806335087f0a1461047357806336568abe146104b357600080fd5b806314bb1361116102945780632f2ff15d116102795780632f2ff15d1461041e57806330bb0911146104405780633408e4701461046057600080fd5b806314bb1361146103c1578063248a9ca3146103ee57600080fd5b806301ffc9a7116102c557806301ffc9a71461034e57806303deb7ea1461037e5780630acc3eb01461039357600080fd5b80624aa320146102e057806301bc5f0814610321575b600080fd5b3480156102ec57600080fd5b5061030e6102fb366004613e1c565b6101026020526000908152604090205481565b6040519081526020015b60405180910390f35b34801561032d57600080fd5b5061034161033c3660046140c7565b6109eb565b60405161031891906142a4565b34801561035a57600080fd5b5061036e6103693660046142b7565b610c83565b6040519015158152602001610318565b34801561038a57600080fd5b5061030e601481565b34801561039f57600080fd5b5061030e6103ae366004613e1c565b6101056020526000908152604090205481565b3480156103cd57600080fd5b506103e16103dc3660046142f9565b610d1c565b6040516103189190614312565b3480156103fa57600080fd5b5061030e6104093660046142f9565b60009081526065602052604090206001015490565b34801561042a57600080fd5b5061043e610439366004614325565b610db6565b005b34801561044c57600080fd5b5061043e61045b366004614355565b610de0565b34801561046c57600080fd5b504661030e565b34801561047f57600080fd5b5060fd54610497906affffffffffffffffffffff1681565b6040516affffffffffffffffffffff9091168152602001610318565b3480156104bf57600080fd5b5061043e6104ce366004614325565b610f1c565b3480156104df57600080fd5b5061043e610fad565b3480156104f457600080fd5b506103416105033660046143b4565b61101f565b34801561051457600080fd5b5061030e61052336600461459a565b6110c9565b34801561053457600080fd5b5060408051808201909152600581527f312e332e3000000000000000000000000000000000000000000000000000000060208201526103e1565b34801561057a57600080fd5b5061043e610589366004614325565b6110e2565b34801561059a57600080fd5b5060fd546105b8906b010000000000000000000000900461ffff1681565b60405161ffff9091168152602001610318565b3480156105d757600080fd5b5060975460ff1661036e565b3480156105ef57600080fd5b5061043e6105fe3660046145fc565b611114565b34801561060f57600080fd5b5061043e61061e36600461465c565b61128d565b34801561062f57600080fd5b5061043e61063e3660046146ff565b6112f8565b34801561064f57600080fd5b5061030e61065e3660046142f9565b6101006020526000908152604090205481565b34801561067d57600080fd5b5061043e61068c366004614732565b611372565b34801561069d57600080fd5b5061043e6114c0565b3480156106b257600080fd5b5061036e6106c1366004614325565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156106f857600080fd5b5061043e61070736600461465c565b611530565b34801561071857600080fd5b5061073c6107273660046142f9565b60c96020526000908152604090205460ff1681565b6040516103189190614806565b34801561075557600080fd5b5061030e600081565b34801561076a57600080fd5b506107956107793660046142f9565b610103602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610318565b3480156107b957600080fd5b506108656107c83660046142f9565b60ff60208190526000918252604090912080546001820154600283015460038401546004909401549483169461010084046001600160a01b039081169575010000000000000000000000000000000000000000009095046affffffffffffffffffffff169465ffffffffffff8516946601000000000000900479ffffffffffffffffffffffffffffffffffffffffffffffffffff16939291169088565b604051610318989796959493929190614824565b61043e6108873660046148f1565b61158e565b61030e61089a36600461498e565b6118ce565b3480156108ab57600080fd5b5060ca54610795906001600160a01b031681565b3480156108cb57600080fd5b5061043e6108da366004614325565b611908565b3480156108eb57600080fd5b5061043e6108fa366004614325565b61192f565b34801561090b57600080fd5b5061030e7f2b36fa99e118fa8485d488becf749a974743fbeb6a7aa57e663893bf5d69a3c181565b34801561093f57600080fd5b5061030e61094e366004613e1c565b6101016020526000908152604090205481565b34801561096d57600080fd5b5061030e61271081565b34801561098357600080fd5b5061030e602081565b34801561099857600080fd5b5061030e60ff81565b3480156109ad57600080fd5b506107956109bc3660046142f9565b610104602052600090815260409020546001600160a01b031681565b61030e6109e6366004614a6a565b611954565b610a67604051806101c00160405280600067ffffffffffffffff168152602001606081526020016000815260200160608152602001600081526020016000815260200160608152602001600081526020016060815260200160608152602001606081526020016060815260200160608152602001606081525090565b6080840151600090815260fe602052604081208054610a8590614b12565b9050905080600003610ac3576040517f016643e200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80856040015151141580610adc5750808560a001515114155b80610aec5750808560e001515114155b80610b0e5750600085610100015151118015610b0e5750808561010001515114155b80610b315750600085610140015151118015610b31575060148561014001515114155b15610b68576040517fbe31c33b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4660408381019190915267ffffffffffffffff841683528051606086811b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000908116602080850191909152845160148186038101825260349586018752828901919091528a51865190851b841681840152865180820390920182528501865283880152898101516080808901919091528a86015160c0808a01919091528b85015160e08a0152908b015160a0808a01919091528b01516101008901528a015194519490921b16908301520160408051601f198184030181529190526101208084019190915260e086015161014080850191909152610100870151610160850152908601516101a0840152909401516101808201529392505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b000000000000000000000000000000000000000000000000000000001480610d1657507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60fe6020526000908152604090208054610d3590614b12565b80601f0160208091040260200160405190810160405280929190818152602001828054610d6190614b12565b8015610dae5780601f10610d8357610100808354040283529160200191610dae565b820191906000526020600020905b815481529060010190602001808311610d9157829003601f168201915b505050505081565b600082815260656020526040902060010154610dd1816119bc565b610ddb83836119c9565b505050565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16610e48576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000816002811115610e5c57610e5c6147c3565b03610e93576040517f4668624100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600083815260fe60205260409020610eab8382614bad565b50600083815260c960205260409020805482919060ff19166001836002811115610ed757610ed76147c3565b02179055507f82568678a169f202360005e72d5ab10d95c3c369ddd502057dacb85e9c700759838383604051610f0f93929190614ca9565b60405180910390a1505050565b6001600160a01b0381163314610f9f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b610fa98282611a6b565b5050565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16611015576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61101d611aee565b565b61109b604051806101c00160405280600067ffffffffffffffff168152602001606081526020016000815260200160608152602001600081526020016000815260200160608152602001600081526020016060815260200160608152602001606081526020016060815260200160608152602001606081525090565b6001600160a01b038216600090815261010160205260409020546110c290849084906109eb565b9392505050565b60006110d482611b40565b805190602001209050919050565b6110ea611d45565b6110f2611d9e565b60006110fc611df1565b9050611109838383611fed565b50610fa9600160cb55565b600054610100900460ff16158080156111345750600054600160ff909116105b8061114e5750303b15801561114e575060005460ff166001145b6111c05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610f96565b6000805460ff19166001179055801561120057600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b611209836123d1565b61121282612468565b61121b84612505565b611223612679565b801561128757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b50505050565b611295611d45565b61129d611d9e565b60006112a7611df1565b835190915060005b818110156112eb576112db8582815181106112cc576112cc614cd1565b60200260200101518585611fed565b6112e481614d2f565b90506112af565b505050610fa9600160cb55565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16611360576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611369826123d1565b610fa981612468565b61137a611d45565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff166113e2576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b815160005b818110156114b457600084828151811061140357611403614cd1565b6020026020010151905060006101026000836001600160a01b03166001600160a01b031681526020019081526020016000205490506114438286836126fe565b6001600160a01b0382811660008181526101026020908152604080832092909255815192835282018490529187168183015290517f036e7dece8303b57678319debe761b27c7298611a5c4e23776a7f1e79c67742a9181900360600190a15050806114ad90614d2f565b90506113e7565b5050610fa9600160cb55565b3360009081527f8a5df9d3b7a9306a1075029813ef25f1a4531de6e935bc9f04ed5dd5e46af951602052604090205460ff16611528576040517f6053780500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61101d61272a565b611538611d45565b611540611d9e565b600061154a611df1565b835190915060005b818110156112eb5761157e85828151811061156f5761156f614cd1565b60200260200101518585612767565b61158781614d2f565b9050611552565b611596611d45565b61159e611d9e565b60006115a9856110c9565b9050336001600160a01b03166115c3866101200151612992565b6001600160a01b031614611603576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8360000361163d576040517f4668624100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081815260ff602052604090206001815460ff166003811115611663576116636147c3565b1461169a576040517fea6eda5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006116a98760600151612992565b90506001600160a01b0381166116f7578534146116f2576040517fdc223cd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611743565b6117378186868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506129fd92505050565b61174381333089612adf565b60fd546000906127109061176b9089906b010000000000000000000000900461ffff16614d67565b6117759190614d7e565b905061178081612c74565b6001840180546006906117ba9084906601000000000000900479ffffffffffffffffffffffffffffffffffffffffffffffffffff16614db9565b92506101000a81548179ffffffffffffffffffffffffffffffffffffffffffffffffffff021916908379ffffffffffffffffffffffffffffffffffffffffffffffffffff16021790555080876118109190614df3565b600085815261010060205260408120805490919061182f908490614e06565b90915550506000848152610100602052604090205460808901517f4f3bc5fae93ae03632b30b624fb1dbfa21466a29216f314d0cfcb269d7c918ff9186916118779190614e06565b60018601546040805193845260208401929092526601000000000000900479ffffffffffffffffffffffffffffffffffffffffffffffffffff169082015260600160405180910390a150505050611287600160cb55565b60006118d8611d45565b6118e0611d9e565b6118f08989898989898989612d0a565b90506118fc600160cb55565b98975050505050505050565b611910611d45565b611918611d9e565b6000611922611df1565b9050611109838383612767565b60008281526065602052604090206001015461194a816119bc565b610ddb8383611a6b565b600061195e611d45565b611966611d9e565b3260009081526101016020526040812080546119a6928a929061198883614d2f565b91905055888888888860405180602001604052806000815250612d0a565b90506119b2600160cb55565b9695505050505050565b6119c681336130f4565b50565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16610fa95760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611a273390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff1615610fa95760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b611af6613169565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b606060ff8260200151511180611b5b575060ff826060015151115b80611b6b575060ff8260c0015151115b80611b7c575060ff82610100015151115b80611b8d575060ff82610120015151115b80611b9e575060ff82610160015151115b80611baf575060ff82610180015151115b15611be6576040517fbe31c33b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81516020808401518051604051611c01949391929101614e19565b60408051601f198184030181528282529084015160608501518051608087015160a0880151949650611c3b95879592939290602001614e90565b60408051601f198184030181529082905260c0840151805160e08601516101008701518051949650611c769587959394939190602001614f03565b60408051601f198184030181529082905261012084015180516101408601518051939550611cad9486949293929190602001614f8e565b60408051601f1981840301815290829052610160840151805161018086015180516101a088015151949650611cef958795939493919291151590602001615015565b60405160208183030381529060405290506000826101a00151511115611d405780826101a0015180519060200120604051602001611d2e9291906150ab565b60405160208183030381529060405290505b919050565b600260cb5403611d975760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610f96565b600260cb55565b60975460ff161561101d5760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610f96565b60008060ca60009054906101000a90046001600160a01b03166001600160a01b0316632da688ac6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6b91906150cd565b90506001600160a01b0381163314611eaf576040517f910e7d9c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000816001600160a01b0316632eb484916040518163ffffffff1660e01b8152600401600060405180830381865afa158015611eef573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611f1791908101906150ea565b9050816001600160a01b031663508ab0a06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f7b9190615161565b9250808051906020012060fe6000858152602001908152602001600020604051611fa5919061517a565b604051809103902014611fe85780836040517f0f25bbaa000000000000000000000000000000000000000000000000000000008152600401610f969291906151f0565b505090565b600083815260ff602052604090206001815460ff166003811115612013576120136147c3565b1461209157600084815261010360205260409081902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038616179055815490517fc65cdb43047b7466a1705cf4c7e88b0c66614ed6da1c1aa7f44026cee8e676269161127e91879160ff16908790615212565b600181015465ffffffffffff1682146120fe576001810154604080518681526001600160a01b038616602082015265ffffffffffff90921690820152606081018390527f29af03f84291900300e96b03eed8a02c0db5cdc94a3b15a880a93bfce8c125a29060800161127e565b60008481526101006020526040812054600283015461211d9190614e06565b825460ff19166002178084559091506001600160a01b03610100909104166121468186846126fe565b6004830154156122ac5760006001600160a01b0382166122205760038401546004850154604080516000815260208101918290526001600160a01b03909316926108fc9291612195919061523d565b600060405180830381858888f193505050503d80600081146121d3576040519150601f19603f3d011682016040523d82523d6000602084013e6121d8565b606091505b5050809150508061221b57600484015460038501546001600160a01b03166000908152610105602052604081208054909190612215908490614e06565b90915550505b612246565b60038401546004850154612242916001600160a01b03858116929116906131bb565b5060015b80156122aa5760038401546004850154604080518a81526001600160a01b0393841660208201529081019190915290831660608201527f9077c15d8bcf2d51f89ed4806cf2fd3d09000b446acd62c04653da6684ee16f09060800160405180910390a15b505b604080518781526001600160a01b0387811660208301528183018590528316606082015290517f33fff3d864e92b6e1ef9e830196fc019c946104ea621b833aaebd3c3e84b2f6f9181900360800190a160018301546001600160a01b0382166000908152610102602052604081208054660100000000000090930479ffffffffffffffffffffffffffffffffffffffffffffffffffff1692909190612352908490614e06565b9091555050825460008080526101026020527f565a22c1af7fcc038f06206699a6bd0ad8c85d23dafe9aebac3e0df68e8fb320805475010000000000000000000000000000000000000000009093046affffffffffffffffffffff16929091906123bd908490614e06565b9091555050505050505050565b600160cb55565b60fd546affffffffffffffffffffff9081169082168114610fa95760fd80547fffffffffffffffffffffffffffffffffffffffffff0000000000000000000000166affffffffffffffffffffff84811691821790925560408051928416835260208301919091527f326751b7ae705d9d8353edbd289cc14a323875cf13ddc42f7575ac304e417fc291015b60405180910390a15050565b60fd5461ffff6b01000000000000000000000090910481169082168114610fa95760fd80547fffffffffffffffffffffffffffffffffffffff0000ffffffffffffffffffffff166b01000000000000000000000061ffff8581169182029290921790925560408051918416825260208201929092527f013cd5c0fbece94c68f9e668b3ab52cdf65f1ee39fb338ac4c803fe21fe043e0910161245c565b600054610100900460ff16158080156125255750600054600160ff909116105b8061253f5750303b15801561253f575060005460ff166001145b6125b15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610f96565b6000805460ff1916600117905580156125f157600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6125f9613264565b612601613264565b612609613264565b6126116132e1565b61261a8261336a565b8015610fa957600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200161245c565b600054610100900460ff166126f65760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f96565b61101d613494565b6001600160a01b03831661271657610ddb8282613511565b610ddb6001600160a01b03841683836131bb565b612732611d9e565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611b233390565b600083815260ff60205260409020600181015465ffffffffffff1682146127d85760018101546040517f804e1c6f0000000000000000000000000000000000000000000000000000000081526004810186905265ffffffffffff909116602482015260448101839052606401610f96565b60008481526101006020526040812054600483015460018401546002850154612827916601000000000000900479ffffffffffffffffffffffffffffffffffffffffffffffffffff1690614e06565b6128319190614e06565b61283b9190614e06565b90506001825460ff166003811115612855576128556147c3565b0361290957815460ff19166003178083556001600160a01b03610100909104166128808186846126fe565b82546128b3908690750100000000000000000000000000000000000000000090046affffffffffffffffffffff16613511565b604080518781526001600160a01b0387811660208301528183018590528316606082015290517f7d7d1c5b3eadbe275ceb358e65cd57410b35997187258dbaaae42ab6e1405fd89181900360800190a15061298b565b600085815261010460205260409081902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038716179055825490517f9302619b5552484dceb0055d13a6b83805ce74ad349b433cf78be991ef30703e9161298291889160ff16908890615212565b60405180910390a15b5050505050565b600081516014146129e55760405162461bcd60e51b815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e647300000000000000000000006044820152606401610f96565b50602001516c01000000000000000000000000900490565b805115610fa9576000612a118260006135b8565b90506000612a208360206135b8565b905060008080612a3186604061361e565b6040517fd505accf000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018990526064810188905260ff8216608482015260a4810184905260c4810183905292955090935091506001600160a01b0388169063d505accf9060e401600060405180830381600087803b158015612abe57600080fd5b505af1158015612ad2573d6000803e3d6000fd5b5050505050505050505050565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b03838116600483015285916000918316906370a0823190602401602060405180830381865afa158015612b43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b679190615161565b9050612b7e6001600160a01b0383168686866136a4565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015260009183918516906370a0823190602401602060405180830381865afa158015612be2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c069190615161565b612c109190614df3565b9050846001600160a01b0316866001600160a01b031614158015612c345750808414155b15612c6b576040517f80b9e73000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050505050565b600079ffffffffffffffffffffffffffffffffffffffffffffffffffff821115612d065760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203260448201527f30382062697473000000000000000000000000000000000000000000000000006064820152608401610f96565b5090565b6000808615612d925760348714612d4d576040517f4115207f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612d8f88888080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250601492506135b8915050565b90505b6000612da7612da08c615259565b328c6109eb565b9050612db58b8288886136f5565b608081015160fd5460009161271091612de191906b010000000000000000000000900461ffff16614d67565b612deb9190614d7e565b9050612df78382614e06565b82608001818151612e089190614df3565b9052506000612e16836110c9565b600081815260ff60205260408120919250815460ff166003811115612e3d57612e3d6147c3565b14612e74576040517fea6eda5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805460ff19166001178155612e8c60208f018f613e1c565b81546001600160a01b0391909116610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff82168117835560fd5475010000000000000000000000000000000000000000006affffffffffffffffffffff9091160274ffffffffffffffffffffffffffffffffffffffffff90911660ff9092169190911717815560a0840151612f2290613837565b6001820180547fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000001665ffffffffffff92909216919091179055612f6483612c74565b60018201805479ffffffffffffffffffffffffffffffffffffffffffffffffffff9290921666010000000000000265ffffffffffff909216919091179055608084015160028201558415613085576000612ff38d8d8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525092506138b5915050565b905060008611801561300c57506001600160a01b038116155b15613043576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600482018690556003820180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03929092169190911790555b507ffc8703fd57380f9dd234a89dce51333782d49c5902f307b02f03e014d18fe47183828d8d60fd60009054906101000a90046affffffffffffffffffffff16878f8d6040516130dc989796959493929190615265565b60405180910390a19c9b505050505050505050505050565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16610fa9576131278161392b565b61313283602061393d565b6040516020016131439291906152f1565b60408051601f198184030181529082905262461bcd60e51b8252610f9691600401614312565b60975460ff1661101d5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610f96565b6040516001600160a01b038316602482015260448101829052610ddb9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613b66565b600054610100900460ff1661101d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f96565b600054610100900460ff1661335e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f96565b6097805460ff19169055565b600054610100900460ff161580801561338a5750600054600160ff909116105b806133a45750303b1580156133a4575060005460ff166001145b6134165760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610f96565b6000805460ff19166001179055801561345657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b60ca80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03841617905561261a600033613c4b565b600054610100900460ff166123ca5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f96565b604080516000808252602082019092526001600160a01b03841690839060405161353b919061523d565b60006040518083038185875af1925050503d8060008114613578576040519150601f19603f3d011682016040523d82523d6000602084013e61357d565b606091505b5050905080610ddb576040517f6d963f8800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006135c5826020614e06565b835110156136155760405162461bcd60e51b815260206004820152601560248201527f746f55696e743235365f6f75744f66426f756e647300000000000000000000006044820152606401610f96565b50016020015190565b8181016020810151604082015160419092015190919060ff16601b81101561364e5761364b601b82615372565b90505b8060ff16601b1415801561366657508060ff16601c14155b1561369d576040517f18ce829400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250925092565b6040516001600160a01b03808516602483015283166044820152606481018290526112879085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401613200565b60006137046020860186613e1c565b6001600160a01b03160361376e5760fd546080840151613731916affffffffffffffffffffff1690614e06565b3414613769576040517fdc223cd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611287565b60fd546affffffffffffffffffffff1634146137cf5760fd546040517f1b0159840000000000000000000000000000000000000000000000000000000081523460048201526affffffffffffffffffffff9091166024820152604401610f96565b61381b6137df6020860186613e1c565b83838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506129fd92505050565b61128761382b6020860186613e1c565b33308660800151612adf565b600065ffffffffffff821115612d065760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203460448201527f38206269747300000000000000000000000000000000000000000000000000006064820152608401610f96565b60006138c2826014614e06565b835110156139125760405162461bcd60e51b815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e647300000000000000000000006044820152606401610f96565b5001602001516c01000000000000000000000000900490565b6060610d166001600160a01b03831660145b6060600061394c836002614d67565b613957906002614e06565b67ffffffffffffffff81111561396f5761396f613e39565b6040519080825280601f01601f191660200182016040528015613999576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106139d0576139d0614cd1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110613a3357613a33614cd1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000613a6f846002614d67565b613a7a906001614e06565b90505b6001811115613b17577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110613abb57613abb614cd1565b1a60f81b828281518110613ad157613ad1614cd1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93613b108161538b565b9050613a7d565b5083156110c25760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610f96565b6000613bbb826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613c559092919063ffffffff16565b805190915015610ddb5780806020019051810190613bd991906153c0565b610ddb5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610f96565b610fa982826119c9565b6060613c648484600085613c6c565b949350505050565b606082471015613ce45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610f96565b600080866001600160a01b03168587604051613d00919061523d565b60006040518083038185875af1925050503d8060008114613d3d576040519150601f19603f3d011682016040523d82523d6000602084013e613d42565b606091505b5091509150613d5387838387613d5e565b979650505050505050565b60608315613dcd578251600003613dc6576001600160a01b0385163b613dc65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f96565b5081613c64565b613c648383815115613de25781518083602001fd5b8060405162461bcd60e51b8152600401610f969190614312565b6001600160a01b03811681146119c657600080fd5b8035611d4081613dfc565b600060208284031215613e2e57600080fd5b81356110c281613dfc565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610160810167ffffffffffffffff81118282101715613e8c57613e8c613e39565b60405290565b6040516101c0810167ffffffffffffffff81118282101715613e8c57613e8c613e39565b604051601f8201601f1916810167ffffffffffffffff81118282101715613edf57613edf613e39565b604052919050565b600067ffffffffffffffff821115613f0157613f01613e39565b50601f01601f191660200190565b600082601f830112613f2057600080fd5b8135613f33613f2e82613ee7565b613eb6565b818152846020838601011115613f4857600080fd5b816020850160208301376000918101602001919091529392505050565b60006101608284031215613f7857600080fd5b613f80613e68565b9050613f8b82613e11565b815260208201356020820152604082013567ffffffffffffffff80821115613fb257600080fd5b613fbe85838601613f0f565b6040840152606084013560608401526080840135608084015260a0840135915080821115613feb57600080fd5b613ff785838601613f0f565b60a084015261400860c08501613e11565b60c084015260e084013591508082111561402157600080fd5b61402d85838601613f0f565b60e08401526101009150818401358181111561404857600080fd5b61405486828701613f0f565b83850152506101209150818401358181111561406f57600080fd5b61407b86828701613f0f565b83850152506101409150818401358181111561409657600080fd5b6140a286828701613f0f565b8385015250505092915050565b803567ffffffffffffffff81168114611d4057600080fd5b6000806000606084860312156140dc57600080fd5b833567ffffffffffffffff8111156140f357600080fd5b6140ff86828701613f65565b935050602084013561411081613dfc565b915061411e604085016140af565b90509250925092565b60005b8381101561414257818101518382015260200161412a565b50506000910152565b60008151808452614163816020860160208601614127565b601f01601f19169290920160200192915050565b805167ffffffffffffffff16825260006101c060208301518160208601526141a18286018261414b565b91505060408301516040850152606083015184820360608601526141c5828261414b565b9150506080830151608085015260a083015160a085015260c083015184820360c08601526141f3828261414b565b91505060e083015160e08501526101008084015185830382870152614218838261414b565b925050506101208084015185830382870152614234838261414b565b925050506101408084015185830382870152614250838261414b565b92505050610160808401518583038287015261426c838261414b565b925050506101808084015185830382870152614288838261414b565b925050506101a080840151858303828701526119b2838261414b565b6020815260006110c26020830184614177565b6000602082840312156142c957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146110c257600080fd5b60006020828403121561430b57600080fd5b5035919050565b6020815260006110c2602083018461414b565b6000806040838503121561433857600080fd5b82359150602083013561434a81613dfc565b809150509250929050565b60008060006060848603121561436a57600080fd5b83359250602084013567ffffffffffffffff81111561438857600080fd5b61439486828701613f0f565b9250506040840135600381106143a957600080fd5b809150509250925092565b600080604083850312156143c757600080fd5b823567ffffffffffffffff8111156143de57600080fd5b6143ea85828601613f65565b925050602083013561434a81613dfc565b60006101c0828403121561440e57600080fd5b614416613e92565b9050614421826140af565b8152602082013567ffffffffffffffff8082111561443e57600080fd5b61444a85838601613f0f565b602084015260408401356040840152606084013591508082111561446d57600080fd5b61447985838601613f0f565b60608401526080840135608084015260a084013560a084015260c08401359150808211156144a657600080fd5b6144b285838601613f0f565b60c084015260e084013560e0840152610100915081840135818111156144d757600080fd5b6144e386828701613f0f565b8385015250610120915081840135818111156144fe57600080fd5b61450a86828701613f0f565b83850152506101409150818401358181111561452557600080fd5b61453186828701613f0f565b83850152506101609150818401358181111561454c57600080fd5b61455886828701613f0f565b83850152506101809150818401358181111561457357600080fd5b61457f86828701613f0f565b83850152506101a09150818401358181111561409657600080fd5b6000602082840312156145ac57600080fd5b813567ffffffffffffffff8111156145c357600080fd5b613c64848285016143fb565b80356affffffffffffffffffffff81168114611d4057600080fd5b803561ffff81168114611d4057600080fd5b60008060006060848603121561461157600080fd5b833561461c81613dfc565b925061462a602085016145cf565b915061411e604085016145ea565b600067ffffffffffffffff82111561465257614652613e39565b5060051b60200190565b6000806040838503121561466f57600080fd5b823567ffffffffffffffff81111561468657600080fd5b8301601f8101851361469757600080fd5b803560206146a7613f2e83614638565b82815260059290921b830181019181810190888411156146c657600080fd5b938201935b838510156146e4578435825293820193908201906146cb565b95506146f39050868201613e11565b93505050509250929050565b6000806040838503121561471257600080fd5b61471b836145cf565b9150614729602084016145ea565b90509250929050565b6000806040838503121561474557600080fd5b823567ffffffffffffffff81111561475c57600080fd5b8301601f8101851361476d57600080fd5b8035602061477d613f2e83614638565b82815260059290921b8301810191818101908884111561479c57600080fd5b938201935b838510156146e45784356147b481613dfc565b825293820193908201906147a1565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60038110614802576148026147c3565b9052565b60208101610d1682846147f2565b60048110614802576148026147c3565b6101008101614833828b614814565b6001600160a01b03808a1660208401526affffffffffffffffffffff8916604084015265ffffffffffff8816606084015279ffffffffffffffffffffffffffffffffffffffffffffffffffff871660808401528560a084015280851660c0840152508260e08301529998505050505050505050565b60008083601f8401126148ba57600080fd5b50813567ffffffffffffffff8111156148d257600080fd5b6020830191508360208285010111156148ea57600080fd5b9250929050565b6000806000806060858703121561490757600080fd5b843567ffffffffffffffff8082111561491f57600080fd5b61492b888389016143fb565b955060208701359450604087013591508082111561494857600080fd5b50614955878288016148a8565b95989497509550505050565b6000610160828403121561497457600080fd5b50919050565b803563ffffffff81168114611d4057600080fd5b60008060008060008060008060c0898b0312156149aa57600080fd5b883567ffffffffffffffff808211156149c257600080fd5b6149ce8c838d01614961565b99506149dc60208c016140af565b985060408b01359150808211156149f257600080fd5b6149fe8c838d016148a8565b9098509650869150614a1260608c0161497a565b955060808b0135915080821115614a2857600080fd5b614a348c838d016148a8565b909550935060a08b0135915080821115614a4d57600080fd5b50614a5a8b828c01613f0f565b9150509295985092959890939650565b60008060008060008060808789031215614a8357600080fd5b863567ffffffffffffffff80821115614a9b57600080fd5b614aa78a838b01614961565b97506020890135915080821115614abd57600080fd5b614ac98a838b016148a8565b9097509550859150614add60408a0161497a565b94506060890135915080821115614af357600080fd5b50614b0089828a016148a8565b979a9699509497509295939492505050565b600181811c90821680614b2657607f821691505b602082108103614974577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b601f821115610ddb57600081815260208120601f850160051c81016020861015614b865750805b601f850160051c820191505b81811015614ba557828155600101614b92565b505050505050565b815167ffffffffffffffff811115614bc757614bc7613e39565b614bdb81614bd58454614b12565b84614b5f565b602080601f831160018114614c2e5760008415614bf85750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555614ba5565b600085815260208120601f198616915b82811015614c5d57888601518255948401946001909101908401614c3e565b5085821015614c9957878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b838152606060208201526000614cc2606083018561414b565b9050613c6460408301846147f2565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614d6057614d60614d00565b5060010190565b8082028115828204841417610d1657610d16614d00565b600082614db4577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b79ffffffffffffffffffffffffffffffffffffffffffffffffffff818116838216019080821115614dec57614dec614d00565b5092915050565b81810381811115610d1657610d16614d00565b80820180821115610d1657610d16614d00565b7fffffffffffffffff0000000000000000000000000000000000000000000000008460c01b1681527fff000000000000000000000000000000000000000000000000000000000000008360f81b16600882015260008251614e81816009850160208701614127565b91909101600901949350505050565b60008751614ea2818460208c01614127565b80830190508781527fff000000000000000000000000000000000000000000000000000000000000008760f81b1660208201528551614ee8816021840160208a01614127565b01602181019490945250506041820152606101949350505050565b60008751614f15818460208c01614127565b80830190507fff00000000000000000000000000000000000000000000000000000000000000808960f81b1682528751614f56816001850160208c01614127565b6001920191820187905260f886901b1660218201528351614f7e816022840160208801614127565b0160220198975050505050505050565b60008651614fa0818460208b01614127565b80830190507fff00000000000000000000000000000000000000000000000000000000000000808860f81b1682528651614fe1816001850160208b01614127565b808301925050808660f81b166001830152508351615006816002840160208801614127565b01600201979650505050505050565b60008751615027818460208c01614127565b80830190507fff00000000000000000000000000000000000000000000000000000000000000808960f81b1682528751615068816001850160208c01614127565b808301925050808760f81b16600183015250845161508d816002840160208901614127565b93151560f81b93016002810193909352505060030195945050505050565b600083516150bd818460208801614127565b9190910191825250602001919050565b6000602082840312156150df57600080fd5b81516110c281613dfc565b6000602082840312156150fc57600080fd5b815167ffffffffffffffff81111561511357600080fd5b8201601f8101841361512457600080fd5b8051615132613f2e82613ee7565b81815285602083850101111561514757600080fd5b615158826020830160208601614127565b95945050505050565b60006020828403121561517357600080fd5b5051919050565b600080835461518881614b12565b600182811680156151a057600181146151b5576151e4565b60ff19841687528215158302870194506151e4565b8760005260208060002060005b858110156151db5781548a8201529084019082016151c2565b50505082870194505b50929695505050505050565b604081526000615203604083018561414b565b90508260208301529392505050565b838152606081016152266020830185614814565b6001600160a01b0383166040830152949350505050565b6000825161524f818460208701614127565b9190910192915050565b6000610d163683613f65565b60e08152600061527860e083018b614177565b896020840152828103604084015287815287896020830137600060208983010152601f19601f890116810190506affffffffffffffffffffff8716606084015285608084015263ffffffff851660a084015260208382030160c08401526152e2602082018561414b565b9b9a5050505050505050505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615329816017850160208801614127565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351615366816028840160208801614127565b01602801949350505050565b60ff8181168382160190811115610d1657610d16614d00565b60008161539a5761539a614d00565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b6000602082840312156153d257600080fd5b815180151581146110c257600080fdfea26469706673582212204ac95ef2c1951ffcdfa9abdf0ebaff2f211cddbd29c73b2134bbd9d395ac2f8264736f6c63430008110033
Deployed Bytecode
0x6080604052600436106102db5760003560e01c80636ac89fa211610184578063b9303701116100d6578063df21dc1d1161008a578063fa82f30911610064578063fa82f3091461098c578063faeb8113146109a1578063fbe16ca7146109d857600080fd5b8063df21dc1d14610933578063e1a4521814610961578063f6ef28b41461097757600080fd5b8063d48b0146116100bb578063d48b0146146108bf578063d547741f146108df578063da615052146108ff57600080fd5b8063b93037011461088c578063ca777fbf1461089f57600080fd5b8063924a062c11610138578063a7c5f50411610112578063a7c5f5041461075e578063b2a453f8146107ad578063b5bbf6e11461087957600080fd5b8063924a062c146106ec5780639dd1aeac1461070c578063a217fddf1461074957600080fd5b80637716d26f116101695780637716d26f146106715780638456cb591461069157806391d14854146106a657600080fd5b80636ac89fa2146106235780636fba7f711461064357600080fd5b806335087f0a1161023d57806354fd4d50116101f15780635c975abb116101cb5780635c975abb146105cb5780635f1f3af7146105e35780636abd4ea71461060357600080fd5b806354fd4d50146105285780635886d8d21461056e5780635c8371981461058e57600080fd5b80633f4ba83a116102225780633f4ba83a146104d35780633fe00dd7146104e857806350e955911461050857600080fd5b806335087f0a1461047357806336568abe146104b357600080fd5b806314bb1361116102945780632f2ff15d116102795780632f2ff15d1461041e57806330bb0911146104405780633408e4701461046057600080fd5b806314bb1361146103c1578063248a9ca3146103ee57600080fd5b806301ffc9a7116102c557806301ffc9a71461034e57806303deb7ea1461037e5780630acc3eb01461039357600080fd5b80624aa320146102e057806301bc5f0814610321575b600080fd5b3480156102ec57600080fd5b5061030e6102fb366004613e1c565b6101026020526000908152604090205481565b6040519081526020015b60405180910390f35b34801561032d57600080fd5b5061034161033c3660046140c7565b6109eb565b60405161031891906142a4565b34801561035a57600080fd5b5061036e6103693660046142b7565b610c83565b6040519015158152602001610318565b34801561038a57600080fd5b5061030e601481565b34801561039f57600080fd5b5061030e6103ae366004613e1c565b6101056020526000908152604090205481565b3480156103cd57600080fd5b506103e16103dc3660046142f9565b610d1c565b6040516103189190614312565b3480156103fa57600080fd5b5061030e6104093660046142f9565b60009081526065602052604090206001015490565b34801561042a57600080fd5b5061043e610439366004614325565b610db6565b005b34801561044c57600080fd5b5061043e61045b366004614355565b610de0565b34801561046c57600080fd5b504661030e565b34801561047f57600080fd5b5060fd54610497906affffffffffffffffffffff1681565b6040516affffffffffffffffffffff9091168152602001610318565b3480156104bf57600080fd5b5061043e6104ce366004614325565b610f1c565b3480156104df57600080fd5b5061043e610fad565b3480156104f457600080fd5b506103416105033660046143b4565b61101f565b34801561051457600080fd5b5061030e61052336600461459a565b6110c9565b34801561053457600080fd5b5060408051808201909152600581527f312e332e3000000000000000000000000000000000000000000000000000000060208201526103e1565b34801561057a57600080fd5b5061043e610589366004614325565b6110e2565b34801561059a57600080fd5b5060fd546105b8906b010000000000000000000000900461ffff1681565b60405161ffff9091168152602001610318565b3480156105d757600080fd5b5060975460ff1661036e565b3480156105ef57600080fd5b5061043e6105fe3660046145fc565b611114565b34801561060f57600080fd5b5061043e61061e36600461465c565b61128d565b34801561062f57600080fd5b5061043e61063e3660046146ff565b6112f8565b34801561064f57600080fd5b5061030e61065e3660046142f9565b6101006020526000908152604090205481565b34801561067d57600080fd5b5061043e61068c366004614732565b611372565b34801561069d57600080fd5b5061043e6114c0565b3480156106b257600080fd5b5061036e6106c1366004614325565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156106f857600080fd5b5061043e61070736600461465c565b611530565b34801561071857600080fd5b5061073c6107273660046142f9565b60c96020526000908152604090205460ff1681565b6040516103189190614806565b34801561075557600080fd5b5061030e600081565b34801561076a57600080fd5b506107956107793660046142f9565b610103602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610318565b3480156107b957600080fd5b506108656107c83660046142f9565b60ff60208190526000918252604090912080546001820154600283015460038401546004909401549483169461010084046001600160a01b039081169575010000000000000000000000000000000000000000009095046affffffffffffffffffffff169465ffffffffffff8516946601000000000000900479ffffffffffffffffffffffffffffffffffffffffffffffffffff16939291169088565b604051610318989796959493929190614824565b61043e6108873660046148f1565b61158e565b61030e61089a36600461498e565b6118ce565b3480156108ab57600080fd5b5060ca54610795906001600160a01b031681565b3480156108cb57600080fd5b5061043e6108da366004614325565b611908565b3480156108eb57600080fd5b5061043e6108fa366004614325565b61192f565b34801561090b57600080fd5b5061030e7f2b36fa99e118fa8485d488becf749a974743fbeb6a7aa57e663893bf5d69a3c181565b34801561093f57600080fd5b5061030e61094e366004613e1c565b6101016020526000908152604090205481565b34801561096d57600080fd5b5061030e61271081565b34801561098357600080fd5b5061030e602081565b34801561099857600080fd5b5061030e60ff81565b3480156109ad57600080fd5b506107956109bc3660046142f9565b610104602052600090815260409020546001600160a01b031681565b61030e6109e6366004614a6a565b611954565b610a67604051806101c00160405280600067ffffffffffffffff168152602001606081526020016000815260200160608152602001600081526020016000815260200160608152602001600081526020016060815260200160608152602001606081526020016060815260200160608152602001606081525090565b6080840151600090815260fe602052604081208054610a8590614b12565b9050905080600003610ac3576040517f016643e200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80856040015151141580610adc5750808560a001515114155b80610aec5750808560e001515114155b80610b0e5750600085610100015151118015610b0e5750808561010001515114155b80610b315750600085610140015151118015610b31575060148561014001515114155b15610b68576040517fbe31c33b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4660408381019190915267ffffffffffffffff841683528051606086811b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000908116602080850191909152845160148186038101825260349586018752828901919091528a51865190851b841681840152865180820390920182528501865283880152898101516080808901919091528a86015160c0808a01919091528b85015160e08a0152908b015160a0808a01919091528b01516101008901528a015194519490921b16908301520160408051601f198184030181529190526101208084019190915260e086015161014080850191909152610100870151610160850152908601516101a0840152909401516101808201529392505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b000000000000000000000000000000000000000000000000000000001480610d1657507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60fe6020526000908152604090208054610d3590614b12565b80601f0160208091040260200160405190810160405280929190818152602001828054610d6190614b12565b8015610dae5780601f10610d8357610100808354040283529160200191610dae565b820191906000526020600020905b815481529060010190602001808311610d9157829003601f168201915b505050505081565b600082815260656020526040902060010154610dd1816119bc565b610ddb83836119c9565b505050565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16610e48576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000816002811115610e5c57610e5c6147c3565b03610e93576040517f4668624100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600083815260fe60205260409020610eab8382614bad565b50600083815260c960205260409020805482919060ff19166001836002811115610ed757610ed76147c3565b02179055507f82568678a169f202360005e72d5ab10d95c3c369ddd502057dacb85e9c700759838383604051610f0f93929190614ca9565b60405180910390a1505050565b6001600160a01b0381163314610f9f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b610fa98282611a6b565b5050565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16611015576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61101d611aee565b565b61109b604051806101c00160405280600067ffffffffffffffff168152602001606081526020016000815260200160608152602001600081526020016000815260200160608152602001600081526020016060815260200160608152602001606081526020016060815260200160608152602001606081525090565b6001600160a01b038216600090815261010160205260409020546110c290849084906109eb565b9392505050565b60006110d482611b40565b805190602001209050919050565b6110ea611d45565b6110f2611d9e565b60006110fc611df1565b9050611109838383611fed565b50610fa9600160cb55565b600054610100900460ff16158080156111345750600054600160ff909116105b8061114e5750303b15801561114e575060005460ff166001145b6111c05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610f96565b6000805460ff19166001179055801561120057600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b611209836123d1565b61121282612468565b61121b84612505565b611223612679565b801561128757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b50505050565b611295611d45565b61129d611d9e565b60006112a7611df1565b835190915060005b818110156112eb576112db8582815181106112cc576112cc614cd1565b60200260200101518585611fed565b6112e481614d2f565b90506112af565b505050610fa9600160cb55565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16611360576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611369826123d1565b610fa981612468565b61137a611d45565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff166113e2576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b815160005b818110156114b457600084828151811061140357611403614cd1565b6020026020010151905060006101026000836001600160a01b03166001600160a01b031681526020019081526020016000205490506114438286836126fe565b6001600160a01b0382811660008181526101026020908152604080832092909255815192835282018490529187168183015290517f036e7dece8303b57678319debe761b27c7298611a5c4e23776a7f1e79c67742a9181900360600190a15050806114ad90614d2f565b90506113e7565b5050610fa9600160cb55565b3360009081527f8a5df9d3b7a9306a1075029813ef25f1a4531de6e935bc9f04ed5dd5e46af951602052604090205460ff16611528576040517f6053780500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61101d61272a565b611538611d45565b611540611d9e565b600061154a611df1565b835190915060005b818110156112eb5761157e85828151811061156f5761156f614cd1565b60200260200101518585612767565b61158781614d2f565b9050611552565b611596611d45565b61159e611d9e565b60006115a9856110c9565b9050336001600160a01b03166115c3866101200151612992565b6001600160a01b031614611603576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8360000361163d576040517f4668624100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081815260ff602052604090206001815460ff166003811115611663576116636147c3565b1461169a576040517fea6eda5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006116a98760600151612992565b90506001600160a01b0381166116f7578534146116f2576040517fdc223cd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611743565b6117378186868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506129fd92505050565b61174381333089612adf565b60fd546000906127109061176b9089906b010000000000000000000000900461ffff16614d67565b6117759190614d7e565b905061178081612c74565b6001840180546006906117ba9084906601000000000000900479ffffffffffffffffffffffffffffffffffffffffffffffffffff16614db9565b92506101000a81548179ffffffffffffffffffffffffffffffffffffffffffffffffffff021916908379ffffffffffffffffffffffffffffffffffffffffffffffffffff16021790555080876118109190614df3565b600085815261010060205260408120805490919061182f908490614e06565b90915550506000848152610100602052604090205460808901517f4f3bc5fae93ae03632b30b624fb1dbfa21466a29216f314d0cfcb269d7c918ff9186916118779190614e06565b60018601546040805193845260208401929092526601000000000000900479ffffffffffffffffffffffffffffffffffffffffffffffffffff169082015260600160405180910390a150505050611287600160cb55565b60006118d8611d45565b6118e0611d9e565b6118f08989898989898989612d0a565b90506118fc600160cb55565b98975050505050505050565b611910611d45565b611918611d9e565b6000611922611df1565b9050611109838383612767565b60008281526065602052604090206001015461194a816119bc565b610ddb8383611a6b565b600061195e611d45565b611966611d9e565b3260009081526101016020526040812080546119a6928a929061198883614d2f565b91905055888888888860405180602001604052806000815250612d0a565b90506119b2600160cb55565b9695505050505050565b6119c681336130f4565b50565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16610fa95760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611a273390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff1615610fa95760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b611af6613169565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b606060ff8260200151511180611b5b575060ff826060015151115b80611b6b575060ff8260c0015151115b80611b7c575060ff82610100015151115b80611b8d575060ff82610120015151115b80611b9e575060ff82610160015151115b80611baf575060ff82610180015151115b15611be6576040517fbe31c33b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81516020808401518051604051611c01949391929101614e19565b60408051601f198184030181528282529084015160608501518051608087015160a0880151949650611c3b95879592939290602001614e90565b60408051601f198184030181529082905260c0840151805160e08601516101008701518051949650611c769587959394939190602001614f03565b60408051601f198184030181529082905261012084015180516101408601518051939550611cad9486949293929190602001614f8e565b60408051601f1981840301815290829052610160840151805161018086015180516101a088015151949650611cef958795939493919291151590602001615015565b60405160208183030381529060405290506000826101a00151511115611d405780826101a0015180519060200120604051602001611d2e9291906150ab565b60405160208183030381529060405290505b919050565b600260cb5403611d975760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610f96565b600260cb55565b60975460ff161561101d5760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610f96565b60008060ca60009054906101000a90046001600160a01b03166001600160a01b0316632da688ac6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6b91906150cd565b90506001600160a01b0381163314611eaf576040517f910e7d9c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000816001600160a01b0316632eb484916040518163ffffffff1660e01b8152600401600060405180830381865afa158015611eef573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611f1791908101906150ea565b9050816001600160a01b031663508ab0a06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f7b9190615161565b9250808051906020012060fe6000858152602001908152602001600020604051611fa5919061517a565b604051809103902014611fe85780836040517f0f25bbaa000000000000000000000000000000000000000000000000000000008152600401610f969291906151f0565b505090565b600083815260ff602052604090206001815460ff166003811115612013576120136147c3565b1461209157600084815261010360205260409081902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038616179055815490517fc65cdb43047b7466a1705cf4c7e88b0c66614ed6da1c1aa7f44026cee8e676269161127e91879160ff16908790615212565b600181015465ffffffffffff1682146120fe576001810154604080518681526001600160a01b038616602082015265ffffffffffff90921690820152606081018390527f29af03f84291900300e96b03eed8a02c0db5cdc94a3b15a880a93bfce8c125a29060800161127e565b60008481526101006020526040812054600283015461211d9190614e06565b825460ff19166002178084559091506001600160a01b03610100909104166121468186846126fe565b6004830154156122ac5760006001600160a01b0382166122205760038401546004850154604080516000815260208101918290526001600160a01b03909316926108fc9291612195919061523d565b600060405180830381858888f193505050503d80600081146121d3576040519150601f19603f3d011682016040523d82523d6000602084013e6121d8565b606091505b5050809150508061221b57600484015460038501546001600160a01b03166000908152610105602052604081208054909190612215908490614e06565b90915550505b612246565b60038401546004850154612242916001600160a01b03858116929116906131bb565b5060015b80156122aa5760038401546004850154604080518a81526001600160a01b0393841660208201529081019190915290831660608201527f9077c15d8bcf2d51f89ed4806cf2fd3d09000b446acd62c04653da6684ee16f09060800160405180910390a15b505b604080518781526001600160a01b0387811660208301528183018590528316606082015290517f33fff3d864e92b6e1ef9e830196fc019c946104ea621b833aaebd3c3e84b2f6f9181900360800190a160018301546001600160a01b0382166000908152610102602052604081208054660100000000000090930479ffffffffffffffffffffffffffffffffffffffffffffffffffff1692909190612352908490614e06565b9091555050825460008080526101026020527f565a22c1af7fcc038f06206699a6bd0ad8c85d23dafe9aebac3e0df68e8fb320805475010000000000000000000000000000000000000000009093046affffffffffffffffffffff16929091906123bd908490614e06565b9091555050505050505050565b600160cb55565b60fd546affffffffffffffffffffff9081169082168114610fa95760fd80547fffffffffffffffffffffffffffffffffffffffffff0000000000000000000000166affffffffffffffffffffff84811691821790925560408051928416835260208301919091527f326751b7ae705d9d8353edbd289cc14a323875cf13ddc42f7575ac304e417fc291015b60405180910390a15050565b60fd5461ffff6b01000000000000000000000090910481169082168114610fa95760fd80547fffffffffffffffffffffffffffffffffffffff0000ffffffffffffffffffffff166b01000000000000000000000061ffff8581169182029290921790925560408051918416825260208201929092527f013cd5c0fbece94c68f9e668b3ab52cdf65f1ee39fb338ac4c803fe21fe043e0910161245c565b600054610100900460ff16158080156125255750600054600160ff909116105b8061253f5750303b15801561253f575060005460ff166001145b6125b15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610f96565b6000805460ff1916600117905580156125f157600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6125f9613264565b612601613264565b612609613264565b6126116132e1565b61261a8261336a565b8015610fa957600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200161245c565b600054610100900460ff166126f65760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f96565b61101d613494565b6001600160a01b03831661271657610ddb8282613511565b610ddb6001600160a01b03841683836131bb565b612732611d9e565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611b233390565b600083815260ff60205260409020600181015465ffffffffffff1682146127d85760018101546040517f804e1c6f0000000000000000000000000000000000000000000000000000000081526004810186905265ffffffffffff909116602482015260448101839052606401610f96565b60008481526101006020526040812054600483015460018401546002850154612827916601000000000000900479ffffffffffffffffffffffffffffffffffffffffffffffffffff1690614e06565b6128319190614e06565b61283b9190614e06565b90506001825460ff166003811115612855576128556147c3565b0361290957815460ff19166003178083556001600160a01b03610100909104166128808186846126fe565b82546128b3908690750100000000000000000000000000000000000000000090046affffffffffffffffffffff16613511565b604080518781526001600160a01b0387811660208301528183018590528316606082015290517f7d7d1c5b3eadbe275ceb358e65cd57410b35997187258dbaaae42ab6e1405fd89181900360800190a15061298b565b600085815261010460205260409081902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038716179055825490517f9302619b5552484dceb0055d13a6b83805ce74ad349b433cf78be991ef30703e9161298291889160ff16908890615212565b60405180910390a15b5050505050565b600081516014146129e55760405162461bcd60e51b815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e647300000000000000000000006044820152606401610f96565b50602001516c01000000000000000000000000900490565b805115610fa9576000612a118260006135b8565b90506000612a208360206135b8565b905060008080612a3186604061361e565b6040517fd505accf000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018990526064810188905260ff8216608482015260a4810184905260c4810183905292955090935091506001600160a01b0388169063d505accf9060e401600060405180830381600087803b158015612abe57600080fd5b505af1158015612ad2573d6000803e3d6000fd5b5050505050505050505050565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b03838116600483015285916000918316906370a0823190602401602060405180830381865afa158015612b43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b679190615161565b9050612b7e6001600160a01b0383168686866136a4565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015260009183918516906370a0823190602401602060405180830381865afa158015612be2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c069190615161565b612c109190614df3565b9050846001600160a01b0316866001600160a01b031614158015612c345750808414155b15612c6b576040517f80b9e73000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050505050565b600079ffffffffffffffffffffffffffffffffffffffffffffffffffff821115612d065760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203260448201527f30382062697473000000000000000000000000000000000000000000000000006064820152608401610f96565b5090565b6000808615612d925760348714612d4d576040517f4115207f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612d8f88888080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250601492506135b8915050565b90505b6000612da7612da08c615259565b328c6109eb565b9050612db58b8288886136f5565b608081015160fd5460009161271091612de191906b010000000000000000000000900461ffff16614d67565b612deb9190614d7e565b9050612df78382614e06565b82608001818151612e089190614df3565b9052506000612e16836110c9565b600081815260ff60205260408120919250815460ff166003811115612e3d57612e3d6147c3565b14612e74576040517fea6eda5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805460ff19166001178155612e8c60208f018f613e1c565b81546001600160a01b0391909116610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff82168117835560fd5475010000000000000000000000000000000000000000006affffffffffffffffffffff9091160274ffffffffffffffffffffffffffffffffffffffffff90911660ff9092169190911717815560a0840151612f2290613837565b6001820180547fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000001665ffffffffffff92909216919091179055612f6483612c74565b60018201805479ffffffffffffffffffffffffffffffffffffffffffffffffffff9290921666010000000000000265ffffffffffff909216919091179055608084015160028201558415613085576000612ff38d8d8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525092506138b5915050565b905060008611801561300c57506001600160a01b038116155b15613043576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600482018690556003820180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03929092169190911790555b507ffc8703fd57380f9dd234a89dce51333782d49c5902f307b02f03e014d18fe47183828d8d60fd60009054906101000a90046affffffffffffffffffffff16878f8d6040516130dc989796959493929190615265565b60405180910390a19c9b505050505050505050505050565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16610fa9576131278161392b565b61313283602061393d565b6040516020016131439291906152f1565b60408051601f198184030181529082905262461bcd60e51b8252610f9691600401614312565b60975460ff1661101d5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610f96565b6040516001600160a01b038316602482015260448101829052610ddb9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613b66565b600054610100900460ff1661101d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f96565b600054610100900460ff1661335e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f96565b6097805460ff19169055565b600054610100900460ff161580801561338a5750600054600160ff909116105b806133a45750303b1580156133a4575060005460ff166001145b6134165760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610f96565b6000805460ff19166001179055801561345657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b60ca80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03841617905561261a600033613c4b565b600054610100900460ff166123ca5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610f96565b604080516000808252602082019092526001600160a01b03841690839060405161353b919061523d565b60006040518083038185875af1925050503d8060008114613578576040519150601f19603f3d011682016040523d82523d6000602084013e61357d565b606091505b5050905080610ddb576040517f6d963f8800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006135c5826020614e06565b835110156136155760405162461bcd60e51b815260206004820152601560248201527f746f55696e743235365f6f75744f66426f756e647300000000000000000000006044820152606401610f96565b50016020015190565b8181016020810151604082015160419092015190919060ff16601b81101561364e5761364b601b82615372565b90505b8060ff16601b1415801561366657508060ff16601c14155b1561369d576040517f18ce829400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250925092565b6040516001600160a01b03808516602483015283166044820152606481018290526112879085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401613200565b60006137046020860186613e1c565b6001600160a01b03160361376e5760fd546080840151613731916affffffffffffffffffffff1690614e06565b3414613769576040517fdc223cd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611287565b60fd546affffffffffffffffffffff1634146137cf5760fd546040517f1b0159840000000000000000000000000000000000000000000000000000000081523460048201526affffffffffffffffffffff9091166024820152604401610f96565b61381b6137df6020860186613e1c565b83838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506129fd92505050565b61128761382b6020860186613e1c565b33308660800151612adf565b600065ffffffffffff821115612d065760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203460448201527f38206269747300000000000000000000000000000000000000000000000000006064820152608401610f96565b60006138c2826014614e06565b835110156139125760405162461bcd60e51b815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e647300000000000000000000006044820152606401610f96565b5001602001516c01000000000000000000000000900490565b6060610d166001600160a01b03831660145b6060600061394c836002614d67565b613957906002614e06565b67ffffffffffffffff81111561396f5761396f613e39565b6040519080825280601f01601f191660200182016040528015613999576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106139d0576139d0614cd1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110613a3357613a33614cd1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000613a6f846002614d67565b613a7a906001614e06565b90505b6001811115613b17577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110613abb57613abb614cd1565b1a60f81b828281518110613ad157613ad1614cd1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93613b108161538b565b9050613a7d565b5083156110c25760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610f96565b6000613bbb826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613c559092919063ffffffff16565b805190915015610ddb5780806020019051810190613bd991906153c0565b610ddb5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610f96565b610fa982826119c9565b6060613c648484600085613c6c565b949350505050565b606082471015613ce45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610f96565b600080866001600160a01b03168587604051613d00919061523d565b60006040518083038185875af1925050503d8060008114613d3d576040519150601f19603f3d011682016040523d82523d6000602084013e613d42565b606091505b5091509150613d5387838387613d5e565b979650505050505050565b60608315613dcd578251600003613dc6576001600160a01b0385163b613dc65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f96565b5081613c64565b613c648383815115613de25781518083602001fd5b8060405162461bcd60e51b8152600401610f969190614312565b6001600160a01b03811681146119c657600080fd5b8035611d4081613dfc565b600060208284031215613e2e57600080fd5b81356110c281613dfc565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610160810167ffffffffffffffff81118282101715613e8c57613e8c613e39565b60405290565b6040516101c0810167ffffffffffffffff81118282101715613e8c57613e8c613e39565b604051601f8201601f1916810167ffffffffffffffff81118282101715613edf57613edf613e39565b604052919050565b600067ffffffffffffffff821115613f0157613f01613e39565b50601f01601f191660200190565b600082601f830112613f2057600080fd5b8135613f33613f2e82613ee7565b613eb6565b818152846020838601011115613f4857600080fd5b816020850160208301376000918101602001919091529392505050565b60006101608284031215613f7857600080fd5b613f80613e68565b9050613f8b82613e11565b815260208201356020820152604082013567ffffffffffffffff80821115613fb257600080fd5b613fbe85838601613f0f565b6040840152606084013560608401526080840135608084015260a0840135915080821115613feb57600080fd5b613ff785838601613f0f565b60a084015261400860c08501613e11565b60c084015260e084013591508082111561402157600080fd5b61402d85838601613f0f565b60e08401526101009150818401358181111561404857600080fd5b61405486828701613f0f565b83850152506101209150818401358181111561406f57600080fd5b61407b86828701613f0f565b83850152506101409150818401358181111561409657600080fd5b6140a286828701613f0f565b8385015250505092915050565b803567ffffffffffffffff81168114611d4057600080fd5b6000806000606084860312156140dc57600080fd5b833567ffffffffffffffff8111156140f357600080fd5b6140ff86828701613f65565b935050602084013561411081613dfc565b915061411e604085016140af565b90509250925092565b60005b8381101561414257818101518382015260200161412a565b50506000910152565b60008151808452614163816020860160208601614127565b601f01601f19169290920160200192915050565b805167ffffffffffffffff16825260006101c060208301518160208601526141a18286018261414b565b91505060408301516040850152606083015184820360608601526141c5828261414b565b9150506080830151608085015260a083015160a085015260c083015184820360c08601526141f3828261414b565b91505060e083015160e08501526101008084015185830382870152614218838261414b565b925050506101208084015185830382870152614234838261414b565b925050506101408084015185830382870152614250838261414b565b92505050610160808401518583038287015261426c838261414b565b925050506101808084015185830382870152614288838261414b565b925050506101a080840151858303828701526119b2838261414b565b6020815260006110c26020830184614177565b6000602082840312156142c957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146110c257600080fd5b60006020828403121561430b57600080fd5b5035919050565b6020815260006110c2602083018461414b565b6000806040838503121561433857600080fd5b82359150602083013561434a81613dfc565b809150509250929050565b60008060006060848603121561436a57600080fd5b83359250602084013567ffffffffffffffff81111561438857600080fd5b61439486828701613f0f565b9250506040840135600381106143a957600080fd5b809150509250925092565b600080604083850312156143c757600080fd5b823567ffffffffffffffff8111156143de57600080fd5b6143ea85828601613f65565b925050602083013561434a81613dfc565b60006101c0828403121561440e57600080fd5b614416613e92565b9050614421826140af565b8152602082013567ffffffffffffffff8082111561443e57600080fd5b61444a85838601613f0f565b602084015260408401356040840152606084013591508082111561446d57600080fd5b61447985838601613f0f565b60608401526080840135608084015260a084013560a084015260c08401359150808211156144a657600080fd5b6144b285838601613f0f565b60c084015260e084013560e0840152610100915081840135818111156144d757600080fd5b6144e386828701613f0f565b8385015250610120915081840135818111156144fe57600080fd5b61450a86828701613f0f565b83850152506101409150818401358181111561452557600080fd5b61453186828701613f0f565b83850152506101609150818401358181111561454c57600080fd5b61455886828701613f0f565b83850152506101809150818401358181111561457357600080fd5b61457f86828701613f0f565b83850152506101a09150818401358181111561409657600080fd5b6000602082840312156145ac57600080fd5b813567ffffffffffffffff8111156145c357600080fd5b613c64848285016143fb565b80356affffffffffffffffffffff81168114611d4057600080fd5b803561ffff81168114611d4057600080fd5b60008060006060848603121561461157600080fd5b833561461c81613dfc565b925061462a602085016145cf565b915061411e604085016145ea565b600067ffffffffffffffff82111561465257614652613e39565b5060051b60200190565b6000806040838503121561466f57600080fd5b823567ffffffffffffffff81111561468657600080fd5b8301601f8101851361469757600080fd5b803560206146a7613f2e83614638565b82815260059290921b830181019181810190888411156146c657600080fd5b938201935b838510156146e4578435825293820193908201906146cb565b95506146f39050868201613e11565b93505050509250929050565b6000806040838503121561471257600080fd5b61471b836145cf565b9150614729602084016145ea565b90509250929050565b6000806040838503121561474557600080fd5b823567ffffffffffffffff81111561475c57600080fd5b8301601f8101851361476d57600080fd5b8035602061477d613f2e83614638565b82815260059290921b8301810191818101908884111561479c57600080fd5b938201935b838510156146e45784356147b481613dfc565b825293820193908201906147a1565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60038110614802576148026147c3565b9052565b60208101610d1682846147f2565b60048110614802576148026147c3565b6101008101614833828b614814565b6001600160a01b03808a1660208401526affffffffffffffffffffff8916604084015265ffffffffffff8816606084015279ffffffffffffffffffffffffffffffffffffffffffffffffffff871660808401528560a084015280851660c0840152508260e08301529998505050505050505050565b60008083601f8401126148ba57600080fd5b50813567ffffffffffffffff8111156148d257600080fd5b6020830191508360208285010111156148ea57600080fd5b9250929050565b6000806000806060858703121561490757600080fd5b843567ffffffffffffffff8082111561491f57600080fd5b61492b888389016143fb565b955060208701359450604087013591508082111561494857600080fd5b50614955878288016148a8565b95989497509550505050565b6000610160828403121561497457600080fd5b50919050565b803563ffffffff81168114611d4057600080fd5b60008060008060008060008060c0898b0312156149aa57600080fd5b883567ffffffffffffffff808211156149c257600080fd5b6149ce8c838d01614961565b99506149dc60208c016140af565b985060408b01359150808211156149f257600080fd5b6149fe8c838d016148a8565b9098509650869150614a1260608c0161497a565b955060808b0135915080821115614a2857600080fd5b614a348c838d016148a8565b909550935060a08b0135915080821115614a4d57600080fd5b50614a5a8b828c01613f0f565b9150509295985092959890939650565b60008060008060008060808789031215614a8357600080fd5b863567ffffffffffffffff80821115614a9b57600080fd5b614aa78a838b01614961565b97506020890135915080821115614abd57600080fd5b614ac98a838b016148a8565b9097509550859150614add60408a0161497a565b94506060890135915080821115614af357600080fd5b50614b0089828a016148a8565b979a9699509497509295939492505050565b600181811c90821680614b2657607f821691505b602082108103614974577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b601f821115610ddb57600081815260208120601f850160051c81016020861015614b865750805b601f850160051c820191505b81811015614ba557828155600101614b92565b505050505050565b815167ffffffffffffffff811115614bc757614bc7613e39565b614bdb81614bd58454614b12565b84614b5f565b602080601f831160018114614c2e5760008415614bf85750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555614ba5565b600085815260208120601f198616915b82811015614c5d57888601518255948401946001909101908401614c3e565b5085821015614c9957878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b838152606060208201526000614cc2606083018561414b565b9050613c6460408301846147f2565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614d6057614d60614d00565b5060010190565b8082028115828204841417610d1657610d16614d00565b600082614db4577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b79ffffffffffffffffffffffffffffffffffffffffffffffffffff818116838216019080821115614dec57614dec614d00565b5092915050565b81810381811115610d1657610d16614d00565b80820180821115610d1657610d16614d00565b7fffffffffffffffff0000000000000000000000000000000000000000000000008460c01b1681527fff000000000000000000000000000000000000000000000000000000000000008360f81b16600882015260008251614e81816009850160208701614127565b91909101600901949350505050565b60008751614ea2818460208c01614127565b80830190508781527fff000000000000000000000000000000000000000000000000000000000000008760f81b1660208201528551614ee8816021840160208a01614127565b01602181019490945250506041820152606101949350505050565b60008751614f15818460208c01614127565b80830190507fff00000000000000000000000000000000000000000000000000000000000000808960f81b1682528751614f56816001850160208c01614127565b6001920191820187905260f886901b1660218201528351614f7e816022840160208801614127565b0160220198975050505050505050565b60008651614fa0818460208b01614127565b80830190507fff00000000000000000000000000000000000000000000000000000000000000808860f81b1682528651614fe1816001850160208b01614127565b808301925050808660f81b166001830152508351615006816002840160208801614127565b01600201979650505050505050565b60008751615027818460208c01614127565b80830190507fff00000000000000000000000000000000000000000000000000000000000000808960f81b1682528751615068816001850160208c01614127565b808301925050808760f81b16600183015250845161508d816002840160208901614127565b93151560f81b93016002810193909352505060030195945050505050565b600083516150bd818460208801614127565b9190910191825250602001919050565b6000602082840312156150df57600080fd5b81516110c281613dfc565b6000602082840312156150fc57600080fd5b815167ffffffffffffffff81111561511357600080fd5b8201601f8101841361512457600080fd5b8051615132613f2e82613ee7565b81815285602083850101111561514757600080fd5b615158826020830160208601614127565b95945050505050565b60006020828403121561517357600080fd5b5051919050565b600080835461518881614b12565b600182811680156151a057600181146151b5576151e4565b60ff19841687528215158302870194506151e4565b8760005260208060002060005b858110156151db5781548a8201529084019082016151c2565b50505082870194505b50929695505050505050565b604081526000615203604083018561414b565b90508260208301529392505050565b838152606081016152266020830185614814565b6001600160a01b0383166040830152949350505050565b6000825161524f818460208701614127565b9190910192915050565b6000610d163683613f65565b60e08152600061527860e083018b614177565b896020840152828103604084015287815287896020830137600060208983010152601f19601f890116810190506affffffffffffffffffffff8716606084015285608084015263ffffffff851660a084015260208382030160c08401526152e2602082018561414b565b9b9a5050505050505050505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615329816017850160208801614127565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351615366816028840160208801614127565b01602801949350505050565b60ff8181168382160190811115610d1657610d16614d00565b60008161539a5761539a614d00565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b6000602082840312156153d257600080fd5b815180151581146110c257600080fdfea26469706673582212204ac95ef2c1951ffcdfa9abdf0ebaff2f211cddbd29c73b2134bbd9d395ac2f8264736f6c63430008110033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.