ETH Price: $3,414.60 (+1.23%)

Contract

0x777e05D02Ea7B42F32f103c089C175017082f531
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Register Remote ...198185112024-05-07 13:32:47203 days ago1715088767IN
0x777e05D0...17082f531
0 ETH0.00079888.75973766
Register Remote ...196704552024-04-16 20:34:47224 days ago1713299687IN
0x777e05D0...17082f531
0 ETH0.000857759.40982441
Register Remote ...196203742024-04-09 20:09:59231 days ago1712693399IN
0x777e05D0...17082f531
0 ETH0.0024537226.91815229
Register Remote ...196202332024-04-09 19:41:47231 days ago1712691707IN
0x777e05D0...17082f531
0 ETH0.0007900725.10813465
Register Remote ...196202232024-04-09 19:39:47231 days ago1712691587IN
0x777e05D0...17082f531
0 ETH0.0021207923.26278257
Register Remote ...194793252024-03-20 23:56:59251 days ago1710979019IN
0x777e05D0...17082f531
0 ETH0.0011370236.1613911
Register Remote ...194793212024-03-20 23:56:11251 days ago1710978971IN
0x777e05D0...17082f531
0 ETH0.0031063434.0731409
Register Remote ...194793092024-03-20 23:53:47251 days ago1710978827IN
0x777e05D0...17082f531
0 ETH0.0011010635.00434994
Register Remote ...194792672024-03-20 23:45:23251 days ago1710978323IN
0x777e05D0...17082f531
0 ETH0.0029242932.07203637
Register Remote ...194791922024-03-20 23:30:11251 days ago1710977411IN
0x777e05D0...17082f531
0 ETH0.0035823339.2993423
Register Remote ...194790312024-03-20 22:57:35251 days ago1710975455IN
0x777e05D0...17082f531
0 ETH0.0036238739.76031006
Register Remote ...194789162024-03-20 22:34:23251 days ago1710974063IN
0x777e05D0...17082f531
0 ETH0.0036870340.45325183
Register Remote ...194789102024-03-20 22:33:11251 days ago1710973991IN
0x777e05D0...17082f531
0 ETH0.0038244641.95566716
Set Bridge Execu...194724582024-03-20 0:49:47252 days ago1710895787IN
0x777e05D0...17082f531
0 ETH0.0014419331.17357334
Set Router194724582024-03-20 0:49:47252 days ago1710895787IN
0x777e05D0...17082f531
0 ETH0.0014412431.17357334
Set Utb194724582024-03-20 0:49:47252 days ago1710895787IN
0x777e05D0...17082f531
0 ETH0.0014440231.17357334
0x60806040194724142024-03-20 0:40:59252 days ago1710895259IN
 Create: StargateBridgeAdapter
0 ETH0.0516512629.85235804

Latest 2 internal transactions

Advanced mode:
Parent Transaction Hash Block From To
195516072024-03-31 4:48:59241 days ago1711860539
0x777e05D0...17082f531
0.00049937 ETH
195516072024-03-31 4:48:59241 days ago1711860539
0x777e05D0...17082f531
0.00049937 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StargateBridgeAdapter

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 19 : StargateBridgeAdapter.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import {IERC20} from "forge-std/interfaces/IERC20.sol";
import {IUTB} from "../interfaces/IUTB.sol";
import {IBridgeAdapter} from "../interfaces/IBridgeAdapter.sol";
import {SwapInstructions} from "../CommonTypes.sol";
import {SwapParams} from "../swappers/SwapParams.sol";
import {IStargateRouter, LzBridgeData} from "./stargate/IStargateRouter.sol";
import {IStargateReceiver} from "./stargate/IStargateReceiver.sol";
import {BaseAdapter} from "./BaseAdapter.sol";

// pool ids: https://stargateprotocol.gitbook.io/stargate/developers/pool-ids
// chain ids: https://stargateprotocol.gitbook.io/stargate/developers/chain-ids

