Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
DeBridgeRouter
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 999999 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "./DeBridgeRouterBase.sol";
import {IDlnDestination} from "./interfaces/IDlnDestination.sol";
import "./libraries/Permit.sol";
import "./libraries/SignatureUtil.sol";
contract DeBridgeRouter is DeBridgeRouterBase {
using SafeERC20Upgradeable for IERC20Upgradeable;
using SignatureUtil for bytes;
uint256 public constant BPS_DENOMINATOR = 10_000;
address public constant NATIVE_TOKEN = address(0);
address private _deBridgeGate; // deprecated since v3.1.0
mapping(address => RouterConfig) public supportedRouters;
address public feeTreasury;
uint16 public swapVariableFeeBps;
/* ========== Events ========== */
event AffiliateFeePaid(
address token,
uint256 amount,
address recipient,
uint32 referralCode
);
event CollectedFee(address token, uint256 amount);
event SameChainSwapExecuted(
address sender, // the msg.sender of the swap
address recipient, // the recipient of the swap outcome
address tokenIn,
uint256 amountIn,
address tokenOut,
uint256 amountOut,
uint256 fee,
uint256 affiliateFee,
uint32 referralCode
);
event FeeTreasuryUpdated(address feeTreasury);
event SwapVariableFeeBpsUpdated(uint16 swapVariableFeeBps);
event SupportedRouter(address srcSwapRouter, bool isSupported);
event SwapExecuted(
address router,
address tokenIn,
uint256 amountIn,
address tokenOut,
uint256 amountOut
);
event Refund(address token, uint256 amount, address recipient);
event AllowanceAggregatorUpdated(address router, address allowanceAggregator);
/* ========== ERRORS ========== */
error ExcessiveMsgValue(uint256 requiredAmount, uint256 providedAmount);
error SwapToSameToken();
error ZeroFeeTreasuryAddress();
error SwapOutcomeTooLow(
address tokenOut,
uint256 amountOut,
uint256 actualAmountOut,
uint256 expectedAmountOut
);
// swap router didn't put target tokens on this (forwarder's) address
error SwapEmptyResult(address srcTokenOut);
error SwapFailed(address srcRouter);
error NotEnoughSrcFundsIn(uint256 amount);
error NotSupportedRouter();
error CallFailed(address target, bytes data);
error CallCausedBalanceDiscrepancy(
address target,
address token,
uint256 expectedBalance,
uint256 actualBalance
);
error InvalidAffiliateFeeDataLength(uint256 length);
error InvalidAffiliateFeeData(uint16 bps, address recipient);
error InvalidSwapVariableFeeBps();
/* ========== STRUCTS ========== */
struct RouterConfig {
bool isSupported;
address allowanceAggregator;
}
struct SameChainSwapDetails {
/// @dev address of an aggregator to give approval (increase allowance) to for the swap
/// (if not zero, it will be used instead of the settings stored in this contract)
address allowanceAggregator;
/// @dev address of a router to call to swap token
address swapRouter;
/// @dev calldata for the router
bytes swapCalldata;
/// @dev address of an outcome token of a swap described in swapCalladata
address tokenOut;
/// @dev expected outcome of a swap
uint256 tokenOutMinAmount;
/// @dev surplus share in bps the the recipient will receive
uint16 surplusShareBps;
/// @dev optional affiliate fee envelope. bytes (uint16 bps + address recipient)
bytes affiliateFeeEnvelope;
/// @dev address of a recipient of the swap outcome
/// (if zero, the swap outcome will be sent to the caller)
address recipient;
}
struct SwapDetails {
/// @dev address of a router to call to swap token
address swapRouter;
/// @dev calldata for the router
bytes swapCalldata;
/// @dev address of an outcome token of a swap described in swapCalladata
address tokenOut;
/// @dev expected outcome of a swap
uint256 tokenOutMinAmount;
/// @dev remainder of swap outcome (which lefts after subtracting tokenOutMinAmount and tokenOutMaxExcessiveAmount
/// from the swap outcome)
address tokenOutRefundRecipient;
}
/* ========== INITIALIZERS ========== */
function initialize(
address _feeTreasury,
uint16 _swapVariableFeeBps
) external initializer {
DeBridgeRouterBase._initializeBase();
// order is important here:
_setFeeTreasury(_feeTreasury);
_setSwapVariableFeeBps(_swapVariableFeeBps);
}
/* ========== PUBLIC METHODS ========== */
/// @dev Performs swap against arbitrary input token, extracts fees, and sends the outcome to the specified recipient
/// @param _tokenIn arbitrary input token to swap from
/// @param _amountIn amount of input token to swap
/// @param _tokenInPermitEnvelope optional permit envelope to grab the token from the caller. bytes (amount + deadline + signature)
/// @param _swapDetails details on how to deal with swap outcome
/// @param _referralCode referral code to be passed to events
/// @return actualAmountOut amount of tokens sent to the recipient
function swap(
address _tokenIn,
uint256 _amountIn,
bytes memory _tokenInPermitEnvelope,
SameChainSwapDetails calldata _swapDetails,
uint32 _referralCode
) external payable returns (
uint256 actualAmountOut
) {
if (msg.value != 0 && _tokenIn != NATIVE_TOKEN)
revert ExcessiveMsgValue(0, msg.value);
if (_tokenIn == _swapDetails.tokenOut)
revert SwapToSameToken();
_obtainSrcTokenIn(_tokenIn, _amountIn, _tokenInPermitEnvelope, true);
(uint256 amountOut, ) = _performSwap(
_tokenIn,
_amountIn,
msg.value,
_swapDetails.swapRouter,
_swapDetails.swapCalldata,
_swapDetails.tokenOut,
_swapDetails.allowanceAggregator
);
uint256 fee = (amountOut * swapVariableFeeBps) / BPS_DENOMINATOR;
actualAmountOut = amountOut - fee;
uint256 affiliateFee = _processAffiliateFee(
_swapDetails.tokenOut,
actualAmountOut,
_swapDetails.affiliateFeeEnvelope,
_referralCode
);
actualAmountOut -= affiliateFee;
if (actualAmountOut < _swapDetails.tokenOutMinAmount) {
revert SwapOutcomeTooLow(
_swapDetails.tokenOut,
amountOut,
actualAmountOut,
_swapDetails.tokenOutMinAmount
);
}
{
uint256 surplus = actualAmountOut - _swapDetails.tokenOutMinAmount;
uint256 userSurplus = (surplus * _swapDetails.surplusShareBps) / BPS_DENOMINATOR;
fee += surplus - userSurplus;
actualAmountOut = _swapDetails.tokenOutMinAmount + userSurplus;
}
if (fee > 0) {
address feeRecipient = feeTreasury;
if (feeRecipient == address(0)) revert ZeroFeeTreasuryAddress();
_safeTransferEthOrToken(_swapDetails.tokenOut, feeRecipient, fee);
emit CollectedFee(_swapDetails.tokenOut, fee);
}
_finishSwap(
_tokenIn,
_amountIn,
_swapDetails.tokenOut,
amountOut,
actualAmountOut,
_swapDetails.recipient == address(0) ? msg.sender : _swapDetails.recipient,
fee,
affiliateFee,
_referralCode
);
}
/// @dev Performs swap against arbitrary input token, refunds excessive outcome of such swap (if any),
/// and calls the specified receiver supplying the outcome of the swap
/// @param _srcTokenIn arbitrary input token to swap from
/// @param _srcAmountIn amount of input token to swap
/// @param _srcTokenInPermitEnvelope optional permit envelope to grab the token from the caller. bytes (amount + deadline + signature)
/// @param _swapDetails details on how to deal with swap outcome
/// @param _target DLN contract to call after successful swap
/// @param _targetData calldata to call against _target
/// @param _orderId Id of an order to be fulfilled
function strictlySwapAndCallDln(
address _srcTokenIn,
uint256 _srcAmountIn,
bytes memory _srcTokenInPermitEnvelope,
SwapDetails calldata _swapDetails,
address _target,
bytes calldata _targetData,
bytes32 _orderId
) external payable {
// check order status as early as possible to safe gas: DLN market is highly concurrent, and txns attempting
// to fulfill the same order may occur in the same block
// _target is checked later when invoking _callCustom()
{
(
uint8 status /*address takerAddress*/ /*uint256 giveChainId*/,
,
) = IDlnDestination(_target).takeOrders(_orderId);
// use require() instead of custom error because string error gives more clarity:
// it is shown on Etherscan as well as on Tenderly
require(status == 0, "ORDER_FULFILLED_OR_CANCELLED");
}
_strictlySwapAndCall(
_srcTokenIn,
_srcAmountIn,
_srcTokenInPermitEnvelope,
_swapDetails.swapRouter,
_swapDetails.swapCalldata,
_swapDetails.tokenOut,
_swapDetails.tokenOutMinAmount,
_swapDetails.tokenOutRefundRecipient,
_target,
_targetData
);
}
/// @dev Performs swap against arbitrary input token, refunds excessive outcome of such swap (if any),
/// and calls the specified receiver supplying the outcome of the swap
/// @param _srcTokenIn arbitrary input token to swap from
/// @param _srcAmountIn amount of input token to swap
/// @param _srcTokenInPermitEnvelope optional permit envelope to grab the token from the caller. bytes (amount + deadline + signature)
/// @param _srcSwapRouter contract to call that performs swap from the input token to the output token
/// @param _srcSwapCalldata calldata to call against _srcSwapRouter
/// @param _srcTokenOut arbitrary output token to swap to
/// @param _srcTokenExpectedAmountOut minimum acceptable outcome of the swap to provide to _target
/// @param _srcTokenRefundRecipient address to send excessive outcome of the swap
/// @param _target contract to call after successful swap
/// @param _targetData calldata to call against _target
function strictlySwapAndCall(
address _srcTokenIn,
uint256 _srcAmountIn,
bytes memory _srcTokenInPermitEnvelope,
address _srcSwapRouter,
bytes calldata _srcSwapCalldata,
address _srcTokenOut,
uint256 _srcTokenExpectedAmountOut,
address _srcTokenRefundRecipient,
address _target,
bytes calldata _targetData
) external payable {
_strictlySwapAndCall(
_srcTokenIn,
_srcAmountIn,
_srcTokenInPermitEnvelope,
_srcSwapRouter,
_srcSwapCalldata,
_srcTokenOut,
_srcTokenExpectedAmountOut,
_srcTokenRefundRecipient,
_target,
_targetData
);
}
function simulateSwap(
address _srcTokenIn,
uint256 _srcAmountIn,
address _srcSwapRouter,
bytes calldata _srcSwapCalldata,
address _srcTokenOut
) external payable returns (
uint256 srcAmountOut
) {
_obtainSrcTokenIn(_srcTokenIn, _srcAmountIn, "", false);
(srcAmountOut, ) = _performSwap(
_srcTokenIn,
_srcAmountIn,
msg.value,
_srcSwapRouter,
_srcSwapCalldata,
_srcTokenOut,
address(0) // No allowance aggregator for simulation
);
}
/* ========== INTERNAL METHODS ========== */
function _finishSwap(
address _tokenIn,
uint256 _amountIn,
address _tokenOut,
uint256 amountOut,
uint256 _actualAmountOut,
address _actualRecipient,
uint256 fee,
uint256 affiliateFee,
uint32 _referralCode
) internal {
_safeTransferEthOrToken(_tokenOut, _actualRecipient, _actualAmountOut);
emit SameChainSwapExecuted(
msg.sender,
_actualRecipient,
_tokenIn,
_amountIn,
_tokenOut,
amountOut,
fee,
affiliateFee,
_referralCode
);
}
function _strictlySwapAndCall(
address _srcTokenIn,
uint256 _srcAmountIn,
bytes memory _srcTokenInPermitEnvelope,
address _srcSwapRouter,
bytes calldata _srcSwapCalldata,
address _srcTokenOut,
uint256 _srcTokenExpectedAmountOut,
address _srcTokenRefundRecipient,
address _target,
bytes calldata _targetData
) internal {
//
// pull the srcInToken from msg.sender
//
_obtainSrcTokenIn(
_srcTokenIn, _srcAmountIn, _srcTokenInPermitEnvelope, false
);
//
// swap srcInToken to srcOutToken
//
(uint256 srcAmountOut, uint256 msgValueAfterSwap) = _performSwap(
_srcTokenIn,
_srcAmountIn,
msg.value,
_srcSwapRouter,
_srcSwapCalldata,
_srcTokenOut,
address(0) // No allowance aggregator for strictly swap and call
);
//
// refund excessive srcTokenOut
//
if (_srcTokenExpectedAmountOut > srcAmountOut) {
// swap returned less than expected - revert the whole txn
revert NotEnoughSrcFundsIn(_srcTokenExpectedAmountOut);
} else if (_srcTokenExpectedAmountOut < srcAmountOut) {
// swap returned more than expected - refund
uint256 refundAmount = srcAmountOut - _srcTokenExpectedAmountOut;
// for native token - don't forget to decrease msg.value
if (_srcTokenOut == NATIVE_TOKEN) {
_safeTransferETH(_srcTokenRefundRecipient, refundAmount);
msgValueAfterSwap -= refundAmount;
} else {
IERC20Upgradeable(_srcTokenOut).safeTransfer(
_srcTokenRefundRecipient,
refundAmount
);
}
emit Refund(_srcTokenOut, refundAmount, _srcTokenRefundRecipient);
}
//
// do the target call
//
_performTargetCall(
_target,
_targetData,
msgValueAfterSwap,
_srcTokenOut,
_srcTokenExpectedAmountOut
);
}
function _performTargetCall(
address _target,
bytes calldata _targetData,
uint256 _targetValue,
address _srcTokenOut,
uint256 _srcAmountOut
) internal {
// we check both native and erc-20 balance before the call
// For sure, we can use only one call of _getBalance, but we still must be
// sure that native currency has the correct accounting after the call
// where erc-20 was used
uint256 tokenBalanceBeforeCall = _getBalance(_srcTokenOut);
uint256 balanceBeforeCall = _getBalance(address(0));
// do the call
if (_srcTokenOut != NATIVE_TOKEN) {
_lazyApprove(_srcTokenOut, _target, address(0), _srcAmountOut);
}
_callCustom(_target, _targetData, _targetValue);
// check balances
uint256 tokenBalanceAfterCall = _getBalance(_srcTokenOut);
uint256 balanceAfterCall = _getBalance(address(0));
// ensure _target has pulled all tokens from this contract
if ((tokenBalanceBeforeCall - tokenBalanceAfterCall) < _srcAmountOut) {
revert CallCausedBalanceDiscrepancy(
_target,
_srcTokenOut,
tokenBalanceBeforeCall - _srcAmountOut,
tokenBalanceBeforeCall - tokenBalanceAfterCall
);
}
if ((balanceBeforeCall - balanceAfterCall) < _targetValue) {
revert CallCausedBalanceDiscrepancy(
_target,
address(0),
tokenBalanceBeforeCall - _targetValue,
balanceBeforeCall - balanceAfterCall
);
}
}
function _getBalance(address _token) internal view returns (uint256) {
if (_token == NATIVE_TOKEN) {
return payable(this).balance;
} else {
return IERC20Upgradeable(_token).balanceOf(address(this));
}
}
function _obtainSrcTokenIn(
address _srcTokenIn,
uint256 _srcAmountIn,
bytes memory _srcTokenInPermitEnvelope,
bool _strictMsgValueCheck
) internal {
if (_srcTokenIn == NATIVE_TOKEN) {
if (msg.value < _srcAmountIn) {
revert NotEnoughSrcFundsIn(_srcAmountIn);
}
if (_strictMsgValueCheck && msg.value > _srcAmountIn) {
revert ExcessiveMsgValue(_srcAmountIn, msg.value);
}
} else {
uint256 srcAmountCleared = _collectSrcERC20In(
IERC20Upgradeable(_srcTokenIn),
_srcAmountIn,
_srcTokenInPermitEnvelope
);
if (srcAmountCleared < _srcAmountIn)
revert NotEnoughSrcFundsIn(_srcAmountIn);
}
}
function _performSwap(
address _srcTokenIn,
uint256 _srcAmountIn,
uint256 _msgValue,
address _srcSwapRouter,
bytes calldata _srcSwapCalldata,
address _srcTokenOut,
address _allowanceAggregator
) internal returns (uint256 srcAmountOut, uint256 msgValueAfterSwap) {
uint256 ethBalanceBefore = address(this).balance - _msgValue;
if (_srcTokenIn == NATIVE_TOKEN) {
srcAmountOut = _swapToERC20Via(
_srcSwapRouter,
_srcSwapCalldata,
_srcAmountIn,
IERC20Upgradeable(_srcTokenOut)
);
} else {
_lazyApprove(_srcTokenIn, _srcSwapRouter, _allowanceAggregator, _srcAmountIn);
if (_srcTokenOut == NATIVE_TOKEN) {
srcAmountOut = _swapToETHVia(_srcSwapRouter, _srcSwapCalldata);
} else {
srcAmountOut = _swapToERC20Via(
_srcSwapRouter,
_srcSwapCalldata,
0 /*value*/,
IERC20Upgradeable(_srcTokenOut)
);
}
}
emit SwapExecuted(
_srcSwapRouter,
_srcTokenIn,
_srcAmountIn,
_srcTokenOut,
srcAmountOut
);
msgValueAfterSwap = address(this).balance - ethBalanceBefore;
}
function _collectSrcERC20In(
IERC20Upgradeable _token,
uint256 _amount,
bytes memory _permitEnvelope
) internal returns (uint256) {
uint256 balanceBefore = _token.balanceOf(address(this));
Permit.executePermit(address(_token), _permitEnvelope);
_token.safeTransferFrom(msg.sender, address(this), _amount);
uint256 balanceAfter = _token.balanceOf(address(this));
if (!(balanceAfter > balanceBefore))
revert NotEnoughSrcFundsIn(_amount);
return (balanceAfter - balanceBefore);
}
function _swapToETHVia(
address _router,
bytes calldata _calldata
) internal returns (uint256) {
uint256 balanceBefore = address(this).balance;
_callCustom(_router, _calldata, 0);
uint256 balanceAfter = address(this).balance;
if (balanceBefore >= balanceAfter) revert SwapEmptyResult(address(0));
uint256 swapDstTokenBalance = balanceAfter - balanceBefore;
return swapDstTokenBalance;
}
function _swapToERC20Via(
address _router,
bytes calldata _calldata,
uint256 _msgValue,
IERC20Upgradeable _targetToken
) internal returns (uint256) {
uint256 balanceBefore = _targetToken.balanceOf(address(this));
_callCustom(_router, _calldata, _msgValue);
uint256 balanceAfter = _targetToken.balanceOf(address(this));
if (balanceBefore >= balanceAfter)
revert SwapEmptyResult(address(_targetToken));
uint256 swapDstTokenBalance = balanceAfter - balanceBefore;
return swapDstTokenBalance;
}
function _lazyApprove(
address _tokenAddress,
address _swapRouter,
address _allowanceAggregator,
uint256 _amount
) internal {
IERC20Upgradeable token = IERC20Upgradeable(_tokenAddress);
address approvalTarget = _swapRouter;
if (_allowanceAggregator != address(0)) {
if (!supportedRouters[_allowanceAggregator].isSupported) revert NotSupportedRouter();
approvalTarget = _allowanceAggregator;
} else {
// check if there's a stored allowanceAggregator for this router
address storedAggregator = supportedRouters[_swapRouter].allowanceAggregator;
if (storedAggregator != address(0)) {
approvalTarget = storedAggregator;
}
}
uint256 currentAllowance = token.allowance(address(this), approvalTarget);
if (currentAllowance < _amount) {
// if an approval was issued before
token.safeApprove(approvalTarget, 0);
// create permanent approve
token.safeApprove(approvalTarget, type(uint256).max);
}
}
function _callCustom(
address _to,
bytes calldata _data,
uint256 _msgValue
) internal {
if (!supportedRouters[_to].isSupported) revert NotSupportedRouter();
(bool success, bytes memory returnData) = _to.call{value: _msgValue}(
_data
);
if (!success) {
revert CallFailed(_to, returnData);
}
}
function _processAffiliateFee(
address _token,
uint256 _totalAmount,
bytes calldata _affiliateFeeEnvelope,
uint32 _referralCode
) internal returns (uint256 affiliateFee) {
(uint16 affiliateFeeBps, address affiliateFeeRecipient)
= _unpackAndValidateAffiliateFee(_affiliateFeeEnvelope);
if (affiliateFeeBps == 0) return 0;
affiliateFee = (_totalAmount * affiliateFeeBps) / BPS_DENOMINATOR;
_safeTransferEthOrToken(
_token,
affiliateFeeRecipient,
affiliateFee
);
emit AffiliateFeePaid(
_token,
affiliateFee,
affiliateFeeRecipient,
_referralCode
);
}
function _unpackAndValidateAffiliateFee(
bytes calldata _data
) internal pure returns (uint16 bps, address recipient) {
if (_data.length == 0)
return (0, address(0));
if (_data.length != 22)
revert InvalidAffiliateFeeDataLength(_data.length);
bps = uint16(bytes2(_data[:2]));
recipient = address(bytes20(_data[2:22]));
if (bps > BPS_DENOMINATOR || (bps != 0 && recipient == address(0)))
revert InvalidAffiliateFeeData(bps, recipient);
}
// ============ ADM ============
function updateFeeTreasury(address _feeTreasury) external onlyAdmin {
_setFeeTreasury(_feeTreasury);
}
function _setFeeTreasury(address _feeTreasury) internal {
if (_feeTreasury == address(0)) revert ZeroFeeTreasuryAddress();
feeTreasury = _feeTreasury;
emit FeeTreasuryUpdated(_feeTreasury);
}
function updateSwapVariableFeeBps(
uint16 _swapVariableFeeBps
) external onlyAdmin {
_setSwapVariableFeeBps(_swapVariableFeeBps);
}
function _setSwapVariableFeeBps(uint16 _swapVariableFeeBps) internal {
if (_swapVariableFeeBps > BPS_DENOMINATOR)
revert InvalidSwapVariableFeeBps();
if (_swapVariableFeeBps > 0 && feeTreasury == address(0))
revert ZeroFeeTreasuryAddress();
swapVariableFeeBps = _swapVariableFeeBps;
emit SwapVariableFeeBpsUpdated(_swapVariableFeeBps);
}
function updateSupportedRouter(
address _srcSwapRouter,
bool _isSupported
) external onlyAdmin {
supportedRouters[_srcSwapRouter].isSupported = _isSupported;
emit SupportedRouter(_srcSwapRouter, _isSupported);
}
function updateAllowanceAggregator(
address _router,
address _allowanceAggregator
) external onlyAdmin {
// If setting allowanceAggregator, ensure it's a supported router
if (!supportedRouters[_allowanceAggregator].isSupported) {
revert NotSupportedRouter();
}
supportedRouters[_router].allowanceAggregator = _allowanceAggregator;
emit AllowanceAggregatorUpdated(_router, _allowanceAggregator);
}
function rescueFunds(
address token,
address recipient,
uint256 amount
) external onlyAdmin {
_safeTransferEthOrToken(token, recipient, amount);
}
function _safeTransferEthOrToken(
address tokenAddress,
address to,
uint256 value
) private {
if (value > 0) {
if (tokenAddress == NATIVE_TOKEN) {
_safeTransferETH(to, value);
} else {
IERC20Upgradeable(tokenAddress).safeTransfer(to, value);
}
}
}
// ============ Version Control ============
/// @dev Get this contract's version
function version() external pure returns (uint256) {
return 310; // 3.1.0
}
}// 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 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: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
contract DeBridgeRouterBase is Initializable, AccessControlUpgradeable {
/* ========== ERRORS ========== */
error EthTransferFailed();
error AdminBadRole();
/* ========== MODIFIERS ========== */
modifier onlyAdmin() {
if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) revert AdminBadRole();
_;
}
/* ========== INITIALIZERS ========== */
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
function _initializeBase() internal initializer {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
/*
* @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();
}
receive() external payable {}
}// SPDX-License-Identifier: UNLICENSED
// !! THIS FILE WAS AUTOGENERATED BY abi-to-sol v0.6.6. SEE SOURCE BELOW. !!
pragma solidity ^0.8.4;
interface IDlnDestination {
function takeOrders(
bytes32
)
external
view
returns (uint8 status, address takerAddress, uint256 giveChainId);
}
// THIS FILE WAS AUTOGENERATED FROM THE FOLLOWING ABI JSON:
/*
[{"inputs":[],"name":"AdminBadRole","type":"error"},{"inputs":[{"internalType":"bytes","name":"expectedBeneficiary","type":"bytes"}],"name":"AllowOnlyForBeneficiary","type":"error"},{"inputs":[],"name":"CallProxyBadRole","type":"error"},{"inputs":[],"name":"EthTransferFailed","type":"error"},{"inputs":[],"name":"ExternalCallIsBlocked","type":"error"},{"inputs":[],"name":"GovMonitoringBadRole","type":"error"},{"inputs":[],"name":"IncorrectOrderStatus","type":"error"},{"inputs":[],"name":"MismatchGiveChainId","type":"error"},{"inputs":[],"name":"MismatchNativeTakerAmount","type":"error"},{"inputs":[],"name":"MismatchTakerAmount","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":"ProposedFeeTooHigh","type":"error"},{"inputs":[],"name":"SignatureInvalidV","type":"error"},{"inputs":[],"name":"TheSameFromTo","type":"error"},{"inputs":[],"name":"TransferAmountNotCoverFees","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"UnexpectedBatchSize","type":"error"},{"inputs":[],"name":"UnknownEngine","type":"error"},{"inputs":[],"name":"WrongAddressLength","type":"error"},{"inputs":[],"name":"WrongArgument","type":"error"},{"inputs":[],"name":"WrongAutoArgument","type":"error"},{"inputs":[],"name":"WrongChain","type":"error"},{"inputs":[],"name":"WrongToken","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"orderTakeFinalAmount","type":"uint256"}],"name":"DecreasedTakeAmount","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 DlnBase.Order","name":"order","type":"tuple"},{"indexed":false,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"unlockAuthority","type":"address"}],"name":"FulfilledOrder","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":[{"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 DlnBase.Order","name":"order","type":"tuple"},{"indexed":false,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"cancelBeneficiary","type":"bytes"},{"indexed":false,"internalType":"bytes32","name":"submissionId","type":"bytes32"}],"name":"SentOrderCancel","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"beneficiary","type":"bytes"},{"indexed":false,"internalType":"bytes32","name":"submissionId","type":"bytes32"}],"name":"SentOrderUnlock","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chainIdFrom","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"dlnSourceAddress","type":"bytes"},{"indexed":false,"internalType":"enum DlnBase.ChainEngine","name":"chainEngine","type":"uint8"}],"name":"SetDlnSourceAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","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":"MAX_ORDER_COUNT_PER_BATCH_EVM_UNLOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NATIVE_AMOUNT_DIVIDER_FOR_TRANSFER_TO_SOLANA","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":[],"name":"SOLANA_CHAIN_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"chainEngines","outputs":[{"internalType":"enum DlnBase.ChainEngine","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deBridgeGate","outputs":[{"internalType":"contract IDeBridgeGate","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"dlnSourceAddresses","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"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 DlnBase.Order","name":"_order","type":"tuple"},{"internalType":"uint256","name":"_fulFillAmount","type":"uint256"},{"internalType":"bytes32","name":"_orderId","type":"bytes32"},{"internalType":"bytes","name":"_permitEnvelope","type":"bytes"},{"internalType":"address","name":"_unlockAuthority","type":"address"}],"name":"fulfillOrder","outputs":[],"stateMutability":"payable","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 DlnBase.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":"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"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","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 DlnBase.Order","name":"_order","type":"tuple"},{"internalType":"uint256","name":"_newSubtrahend","type":"uint256"}],"name":"patchOrderTake","outputs":[],"stateMutability":"nonpayable","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":"bytes32[]","name":"_orderIds","type":"bytes32[]"},{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"uint256","name":"_executionFee","type":"uint256"}],"name":"sendBatchEvmUnlock","outputs":[],"stateMutability":"payable","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 DlnBase.Order","name":"_order","type":"tuple"},{"internalType":"address","name":"_cancelBeneficiary","type":"address"},{"internalType":"uint256","name":"_executionFee","type":"uint256"}],"name":"sendEvmOrderCancel","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_orderId","type":"bytes32"},{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"uint256","name":"_executionFee","type":"uint256"}],"name":"sendEvmUnlock","outputs":[],"stateMutability":"payable","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 DlnBase.Order","name":"_order","type":"tuple"},{"internalType":"bytes32","name":"_cancelBeneficiary","type":"bytes32"},{"internalType":"uint256","name":"_executionFee","type":"uint256"},{"internalType":"uint64","name":"_reward1","type":"uint64"},{"internalType":"uint64","name":"_reward2","type":"uint64"}],"name":"sendSolanaOrderCancel","outputs":[],"stateMutability":"payable","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 DlnBase.Order","name":"_order","type":"tuple"},{"internalType":"bytes32","name":"_beneficiary","type":"bytes32"},{"internalType":"uint256","name":"_executionFee","type":"uint256"},{"internalType":"uint64","name":"_solanaExternalCallReward1","type":"uint64"},{"internalType":"uint64","name":"_solanaExternalCallReward2","type":"uint64"}],"name":"sendSolanaUnlock","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_chainIdFrom","type":"uint256"},{"internalType":"bytes","name":"_dlnSourceAddress","type":"bytes"},{"internalType":"enum DlnBase.ChainEngine","name":"_chainEngine","type":"uint8"}],"name":"setDlnSourceAddress","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":"bytes32","name":"","type":"bytes32"}],"name":"takeOrders","outputs":[{"internalType":"enum DlnDestination.OrderTakeStatus","name":"status","type":"uint8"},{"internalType":"address","name":"takerAddress","type":"address"},{"internalType":"uint256","name":"giveChainId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"takePatches","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"}]
*/// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./SignatureUtil.sol";
library Permit {
using SignatureUtil for bytes;
function executePermit(
address _tokenAddress,
bytes memory _permitEnvelope
) internal {
if (_permitEnvelope.length > 0) {
uint256 permitAmount = _permitEnvelope.toUint256(0);
uint256 deadline = _permitEnvelope.toUint256(32);
(bytes32 r, bytes32 s, uint8 v) = _permitEnvelope.parseSignature(
64
);
try
IERC20Permit(_tokenAddress).permit(
msg.sender,
address(this),
permitAmount,
deadline,
v,
r,
s
)
{
return;
} catch {
if (
IERC20(_tokenAddress).allowance(
msg.sender,
address(this)
) >= permitAmount
) {
return;
}
}
revert("Permit failure");
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
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))
}
}
}{
"optimizer": {
"enabled": true,
"runs": 999999
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"AdminBadRole","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"expectedBalance","type":"uint256"},{"internalType":"uint256","name":"actualBalance","type":"uint256"}],"name":"CallCausedBalanceDiscrepancy","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"CallFailed","type":"error"},{"inputs":[],"name":"EthTransferFailed","type":"error"},{"inputs":[{"internalType":"uint256","name":"requiredAmount","type":"uint256"},{"internalType":"uint256","name":"providedAmount","type":"uint256"}],"name":"ExcessiveMsgValue","type":"error"},{"inputs":[{"internalType":"uint16","name":"bps","type":"uint16"},{"internalType":"address","name":"recipient","type":"address"}],"name":"InvalidAffiliateFeeData","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"InvalidAffiliateFeeDataLength","type":"error"},{"inputs":[],"name":"InvalidSwapVariableFeeBps","type":"error"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"NotEnoughSrcFundsIn","type":"error"},{"inputs":[],"name":"NotSupportedRouter","type":"error"},{"inputs":[],"name":"SignatureInvalidV","type":"error"},{"inputs":[{"internalType":"address","name":"srcTokenOut","type":"address"}],"name":"SwapEmptyResult","type":"error"},{"inputs":[{"internalType":"address","name":"srcRouter","type":"address"}],"name":"SwapFailed","type":"error"},{"inputs":[{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"actualAmountOut","type":"uint256"},{"internalType":"uint256","name":"expectedAmountOut","type":"uint256"}],"name":"SwapOutcomeTooLow","type":"error"},{"inputs":[],"name":"SwapToSameToken","type":"error"},{"inputs":[],"name":"WrongArgumentLength","type":"error"},{"inputs":[],"name":"ZeroFeeTreasuryAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint32","name":"referralCode","type":"uint32"}],"name":"AffiliateFeePaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"router","type":"address"},{"indexed":false,"internalType":"address","name":"allowanceAggregator","type":"address"}],"name":"AllowanceAggregatorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CollectedFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"feeTreasury","type":"address"}],"name":"FeeTreasuryUpdated","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":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"Refund","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":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"affiliateFee","type":"uint256"},{"indexed":false,"internalType":"uint32","name":"referralCode","type":"uint32"}],"name":"SameChainSwapExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"srcSwapRouter","type":"address"},{"indexed":false,"internalType":"bool","name":"isSupported","type":"bool"}],"name":"SupportedRouter","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"router","type":"address"},{"indexed":false,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"SwapExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"swapVariableFeeBps","type":"uint16"}],"name":"SwapVariableFeeBpsUpdated","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":"NATIVE_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeTreasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_feeTreasury","type":"address"},{"internalType":"uint16","name":"_swapVariableFeeBps","type":"uint16"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueFunds","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":"address","name":"_srcTokenIn","type":"address"},{"internalType":"uint256","name":"_srcAmountIn","type":"uint256"},{"internalType":"address","name":"_srcSwapRouter","type":"address"},{"internalType":"bytes","name":"_srcSwapCalldata","type":"bytes"},{"internalType":"address","name":"_srcTokenOut","type":"address"}],"name":"simulateSwap","outputs":[{"internalType":"uint256","name":"srcAmountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_srcTokenIn","type":"address"},{"internalType":"uint256","name":"_srcAmountIn","type":"uint256"},{"internalType":"bytes","name":"_srcTokenInPermitEnvelope","type":"bytes"},{"internalType":"address","name":"_srcSwapRouter","type":"address"},{"internalType":"bytes","name":"_srcSwapCalldata","type":"bytes"},{"internalType":"address","name":"_srcTokenOut","type":"address"},{"internalType":"uint256","name":"_srcTokenExpectedAmountOut","type":"uint256"},{"internalType":"address","name":"_srcTokenRefundRecipient","type":"address"},{"internalType":"address","name":"_target","type":"address"},{"internalType":"bytes","name":"_targetData","type":"bytes"}],"name":"strictlySwapAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_srcTokenIn","type":"address"},{"internalType":"uint256","name":"_srcAmountIn","type":"uint256"},{"internalType":"bytes","name":"_srcTokenInPermitEnvelope","type":"bytes"},{"components":[{"internalType":"address","name":"swapRouter","type":"address"},{"internalType":"bytes","name":"swapCalldata","type":"bytes"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"tokenOutMinAmount","type":"uint256"},{"internalType":"address","name":"tokenOutRefundRecipient","type":"address"}],"internalType":"struct DeBridgeRouter.SwapDetails","name":"_swapDetails","type":"tuple"},{"internalType":"address","name":"_target","type":"address"},{"internalType":"bytes","name":"_targetData","type":"bytes"},{"internalType":"bytes32","name":"_orderId","type":"bytes32"}],"name":"strictlySwapAndCallDln","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supportedRouters","outputs":[{"internalType":"bool","name":"isSupported","type":"bool"},{"internalType":"address","name":"allowanceAggregator","type":"address"}],"stateMutability":"view","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":"_tokenIn","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"bytes","name":"_tokenInPermitEnvelope","type":"bytes"},{"components":[{"internalType":"address","name":"allowanceAggregator","type":"address"},{"internalType":"address","name":"swapRouter","type":"address"},{"internalType":"bytes","name":"swapCalldata","type":"bytes"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"tokenOutMinAmount","type":"uint256"},{"internalType":"uint16","name":"surplusShareBps","type":"uint16"},{"internalType":"bytes","name":"affiliateFeeEnvelope","type":"bytes"},{"internalType":"address","name":"recipient","type":"address"}],"internalType":"struct DeBridgeRouter.SameChainSwapDetails","name":"_swapDetails","type":"tuple"},{"internalType":"uint32","name":"_referralCode","type":"uint32"}],"name":"swap","outputs":[{"internalType":"uint256","name":"actualAmountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"swapVariableFeeBps","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"},{"internalType":"address","name":"_allowanceAggregator","type":"address"}],"name":"updateAllowanceAggregator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeTreasury","type":"address"}],"name":"updateFeeTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_srcSwapRouter","type":"address"},{"internalType":"bool","name":"_isSupported","type":"bool"}],"name":"updateSupportedRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_swapVariableFeeBps","type":"uint16"}],"name":"updateSwapVariableFeeBps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
6080604052348015600f57600080fd5b506016601a565b60d8565b600054610100900460ff161560855760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116101560d6576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b613c78806100e76000396000f3fe6080604052600436106101845760003560e01c80638fca8a02116100d6578063d33f532e1161007f578063e1a4521811610059578063e1a45218146104ae578063edc8fef6146104c4578063f39e69a41461050a57600080fd5b8063d33f532e1461044e578063d4a0d4c61461046e578063d547741f1461048e57600080fd5b8063a217fddf116100b0578063a217fddf14610406578063ab804a471461041b578063c7a769691461043b57600080fd5b80638fca8a021461031a57806391d148541461033a5780639879c48d1461038d57600080fd5b806336568abe1161013857806360dc23401161011257806360dc2340146102ba5780636ccae054146102e75780636e8f99c91461030757600080fd5b806336568abe146102725780634d8160ba1461029257806354fd4d50146102a557600080fd5b8063258c16ee11610169578063258c16ee146102035780632f2ff15d1461021657806331f7d9641461023857600080fd5b806301ffc9a714610190578063248a9ca3146101c557600080fd5b3661018b57005b600080fd5b34801561019c57600080fd5b506101b06101ab3660046131a2565b61052a565b60405190151581526020015b60405180910390f35b3480156101d157600080fd5b506101f56101e03660046131e4565b60009081526065602052604090206001015490565b6040519081526020016101bc565b6101f5610211366004613325565b6105c3565b34801561022257600080fd5b506102366102313660046133ce565b6109a4565b005b34801561024457600080fd5b5061024d600081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101bc565b34801561027e57600080fd5b5061023661028d3660046133ce565b6109ce565b6102366102a0366004613440565b610a81565b3480156102b157600080fd5b506101366101f5565b3480156102c657600080fd5b5060995461024d9073ffffffffffffffffffffffffffffffffffffffff1681565b3480156102f357600080fd5b50610236610302366004613551565b610aa3565b6101f5610315366004613592565b610b16565b34801561032657600080fd5b50610236610335366004613629565b610b51565b34801561034657600080fd5b506101b06103553660046133ce565b600091825260656020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561039957600080fd5b506103da6103a8366004613644565b60986020526000908152604090205460ff811690610100900473ffffffffffffffffffffffffffffffffffffffff1682565b60408051921515835273ffffffffffffffffffffffffffffffffffffffff9091166020830152016101bc565b34801561041257600080fd5b506101f5600081565b34801561042757600080fd5b50610236610436366004613661565b610bc5565b6102366104493660046136a7565b610d21565b34801561045a57600080fd5b50610236610469366004613784565b610e7f565b34801561047a57600080fd5b50610236610489366004613644565b610f6e565b34801561049a57600080fd5b506102366104a93660046133ce565b610fdf565b3480156104ba57600080fd5b506101f561271081565b3480156104d057600080fd5b506099546104f79074010000000000000000000000000000000000000000900461ffff1681565b60405161ffff90911681526020016101bc565b34801561051657600080fd5b506102366105253660046137b2565b611004565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806105bd57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b600034158015906105e9575073ffffffffffffffffffffffffffffffffffffffff861615155b1561062e576040517f1fce9ca9000000000000000000000000000000000000000000000000000000008152600060048201523460248201526044015b60405180910390fd5b61063e6080840160608501613644565b73ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16036106a2576040517f55bbdeb000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6106af86868660016111a9565b60006106f68787346106c76040890160208a01613644565b6106d460408a018a6137e7565b6106e460808c0160608d01613644565b6106f160208d018d613644565b6112a6565b506099549091506000906127109061072a9074010000000000000000000000000000000000000000900461ffff168461387b565b6107349190613892565b905061074081836138cd565b9250600061076b6107576080880160608901613644565b8561076560c08a018a6137e7565b896113a8565b905061077781856138cd565b935085608001358410156107f8576107956080870160608801613644565b6040517fc0bf820b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018490526044810185905260808701356064820152608401610625565b60006108086080880135866138cd565b9050600061271061081f60c08a0160a08b01613629565b61082d9061ffff168461387b565b6108379190613892565b905061084381836138cd565b61084d90856138e0565b935061085d8160808a01356138e0565b955050821590506109335760995473ffffffffffffffffffffffffffffffffffffffff16806108b8576040517f4af6fd5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108d26108cb6080890160608a01613644565b8285611469565b7f5a7af898dfbf9d56c66a7883a2e9229f5c9ff2484d9525f2c80cff815e2328276109036080890160608a01613644565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252602082018690520160405180910390a1505b610998898961094860808a0160608b01613644565b8688600061095d6101008e0160e08f01613644565b73ffffffffffffffffffffffffffffffffffffffff161461098e576109896101008d0160e08e01613644565b610990565b335b88888d6114b5565b50505095945050505050565b6000828152606560205260409020600101546109bf81611553565b6109c9838361155d565b505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610a73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610625565b610a7d8282611651565b5050565b610a958c8c8c8c8c8c8c8c8c8c8c8c61170c565b505050505050505050505050565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16610b0b576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109c9838383611469565b6000610b3487876040518060200160405280600081525060006111a9565b610b458787348888888860006112a6565b50979650505050505050565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16610bb9576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bc281611852565b50565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16610c2d576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526098602052604090205460ff16610c8c576040517f2a070fb400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82811660008181526098602090815260409182902080547fffffffffffffffffffffff0000000000000000000000000000000000000000ff1661010095871695860217905581519283528201929092527f17acbaf0bcb36a981255b884e821edcf811a3b401972432678b01cd1a7f0d50091015b60405180910390a15050565b6040517f5b2f30e90000000000000000000000000000000000000000000000000000000081526004810182905260009073ffffffffffffffffffffffffffffffffffffffff861690635b2f30e990602401606060405180830381865afa158015610d8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db391906138f3565b505090508060ff16600014610e24576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f524445525f46554c46494c4c45445f4f525f43414e43454c4c4544000000006044820152606401610625565b50610e75888888610e3860208a018a613644565b610e4560208b018b6137e7565b610e5560608d0160408e01613644565b8c606001358d6080016020810190610e6d9190613644565b8d8d8d61170c565b5050505050505050565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16610ee7576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821660008181526098602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168515159081179091558251938452908301527f3fc30fe9d1afedc310e6ec6fd5f84b0ae3b800cdc1bcb04b65b986fdd35868f09101610d15565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16610fd6576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bc281611975565b600082815260656020526040902060010154610ffa81611553565b6109c98383611651565b600054610100900460ff16158080156110245750600054600160ff909116105b8061103e5750303b15801561103e575060005460ff166001145b6110ca576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610625565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561112857600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b611130611a35565b61113983611975565b61114282611852565b80156109c957600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b73ffffffffffffffffffffffffffffffffffffffff84166112525782341015611201576040517fc0159a6100000000000000000000000000000000000000000000000000000000815260048101849052602401610625565b80801561120d57508234115b1561124d576040517f1fce9ca900000000000000000000000000000000000000000000000000000000815260048101849052346024820152604401610625565b6112a0565b600061125f858585611bc3565b90508381101561129e576040517fc0159a6100000000000000000000000000000000000000000000000000000000815260048101859052602401610625565b505b50505050565b600080806112b489476138cd565b905073ffffffffffffffffffffffffffffffffffffffff8b166112e5576112de8888888d89611d67565b9250611328565b6112f18b89868d611f05565b73ffffffffffffffffffffffffffffffffffffffff8516611317576112de8888886120d2565b611325888888600089611d67565b92505b6040805173ffffffffffffffffffffffffffffffffffffffff8a811682528d811660208301528183018d9052871660608201526080810185905290517fdde2f3711ab09cdddcfee16ca03e54d21fb8cf3fa647b9797913c950d38ad6939181900360a00190a161139881476138cd565b9150509850989650505050505050565b60008060006113b78686612135565b915091508161ffff166000036113d257600092505050611460565b6127106113e361ffff84168961387b565b6113ed9190613892565b92506113fa888285611469565b6040805173ffffffffffffffffffffffffffffffffffffffff8a811682526020820186905283168183015263ffffffff8616606082015290517f6a0f4594999005114d250d0dce53dea802de70666f009552d1aa0b39e58463619181900360800190a150505b95945050505050565b80156109c95773ffffffffffffffffffffffffffffffffffffffff8316611494576109c98282612255565b6109c973ffffffffffffffffffffffffffffffffffffffff84168383612309565b6114c0878587611469565b6040805133815273ffffffffffffffffffffffffffffffffffffffff86811660208301528b811682840152606082018b90528916608082015260a0810188905260c0810185905260e0810184905263ffffffff831661010082015290517fecfedc7a2bb58de8119427cef1d856aa76747d4a6e13307a7ca485bf8df20904918190036101200190a1505050505050505050565b610bc281336123dd565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610a7d57600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556115f33390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615610a7d57600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6117198c8c8c60006111a9565b60008061172d8e8e348e8e8e8e60006112a6565b915091508187111561176e576040517fc0159a6100000000000000000000000000000000000000000000000000000000815260048101889052602401610625565b8187101561183457600061178288846138cd565b905073ffffffffffffffffffffffffffffffffffffffff89166117ba576117a98782612255565b6117b381836138cd565b91506117db565b6117db73ffffffffffffffffffffffffffffffffffffffff8a168883612309565b6040805173ffffffffffffffffffffffffffffffffffffffff8b811682526020820184905289168183015290517f149635d19f798f6b7c74c74a500d362c89316a0ab808abe5e0c0de45da9b1d2c9181900360600190a1505b611842858585848c8c612497565b5050505050505050505050505050565b6127108161ffff161115611892576040517f0bcf616f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008161ffff161180156118bc575060995473ffffffffffffffffffffffffffffffffffffffff16155b156118f3576040517f4af6fd5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b609980547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8416908102919091179091556040519081527f6b24b4ecbdb33b853813a087738a34121649900030572f4286ddf4ad24586386906020015b60405180910390a150565b73ffffffffffffffffffffffffffffffffffffffff81166119c2576040517f4af6fd5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b609980547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f10d6c00fd9d176c2872e8e72b76641ca85aba29bb682a658aeedbc38814fe45f9060200161196a565b600054610100900460ff1615808015611a555750600054600160ff909116105b80611a6f5750303b158015611a6f575060005460ff166001145b611afb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610625565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558015611b5957600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b611b646000336125bb565b8015610bc257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200161196a565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600090819073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190602401602060405180830381865afa158015611c32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c56919061393d565b9050611c6285846125c5565b611c8473ffffffffffffffffffffffffffffffffffffffff86163330876127ad565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8716906370a0823190602401602060405180830381865afa158015611cf1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d15919061393d565b9050818111611d53576040517fc0159a6100000000000000000000000000000000000000000000000000000000815260048101869052602401610625565b611d5d82826138cd565b9695505050505050565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600090819073ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa158015611dd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dfa919061393d565b9050611e088787878761280b565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8516906370a0823190602401602060405180830381865afa158015611e75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e99919061393d565b9050808210611eec576040517f5743851400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401610625565b6000611ef883836138cd565b9998505050505050505050565b838373ffffffffffffffffffffffffffffffffffffffff841615611f895773ffffffffffffffffffffffffffffffffffffffff841660009081526098602052604090205460ff16611f82576040517f2a070fb400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5082611fc2565b73ffffffffffffffffffffffffffffffffffffffff8086166000908152609860205260409020546101009004168015611fc0578091505b505b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff82811660248301526000919084169063dd62ed3e90604401602060405180830381865afa158015612038573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061205c919061393d565b9050838110156120c95761208873ffffffffffffffffffffffffffffffffffffffff841683600061291f565b6120c973ffffffffffffffffffffffffffffffffffffffff8416837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61291f565b50505050505050565b6000476120e18585858561280b565b4780821061211e576040517f5743851400000000000000000000000000000000000000000000000000000000815260006004820152602401610625565b600061212a83836138cd565b979650505050505050565b60008082810361214a5750600090508061224e565b60168314612187576040517f611a89c400000000000000000000000000000000000000000000000000000000815260048101849052602401610625565b612195600260008587613956565b61219e91613980565b60f01c91506121b1601660028587613956565b6121ba916139e6565b60601c90506127108261ffff1611806121f5575061ffff8216158015906121f5575073ffffffffffffffffffffffffffffffffffffffff8116155b1561224e576040517fce8f8d9300000000000000000000000000000000000000000000000000000000815261ffff8316600482015273ffffffffffffffffffffffffffffffffffffffff82166024820152604401610625565b9250929050565b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff841690839060405161228c9190613a6f565b60006040518083038185875af1925050503d80600081146122c9576040519150601f19603f3d011682016040523d82523d6000602084013e6122ce565b606091505b50509050806109c9576040517f6d963f8800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526109c99084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612aa1565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610a7d5761241d81612bad565b612428836020612bcc565b604051602001612439929190613a8b565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a000000000000000000000000000000000000000000000000000000000825261062591600401613b56565b60006124a283612e16565b905060006124b06000612e16565b905073ffffffffffffffffffffffffffffffffffffffff8416156124db576124db8489600086611f05565b6124e78888888861280b565b60006124f285612e16565b905060006125006000612e16565b90508461250d83866138cd565b101561258757898661251f87876138cd565b61252985886138cd565b6040517ff52b9cd600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff948516600482015293909216602484015260448301526064820152608401610625565b8661259282856138cd565b10156125af578960006125a589876138cd565b61252984876138cd565b50505050505050505050565b610a7d828261155d565b805115610a7d5760006125d88282612ecd565b905060006125e7836020612ecd565b9050600080806125f8866040612f1d565b6040517fd505accf000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018990526064810188905260ff8216608482015260a4810184905260c48101839052929550909350915073ffffffffffffffffffffffffffffffffffffffff88169063d505accf9060e401600060405180830381600087803b15801561269257600080fd5b505af19250505080156126a3575060015b6120c9576040517fdd62ed3e000000000000000000000000000000000000000000000000000000008152336004820152306024820152859073ffffffffffffffffffffffffffffffffffffffff89169063dd62ed3e90604401602060405180830381865afa158015612719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061273d919061393d565b1061274b5750505050505050565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f5065726d6974206661696c7572650000000000000000000000000000000000006044820152606401610625565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526112a09085907f23b872dd000000000000000000000000000000000000000000000000000000009060840161235b565b73ffffffffffffffffffffffffffffffffffffffff841660009081526098602052604090205460ff1661286a576040517f2a070fb400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808573ffffffffffffffffffffffffffffffffffffffff16838686604051612895929190613b69565b60006040518083038185875af1925050503d80600081146128d2576040519150601f19603f3d011682016040523d82523d6000602084013e6128d7565b606091505b5091509150816129175785816040517f6c544f33000000000000000000000000000000000000000000000000000000008152600401610625929190613b79565b505050505050565b8015806129bf57506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e90604401602060405180830381865afa158015612999573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129bd919061393d565b155b612a4b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152608401610625565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526109c99084907f095ea7b3000000000000000000000000000000000000000000000000000000009060640161235b565b6000612b03826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16612fa39092919063ffffffff16565b8051909150156109c95780806020019051810190612b219190613ba8565b6109c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610625565b60606105bd73ffffffffffffffffffffffffffffffffffffffff831660145b60606000612bdb83600261387b565b612be69060026138e0565b67ffffffffffffffff811115612bfe57612bfe61322a565b6040519080825280601f01601f191660200182016040528015612c28576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110612c5f57612c5f613bc5565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110612cc257612cc2613bc5565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000612cfe84600261387b565b612d099060016138e0565b90505b6001811115612da6577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110612d4a57612d4a613bc5565b1a60f81b828281518110612d6057612d60613bc5565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93612d9f81613bf4565b9050612d0c565b508315612e0f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610625565b9392505050565b600073ffffffffffffffffffffffffffffffffffffffff8216612e3a575047919050565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa158015612ea4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105bd919061393d565b919050565b6000612eda8260206138e0565b83511015612f14576040517f40f0f32900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50016020015190565b8181016020810151604082015160419092015190919060ff16601b811015612f4d57612f4a601b82613c29565b90505b8060ff16601b14158015612f6557508060ff16601c14155b15612f9c576040517f18ce829400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250925092565b6060612fb28484600085612fba565b949350505050565b60608247101561304c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610625565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516130759190613a6f565b60006040518083038185875af1925050503d80600081146130b2576040519150601f19603f3d011682016040523d82523d6000602084013e6130b7565b606091505b509150915061212a87838387606083156131595782516000036131525773ffffffffffffffffffffffffffffffffffffffff85163b613152576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610625565b5081612fb2565b612fb2838381511561316e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106259190613b56565b6000602082840312156131b457600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114612e0f57600080fd5b6000602082840312156131f657600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff81168114610bc257600080fd5b8035612ec8816131fd565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261326a57600080fd5b813567ffffffffffffffff8111156132845761328461322a565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff821117156132f0576132f061322a565b60405281815283820160200185101561330857600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a0868803121561333d57600080fd5b8535613348816131fd565b945060208601359350604086013567ffffffffffffffff81111561336b57600080fd5b61337788828901613259565b935050606086013567ffffffffffffffff81111561339457600080fd5b860161010081890312156133a757600080fd5b9150608086013563ffffffff811681146133c057600080fd5b809150509295509295909350565b600080604083850312156133e157600080fd5b8235915060208301356133f3816131fd565b809150509250929050565b60008083601f84011261341057600080fd5b50813567ffffffffffffffff81111561342857600080fd5b60208301915083602082850101111561224e57600080fd5b6000806000806000806000806000806000806101408d8f03121561346357600080fd5b61346c8d61321f565b9b5060208d01359a5067ffffffffffffffff60408e0135111561348e57600080fd5b61349e8e60408f01358f01613259565b99506134ac60608e0161321f565b985067ffffffffffffffff60808e013511156134c757600080fd5b6134d78e60808f01358f016133fe565b90985096506134e860a08e0161321f565b955060c08d013594506134fd60e08e0161321f565b935061350c6101008e0161321f565b925067ffffffffffffffff6101208e0135111561352857600080fd5b6135398e6101208f01358f016133fe565b81935080925050509295989b509295989b509295989b565b60008060006060848603121561356657600080fd5b8335613571816131fd565b92506020840135613581816131fd565b929592945050506040919091013590565b60008060008060008060a087890312156135ab57600080fd5b86356135b6816131fd565b95506020870135945060408701356135cd816131fd565b9350606087013567ffffffffffffffff8111156135e957600080fd5b6135f589828a016133fe565b9094509250506080870135613609816131fd565b809150509295509295509295565b803561ffff81168114612ec857600080fd5b60006020828403121561363b57600080fd5b612e0f82613617565b60006020828403121561365657600080fd5b8135612e0f816131fd565b6000806040838503121561367457600080fd5b823561367f816131fd565b915060208301356133f3816131fd565b600060a082840312156136a157600080fd5b50919050565b60008060008060008060008060e0898b0312156136c357600080fd5b88356136ce816131fd565b975060208901359650604089013567ffffffffffffffff8111156136f157600080fd5b6136fd8b828c01613259565b965050606089013567ffffffffffffffff81111561371a57600080fd5b6137268b828c0161368f565b95505061373560808a0161321f565b935060a089013567ffffffffffffffff81111561375157600080fd5b61375d8b828c016133fe565b999c989b50969995989497949560c00135949350505050565b8015158114610bc257600080fd5b6000806040838503121561379757600080fd5b82356137a2816131fd565b915060208301356133f381613776565b600080604083850312156137c557600080fd5b82356137d0816131fd565b91506137de60208401613617565b90509250929050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261381c57600080fd5b83018035915067ffffffffffffffff82111561383757600080fd5b60200191503681900382131561224e57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820281158282048414176105bd576105bd61384c565b6000826138c8577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b818103818111156105bd576105bd61384c565b808201808211156105bd576105bd61384c565b60008060006060848603121561390857600080fd5b835160ff8116811461391957600080fd5b602085015190935061392a816131fd565b6040949094015192959394509192915050565b60006020828403121561394f57600080fd5b5051919050565b6000808585111561396657600080fd5b8386111561397357600080fd5b5050820193919092039150565b80357fffff00000000000000000000000000000000000000000000000000000000000081169060028410156139df577fffff000000000000000000000000000000000000000000000000000000000000808560020360031b1b82161691505b5092915050565b80357fffffffffffffffffffffffffffffffffffffffff00000000000000000000000081169060148410156139df577fffffffffffffffffffffffffffffffffffffffff000000000000000000000000808560140360031b1b82161691505092915050565b60005b83811015613a66578181015183820152602001613a4e565b50506000910152565b60008251613a81818460208701613a4b565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613ac3816017850160208801613a4b565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613b00816028840160208801613a4b565b01602801949350505050565b60008151808452613b24816020860160208601613a4b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000612e0f6020830184613b0c565b8183823760009101908152919050565b73ffffffffffffffffffffffffffffffffffffffff83168152604060208201526000612fb26040830184613b0c565b600060208284031215613bba57600080fd5b8151612e0f81613776565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081613c0357613c0361384c565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b60ff81811683821601908111156105bd576105bd61384c56fea264697066735822122015e8cf855d6c06a87a304a9e8535a47823c0ca36643d1846258b92189d66c9a464736f6c634300081c0033
Deployed Bytecode
0x6080604052600436106101845760003560e01c80638fca8a02116100d6578063d33f532e1161007f578063e1a4521811610059578063e1a45218146104ae578063edc8fef6146104c4578063f39e69a41461050a57600080fd5b8063d33f532e1461044e578063d4a0d4c61461046e578063d547741f1461048e57600080fd5b8063a217fddf116100b0578063a217fddf14610406578063ab804a471461041b578063c7a769691461043b57600080fd5b80638fca8a021461031a57806391d148541461033a5780639879c48d1461038d57600080fd5b806336568abe1161013857806360dc23401161011257806360dc2340146102ba5780636ccae054146102e75780636e8f99c91461030757600080fd5b806336568abe146102725780634d8160ba1461029257806354fd4d50146102a557600080fd5b8063258c16ee11610169578063258c16ee146102035780632f2ff15d1461021657806331f7d9641461023857600080fd5b806301ffc9a714610190578063248a9ca3146101c557600080fd5b3661018b57005b600080fd5b34801561019c57600080fd5b506101b06101ab3660046131a2565b61052a565b60405190151581526020015b60405180910390f35b3480156101d157600080fd5b506101f56101e03660046131e4565b60009081526065602052604090206001015490565b6040519081526020016101bc565b6101f5610211366004613325565b6105c3565b34801561022257600080fd5b506102366102313660046133ce565b6109a4565b005b34801561024457600080fd5b5061024d600081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101bc565b34801561027e57600080fd5b5061023661028d3660046133ce565b6109ce565b6102366102a0366004613440565b610a81565b3480156102b157600080fd5b506101366101f5565b3480156102c657600080fd5b5060995461024d9073ffffffffffffffffffffffffffffffffffffffff1681565b3480156102f357600080fd5b50610236610302366004613551565b610aa3565b6101f5610315366004613592565b610b16565b34801561032657600080fd5b50610236610335366004613629565b610b51565b34801561034657600080fd5b506101b06103553660046133ce565b600091825260656020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561039957600080fd5b506103da6103a8366004613644565b60986020526000908152604090205460ff811690610100900473ffffffffffffffffffffffffffffffffffffffff1682565b60408051921515835273ffffffffffffffffffffffffffffffffffffffff9091166020830152016101bc565b34801561041257600080fd5b506101f5600081565b34801561042757600080fd5b50610236610436366004613661565b610bc5565b6102366104493660046136a7565b610d21565b34801561045a57600080fd5b50610236610469366004613784565b610e7f565b34801561047a57600080fd5b50610236610489366004613644565b610f6e565b34801561049a57600080fd5b506102366104a93660046133ce565b610fdf565b3480156104ba57600080fd5b506101f561271081565b3480156104d057600080fd5b506099546104f79074010000000000000000000000000000000000000000900461ffff1681565b60405161ffff90911681526020016101bc565b34801561051657600080fd5b506102366105253660046137b2565b611004565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806105bd57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b600034158015906105e9575073ffffffffffffffffffffffffffffffffffffffff861615155b1561062e576040517f1fce9ca9000000000000000000000000000000000000000000000000000000008152600060048201523460248201526044015b60405180910390fd5b61063e6080840160608501613644565b73ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16036106a2576040517f55bbdeb000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6106af86868660016111a9565b60006106f68787346106c76040890160208a01613644565b6106d460408a018a6137e7565b6106e460808c0160608d01613644565b6106f160208d018d613644565b6112a6565b506099549091506000906127109061072a9074010000000000000000000000000000000000000000900461ffff168461387b565b6107349190613892565b905061074081836138cd565b9250600061076b6107576080880160608901613644565b8561076560c08a018a6137e7565b896113a8565b905061077781856138cd565b935085608001358410156107f8576107956080870160608801613644565b6040517fc0bf820b00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018490526044810185905260808701356064820152608401610625565b60006108086080880135866138cd565b9050600061271061081f60c08a0160a08b01613629565b61082d9061ffff168461387b565b6108379190613892565b905061084381836138cd565b61084d90856138e0565b935061085d8160808a01356138e0565b955050821590506109335760995473ffffffffffffffffffffffffffffffffffffffff16806108b8576040517f4af6fd5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108d26108cb6080890160608a01613644565b8285611469565b7f5a7af898dfbf9d56c66a7883a2e9229f5c9ff2484d9525f2c80cff815e2328276109036080890160608a01613644565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252602082018690520160405180910390a1505b610998898961094860808a0160608b01613644565b8688600061095d6101008e0160e08f01613644565b73ffffffffffffffffffffffffffffffffffffffff161461098e576109896101008d0160e08e01613644565b610990565b335b88888d6114b5565b50505095945050505050565b6000828152606560205260409020600101546109bf81611553565b6109c9838361155d565b505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610a73576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610625565b610a7d8282611651565b5050565b610a958c8c8c8c8c8c8c8c8c8c8c8c61170c565b505050505050505050505050565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16610b0b576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109c9838383611469565b6000610b3487876040518060200160405280600081525060006111a9565b610b458787348888888860006112a6565b50979650505050505050565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16610bb9576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bc281611852565b50565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16610c2d576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff811660009081526098602052604090205460ff16610c8c576040517f2a070fb400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82811660008181526098602090815260409182902080547fffffffffffffffffffffff0000000000000000000000000000000000000000ff1661010095871695860217905581519283528201929092527f17acbaf0bcb36a981255b884e821edcf811a3b401972432678b01cd1a7f0d50091015b60405180910390a15050565b6040517f5b2f30e90000000000000000000000000000000000000000000000000000000081526004810182905260009073ffffffffffffffffffffffffffffffffffffffff861690635b2f30e990602401606060405180830381865afa158015610d8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db391906138f3565b505090508060ff16600014610e24576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4f524445525f46554c46494c4c45445f4f525f43414e43454c4c4544000000006044820152606401610625565b50610e75888888610e3860208a018a613644565b610e4560208b018b6137e7565b610e5560608d0160408e01613644565b8c606001358d6080016020810190610e6d9190613644565b8d8d8d61170c565b5050505050505050565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16610ee7576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff821660008181526098602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168515159081179091558251938452908301527f3fc30fe9d1afedc310e6ec6fd5f84b0ae3b800cdc1bcb04b65b986fdd35868f09101610d15565b3360009081527fffdfc1249c027f9191656349feb0761381bb32c9f557e01f419fd08754bf5a1b602052604090205460ff16610fd6576040517fde8e41fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bc281611975565b600082815260656020526040902060010154610ffa81611553565b6109c98383611651565b600054610100900460ff16158080156110245750600054600160ff909116105b8061103e5750303b15801561103e575060005460ff166001145b6110ca576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610625565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561112857600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b611130611a35565b61113983611975565b61114282611852565b80156109c957600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b73ffffffffffffffffffffffffffffffffffffffff84166112525782341015611201576040517fc0159a6100000000000000000000000000000000000000000000000000000000815260048101849052602401610625565b80801561120d57508234115b1561124d576040517f1fce9ca900000000000000000000000000000000000000000000000000000000815260048101849052346024820152604401610625565b6112a0565b600061125f858585611bc3565b90508381101561129e576040517fc0159a6100000000000000000000000000000000000000000000000000000000815260048101859052602401610625565b505b50505050565b600080806112b489476138cd565b905073ffffffffffffffffffffffffffffffffffffffff8b166112e5576112de8888888d89611d67565b9250611328565b6112f18b89868d611f05565b73ffffffffffffffffffffffffffffffffffffffff8516611317576112de8888886120d2565b611325888888600089611d67565b92505b6040805173ffffffffffffffffffffffffffffffffffffffff8a811682528d811660208301528183018d9052871660608201526080810185905290517fdde2f3711ab09cdddcfee16ca03e54d21fb8cf3fa647b9797913c950d38ad6939181900360a00190a161139881476138cd565b9150509850989650505050505050565b60008060006113b78686612135565b915091508161ffff166000036113d257600092505050611460565b6127106113e361ffff84168961387b565b6113ed9190613892565b92506113fa888285611469565b6040805173ffffffffffffffffffffffffffffffffffffffff8a811682526020820186905283168183015263ffffffff8616606082015290517f6a0f4594999005114d250d0dce53dea802de70666f009552d1aa0b39e58463619181900360800190a150505b95945050505050565b80156109c95773ffffffffffffffffffffffffffffffffffffffff8316611494576109c98282612255565b6109c973ffffffffffffffffffffffffffffffffffffffff84168383612309565b6114c0878587611469565b6040805133815273ffffffffffffffffffffffffffffffffffffffff86811660208301528b811682840152606082018b90528916608082015260a0810188905260c0810185905260e0810184905263ffffffff831661010082015290517fecfedc7a2bb58de8119427cef1d856aa76747d4a6e13307a7ca485bf8df20904918190036101200190a1505050505050505050565b610bc281336123dd565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610a7d57600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556115f33390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1615610a7d57600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6117198c8c8c60006111a9565b60008061172d8e8e348e8e8e8e60006112a6565b915091508187111561176e576040517fc0159a6100000000000000000000000000000000000000000000000000000000815260048101889052602401610625565b8187101561183457600061178288846138cd565b905073ffffffffffffffffffffffffffffffffffffffff89166117ba576117a98782612255565b6117b381836138cd565b91506117db565b6117db73ffffffffffffffffffffffffffffffffffffffff8a168883612309565b6040805173ffffffffffffffffffffffffffffffffffffffff8b811682526020820184905289168183015290517f149635d19f798f6b7c74c74a500d362c89316a0ab808abe5e0c0de45da9b1d2c9181900360600190a1505b611842858585848c8c612497565b5050505050505050505050505050565b6127108161ffff161115611892576040517f0bcf616f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008161ffff161180156118bc575060995473ffffffffffffffffffffffffffffffffffffffff16155b156118f3576040517f4af6fd5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b609980547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8416908102919091179091556040519081527f6b24b4ecbdb33b853813a087738a34121649900030572f4286ddf4ad24586386906020015b60405180910390a150565b73ffffffffffffffffffffffffffffffffffffffff81166119c2576040517f4af6fd5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b609980547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f10d6c00fd9d176c2872e8e72b76641ca85aba29bb682a658aeedbc38814fe45f9060200161196a565b600054610100900460ff1615808015611a555750600054600160ff909116105b80611a6f5750303b158015611a6f575060005460ff166001145b611afb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610625565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558015611b5957600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b611b646000336125bb565b8015610bc257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200161196a565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600090819073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190602401602060405180830381865afa158015611c32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c56919061393d565b9050611c6285846125c5565b611c8473ffffffffffffffffffffffffffffffffffffffff86163330876127ad565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8716906370a0823190602401602060405180830381865afa158015611cf1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d15919061393d565b9050818111611d53576040517fc0159a6100000000000000000000000000000000000000000000000000000000815260048101869052602401610625565b611d5d82826138cd565b9695505050505050565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600090819073ffffffffffffffffffffffffffffffffffffffff8416906370a0823190602401602060405180830381865afa158015611dd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dfa919061393d565b9050611e088787878761280b565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8516906370a0823190602401602060405180830381865afa158015611e75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e99919061393d565b9050808210611eec576040517f5743851400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401610625565b6000611ef883836138cd565b9998505050505050505050565b838373ffffffffffffffffffffffffffffffffffffffff841615611f895773ffffffffffffffffffffffffffffffffffffffff841660009081526098602052604090205460ff16611f82576040517f2a070fb400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5082611fc2565b73ffffffffffffffffffffffffffffffffffffffff8086166000908152609860205260409020546101009004168015611fc0578091505b505b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff82811660248301526000919084169063dd62ed3e90604401602060405180830381865afa158015612038573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061205c919061393d565b9050838110156120c95761208873ffffffffffffffffffffffffffffffffffffffff841683600061291f565b6120c973ffffffffffffffffffffffffffffffffffffffff8416837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61291f565b50505050505050565b6000476120e18585858561280b565b4780821061211e576040517f5743851400000000000000000000000000000000000000000000000000000000815260006004820152602401610625565b600061212a83836138cd565b979650505050505050565b60008082810361214a5750600090508061224e565b60168314612187576040517f611a89c400000000000000000000000000000000000000000000000000000000815260048101849052602401610625565b612195600260008587613956565b61219e91613980565b60f01c91506121b1601660028587613956565b6121ba916139e6565b60601c90506127108261ffff1611806121f5575061ffff8216158015906121f5575073ffffffffffffffffffffffffffffffffffffffff8116155b1561224e576040517fce8f8d9300000000000000000000000000000000000000000000000000000000815261ffff8316600482015273ffffffffffffffffffffffffffffffffffffffff82166024820152604401610625565b9250929050565b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff841690839060405161228c9190613a6f565b60006040518083038185875af1925050503d80600081146122c9576040519150601f19603f3d011682016040523d82523d6000602084013e6122ce565b606091505b50509050806109c9576040517f6d963f8800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526109c99084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612aa1565b600082815260656020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16610a7d5761241d81612bad565b612428836020612bcc565b604051602001612439929190613a8b565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a000000000000000000000000000000000000000000000000000000000825261062591600401613b56565b60006124a283612e16565b905060006124b06000612e16565b905073ffffffffffffffffffffffffffffffffffffffff8416156124db576124db8489600086611f05565b6124e78888888861280b565b60006124f285612e16565b905060006125006000612e16565b90508461250d83866138cd565b101561258757898661251f87876138cd565b61252985886138cd565b6040517ff52b9cd600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff948516600482015293909216602484015260448301526064820152608401610625565b8661259282856138cd565b10156125af578960006125a589876138cd565b61252984876138cd565b50505050505050505050565b610a7d828261155d565b805115610a7d5760006125d88282612ecd565b905060006125e7836020612ecd565b9050600080806125f8866040612f1d565b6040517fd505accf000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018990526064810188905260ff8216608482015260a4810184905260c48101839052929550909350915073ffffffffffffffffffffffffffffffffffffffff88169063d505accf9060e401600060405180830381600087803b15801561269257600080fd5b505af19250505080156126a3575060015b6120c9576040517fdd62ed3e000000000000000000000000000000000000000000000000000000008152336004820152306024820152859073ffffffffffffffffffffffffffffffffffffffff89169063dd62ed3e90604401602060405180830381865afa158015612719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061273d919061393d565b1061274b5750505050505050565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f5065726d6974206661696c7572650000000000000000000000000000000000006044820152606401610625565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526112a09085907f23b872dd000000000000000000000000000000000000000000000000000000009060840161235b565b73ffffffffffffffffffffffffffffffffffffffff841660009081526098602052604090205460ff1661286a576040517f2a070fb400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808573ffffffffffffffffffffffffffffffffffffffff16838686604051612895929190613b69565b60006040518083038185875af1925050503d80600081146128d2576040519150601f19603f3d011682016040523d82523d6000602084013e6128d7565b606091505b5091509150816129175785816040517f6c544f33000000000000000000000000000000000000000000000000000000008152600401610625929190613b79565b505050505050565b8015806129bf57506040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff838116602483015284169063dd62ed3e90604401602060405180830381865afa158015612999573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129bd919061393d565b155b612a4b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152608401610625565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526109c99084907f095ea7b3000000000000000000000000000000000000000000000000000000009060640161235b565b6000612b03826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16612fa39092919063ffffffff16565b8051909150156109c95780806020019051810190612b219190613ba8565b6109c9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610625565b60606105bd73ffffffffffffffffffffffffffffffffffffffff831660145b60606000612bdb83600261387b565b612be69060026138e0565b67ffffffffffffffff811115612bfe57612bfe61322a565b6040519080825280601f01601f191660200182016040528015612c28576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110612c5f57612c5f613bc5565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110612cc257612cc2613bc5565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000612cfe84600261387b565b612d099060016138e0565b90505b6001811115612da6577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110612d4a57612d4a613bc5565b1a60f81b828281518110612d6057612d60613bc5565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93612d9f81613bf4565b9050612d0c565b508315612e0f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610625565b9392505050565b600073ffffffffffffffffffffffffffffffffffffffff8216612e3a575047919050565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa158015612ea4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105bd919061393d565b919050565b6000612eda8260206138e0565b83511015612f14576040517f40f0f32900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50016020015190565b8181016020810151604082015160419092015190919060ff16601b811015612f4d57612f4a601b82613c29565b90505b8060ff16601b14158015612f6557508060ff16601c14155b15612f9c576040517f18ce829400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250925092565b6060612fb28484600085612fba565b949350505050565b60608247101561304c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610625565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516130759190613a6f565b60006040518083038185875af1925050503d80600081146130b2576040519150601f19603f3d011682016040523d82523d6000602084013e6130b7565b606091505b509150915061212a87838387606083156131595782516000036131525773ffffffffffffffffffffffffffffffffffffffff85163b613152576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610625565b5081612fb2565b612fb2838381511561316e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106259190613b56565b6000602082840312156131b457600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114612e0f57600080fd5b6000602082840312156131f657600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff81168114610bc257600080fd5b8035612ec8816131fd565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261326a57600080fd5b813567ffffffffffffffff8111156132845761328461322a565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff821117156132f0576132f061322a565b60405281815283820160200185101561330857600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a0868803121561333d57600080fd5b8535613348816131fd565b945060208601359350604086013567ffffffffffffffff81111561336b57600080fd5b61337788828901613259565b935050606086013567ffffffffffffffff81111561339457600080fd5b860161010081890312156133a757600080fd5b9150608086013563ffffffff811681146133c057600080fd5b809150509295509295909350565b600080604083850312156133e157600080fd5b8235915060208301356133f3816131fd565b809150509250929050565b60008083601f84011261341057600080fd5b50813567ffffffffffffffff81111561342857600080fd5b60208301915083602082850101111561224e57600080fd5b6000806000806000806000806000806000806101408d8f03121561346357600080fd5b61346c8d61321f565b9b5060208d01359a5067ffffffffffffffff60408e0135111561348e57600080fd5b61349e8e60408f01358f01613259565b99506134ac60608e0161321f565b985067ffffffffffffffff60808e013511156134c757600080fd5b6134d78e60808f01358f016133fe565b90985096506134e860a08e0161321f565b955060c08d013594506134fd60e08e0161321f565b935061350c6101008e0161321f565b925067ffffffffffffffff6101208e0135111561352857600080fd5b6135398e6101208f01358f016133fe565b81935080925050509295989b509295989b509295989b565b60008060006060848603121561356657600080fd5b8335613571816131fd565b92506020840135613581816131fd565b929592945050506040919091013590565b60008060008060008060a087890312156135ab57600080fd5b86356135b6816131fd565b95506020870135945060408701356135cd816131fd565b9350606087013567ffffffffffffffff8111156135e957600080fd5b6135f589828a016133fe565b9094509250506080870135613609816131fd565b809150509295509295509295565b803561ffff81168114612ec857600080fd5b60006020828403121561363b57600080fd5b612e0f82613617565b60006020828403121561365657600080fd5b8135612e0f816131fd565b6000806040838503121561367457600080fd5b823561367f816131fd565b915060208301356133f3816131fd565b600060a082840312156136a157600080fd5b50919050565b60008060008060008060008060e0898b0312156136c357600080fd5b88356136ce816131fd565b975060208901359650604089013567ffffffffffffffff8111156136f157600080fd5b6136fd8b828c01613259565b965050606089013567ffffffffffffffff81111561371a57600080fd5b6137268b828c0161368f565b95505061373560808a0161321f565b935060a089013567ffffffffffffffff81111561375157600080fd5b61375d8b828c016133fe565b999c989b50969995989497949560c00135949350505050565b8015158114610bc257600080fd5b6000806040838503121561379757600080fd5b82356137a2816131fd565b915060208301356133f381613776565b600080604083850312156137c557600080fd5b82356137d0816131fd565b91506137de60208401613617565b90509250929050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261381c57600080fd5b83018035915067ffffffffffffffff82111561383757600080fd5b60200191503681900382131561224e57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820281158282048414176105bd576105bd61384c565b6000826138c8577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b818103818111156105bd576105bd61384c565b808201808211156105bd576105bd61384c565b60008060006060848603121561390857600080fd5b835160ff8116811461391957600080fd5b602085015190935061392a816131fd565b6040949094015192959394509192915050565b60006020828403121561394f57600080fd5b5051919050565b6000808585111561396657600080fd5b8386111561397357600080fd5b5050820193919092039150565b80357fffff00000000000000000000000000000000000000000000000000000000000081169060028410156139df577fffff000000000000000000000000000000000000000000000000000000000000808560020360031b1b82161691505b5092915050565b80357fffffffffffffffffffffffffffffffffffffffff00000000000000000000000081169060148410156139df577fffffffffffffffffffffffffffffffffffffffff000000000000000000000000808560140360031b1b82161691505092915050565b60005b83811015613a66578181015183820152602001613a4e565b50506000910152565b60008251613a81818460208701613a4b565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613ac3816017850160208801613a4b565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613b00816028840160208801613a4b565b01602801949350505050565b60008151808452613b24816020860160208601613a4b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000612e0f6020830184613b0c565b8183823760009101908152919050565b73ffffffffffffffffffffffffffffffffffffffff83168152604060208201526000612fb26040830184613b0c565b600060208284031215613bba57600080fd5b8151612e0f81613776565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081613c0357613c0361384c565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b60ff81811683821601908111156105bd576105bd61384c56fea264697066735822122015e8cf855d6c06a87a304a9e8535a47823c0ca36643d1846258b92189d66c9a464736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.