contract StargateBridgeAdapter is
    BaseAdapter,
    IBridgeAdapter,
    IStargateReceiver
{
    uint8 public constant BRIDGE_ID = 1;
    uint8 public constant SG_FEE_BPS = 6;
    mapping(uint256 => address) public destinationBridgeAdapter;
    mapping(uint256 => uint16) public lzIdLookup;
    mapping(uint16 => uint256) public chainIdLookup;

    constructor() BaseAdapter() {}

    IStargateRouter public router;

    function setRouter(address _router) public onlyAdmin {
        router = IStargateRouter(_router);
    }

    function getId() public pure returns (uint8) {
        return BRIDGE_ID;
    }

    function registerRemoteBridgeAdapter(
        uint256 dstChainId,
        uint16 dstLzId,
        address decentBridgeAdapter
    ) public onlyAdmin {
        lzIdLookup[dstChainId] = dstLzId;
        chainIdLookup[dstLzId] = dstChainId;
        destinationBridgeAdapter[dstChainId] = decentBridgeAdapter;
    }

    function getBridgeToken(
        bytes calldata additionalArgs
    ) external pure returns (address bridgeToken) {
        bridgeToken = abi.decode(additionalArgs, (address));
    }

    function getBridgedAmount(
        uint256 amt2Bridge,
        address /*preBridgeToken*/,
        address /*postBridgeToken*/,
        bytes calldata additionalArgs
    ) external pure returns (uint256) {
        return (amt2Bridge * (100_00 - getSlippage(additionalArgs) - SG_FEE_BPS)) / 100_00;
    }

    function bridge(
        uint256 amt2Bridge,
        SwapInstructions memory postBridge,
        uint256 dstChainId,
        address target,
        address paymentOperator,
        bytes memory payload,
        bytes calldata additionalArgs,
        address refund
    ) public payable onlyUtb returns (bytes memory bridgePayload) {
        address bridgeToken = abi.decode(additionalArgs, (address));

        bridgePayload = abi.encode(
            postBridge,
            target,
            paymentOperator,
            payload,
            payable(refund)
        );

        if ( bridgeToken != address(0) ) {
            IERC20(bridgeToken).transferFrom(msg.sender, address(this), amt2Bridge);
            IERC20(bridgeToken).approve(address(router), amt2Bridge);
        }

        callBridge(
            amt2Bridge,
            dstChainId,
            bridgePayload,
            additionalArgs,
            refund
        );
    }

    function getValue(
        bytes calldata additionalArgs,
        uint256 amt2Bridge
    ) private pure returns (uint value) {
        (address bridgeToken, LzBridgeData memory lzBridgeData) = abi.decode(
            additionalArgs,
            (address, LzBridgeData)
        );
        return bridgeToken == address(0)
            ? (lzBridgeData.fee + amt2Bridge)
            : lzBridgeData.fee;
    }

    function getLzTxObj(
        bytes calldata additionalArgs
    ) private pure returns (IStargateRouter.lzTxObj memory) {
        (, , IStargateRouter.lzTxObj memory lzTxObj) = abi.decode(
            additionalArgs,
            (address, LzBridgeData, IStargateRouter.lzTxObj)
        );
        return lzTxObj;
    }

    function getSlippage(
        bytes calldata additionalArgs
    ) private pure returns (uint16) {
        (, , , uint16 slippage) = abi.decode(
            additionalArgs,
            (address, LzBridgeData, IStargateRouter.lzTxObj, uint16)
        );
        return slippage;
    }

    function getDstChainId(
        bytes calldata additionalArgs
    ) private pure returns (uint16) {
        (, LzBridgeData memory lzBridgeData, ) = abi.decode(
            additionalArgs,
            (address, LzBridgeData, IStargateRouter.lzTxObj)
        );
        return lzBridgeData._dstChainId;
    }

    function getSrcPoolId(
        bytes calldata additionalArgs
    ) private pure returns (uint120) {
        (, LzBridgeData memory lzBridgeData, ) = abi.decode(
            additionalArgs,
            (address, LzBridgeData, IStargateRouter.lzTxObj)
        );
        return lzBridgeData._srcPoolId;
    }

    function getDstPoolId(
        bytes calldata additionalArgs
    ) private pure returns (uint120) {
        (, LzBridgeData memory lzBridgeData, ) = abi.decode(
            additionalArgs,
            (address, LzBridgeData, IStargateRouter.lzTxObj)
        );
        return lzBridgeData._dstPoolId;
    }

    function getDestAdapter(uint chainId) private view returns (address dstAddr) {
        dstAddr = destinationBridgeAdapter[chainId];

        if (dstAddr == address(0)) revert NoDstBridge();
    }

    function callBridge(
        uint256 amt2Bridge,
        uint256 dstChainId,
        bytes memory bridgePayload,
        bytes calldata additionalArgs,
        address refund
    ) private {
        router.swap{value: getValue(additionalArgs, amt2Bridge)}(
            getDstChainId(additionalArgs), //lzBridgeData._dstChainId, // send to LayerZero chainId
            getSrcPoolId(additionalArgs), //lzBridgeData._srcPoolId, // source pool id
            getDstPoolId(additionalArgs), //lzBridgeData._dstPoolId, // dst pool id
            payable(refund), // refund adddress. extra gas (if any) is returned to this address
            amt2Bridge, // quantity to swap
            (amt2Bridge * (100_00 - getSlippage(additionalArgs) - SG_FEE_BPS)) / 100_00, // the min qty you would accept on the destination, fee is 6 bips
            getLzTxObj(additionalArgs), // additional gasLimit increase, airdrop, at address
            abi.encodePacked(getDestAdapter(dstChainId)),
            bridgePayload // bytes param, if you wish to send additional payload you can abi.encode() them here
        );
    }

    function sgReceive(
        uint16, // _srcChainid
        bytes memory, // _srcAddress
        uint256, // _nonce
        address tokenIn, // _token
        uint256 amountLD, // amountLD
        bytes memory payload
    ) external override onlyExecutor {
        (
            SwapInstructions memory postBridge,
            address target,
            address paymentOperator,
            bytes memory utbPayload,
            address payable refund
        ) = abi.decode(
                payload,
                (SwapInstructions, address, address, bytes, address)
            );

        SwapParams memory swapParams = abi.decode(
            postBridge.swapPayload,
            (SwapParams)
        );

        uint256 bridgeValue;
        if ( swapParams.tokenIn == address(0) ) {
            bridgeValue = swapParams.amountIn;
        } else {
            IERC20(swapParams.tokenIn).approve(utb, swapParams.amountIn);
        }

        if ( amountLD > swapParams.amountIn ) {
            _refundUser(refund, tokenIn, amountLD - swapParams.amountIn);
        }

        IUTB(utb).receiveFromBridge{value: bridgeValue}(
            postBridge,
            target,
            paymentOperator,
            utbPayload,
            refund,
            BRIDGE_ID
        );
    }

    function _refundUser(address user, address token, uint amount) private {
        if ( token == address(0) ) {
            (bool success, ) = user.call{value: amount}("");
            require(success);
        } else {
            IERC20(token).transfer(user, amount);
        }
    }

    receive() external payable {}

    fallback() external payable {}
}

File 2 of 19 : IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2;

/// @dev Interface of the ERC20 standard as defined in the EIP.
/// @dev This includes the optional name, symbol, and decimals metadata.
interface IERC20 {
    /// @dev Emitted when `value` tokens are moved from one account (`from`) to another (`to`).
    event Transfer(address indexed from, address indexed to, uint256 value);

    /// @dev Emitted when the allowance of a `spender` for an `owner` is set, where `value`
    /// is the new allowance.
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /// @notice Returns the amount of tokens in existence.
    function totalSupply() external view returns (uint256);

    /// @notice Returns the amount of tokens owned by `account`.
    function balanceOf(address account) external view returns (uint256);

    /// @notice Moves `amount` tokens from the caller's account to `to`.
    function transfer(address to, uint256 amount) external returns (bool);

    /// @notice Returns the remaining number of tokens that `spender` is allowed
    /// to spend on behalf of `owner`
    function allowance(address owner, address spender) external view returns (uint256);

    /// @notice Sets `amount` as the allowance of `spender` over the caller's tokens.
    /// @dev Be aware of front-running risks: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
    function approve(address spender, uint256 amount) external returns (bool);

    /// @notice Moves `amount` tokens from `from` to `to` using the allowance mechanism.
    /// `amount` is then deducted from the caller's allowance.
    function transferFrom(address from, address to, uint256 amount) external returns (bool);

    /// @notice Returns the name of the token.
    function name() external view returns (string memory);

    /// @notice Returns the symbol of the token.
    function symbol() external view returns (string memory);

    /// @notice Returns the decimals places of the token.
    function decimals() external view returns (uint8);
}

File 3 of 19 : IUTB.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import {SwapInstructions, FeeData, BridgeInstructions, SwapAndExecuteInstructions} from "../CommonTypes.sol";

interface IUTB {

    event Swapped();
    event BridgeCalled();
    event RecievedFromBridge();

    /// @notice Thrown when protocol fees cannot be collected
    error ProtocolFeeCannotBeFetched();

    /// @notice Thrown when UTB is paused
    error UTBPaused();

    /// @notice Thrown when not enough native is passed for swap
    error NotEnoughNative();

    /// @notice Thrown when receive from bridge is not called from a bridge adapter
    error OnlyBridgeAdapter();

    /**
     * @dev Swaps currency from the incoming to the outgoing token and executes a transaction with payment.
     * @param instructions The token swap data and payment transaction payload.
     * @param feeData The bridge fee in native, as well as utb fee tokens and amounts.
     * @param signature The ECDSA signature to verify the fee structure.
     */
    function swapAndExecute(
        SwapAndExecuteInstructions memory instructions,
        FeeData memory feeData,
        bytes memory signature
    ) external payable;

    /**
     * @dev Bridges funds in native or ERC20 and a payment transaction payload to the destination chain
     * @param instructions The bridge data, token swap data, and payment transaction payload.
     * @param feeData The bridge fee in native, as well as utb fee tokens and amounts.
     * @param signature The ECDSA signature to verify the fee structure.
     */
    function bridgeAndExecute(
        BridgeInstructions memory instructions,
        FeeData memory feeData,
        bytes memory signature
    ) external payable returns (bytes memory);

    /**
     * @dev Receives funds from the bridge adapter, executes a swap, and executes a payment transaction.
     * @param postBridge The swapper ID and calldata to execute a swap.
     * @param target The address of the target contract for the payment transaction.
     * @param paymentOperator The operator address for payment transfers requiring ERC20 approvals.
     * @param payload The calldata to execute the payment transaction.
     * @param refund The account receiving any refunds, typically the EOA which initiated the transaction.
     */
    function receiveFromBridge(
        SwapInstructions memory postBridge,
        address target,
        address paymentOperator,
        bytes memory payload,
        address refund,
        uint8 bridgeId
    ) external payable;

    /**
     * @dev Registers and maps a bridge adapter to a bridge adapter ID.
     * @param bridge The address of the bridge adapter.
     */
    function registerBridge(address bridge) external;

    /**
     * @dev Registers and maps a swapper to a swapper ID.
     * @param swapper The address of the swapper.
     */
    function registerSwapper(address swapper) external;

    function setExecutor(address _executor) external;

    function setFeeManager(address _feeManager) external;

    function setWrapped(address _wrapped) external;
}

File 4 of 19 : IBridgeAdapter.sol
pragma solidity ^0.8.0;

import {SwapInstructions} from "../CommonTypes.sol";

interface IBridgeAdapter {

    error NoDstBridge();

    function getId() external returns (uint8);

    function getBridgeToken(
        bytes calldata additionalArgs
    ) external returns (address);

    function getBridgedAmount(
        uint256 amt2Bridge,
        address preBridgeToken,
        address postBridgeToken,
        bytes calldata additionalArgs
    ) external returns (uint256);

    function bridge(
        uint256 amt2Bridge,
        SwapInstructions memory postBridge,
        uint256 dstChainId,
        address target,
        address paymentOperator,
        bytes memory payload,
        bytes calldata additionalArgs,
        address refund
    ) external payable returns (bytes memory);
}

File 5 of 19 : CommonTypes.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

struct SwapInstructions {
    uint8 swapperId;
    bytes swapPayload;
}

struct FeeData {
    bytes4 appId;
    bytes4 affiliateId;
    uint bridgeFee;
    Fee[] appFees;
}

struct Fee {
    address recipient;
    address token;
    uint amount;
}

struct SwapAndExecuteInstructions {
    SwapInstructions swapInstructions;
    address target;
    address paymentOperator;
    address refund;
    bytes payload;
}

struct BridgeInstructions {
    SwapInstructions preBridge;
    SwapInstructions postBridge;
    uint8 bridgeId;
    uint256 dstChainId;
    address target;
    address paymentOperator;
    address refund;
    bytes payload;
    bytes additionalArgs;
}

File 6 of 19 : SwapParams.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

library SwapDirection {
    uint8 constant EXACT_IN = 0;
    uint8 constant EXACT_OUT = 1;
}

struct SwapParams {
    uint256 amountIn;
    uint256 amountOut;
    address tokenIn;
    address tokenOut;
    uint8 direction;
    // if direction is exactAmountIn
    // then amount out will be the minimum amount out
    // if direction is exactAmountOutA
    // then amount in is maximum amount in
    bytes path;
}

File 7 of 19 : IStargateRouter.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
pragma abicoder v2;

struct LzBridgeData {
    uint120 _srcPoolId;
    uint120 _dstPoolId;
    uint16 _dstChainId;
    address _bridgeAddress;
    uint96 fee;
}

interface IStargateRouter {
    struct lzTxObj {
        uint256 dstGasForCall;
        uint256 dstNativeAmount;
        bytes dstNativeAddr;
    }

    function addLiquidity(
        uint256 _poolId,
        uint256 _amountLD,
        address _to
    ) external;

    function swap(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLD,
        uint256 _minAmountLD,
        lzTxObj memory _lzTxParams,
        bytes calldata _to,
        bytes calldata _payload
    ) external payable;

    function redeemRemote(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLP,
        uint256 _minAmountLD,
        bytes calldata _to,
        lzTxObj memory _lzTxParams
    ) external payable;

    function instantRedeemLocal(
        uint16 _srcPoolId,
        uint256 _amountLP,
        address _to
    ) external returns (uint256);

    function redeemLocal(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLP,
        bytes calldata _to,
        lzTxObj memory _lzTxParams
    ) external payable;

    function sendCredits(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress
    ) external payable;

    function quoteLayerZeroFee(
        uint16 _dstChainId,
        uint8 _functionType,
        bytes calldata _toAddress,
        bytes calldata _transferAndCallPayload,
        lzTxObj memory _lzTxParams
    ) external view returns (uint256, uint256);
}

File 8 of 19 : IStargateReceiver.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

interface IStargateReceiver {
    event ReceivedOnDestination(address token, uint256 amountLD);

    /*
     * @dev Called by the Stargate Router on the destination chain upon bridging funds
     * @dev unused @param _srcChainId The remote chainId sending the tokens
     * @dev unused @param _srcAddress The remote Bridge address
     * @dev unused @param _nonce The message ordering nonce
     * @param _token The token contract on the local chain
     * @param amountLD The qty of local _token contract tokens
     * @param payload The bytes containing the execution paramaters
     */
    function sgReceive(
        uint16, // _srcChainId
        bytes memory, // _srcAddress
        uint256, // _nonce
        address _token,
        uint256 amountLD,
        bytes memory payload
    ) external;
}

File 9 of 19 : BaseAdapter.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import {UTBOwned} from "../UTBOwned.sol";

contract BaseAdapter is UTBOwned {
    address public bridgeExecutor;

    constructor() UTBOwned() {}

    error OnlyExecutor();
    modifier onlyExecutor() {
        if (msg.sender != address(bridgeExecutor)) revert OnlyExecutor();
        _;
    }

    function setBridgeExecutor(address _executor) public onlyAdmin {
        bridgeExecutor = _executor;
    }
}

File 10 of 19 : UTBOwned.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import {Roles} from "decent-bridge/src/utils/Roles.sol";

contract UTBOwned is Roles {
    address payable public utb;

    constructor() Roles(msg.sender) {}

    /**
     * @dev Limit access to the approved UTB.
     */
    modifier onlyUtb() {
        require(msg.sender == utb, "Only utb");
        _;
    }

    /**
     * @dev Sets the approved UTB.
     * @param _utb The address of the UTB.
     */
    function setUtb(address _utb) public onlyAdmin {
        utb = payable(_utb);
    }
}

File 11 of 19 : Roles.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";

abstract contract Roles is AccessControl {
    constructor(address admin) {
        _grantRole(DEFAULT_ADMIN_ROLE, admin);
    }

    modifier onlyAdmin() {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Only admin");
        _;
    }
}

File 12 of 19 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(account),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 13 of 19 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 14 of 19 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 15 of 19 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    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 = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        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);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 16 of 19 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 17 of 19 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 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 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}

File 18 of 19 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

File 19 of 19 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Settings
{
  "remappings": [
    "forge-std/=lib/forge-std/src/",
    "solmate/=lib/solmate/src/",
    "@uniswap/v3-periphery/=lib/v3-periphery/",
    "@uniswap/v3-core/=lib/v3-core/",
    "@uniswap/swap-contracts/=lib/swap-router-contracts/contracts/",
    "decent-bridge/=lib/decent-bridge/",
    "better-deployer/=lib/decent-bridge/lib/better-deployer/src/",
    "forge-toolkit/=lib/forge-toolkit/src/",
    "openzeppelin-contracts/=lib/decent-bridge/lib/openzeppelin-contracts/contracts/",
    "solidity-examples/=lib/solidity-examples/contracts/",
    "@openzeppelin/=lib/decent-bridge/lib/openzeppelin-contracts/",
    "@openzeppelin/contracts/=lib/decent-bridge/lib/openzeppelin-contracts/contracts/",
    "LayerZero/=lib/forge-toolkit/lib/LayerZero/contracts/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/decent-bridge/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "openzeppelin/=lib/decent-bridge/lib/openzeppelin-contracts/contracts/",
    "solidity-stringutils/=lib/decent-bridge/lib/solidity-stringutils/",
    "swap-router-contracts/=lib/swap-router-contracts/contracts/",
    "v3-core/=lib/v3-core/",
    "v3-periphery/=lib/v3-periphery/contracts/",
    "lib/forge-std:ds-test/=lib/decent-bridge/lib/forge-std/lib/ds-test/src/",
    "lib/openzeppelin-contracts:ds-test/=lib/decent-bridge/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "lib/openzeppelin-contracts:erc4626-tests/=lib/decent-bridge/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "lib/openzeppelin-contracts:forge-std/=lib/decent-bridge/lib/openzeppelin-contracts/lib/forge-std/src/",
    "lib/openzeppelin-contracts:openzeppelin/=lib/decent-bridge/lib/openzeppelin-contracts/contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"NoDstBridge","type":"error"},{"inputs":[],"name":"OnlyExecutor","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountLD","type":"uint256"}],"name":"ReceivedOnDestination","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"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"BRIDGE_ID","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SG_FEE_BPS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amt2Bridge","type":"uint256"},{"components":[{"internalType":"uint8","name":"swapperId","type":"uint8"},{"internalType":"bytes","name":"swapPayload","type":"bytes"}],"internalType":"struct SwapInstructions","name":"postBridge","type":"tuple"},{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"target","type":"address"},{"internalType":"address","name":"paymentOperator","type":"address"},{"internalType":"bytes","name":"payload","type":"bytes"},{"internalType":"bytes","name":"additionalArgs","type":"bytes"},{"internalType":"address","name":"refund","type":"address"}],"name":"bridge","outputs":[{"internalType":"bytes","name":"bridgePayload","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"bridgeExecutor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"chainIdLookup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"destinationBridgeAdapter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"additionalArgs","type":"bytes"}],"name":"getBridgeToken","outputs":[{"internalType":"address","name":"bridgeToken","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"amt2Bridge","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bytes","name":"additionalArgs","type":"bytes"}],"name":"getBridgedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getId","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"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":"uint256","name":"","type":"uint256"}],"name":"lzIdLookup","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint16","name":"dstLzId","type":"uint16"},{"internalType":"address","name":"decentBridgeAdapter","type":"address"}],"name":"registerRemoteBridgeAdapter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"contract IStargateRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_executor","type":"address"}],"name":"setBridgeExecutor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"name":"setRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_utb","type":"address"}],"name":"setUtb","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"sgReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"utb","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801561001057600080fd5b503361001d600082610023565b506100c2565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166100be576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916600117905561007d3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b611dd7806100d16000396000f3fe6080604052600436106101435760003560e01c8063a10bab0b116100b0578063c0d786551161006c578063c0d78655146103df578063cba25e4b146103ff578063ccfd4c9c1461041f578063d37ea4e414610463578063d547741f14610483578063f887ea40146104a357005b8063a10bab0b1461031f578063a217fddf1461033f578063ab8236f314610354578063af4482af14610374578063b1d456bf14610389578063b5bcae44146103a957005b80633882321c116100ff5780633882321c1461025e5780634dee98c11461028b5780635d1ca631146102ab57806391d14854146102bf5780639a43334c146102df578063a0756610146102ff57005b806301ffc9a71461014c5780631c624af514610181578063248a9ca3146101b95780632f2ff15d146101f757806330346fab1461021757806336568abe1461023e57005b3661014a57005b005b34801561015857600080fd5b5061016c610167366004611129565b6104c3565b60405190151581526020015b60405180910390f35b34801561018d57600080fd5b506101a161019c36600461119b565b6104fa565b6040516001600160a01b039091168152602001610178565b3480156101c557600080fd5b506101e96101d43660046111dc565b60009081526020819052604090206001015490565b604051908152602001610178565b34801561020357600080fd5b5061014a610212366004611215565b61050f565b34801561022357600080fd5b5061022c600681565b60405160ff9091168152602001610178565b34801561024a57600080fd5b5061014a610259366004611215565b610539565b34801561026a57600080fd5b506101e9610279366004611257565b60056020526000908152604090205481565b61029e6102993660046113e8565b6105bc565b604051610178919061150b565b3480156102b757600080fd5b50600161022c565b3480156102cb57600080fd5b5061016c6102da366004611215565b61075b565b3480156102eb57600080fd5b506101e96102fa36600461151e565b610784565b34801561030b57600080fd5b506001546101a1906001600160a01b031681565b34801561032b57600080fd5b506002546101a1906001600160a01b031681565b34801561034b57600080fd5b506101e9600081565b34801561036057600080fd5b5061014a61036f366004611590565b6107cd565b34801561038057600080fd5b5061022c600181565b34801561039557600080fd5b5061014a6103a436600461162a565b610977565b3480156103b557600080fd5b506101a16103c43660046111dc565b6003602052600090815260409020546001600160a01b031681565b3480156103eb57600080fd5b5061014a6103fa36600461162a565b6109c0565b34801561040b57600080fd5b5061014a61041a36600461162a565b610a09565b34801561042b57600080fd5b5061045061043a3660046111dc565b60046020526000908152604090205461ffff1681565b60405161ffff9091168152602001610178565b34801561046f57600080fd5b5061014a61047e366004611647565b610a52565b34801561048f57600080fd5b5061014a61049e366004611215565b610ad3565b3480156104af57600080fd5b506006546101a1906001600160a01b031681565b60006001600160e01b03198216637965db0b60e01b14806104f457506301ffc9a760e01b6001600160e01b03198316145b92915050565b60006105088284018461162a565b9392505050565b60008281526020819052604090206001015461052a81610af8565b6105348383610b05565b505050565b6001600160a01b03811633146105ae5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6105b88282610b89565b5050565b6001546060906001600160a01b031633146106045760405162461bcd60e51b815260206004820152600860248201526727b7363c903aba3160c11b60448201526064016105a5565b60006106128486018661162a565b9050898888888660405160200161062d9594939291906116b1565b60408051601f1981840301815291905291506001600160a01b0381161561073f576040516323b872dd60e01b8152336004820152306024820152604481018c90526001600160a01b038216906323b872dd906064016020604051808303816000875af11580156106a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c59190611704565b5060065460405163095ea7b360e01b81526001600160a01b039182166004820152602481018d90529082169063095ea7b3906044016020604051808303816000875af1158015610719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073d9190611704565b505b61074d8b8a84888888610bee565b509998505050505050505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b600061271060066107958585610d11565b6107a19061271061173c565b6107ab919061173c565b6107b99061ffff168861175e565b6107c39190611775565b9695505050505050565b6002546001600160a01b031633146107f857604051633fdb5f0160e11b815260040160405180910390fd5b60008060008060008580602001905181019061081491906117e7565b945094509450945094506000856020015180602001905181019061083891906118bf565b60408101519091506000906001600160a01b0316610858575080516108d7565b6040828101516001548451925163095ea7b360e01b81526001600160a01b0391821660048201526024810193909352169063095ea7b3906044016020604051808303816000875af11580156108b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d59190611704565b505b81518911156108fa576108fa838b84600001518c6108f59190611978565b610d2b565b60018054604051633c7aee0560e21b81526001600160a01b039091169163f1ebb814918491610936918c918c918c918c918c919060040161198b565b6000604051808303818588803b15801561094f57600080fd5b505af1158015610963573d6000803e3d6000fd5b505050505050505050505050505050505050565b61098260003361075b565b61099e5760405162461bcd60e51b81526004016105a5906119e5565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6109cb60003361075b565b6109e75760405162461bcd60e51b81526004016105a5906119e5565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b610a1460003361075b565b610a305760405162461bcd60e51b81526004016105a5906119e5565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b610a5d60003361075b565b610a795760405162461bcd60e51b81526004016105a5906119e5565b6000838152600460209081526040808320805461ffff191661ffff969096169586179055938252600581528382208590559381526003909352912080546001600160a01b0319166001600160a01b03909216919091179055565b600082815260208190526040902060010154610aee81610af8565b6105348383610b89565b610b028133610e12565b50565b610b0f828261075b565b6105b8576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610b453390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610b93828261075b565b156105b8576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6006546001600160a01b0316639fbf10fc610c0a85858a610e6b565b610c148686610ebb565b610c1e8787610ed8565b610c288888610ef2565b868c6127106006610c398d8d610d11565b610c459061271061173c565b610c4f919061173c565b61ffff168f610c5e919061175e565b610c689190611775565b610c728c8c610f0f565b610c7b8f610f41565b604051602001610ca3919060609190911b6bffffffffffffffffffffffff1916815260140190565b6040516020818303038152906040528e6040518b63ffffffff1660e01b8152600401610cd799989796959493929190611a09565b6000604051808303818588803b158015610cf057600080fd5b505af1158015610d04573d6000803e3d6000fd5b5050505050505050505050565b600080610d2083850185611be4565b979650505050505050565b6001600160a01b038216610d9f576000836001600160a01b03168260405160006040518083038185875af1925050503d8060008114610d86576040519150601f19603f3d011682016040523d82523d6000602084013e610d8b565b606091505b5050905080610d9957600080fd5b50505050565b60405163a9059cbb60e01b81526001600160a01b0384811660048301526024820183905283169063a9059cbb906044016020604051808303816000875af1158015610dee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d999190611704565b610e1c828261075b565b6105b857610e2981610f7c565b610e34836020610f8e565b604051602001610e45929190611c56565b60408051601f198184030181529082905262461bcd60e51b82526105a59160040161150b565b60008080610e7b85870187611ccb565b90925090506001600160a01b03821615610ea25780608001516001600160601b03166107c3565b8381608001516001600160601b03166107c39190611d01565b600080610eca83850185611d14565b506040015195945050505050565b600080610ee783850185611d14565b505195945050505050565b600080610f0183850185611d14565b506020015195945050505050565b610f3360405180606001604052806000815260200160008152602001606081525090565b60006107c383850185611d14565b6000818152600360205260409020546001600160a01b031680610f7757604051632e2f6d5960e11b815260040160405180910390fd5b919050565b60606104f46001600160a01b03831660145b60606000610f9d83600261175e565b610fa8906002611d01565b6001600160401b03811115610fbf57610fbf611272565b6040519080825280601f01601f191660200182016040528015610fe9576020820181803683370190505b509050600360fc1b8160008151811061100457611004611d74565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061103357611033611d74565b60200101906001600160f81b031916908160001a905350600061105784600261175e565b611062906001611d01565b90505b60018111156110da576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061109657611096611d74565b1a60f81b8282815181106110ac576110ac611d74565b60200101906001600160f81b031916908160001a90535060049490941c936110d381611d8a565b9050611065565b5083156105085760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016105a5565b60006020828403121561113b57600080fd5b81356001600160e01b03198116811461050857600080fd5b60008083601f84011261116557600080fd5b5081356001600160401b0381111561117c57600080fd5b60208301915083602082850101111561119457600080fd5b9250929050565b600080602083850312156111ae57600080fd5b82356001600160401b038111156111c457600080fd5b6111d085828601611153565b90969095509350505050565b6000602082840312156111ee57600080fd5b5035919050565b6001600160a01b0381168114610b0257600080fd5b8035610f77816111f5565b6000806040838503121561122857600080fd5b82359150602083013561123a816111f5565b809150509250929050565b803561ffff81168114610f7757600080fd5b60006020828403121561126957600080fd5b61050882611245565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156112aa576112aa611272565b60405290565b60405160c081016001600160401b03811182821017156112aa576112aa611272565b604051601f8201601f191681016001600160401b03811182821017156112fa576112fa611272565b604052919050565b60ff81168114610b0257600080fd5b60006001600160401b0382111561132a5761132a611272565b50601f01601f191660200190565b600082601f83011261134957600080fd5b813561135c61135782611311565b6112d2565b81815284602083860101111561137157600080fd5b816020850160208301376000918101602001919091529392505050565b6000604082840312156113a057600080fd5b6113a8611288565b905081356113b581611302565b815260208201356001600160401b038111156113d057600080fd5b6113dc84828501611338565b60208301525092915050565b60008060008060008060008060006101008a8c03121561140757600080fd5b8935985060208a01356001600160401b038082111561142557600080fd5b6114318d838e0161138e565b995060408c0135985061144660608d0161120a565b975061145460808d0161120a565b965060a08c013591508082111561146a57600080fd5b6114768d838e01611338565b955060c08c013591508082111561148c57600080fd5b506114998c828d01611153565b90945092506114ac905060e08b0161120a565b90509295985092959850929598565b60005b838110156114d65781810151838201526020016114be565b50506000910152565b600081518084526114f78160208601602086016114bb565b601f01601f19169290920160200192915050565b60208152600061050860208301846114df565b60008060008060006080868803121561153657600080fd5b853594506020860135611548816111f5565b93506040860135611558816111f5565b925060608601356001600160401b0381111561157357600080fd5b61157f88828901611153565b969995985093965092949392505050565b60008060008060008060c087890312156115a957600080fd5b6115b287611245565b955060208701356001600160401b03808211156115ce57600080fd5b6115da8a838b01611338565b965060408901359550606089013591506115f3826111f5565b9093506080880135925060a0880135908082111561161057600080fd5b5061161d89828a01611338565b9150509295509295509295565b60006020828403121561163c57600080fd5b8135610508816111f5565b60008060006060848603121561165c57600080fd5b8335925061166c60208501611245565b9150604084013561167c816111f5565b809150509250925092565b60ff815116825260006020820151604060208501526116a960408501826114df565b949350505050565b60a0815260006116c460a0830188611687565b6001600160a01b038781166020850152868116604085015283820360608501526116ee82876114df565b9250808516608085015250509695505050505050565b60006020828403121561171657600080fd5b8151801515811461050857600080fd5b634e487b7160e01b600052601160045260246000fd5b61ffff82811682821603908082111561175757611757611726565b5092915050565b80820281158282048414176104f4576104f4611726565b60008261179257634e487b7160e01b600052601260045260246000fd5b500490565b600082601f8301126117a857600080fd5b81516117b661135782611311565b8181528460208386010111156117cb57600080fd5b6116a98260208301602087016114bb565b8051610f77816111f5565b600080600080600060a086880312156117ff57600080fd5b85516001600160401b038082111561181657600080fd5b908701906040828a03121561182a57600080fd5b611832611288565b825161183d81611302565b815260208301518281111561185157600080fd5b61185d8b828601611797565b60208301525080975050611873602089016117dc565b9550611881604089016117dc565b9450606088015191508082111561189757600080fd5b506118a488828901611797565b9250506118b3608087016117dc565b90509295509295909350565b6000602082840312156118d157600080fd5b81516001600160401b03808211156118e857600080fd5b9083019060c082860312156118fc57600080fd5b6119046112b0565b82518152602083015160208201526040830151611920816111f5565b60408201526060830151611933816111f5565b6060820152608083015161194681611302565b608082015260a08301518281111561195d57600080fd5b61196987828601611797565b60a08301525095945050505050565b818103818111156104f4576104f4611726565b60c08152600061199e60c0830189611687565b6001600160a01b038881166020850152878116604085015283820360608501526119c882886114df565b95166080840152505060ff9190911660a090910152949350505050565b6020808252600a908201526927b7363c9030b236b4b760b11b604082015260600190565b600061012061ffff8c1683526001600160781b03808c166020850152808b1660408501525060018060a01b03891660608401528760808401528660a08401528060c084015285518184015250602085015161014083015260408501516060610160840152611a7b6101808401826114df565b905082810360e0840152611a8f81866114df565b9050828103610100840152611aa481856114df565b9c9b505050505050505050505050565b80356001600160781b0381168114610f7757600080fd5b600060a08284031215611add57600080fd5b60405160a081018181106001600160401b0382111715611aff57611aff611272565b604052905080611b0e83611ab4565b8152611b1c60208401611ab4565b6020820152611b2d60408401611245565b60408201526060830135611b40816111f5565b606082015260808301356001600160601b0381168114611b5f57600080fd5b6080919091015292915050565b600060608284031215611b7e57600080fd5b604051606081016001600160401b038282108183111715611ba157611ba1611272565b8160405282935084358352602085013560208401526040850135915080821115611bca57600080fd5b50611bd785828601611338565b6040830152505092915050565b6000806000806101008587031215611bfb57600080fd5b8435611c06816111f5565b9350611c158660208701611acb565b925060c08501356001600160401b03811115611c3057600080fd5b611c3c87828801611b6c565b925050611c4b60e08601611245565b905092959194509250565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611c8e8160178501602088016114bb565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611cbf8160288401602088016114bb565b01602801949350505050565b60008060c08385031215611cde57600080fd5b8235611ce9816111f5565b9150611cf88460208501611acb565b90509250929050565b808201808211156104f4576104f4611726565b600080600060e08486031215611d2957600080fd5b8335611d34816111f5565b9250611d438560208601611acb565b915060c08401356001600160401b03811115611d5e57600080fd5b611d6a86828701611b6c565b9150509250925092565b634e487b7160e01b600052603260045260246000fd5b600081611d9957611d99611726565b50600019019056fea2646970667358221220adbda9a66da271f0545a9a6dd80c8581bf34c914fd04b2d6ea70f795438ecd0d64736f6c63430008140033

Deployed Bytecode

0x6080604052600436106101435760003560e01c8063a10bab0b116100b0578063c0d786551161006c578063c0d78655146103df578063cba25e4b146103ff578063ccfd4c9c1461041f578063d37ea4e414610463578063d547741f14610483578063f887ea40146104a357005b8063a10bab0b1461031f578063a217fddf1461033f578063ab8236f314610354578063af4482af14610374578063b1d456bf14610389578063b5bcae44146103a957005b80633882321c116100ff5780633882321c1461025e5780634dee98c11461028b5780635d1ca631146102ab57806391d14854146102bf5780639a43334c146102df578063a0756610146102ff57005b806301ffc9a71461014c5780631c624af514610181578063248a9ca3146101b95780632f2ff15d146101f757806330346fab1461021757806336568abe1461023e57005b3661014a57005b005b34801561015857600080fd5b5061016c610167366004611129565b6104c3565b60405190151581526020015b60405180910390f35b34801561018d57600080fd5b506101a161019c36600461119b565b6104fa565b6040516001600160a01b039091168152602001610178565b3480156101c557600080fd5b506101e96101d43660046111dc565b60009081526020819052604090206001015490565b604051908152602001610178565b34801561020357600080fd5b5061014a610212366004611215565b61050f565b34801561022357600080fd5b5061022c600681565b60405160ff9091168152602001610178565b34801561024a57600080fd5b5061014a610259366004611215565b610539565b34801561026a57600080fd5b506101e9610279366004611257565b60056020526000908152604090205481565b61029e6102993660046113e8565b6105bc565b604051610178919061150b565b3480156102b757600080fd5b50600161022c565b3480156102cb57600080fd5b5061016c6102da366004611215565b61075b565b3480156102eb57600080fd5b506101e96102fa36600461151e565b610784565b34801561030b57600080fd5b506001546101a1906001600160a01b031681565b34801561032b57600080fd5b506002546101a1906001600160a01b031681565b34801561034b57600080fd5b506101e9600081565b34801561036057600080fd5b5061014a61036f366004611590565b6107cd565b34801561038057600080fd5b5061022c600181565b34801561039557600080fd5b5061014a6103a436600461162a565b610977565b3480156103b557600080fd5b506101a16103c43660046111dc565b6003602052600090815260409020546001600160a01b031681565b3480156103eb57600080fd5b5061014a6103fa36600461162a565b6109c0565b34801561040b57600080fd5b5061014a61041a36600461162a565b610a09565b34801561042b57600080fd5b5061045061043a3660046111dc565b60046020526000908152604090205461ffff1681565b60405161ffff9091168152602001610178565b34801561046f57600080fd5b5061014a61047e366004611647565b610a52565b34801561048f57600080fd5b5061014a61049e366004611215565b610ad3565b3480156104af57600080fd5b506006546101a1906001600160a01b031681565b60006001600160e01b03198216637965db0b60e01b14806104f457506301ffc9a760e01b6001600160e01b03198316145b92915050565b60006105088284018461162a565b9392505050565b60008281526020819052604090206001015461052a81610af8565b6105348383610b05565b505050565b6001600160a01b03811633146105ae5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6105b88282610b89565b5050565b6001546060906001600160a01b031633146106045760405162461bcd60e51b815260206004820152600860248201526727b7363c903aba3160c11b60448201526064016105a5565b60006106128486018661162a565b9050898888888660405160200161062d9594939291906116b1565b60408051601f1981840301815291905291506001600160a01b0381161561073f576040516323b872dd60e01b8152336004820152306024820152604481018c90526001600160a01b038216906323b872dd906064016020604051808303816000875af11580156106a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c59190611704565b5060065460405163095ea7b360e01b81526001600160a01b039182166004820152602481018d90529082169063095ea7b3906044016020604051808303816000875af1158015610719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073d9190611704565b505b61074d8b8a84888888610bee565b509998505050505050505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b600061271060066107958585610d11565b6107a19061271061173c565b6107ab919061173c565b6107b99061ffff168861175e565b6107c39190611775565b9695505050505050565b6002546001600160a01b031633146107f857604051633fdb5f0160e11b815260040160405180910390fd5b60008060008060008580602001905181019061081491906117e7565b945094509450945094506000856020015180602001905181019061083891906118bf565b60408101519091506000906001600160a01b0316610858575080516108d7565b6040828101516001548451925163095ea7b360e01b81526001600160a01b0391821660048201526024810193909352169063095ea7b3906044016020604051808303816000875af11580156108b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d59190611704565b505b81518911156108fa576108fa838b84600001518c6108f59190611978565b610d2b565b60018054604051633c7aee0560e21b81526001600160a01b039091169163f1ebb814918491610936918c918c918c918c918c919060040161198b565b6000604051808303818588803b15801561094f57600080fd5b505af1158015610963573d6000803e3d6000fd5b505050505050505050505050505050505050565b61098260003361075b565b61099e5760405162461bcd60e51b81526004016105a5906119e5565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6109cb60003361075b565b6109e75760405162461bcd60e51b81526004016105a5906119e5565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b610a1460003361075b565b610a305760405162461bcd60e51b81526004016105a5906119e5565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b610a5d60003361075b565b610a795760405162461bcd60e51b81526004016105a5906119e5565b6000838152600460209081526040808320805461ffff191661ffff969096169586179055938252600581528382208590559381526003909352912080546001600160a01b0319166001600160a01b03909216919091179055565b600082815260208190526040902060010154610aee81610af8565b6105348383610b89565b610b028133610e12565b50565b610b0f828261075b565b6105b8576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610b453390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610b93828261075b565b156105b8576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6006546001600160a01b0316639fbf10fc610c0a85858a610e6b565b610c148686610ebb565b610c1e8787610ed8565b610c288888610ef2565b868c6127106006610c398d8d610d11565b610c459061271061173c565b610c4f919061173c565b61ffff168f610c5e919061175e565b610c689190611775565b610c728c8c610f0f565b610c7b8f610f41565b604051602001610ca3919060609190911b6bffffffffffffffffffffffff1916815260140190565b6040516020818303038152906040528e6040518b63ffffffff1660e01b8152600401610cd799989796959493929190611a09565b6000604051808303818588803b158015610cf057600080fd5b505af1158015610d04573d6000803e3d6000fd5b5050505050505050505050565b600080610d2083850185611be4565b979650505050505050565b6001600160a01b038216610d9f576000836001600160a01b03168260405160006040518083038185875af1925050503d8060008114610d86576040519150601f19603f3d011682016040523d82523d6000602084013e610d8b565b606091505b5050905080610d9957600080fd5b50505050565b60405163a9059cbb60e01b81526001600160a01b0384811660048301526024820183905283169063a9059cbb906044016020604051808303816000875af1158015610dee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d999190611704565b610e1c828261075b565b6105b857610e2981610f7c565b610e34836020610f8e565b604051602001610e45929190611c56565b60408051601f198184030181529082905262461bcd60e51b82526105a59160040161150b565b60008080610e7b85870187611ccb565b90925090506001600160a01b03821615610ea25780608001516001600160601b03166107c3565b8381608001516001600160601b03166107c39190611d01565b600080610eca83850185611d14565b506040015195945050505050565b600080610ee783850185611d14565b505195945050505050565b600080610f0183850185611d14565b506020015195945050505050565b610f3360405180606001604052806000815260200160008152602001606081525090565b60006107c383850185611d14565b6000818152600360205260409020546001600160a01b031680610f7757604051632e2f6d5960e11b815260040160405180910390fd5b919050565b60606104f46001600160a01b03831660145b60606000610f9d83600261175e565b610fa8906002611d01565b6001600160401b03811115610fbf57610fbf611272565b6040519080825280601f01601f191660200182016040528015610fe9576020820181803683370190505b509050600360fc1b8160008151811061100457611004611d74565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061103357611033611d74565b60200101906001600160f81b031916908160001a905350600061105784600261175e565b611062906001611d01565b90505b60018111156110da576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061109657611096611d74565b1a60f81b8282815181106110ac576110ac611d74565b60200101906001600160f81b031916908160001a90535060049490941c936110d381611d8a565b9050611065565b5083156105085760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016105a5565b60006020828403121561113b57600080fd5b81356001600160e01b03198116811461050857600080fd5b60008083601f84011261116557600080fd5b5081356001600160401b0381111561117c57600080fd5b60208301915083602082850101111561119457600080fd5b9250929050565b600080602083850312156111ae57600080fd5b82356001600160401b038111156111c457600080fd5b6111d085828601611153565b90969095509350505050565b6000602082840312156111ee57600080fd5b5035919050565b6001600160a01b0381168114610b0257600080fd5b8035610f77816111f5565b6000806040838503121561122857600080fd5b82359150602083013561123a816111f5565b809150509250929050565b803561ffff81168114610f7757600080fd5b60006020828403121561126957600080fd5b61050882611245565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156112aa576112aa611272565b60405290565b60405160c081016001600160401b03811182821017156112aa576112aa611272565b604051601f8201601f191681016001600160401b03811182821017156112fa576112fa611272565b604052919050565b60ff81168114610b0257600080fd5b60006001600160401b0382111561132a5761132a611272565b50601f01601f191660200190565b600082601f83011261134957600080fd5b813561135c61135782611311565b6112d2565b81815284602083860101111561137157600080fd5b816020850160208301376000918101602001919091529392505050565b6000604082840312156113a057600080fd5b6113a8611288565b905081356113b581611302565b815260208201356001600160401b038111156113d057600080fd5b6113dc84828501611338565b60208301525092915050565b60008060008060008060008060006101008a8c03121561140757600080fd5b8935985060208a01356001600160401b038082111561142557600080fd5b6114318d838e0161138e565b995060408c0135985061144660608d0161120a565b975061145460808d0161120a565b965060a08c013591508082111561146a57600080fd5b6114768d838e01611338565b955060c08c013591508082111561148c57600080fd5b506114998c828d01611153565b90945092506114ac905060e08b0161120a565b90509295985092959850929598565b60005b838110156114d65781810151838201526020016114be565b50506000910152565b600081518084526114f78160208601602086016114bb565b601f01601f19169290920160200192915050565b60208152600061050860208301846114df565b60008060008060006080868803121561153657600080fd5b853594506020860135611548816111f5565b93506040860135611558816111f5565b925060608601356001600160401b0381111561157357600080fd5b61157f88828901611153565b969995985093965092949392505050565b60008060008060008060c087890312156115a957600080fd5b6115b287611245565b955060208701356001600160401b03808211156115ce57600080fd5b6115da8a838b01611338565b965060408901359550606089013591506115f3826111f5565b9093506080880135925060a0880135908082111561161057600080fd5b5061161d89828a01611338565b9150509295509295509295565b60006020828403121561163c57600080fd5b8135610508816111f5565b60008060006060848603121561165c57600080fd5b8335925061166c60208501611245565b9150604084013561167c816111f5565b809150509250925092565b60ff815116825260006020820151604060208501526116a960408501826114df565b949350505050565b60a0815260006116c460a0830188611687565b6001600160a01b038781166020850152868116604085015283820360608501526116ee82876114df565b9250808516608085015250509695505050505050565b60006020828403121561171657600080fd5b8151801515811461050857600080fd5b634e487b7160e01b600052601160045260246000fd5b61ffff82811682821603908082111561175757611757611726565b5092915050565b80820281158282048414176104f4576104f4611726565b60008261179257634e487b7160e01b600052601260045260246000fd5b500490565b600082601f8301126117a857600080fd5b81516117b661135782611311565b8181528460208386010111156117cb57600080fd5b6116a98260208301602087016114bb565b8051610f77816111f5565b600080600080600060a086880312156117ff57600080fd5b85516001600160401b038082111561181657600080fd5b908701906040828a03121561182a57600080fd5b611832611288565b825161183d81611302565b815260208301518281111561185157600080fd5b61185d8b828601611797565b60208301525080975050611873602089016117dc565b9550611881604089016117dc565b9450606088015191508082111561189757600080fd5b506118a488828901611797565b9250506118b3608087016117dc565b90509295509295909350565b6000602082840312156118d157600080fd5b81516001600160401b03808211156118e857600080fd5b9083019060c082860312156118fc57600080fd5b6119046112b0565b82518152602083015160208201526040830151611920816111f5565b60408201526060830151611933816111f5565b6060820152608083015161194681611302565b608082015260a08301518281111561195d57600080fd5b61196987828601611797565b60a08301525095945050505050565b818103818111156104f4576104f4611726565b60c08152600061199e60c0830189611687565b6001600160a01b038881166020850152878116604085015283820360608501526119c882886114df565b95166080840152505060ff9190911660a090910152949350505050565b6020808252600a908201526927b7363c9030b236b4b760b11b604082015260600190565b600061012061ffff8c1683526001600160781b03808c166020850152808b1660408501525060018060a01b03891660608401528760808401528660a08401528060c084015285518184015250602085015161014083015260408501516060610160840152611a7b6101808401826114df565b905082810360e0840152611a8f81866114df565b9050828103610100840152611aa481856114df565b9c9b505050505050505050505050565b80356001600160781b0381168114610f7757600080fd5b600060a08284031215611add57600080fd5b60405160a081018181106001600160401b0382111715611aff57611aff611272565b604052905080611b0e83611ab4565b8152611b1c60208401611ab4565b6020820152611b2d60408401611245565b60408201526060830135611b40816111f5565b606082015260808301356001600160601b0381168114611b5f57600080fd5b6080919091015292915050565b600060608284031215611b7e57600080fd5b604051606081016001600160401b038282108183111715611ba157611ba1611272565b8160405282935084358352602085013560208401526040850135915080821115611bca57600080fd5b50611bd785828601611338565b6040830152505092915050565b6000806000806101008587031215611bfb57600080fd5b8435611c06816111f5565b9350611c158660208701611acb565b925060c08501356001600160401b03811115611c3057600080fd5b611c3c87828801611b6c565b925050611c4b60e08601611245565b905092959194509250565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611c8e8160178501602088016114bb565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611cbf8160288401602088016114bb565b01602801949350505050565b60008060c08385031215611cde57600080fd5b8235611ce9816111f5565b9150611cf88460208501611acb565b90509250929050565b808201808211156104f4576104f4611726565b600080600060e08486031215611d2957600080fd5b8335611d34816111f5565b9250611d438560208601611acb565b915060c08401356001600160401b03811115611d5e57600080fd5b611d6a86828701611b6c565b9150509250925092565b634e487b7160e01b600052603260045260246000fd5b600081611d9957611d99611726565b50600019019056fea2646970667358221220adbda9a66da271f0545a9a6dd80c8581bf34c914fd04b2d6ea70f795438ecd0d64736f6c63430008140033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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