Contract 0x76303b0C86Ec887867e22E44a681bDbCaE85Ccdf

Txn Hash Method
Block
From
To
Value
0xf5ffeced18eff13b67c1b3437b5be9a7488e6c87e9502de64ae0915f49b7407fContinue Swap212895202024-02-15 14:25:0811 days 22 hrs ago0xc4d96ddecc96db3f18159715a2077cc3bf7f99d4 IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0 ETH0.0003585753631.500000252
0xd6bdda0353621cd8d457eb86f47b64ff77a96f9b43aa8547ce995dbd38e3120cContinue Swap212859212024-02-15 12:25:1012 days 31 mins ago0xc4d96ddecc96db3f18159715a2077cc3bf7f99d4 IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0 ETH0.0003583318231.500000252
0x04af2efde10896e5d815ea7e4f135e1f9fa5af53ede43969fab84df3955bf77dStart Swap212856332024-02-15 12:15:3412 days 41 mins ago0xde8b14744c9581320868b0c9a82356556a4d208f IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.005438344059864 ETH0.0000090599680.004001008
0x00602c813224e0b25e165d91aeb760a3ee905f0562592b9eb0ac415d534b73bcStart Swap212841542024-02-15 11:26:1612 days 1 hr ago0xc189b7380783391b71ed64985aa89da80f1e779e IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.000104171704036 ETH0.0000087319030.004001008
0xcae98f9295247e0111a37f2a7d4715dccefb6aaf44acb198e9b36f8cb7ced36dContinue Swap212833072024-02-15 10:58:0212 days 1 hr ago0xc4d96ddecc96db3f18159715a2077cc3bf7f99d4 IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0 ETH0.0003578746681.500000252
0x676cd0caa860b829c5d3ed12b20f954f91c5f6fab094f4d7a16dbe2703aeee5bStart Swap212788092024-02-15 8:28:0612 days 4 hrs ago0x10b320b7bf3e995601de9c35085f22c854eac30a IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.005003862087088 ETH0.0016796497872.000000252
0x248341008e29f7856609df81452eefd1e9762ea82b77b0a6f64366ff252ef031Start Swap212787922024-02-15 8:27:3212 days 4 hrs ago0x10b320b7bf3e995601de9c35085f22c854eac30a IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.005438344059864 ETH0.0016756897872.000000252
0xf0ab6dfa8b0e025ba7e7520785933ceb477ab2b26284a0919a4871cfc7e2834eStart Swap212787712024-02-15 8:26:5012 days 4 hrs ago0x10b320b7bf3e995601de9c35085f22c854eac30a IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.005004171704036 ETH0.0016767193182.000000252
0x95e2fa672a28cb0631ef93e55b8751c9254be054352e0133eae413658392519fStart Swap212787482024-02-15 8:26:0412 days 4 hrs ago0x10b320b7bf3e995601de9c35085f22c854eac30a IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.01069944019041 ETH0.0016510257842.000000252
0xffd274f98cb5649989969a08f8cfcbe8042e6e8ee10efe7b32a2cd59944fb247Continue Swap212745622024-02-15 6:06:3212 days 6 hrs ago0xc4d96ddecc96db3f18159715a2077cc3bf7f99d4 IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0 ETH0.0003583317941.500000252
0xfa5ca05e591d4b9fa2018040a6b5837ead6633ee09209bacda609a444304faa3Continue Swap212700262024-02-15 3:35:2012 days 9 hrs ago0xc4d96ddecc96db3f18159715a2077cc3bf7f99d4 IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0 ETH0.0003956066241.500000252
0xaedd64b7624796567ca6fae1847832a3cffacc12e481e8475c20eb0fb6451dbcStart Swap212681122024-02-15 2:31:3212 days 10 hrs ago0xf87466d10d542d85e1c4eb0cf0975e6d2d7c17e2 IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.01179944019041 ETH0.0000095396070.004001008
0x1bd29b0cbb69d388cb76c6e97fe97c54ddc790d51628e4133cbc13a92358c72bContinue Swap212678832024-02-15 2:23:5412 days 10 hrs ago0xc4d96ddecc96db3f18159715a2077cc3bf7f99d4 IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0 ETH0.0003955757631.500000252
0x6645dcbe5e1d1bcd801a2181bdff00db83e34135e968db8be9d60a4295764d05Start Swap212677292024-02-15 2:18:4612 days 10 hrs ago0xf3970142a0f6231bc51d476e07b70ff33e0aefd1 IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.100004172549421 ETH0.0000090283230.004001008
0x3ed8a44da2775089b31bbf1c571ff1c4f1812f7ea3f6f174c16a229ceca796cbStart Swap212615822024-02-14 22:53:5212 days 14 hrs ago0xbdd04d2a31d25fcc1c786dc293ce17538b41ce04 IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.100004180110323 ETH0.000009318490.004001008
0x87cd30be067449a8d13c6f4db300ed5cc1e3c6c7198452d836deb1e89e9656a9Start Swap212479762024-02-14 15:20:2012 days 21 hrs ago0x355178f20a059159f9879492d4570358222b1e4a IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.001948028734873 ETH0.0000100339390.004001008
0xdf4456634c371061361ae0f44a38c46ee461aeb0f671f751d8b2e5ae896b4982Start Swap212455572024-02-14 13:59:4212 days 22 hrs ago0xd76e36ef347719e0af79efe51feb90b95b66927d IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.010004181041627 ETH0.0000095261830.004001008
0x31f4795842a70435f12f3f9ba719b31821555af6c3b0ab7030caf6e5b0879a5dStart Swap212453932024-02-14 13:54:1412 days 23 hrs ago0xd76e36ef347719e0af79efe51feb90b95b66927d IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.100438344059864 ETH0.000010053310.004001008
0xc580e854b6760bcdfa3aaffbf2a238469a1a17f272d16a60ce60ab6d271d75beStart Swap212452512024-02-14 13:49:3012 days 23 hrs ago0xd76e36ef347719e0af79efe51feb90b95b66927d IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf1.000004181041627 ETH0.000008655430.004001008
0x888cea09068026d2d9a337d5585a766913f671e3803d3d9fbd23dc8fe542c516Start Swap212440782024-02-14 13:10:2412 days 23 hrs ago0xee4f9221333e228906baa767afeaaf2d62b4b53d IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.020003715061098 ETH0.0000097482030.004001008
0xed12debdbd3d3dd770b074770a2e43981d2de612374e7bb9f5f069941a417451Start Swap212439232024-02-14 13:05:1412 days 23 hrs ago0xee4f9221333e228906baa767afeaaf2d62b4b53d IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.020003715060348 ETH0.0000090228740.004001008
0xc26743af79f564c59557c8808cce758eb0d69252bc6f6c47fe2756b8d91dae25Continue Swap212432692024-02-14 12:43:2613 days 13 mins ago0xc4d96ddecc96db3f18159715a2077cc3bf7f99d4 IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0 ETH0.0003583317941.500000252
0x2246a29478d0708cf81515d4f588f4e4d0da4cae41996aae75c2d49bfb7fbca2Start Swap212426622024-02-14 12:23:1213 days 33 mins ago0xc0dec722b431c02a0787f349587b783a0f2f3281 IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf2.00069944019041 ETH0.0000094212770.004001008
0x867d1cfa98ae9d8d36f2284bd2dd86c9ffed70f8695112978775885a146832f8Start Swap212423292024-02-14 12:12:0613 days 44 mins ago0x31504df08fdac1d22d4b0d1bbf5b3ad348ed24de IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.00109944019041 ETH0.0000091701340.004001008
0x1aa0ffb63fd108e5253bc99e23522ad6589e80ba853d52934e2d6437110e6026Start Swap212422202024-02-14 12:08:2813 days 48 mins ago0x0429f4fd5279959ed83042a4095385300d86e396 IN 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0.100003862087088 ETH0.0000093007220.004001008
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xf5ffeced18eff13b67c1b3437b5be9a7488e6c87e9502de64ae0915f49b7407f212895202024-02-15 14:25:0811 days 22 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0xc4b03e54f65a3cabc3ad72a0a1955a64581263cf0.026058724046375752 ETH
0xf5ffeced18eff13b67c1b3437b5be9a7488e6c87e9502de64ae0915f49b7407f212895202024-02-15 14:25:0811 days 22 hrs ago 0x42000000000000000000000000000000000000060x76303b0c86ec887867e22e44a681bdbcae85ccdf0.026058724046375752 ETH
0xd6bdda0353621cd8d457eb86f47b64ff77a96f9b43aa8547ce995dbd38e3120c212859212024-02-15 12:25:1012 days 31 mins ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x87f2cfb8bd267a9b525d7b86cb816186ec65e9570.002514568044163832 ETH
0xd6bdda0353621cd8d457eb86f47b64ff77a96f9b43aa8547ce995dbd38e3120c212859212024-02-15 12:25:1012 days 31 mins ago 0x42000000000000000000000000000000000000060x76303b0c86ec887867e22e44a681bdbcae85ccdf0.002514568044163832 ETH
0x04af2efde10896e5d815ea7e4f135e1f9fa5af53ede43969fab84df3955bf77d212856332024-02-15 12:15:3412 days 41 mins ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x9731f8a3b2a9ee5e017483e6b4b62a9ac1af532d0.000438344059864876 ETH
0x04af2efde10896e5d815ea7e4f135e1f9fa5af53ede43969fab84df3955bf77d212856332024-02-15 12:15:3412 days 41 mins ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x42000000000000000000000000000000000000060.005 ETH
0x00602c813224e0b25e165d91aeb760a3ee905f0562592b9eb0ac415d534b73bc212841542024-02-15 11:26:1612 days 1 hr ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x9731f8a3b2a9ee5e017483e6b4b62a9ac1af532d0.000004171704036027 ETH
0x00602c813224e0b25e165d91aeb760a3ee905f0562592b9eb0ac415d534b73bc212841542024-02-15 11:26:1612 days 1 hr ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x42000000000000000000000000000000000000060.0001 ETH
0xcae98f9295247e0111a37f2a7d4715dccefb6aaf44acb198e9b36f8cb7ced36d212833072024-02-15 10:58:0212 days 1 hr ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x7696badd80e8abe92622b5ae7cb2efa3a32b10e10.00245467561156012 ETH
0xcae98f9295247e0111a37f2a7d4715dccefb6aaf44acb198e9b36f8cb7ced36d212833072024-02-15 10:58:0212 days 1 hr ago 0x42000000000000000000000000000000000000060x76303b0c86ec887867e22e44a681bdbcae85ccdf0.00245467561156012 ETH
0x676cd0caa860b829c5d3ed12b20f954f91c5f6fab094f4d7a16dbe2703aeee5b212788092024-02-15 8:28:0612 days 4 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x9731f8a3b2a9ee5e017483e6b4b62a9ac1af532d0.00000386208708819 ETH
0x676cd0caa860b829c5d3ed12b20f954f91c5f6fab094f4d7a16dbe2703aeee5b212788092024-02-15 8:28:0612 days 4 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x42000000000000000000000000000000000000060.005 ETH
0x248341008e29f7856609df81452eefd1e9762ea82b77b0a6f64366ff252ef031212787922024-02-15 8:27:3212 days 4 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x9731f8a3b2a9ee5e017483e6b4b62a9ac1af532d0.000438344059864876 ETH
0x248341008e29f7856609df81452eefd1e9762ea82b77b0a6f64366ff252ef031212787922024-02-15 8:27:3212 days 4 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x42000000000000000000000000000000000000060.005 ETH
0xf0ab6dfa8b0e025ba7e7520785933ceb477ab2b26284a0919a4871cfc7e2834e212787712024-02-15 8:26:5012 days 4 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x9731f8a3b2a9ee5e017483e6b4b62a9ac1af532d0.000004171704036027 ETH
0xf0ab6dfa8b0e025ba7e7520785933ceb477ab2b26284a0919a4871cfc7e2834e212787712024-02-15 8:26:5012 days 4 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x42000000000000000000000000000000000000060.005 ETH
0x95e2fa672a28cb0631ef93e55b8751c9254be054352e0133eae413658392519f212787482024-02-15 8:26:0412 days 4 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x9731f8a3b2a9ee5e017483e6b4b62a9ac1af532d0.000699440190410745 ETH
0x95e2fa672a28cb0631ef93e55b8751c9254be054352e0133eae413658392519f212787482024-02-15 8:26:0412 days 4 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x42000000000000000000000000000000000000060.01 ETH
0xffd274f98cb5649989969a08f8cfcbe8042e6e8ee10efe7b32a2cd59944fb247212745622024-02-15 6:06:3212 days 6 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x00edfe85cdbe5fe87c0f92904eedbe9bac993df50.000014368034284465 ETH
0xffd274f98cb5649989969a08f8cfcbe8042e6e8ee10efe7b32a2cd59944fb247212745622024-02-15 6:06:3212 days 6 hrs ago 0x42000000000000000000000000000000000000060x76303b0c86ec887867e22e44a681bdbcae85ccdf0.000014368034284465 ETH
0xfa5ca05e591d4b9fa2018040a6b5837ead6633ee09209bacda609a444304faa3212700262024-02-15 3:35:2012 days 9 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0xcaa05cfc2d5f96ca276cde60ff590a517560d6db0.001491079727158319 ETH
0xfa5ca05e591d4b9fa2018040a6b5837ead6633ee09209bacda609a444304faa3212700262024-02-15 3:35:2012 days 9 hrs ago 0x42000000000000000000000000000000000000060x76303b0c86ec887867e22e44a681bdbcae85ccdf0.001491079727158319 ETH
0xaedd64b7624796567ca6fae1847832a3cffacc12e481e8475c20eb0fb6451dbc212681122024-02-15 2:31:3212 days 10 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x9731f8a3b2a9ee5e017483e6b4b62a9ac1af532d0.000699440190410745 ETH
0xaedd64b7624796567ca6fae1847832a3cffacc12e481e8475c20eb0fb6451dbc212681122024-02-15 2:31:3212 days 10 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x42000000000000000000000000000000000000060.0111 ETH
0x1bd29b0cbb69d388cb76c6e97fe97c54ddc790d51628e4133cbc13a92358c72b212678832024-02-15 2:23:5412 days 10 hrs ago 0x76303b0c86ec887867e22e44a681bdbcae85ccdf0x99d182c5d4e2107c39ab647a43bcd94b020f399a0.002216213205838937 ETH
[ Download CSV Export 
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x7690368fD318378f99E6ddc4f071fa258F189807
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
CashmereAggregatorUniswap

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion, MIT license
File 1 of 25 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract 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 2 of 25 : 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 3 of 25 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 4 of 25 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

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

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 5 of 25 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

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

File 6 of 25 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 7 of 25 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 8 of 25 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 9 of 25 : 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 10 of 25 : Counters.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library Counters {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 11 of 25 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.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 `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);
    }
}

File 12 of 25 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 13 of 25 : 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 14 of 25 : 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);
}

File 15 of 25 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library 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) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 16 of 25 : IUniswapV2Router02.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);

    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint256 amountADesired,
        uint256 amountBDesired,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline
    )
        external
        returns (
            uint256 amountA,
            uint256 amountB,
            uint256 liquidity
        );

    function addLiquidityETH(
        address token,
        uint256 amountTokenDesired,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    )
        external
        payable
        returns (
            uint256 amountToken,
            uint256 amountETH,
            uint256 liquidity
        );

    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint256 liquidity,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountA, uint256 amountB);

    function removeLiquidityETH(
        address token,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountToken, uint256 amountETH);

    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint256 liquidity,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline,
        bool approveMax,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint256 amountA, uint256 amountB);

    function removeLiquidityETHWithPermit(
        address token,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline,
        bool approveMax,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint256 amountToken, uint256 amountETH);

    function swapExactTokensForTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapTokensForExactTokens(
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapExactETHForTokens(
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external payable returns (uint256[] memory amounts);

    function swapTokensForExactETH(
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapExactTokensForETH(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapETHForExactTokens(
        uint256 amountOut,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external payable returns (uint256[] memory amounts);

    function quote(
        uint256 amountA,
        uint256 reserveA,
        uint256 reserveB
    ) external pure returns (uint256 amountB);

    function getAmountOut(
        uint256 amountIn,
        uint256 reserveIn,
        uint256 reserveOut
    ) external pure returns (uint256 amountOut);

    function getAmountIn(
        uint256 amountOut,
        uint256 reserveIn,
        uint256 reserveOut
    ) external pure returns (uint256 amountIn);

    function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);

    function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);
}

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountETH);

    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline,
        bool approveMax,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint256 amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external;

    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external payable;

    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external;
}

File 17 of 25 : IWrappedNativeToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IWrappedNativeToken is IERC20 {
    function deposit() external payable;

    function withdraw(uint256 wad) external;
}

File 18 of 25 : EIP712.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 */
abstract contract EIP712 {
    /* solhint-disable var-name-mixedcase */
    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    //    bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
    //    uint256 private immutable _CACHED_CHAIN_ID;
    //    address private immutable _CACHED_THIS;

    bytes32 private immutable _HASHED_NAME;
    bytes32 private immutable _HASHED_VERSION;
    bytes32 private immutable _TYPE_HASH;

    // address(this) => chainid => cached domain separator
    mapping(address => mapping(uint256 => bytes32)) private _cachedDomainSeparators;

    /* solhint-enable var-name-mixedcase */

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        bytes32 typeHash = keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
        _cachedDomainSeparators[address(this)][block.chainid] = _buildDomainSeparator(
            typeHash,
            hashedName,
            hashedVersion,
            block.chainid,
            address(this)
        );
        //        _CACHED_CHAIN_ID = block.chainid;
        //        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
        //        _CACHED_THIS = address(this);
        _TYPE_HASH = typeHash;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4(uint256 chainid, address srcAddress) internal returns (bytes32) {
        if (_cachedDomainSeparators[srcAddress][chainid] == bytes32(0)) {
            _cachedDomainSeparators[srcAddress][chainid] = _buildDomainSeparator(
                _TYPE_HASH,
                _HASHED_NAME,
                _HASHED_VERSION,
                chainid,
                srcAddress
            );
        }
        return _cachedDomainSeparators[srcAddress][chainid];
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash,
        uint256 chainid,
        address srcAddress
    ) private pure returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, chainid, srcAddress));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(
        bytes32 structHash,
        uint256 chainid,
        address srcAddress
    ) internal virtual returns (bytes32) {
        return ECDSA.toTypedDataHash(_domainSeparatorV4(chainid, srcAddress), structHash);
    }
}

File 19 of 25 : IAssetRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

interface IAssetRouter {
    //---------------------------------------------------------------------------
    // STRUCTS
    struct ChainPath {
        bool active;
        uint16 srcPoolId;
        uint16 dstChainId;
        uint16 dstPoolId;
        uint16 weight;
        uint256 bandwidth; // local bandwidth
        uint256 actualBandwidth; // local bandwidth
        uint256 kbp; // kbp = Known Bandwidth Proof dst bandwidth
        uint256 actualKbp; // kbp = Known Bandwidth Proof dst bandwidth
        uint256 vouchers;
        uint256 optimalDstBandwidth; // optimal dst bandwidth
        address poolAddress;
    }

    struct SwapParams {
        uint16 srcPoolId;
        uint16 dstPoolId;
        uint16 dstChainId;
        uint256 amount;
        uint256 minAmount;
        address payable refundAddress;
        address to;
        bytes payload;
    }

    struct VoucherObject {
        uint256 vouchers;
        uint256 optimalDstBandwidth;
        bool swap;
    }

    struct PoolObject {
        uint16 poolId;
        address poolAddress;
        uint256 totalWeight;
        uint256 totalLiquidity;
        uint256 undistributedVouchers;
    }

    struct ChainData {
        uint16 srcPoolId;
        uint16 srcChainId;
        uint16 dstPoolId;
        uint16 dstChainId;
    }

    struct SwapMessage {
        uint16 srcChainId;
        uint16 srcPoolId;
        uint16 dstPoolId;
        address receiver;
        uint256 amount;
        uint256 fee;
        uint256 vouchers;
        uint256 optimalDstBandwidth;
        bytes32 id;
        bytes payload;
    }

    struct ReceiveSwapMessage {
        uint16 srcPoolId;
        uint16 dstPoolId;
        uint16 srcChainId;
        address receiver;
        uint256 amount;
        uint256 fee;
        uint256 vouchers;
        uint256 optimalDstBandwidth;
    }

    struct LiquidityMessage {
        uint16 srcPoolId;
        uint16 dstPoolId;
        uint256 vouchers;
        uint256 optimalDstBandwidth;
        bytes32 id;
    }

    function receiveVouchers(
        uint16 _srcChainId,
        uint16 _srcPoolId,
        uint16 _dstPoolId,
        uint256 _vouchers,
        uint256 _optimalDstBandwidth,
        bool _swap
    ) external;

    function swapRemote(
        uint16 _srcPoolId,
        uint16 _dstPoolId,
        uint16 _srcChainId,
        address _to,
        uint256 _amount,
        uint256 _fee,
        uint256 _vouchers,
        uint256 _optimalDstBandwidth
    ) external;

    enum MESSAGE_TYPE {
        NONE,
        SWAP,
        ADD_LIQUIDITY
    }

    function swap(SwapParams memory swapParams) external payable returns (bytes32);

    function getPool(uint16 _poolId) external view returns (PoolObject memory);
}

File 20 of 25 : IAssetV2.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

import "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "./IAssetRouter.sol";

interface IAssetV2 {
    function mint(address _to, uint256 _amountLD) external returns (uint256);

    function release(address _to, uint256 _amount) external;

    function token() external view returns (address);
}

File 21 of 25 : IBridge.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import "./ILayerZeroReceiver.sol";
import "./ILayerZeroEndpoint.sol";
import "./ILayerZeroUserApplicationConfig.sol";
import "./IAssetRouter.sol";

interface IBridge is ILayerZeroReceiver, ILayerZeroUserApplicationConfig {
    function lzReceive(
        uint16 _srcChainId,
        bytes memory _srcAddress,
        uint64 _nonce,
        bytes memory _payload
    ) external;

    // function swap(
    //     IAssetRouter.SwapParams memory _swapParams,
    //     IAssetRouter.CreditObj memory _c,
    //     IAssetRouter.SwapObj memory _s
    // ) external payable;

    // function sendVouchers(
    //     uint16 _chainId,
    //     uint16 _srcPoolId,
    //     uint16 _dstPoolId,
    //     address payable _refundAddress,
    //     IAssetRouter.VoucherObject memory _c
    // ) external payable;

    function nextNonce(uint16 dstChain_) external view returns (uint256);

    function getReceivedSwaps(uint16 _srcChainId, bytes32 _id) external view returns (IAssetRouter.SwapMessage memory);

    function getReceivedLiquidity(uint16 srcChain_, bytes32 id_)
        external
        view
        returns (IAssetRouter.LiquidityMessage memory);

    function dispatchMessage(
        uint16 _chainId,
        IAssetRouter.MESSAGE_TYPE _type,
        address payable _refundAddress,
        bytes memory _payload
    ) external payable;

    function quoteLayerZeroFee(
        uint16 _chainId,
        IAssetRouter.MESSAGE_TYPE _type,
        bytes memory _payload
    ) external view returns (uint256, uint256);
}

File 22 of 25 : ILayerZeroEndpoint.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity >=0.5.0;

import "./ILayerZeroUserApplicationConfig.sol";

interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig {
    // @notice send a LayerZero message to the specified address at a LayerZero endpoint.
    // @param _dstChainId - the destination chain identifier
    // @param _destination - the address on destination chain (in bytes). address length/format may vary by chains
    // @param _payload - a custom bytes payload to send to the destination contract
    // @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address
    // @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction
    // @param _adapterParams - parameters for custom functionality. ie: pay for a specified destination gasAmount, or receive airdropped native gas from the relayer on destination
    function send(
        uint16 _dstChainId,
        bytes calldata _destination,
        bytes calldata _payload,
        address payable _refundAddress,
        address _zroPaymentAddress,
        bytes calldata _adapterParams
    ) external payable;

    // @notice used by the messaging library to publish verified payload
    // @param _srcChainId - the source chain identifier
    // @param _srcAddress - the source contract (as bytes) at the source chain
    // @param _dstAddress - the address on destination chain
    // @param _nonce - the unbound message ordering nonce
    // @param _gasLimit - the gas limit for external contract execution
    // @param _payload - verified payload to send to the destination contract
    function receivePayload(
        uint16 _srcChainId,
        bytes calldata _srcAddress,
        address _dstAddress,
        uint64 _nonce,
        uint256 _gasLimit,
        bytes calldata _payload
    ) external;

    // @notice get the inboundNonce of a receiver from a source chain which could be EVM or non-EVM chain
    // @param _srcChainId - the source chain identifier
    // @param _srcAddress - the source chain contract address
    function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);

    // @notice get the outboundNonce from this source chain which, consequently, is always an EVM
    // @param _srcAddress - the source chain contract address
    function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64);

    // @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery
    // @param _dstChainId - the destination chain identifier
    // @param _userApplication - the user app address on this EVM chain
    // @param _payload - the custom message to send over LayerZero
    // @param _payInZRO - if false, user app pays the protocol fee in native token
    // @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain
    function estimateFees(
        uint16 _dstChainId,
        address _userApplication,
        bytes calldata _payload,
        bool _payInZRO,
        bytes calldata _adapterParam
    ) external view returns (uint256 nativeFee, uint256 zroFee);

    // @notice get this Endpoint's immutable source identifier
    function getChainId() external view returns (uint16);

    // @notice the interface to retry failed message on this Endpoint destination
    // @param _srcChainId - the source chain identifier
    // @param _srcAddress - the source chain contract address
    // @param _payload - the payload to be retried
    function retryPayload(
        uint16 _srcChainId,
        bytes calldata _srcAddress,
        bytes calldata _payload
    ) external;

    // @notice query if any STORED payload (message blocking) at the endpoint.
    // @param _srcChainId - the source chain identifier
    // @param _srcAddress - the source chain contract address
    function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);

    // @notice query if the _libraryAddress is valid for sending msgs.
    // @param _userApplication - the user app address on this EVM chain
    function getSendLibraryAddress(address _userApplication) external view returns (address);

    // @notice query if the _libraryAddress is valid for receiving msgs.
    // @param _userApplication - the user app address on this EVM chain
    function getReceiveLibraryAddress(address _userApplication) external view returns (address);

    // @notice query if the non-reentrancy guard for send() is on
    // @return true if the guard is on. false otherwise
    function isSendingPayload() external view returns (bool);

    // @notice query if the non-reentrancy guard for receive() is on
    // @return true if the guard is on. false otherwise
    function isReceivingPayload() external view returns (bool);

    // @notice get the configuration of the LayerZero messaging library of the specified version
    // @param _version - messaging library version
    // @param _chainId - the chainId for the pending config change
    // @param _userApplication - the contract address of the user application
    // @param _configType - type of configuration. every messaging library has its own convention.
    function getConfig(
        uint16 _version,
        uint16 _chainId,
        address _userApplication,
        uint256 _configType
    ) external view returns (bytes memory);

    // @notice get the send() LayerZero messaging library version
    // @param _userApplication - the contract address of the user application
    function getSendVersion(address _userApplication) external view returns (uint16);

    // @notice get the lzReceive() LayerZero messaging library version
    // @param _userApplication - the contract address of the user application
    function getReceiveVersion(address _userApplication) external view returns (uint16);
}

File 23 of 25 : ILayerZeroReceiver.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity >=0.5.0;

interface ILayerZeroReceiver {
    // @notice LayerZero endpoint will invoke this function to deliver the message on the destination
    // @param _srcChainId - the source endpoint identifier
    // @param _srcAddress - the source sending contract address from the source chain
    // @param _nonce - the ordered message nonce
    // @param _payload - the signed payload is the UA bytes has encoded to be sent
    function lzReceive(
        uint16 _srcChainId,
        bytes calldata _srcAddress,
        uint64 _nonce,
        bytes calldata _payload
    ) external;
}

File 24 of 25 : ILayerZeroUserApplicationConfig.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity >=0.5.0;

interface ILayerZeroUserApplicationConfig {
    // @notice set the configuration of the LayerZero messaging library of the specified version
    // @param _version - messaging library version
    // @param _chainId - the chainId for the pending config change
    // @param _configType - type of configuration. every messaging library has its own convention.
    // @param _config - configuration in the bytes. can encode arbitrary content.
    function setConfig(
        uint16 _version,
        uint16 _chainId,
        uint256 _configType,
        bytes calldata _config
    ) external;

    // @notice set the send() LayerZero messaging library version to _version
    // @param _version - new messaging library version
    function setSendVersion(uint16 _version) external;

    // @notice set the lzReceive() LayerZero messaging library version to _version
    // @param _version - new messaging library version
    function setReceiveVersion(uint16 _version) external;

    // @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload
    // @param _srcChainId - the chainId of the source chain
    // @param _srcAddress - the contract address of the source contract at the source chain
    function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;
}

File 25 of 25 : CashmereAggregatorUniswap.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "../libraries/EIP712.sol";
import "../poolv2-implementation/interfaces/IAssetRouter.sol";
import "../poolv2-implementation/interfaces/IBridge.sol";
import "../poolv2-implementation/interfaces/IAssetV2.sol";
import "../interfaces/IUniswapV2Router02.sol";
import "../interfaces/IWrappedNativeToken.sol";

contract CashmereAggregatorUniswap is AccessControl, ReentrancyGuard, EIP712 {
    using SafeERC20 for IERC20;
    using ECDSA for bytes32;
    using Counters for Counters.Counter;

    struct PendingSwap {
        bytes32 id;
        IERC20 lwsToken;
        uint16 lwsPoolId;
        uint16 hgsPoolId;
        IERC20 dstToken;
        uint16 dstChainId;
        address receiver;
        bool processed;
        uint256 minHgsAmount;
        bytes signature;
    }

    struct SwapParams {
        IERC20 srcToken;
        uint256 srcAmount;
        //        address router1Inch;
        //        bytes data;
        uint16 lwsPoolId;
        uint16 hgsPoolId;
        IERC20 dstToken;
        uint16 dstChain;
        address dstAggregatorAddress;
        uint256 minHgsAmount;
        bytes signature;
    }

    struct ContinueSwapParams {
        uint16 srcChainId;
        bytes32 id;
        //        address router1Inch;
        //        bytes data;
    }

    struct PayloadData {
        //        uint256 srcChainId;
        //        address srcAggregatorAddress;
        uint16 lwsPoolId;
        uint16 hgsPoolId;
        IERC20 dstToken;
        uint256 minHgsAmount;
        address receiver;
        bytes signature;
    }

    struct AggregatorInfo {
        address srcAggregatorAddress;
        uint16 l0ChainId;
        uint256 chainId;
    }

    IAssetRouter public assetRouter;
    IBridge public bridge;
    IUniswapV2Router02 public uniswap;
    mapping(bytes32 => PendingSwap) public pendingSwaps;
    bool initialized;
    IWrappedNativeToken public wrappedNativeToken;
    mapping(uint16 => AggregatorInfo) public aggregatorInfos;
    mapping(uint16 => mapping(bytes32 => bool)) public continuedSwaps;

    bytes32 public constant CONTINUE_EXECUTOR_ROLE = keccak256("CONTINUE_EXECUTOR_ROLE");
    address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

    event NewPendingSwap(bytes32 id);
    event SwapContinued(bytes32 id);
    event AggregatorInfosUpdated();

    constructor() EIP712("Cashmere Swap", "0.0.2") {}

    function initialize(
        IAssetRouter assetRouter_,
        IBridge bridge_,
        IUniswapV2Router02 uniswap_,
        IWrappedNativeToken wrappedNativeToken_,
        address admin
    ) external {
        require(!initialized, "initialized");
        assetRouter = assetRouter_;
        bridge = bridge_;
        uniswap = uniswap_;
        wrappedNativeToken = wrappedNativeToken_;
        _grantRole(DEFAULT_ADMIN_ROLE, admin);
        initialized = true;
    }

    function setAggregatorInfos(AggregatorInfo[] calldata infos) external onlyRole(DEFAULT_ADMIN_ROLE) {
        for (uint256 i = 0; i < infos.length; i++) {
            aggregatorInfos[infos[i].l0ChainId] = infos[i];
        }
        emit AggregatorInfosUpdated();
    }

    function updateAssetRouter(IAssetRouter assetRouter_) external onlyRole(DEFAULT_ADMIN_ROLE) {
        assetRouter = assetRouter_;
    }

    function updateBridge(IBridge bridge_) external onlyRole(DEFAULT_ADMIN_ROLE) {
        bridge = bridge_;
    }

    function _approve(IERC20 token, address operator, uint256 amount) internal {
        token.safeApprove(operator, 0);
        token.safeApprove(operator, amount);
    }

    function startSwap(SwapParams memory params) external payable {
        uint256 value = msg.value;

        require(params.lwsPoolId != 0 && params.hgsPoolId != 0, "!lws/hgs");
        IERC20 lwsToken = IERC20(IAssetV2(assetRouter.getPool(params.lwsPoolId).poolAddress).token());
        require(
            _hashTypedDataV4(
                keccak256(
                    abi.encode(
                        keccak256(
                            "Parameters(address receiver,uint16 lwsPoolId,uint16 hgsPoolId,address dstToken,uint256 minHgsAmount)"
                        ),
                        msg.sender,
                        params.lwsPoolId,
                        params.hgsPoolId,
                        params.dstToken,
                        params.minHgsAmount
                    )
                ),
                block.chainid,
                address(this)
            ).recover(params.signature) == msg.sender,
            "!signature"
        );

        // src -> lws
        if (address(params.srcToken) == NATIVE_TOKEN) {
            require(value >= params.srcAmount, "insufficient value");
            value -= params.srcAmount;
            wrappedNativeToken.deposit{ value: params.srcAmount }();
            params.srcToken = IERC20(wrappedNativeToken);
        } else {
            params.srcToken.safeTransferFrom(msg.sender, address(this), params.srcAmount);
        }
        uint256 returnAmount;
        if (params.srcToken != lwsToken /*&& params.router1Inch != address(0)*/) {
            uint256 srcBefore = params.srcToken.balanceOf(address(this)) - params.srcAmount;
            uint256 lwsBefore = lwsToken.balanceOf(address(this));

            _approve(params.srcToken, address(uniswap), params.srcAmount);

            //            (bool success, ) = params.router1Inch.call{ value: 0 }(params.data);
            //            require(success, "!inSuccess");
            uniswapSwap(params.srcToken, lwsToken, params.srcAmount);
            uint256 unspentAmount = params.srcToken.balanceOf(address(this)) - srcBefore;
            returnAmount = lwsToken.balanceOf(address(this)) - lwsBefore;
            if (unspentAmount > 0) {
                params.srcToken.safeTransfer(msg.sender, unspentAmount);
            }
        } else {
            returnAmount = params.srcAmount;
        }

        // lws -> hgs
        _approve(lwsToken, address(assetRouter), returnAmount);
        bytes memory payload = abi.encodePacked(
            params.lwsPoolId,
            params.hgsPoolId,
            params.dstToken,
            params.minHgsAmount,
            msg.sender,
            params.signature
        );
        bytes32 swapId = assetRouter.swap{ value: value }(
            IAssetRouter.SwapParams({
                srcPoolId: params.lwsPoolId,
                dstPoolId: params.hgsPoolId,
                dstChainId: params.dstChain,
                amount: returnAmount,
                minAmount: params.minHgsAmount,
                refundAddress: payable(msg.sender),
                to: params.dstAggregatorAddress,
                payload: payload
            })
        );

        PendingSwap storage swap = pendingSwaps[swapId];
        swap.id = swapId;
        swap.lwsToken = lwsToken;
        swap.lwsPoolId = params.lwsPoolId;
        swap.hgsPoolId = params.hgsPoolId;
        swap.dstToken = params.dstToken;
        swap.dstChainId = params.dstChain;
        swap.receiver = msg.sender;
        swap.minHgsAmount = params.minHgsAmount;
        swap.signature = params.signature;

        emit NewPendingSwap(swapId);
    }

    function continueSwap(ContinueSwapParams memory params) external onlyRole(CONTINUE_EXECUTOR_ROLE) {
        require(!continuedSwaps[params.srcChainId][params.id], "already continued");
        IAssetRouter.SwapMessage memory swapMsg = bridge.getReceivedSwaps(params.srcChainId, params.id);
        PayloadData memory payload;
        bytes memory data = swapMsg.payload;
        // TODO: check for dirty bits
        assembly ("memory-safe") {
            let sigLength := sub(mload(data), 76)
            data := add(data, 32)
            let payloadPtr := payload

            //            mstore(payloadPtr, mload(data)) // uint256 srcChainId
            //            data := add(data, 32)
            //            payloadPtr := add(payloadPtr, 32)
            //
            //            mstore(payloadPtr, shr(96, mload(data))) // address srcAggregatorAddress
            //            data := add(data, 20)
            //            payloadPtr := add(payloadPtr, 32)

            mstore(payloadPtr, shr(240, mload(data))) // uint16 lwsPoolId
            data := add(data, 2)
            payloadPtr := add(payloadPtr, 32)

            mstore(payloadPtr, shr(240, mload(data))) // uint16 hgsPoolId
            data := add(data, 2)
            payloadPtr := add(payloadPtr, 32)

            mstore(payloadPtr, shr(96, mload(data))) // address dstToken
            data := add(data, 20)
            payloadPtr := add(payloadPtr, 32)

            mstore(payloadPtr, mload(data)) // uint256 minHgsAmount
            data := add(data, 32)
            payloadPtr := add(payloadPtr, 32)

            mstore(payloadPtr, shr(96, mload(data))) // address receiver
            data := sub(data, 12) // + 20 - 32
            payloadPtr := add(payloadPtr, 32)

            mstore(data, sigLength) // set signature length
            mstore(payloadPtr, data) // bytes signature
        }
        IERC20 hgsToken = IERC20(IAssetV2(assetRouter.getPool(payload.hgsPoolId).poolAddress).token());

        require(
            _hashTypedDataV4(
                keccak256(
                    abi.encode(
                        keccak256(
                            "Parameters(address receiver,uint16 lwsPoolId,uint16 hgsPoolId,address dstToken,uint256 minHgsAmount)"
                        ),
                        payload.receiver,
                        payload.lwsPoolId,
                        payload.hgsPoolId,
                        payload.dstToken,
                        payload.minHgsAmount
                    )
                ),
                aggregatorInfos[swapMsg.srcChainId].chainId,
                aggregatorInfos[swapMsg.srcChainId].srcAggregatorAddress
            ).recover(payload.signature) == payload.receiver,
            "!signature"
        );

        // hgs -> dst
        bool isDstNative = address(payload.dstToken) == NATIVE_TOKEN;
        if (isDstNative) {
            payload.dstToken = IERC20(wrappedNativeToken);
        }
        uint256 returnAmount;
        if (hgsToken != payload.dstToken /*&& params.router1Inch != address(0)*/) {
            uint256 hgsBefore = hgsToken.balanceOf(address(this)) - swapMsg.amount;
            uint256 dstBefore = payload.dstToken.balanceOf(address(this));

            _approve(hgsToken, address(uniswap), swapMsg.amount);
            //            (bool success, ) = params.router1Inch.call{ value: 0 }(params.data);
            //            require(success, "!inSuccess");
            uniswapSwap(hgsToken, payload.dstToken, swapMsg.amount);
            uint256 unspentAmount = hgsToken.balanceOf(address(this)) - hgsBefore;
            returnAmount = payload.dstToken.balanceOf(address(this)) - dstBefore;
            if (unspentAmount > 0) {
                hgsToken.safeTransfer(payload.receiver, unspentAmount);
            }
        } else {
            returnAmount = swapMsg.amount;
        }
        if (returnAmount > 0) {
            if (isDstNative) {
                wrappedNativeToken.withdraw(returnAmount);
                payable(payload.receiver).transfer(returnAmount);
            } else {
                payload.dstToken.safeTransfer(payload.receiver, returnAmount);
            }
        }
        continuedSwaps[params.srcChainId][params.id] = true;
        emit SwapContinued(params.id);
    }

    function withdrawTokens(IERC20 token, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
        token.safeTransfer(msg.sender, amount);
    }

    function uniswapSwap(IERC20 fromToken, IERC20 toToken, uint256 fromAmount) internal {
        address[] memory path = new address[](2);
        path[0] = address(fromToken);
        path[1] = address(toToken);
        uniswap.swapExactTokensForTokens(fromAmount, 0, path, address(this), block.timestamp + 1000);
    }

    receive() external payable {
        require(msg.sender == address(wrappedNativeToken), "invalid sender");
    }
}

Settings
{
  "evmVersion": "london",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[],"name":"AggregatorInfosUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"NewPendingSwap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"SwapContinued","type":"event"},{"inputs":[],"name":"CONTINUE_EXECUTOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NATIVE_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"aggregatorInfos","outputs":[{"internalType":"address","name":"srcAggregatorAddress","type":"address"},{"internalType":"uint16","name":"l0ChainId","type":"uint16"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assetRouter","outputs":[{"internalType":"contract IAssetRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridge","outputs":[{"internalType":"contract IBridge","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes32","name":"id","type":"bytes32"}],"internalType":"struct CashmereAggregatorUniswap.ContinueSwapParams","name":"params","type":"tuple"}],"name":"continueSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"continuedSwaps","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IAssetRouter","name":"assetRouter_","type":"address"},{"internalType":"contract IBridge","name":"bridge_","type":"address"},{"internalType":"contract IUniswapV2Router02","name":"uniswap_","type":"address"},{"internalType":"contract IWrappedNativeToken","name":"wrappedNativeToken_","type":"address"},{"internalType":"address","name":"admin","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"pendingSwaps","outputs":[{"internalType":"bytes32","name":"id","type":"bytes32"},{"internalType":"contract IERC20","name":"lwsToken","type":"address"},{"internalType":"uint16","name":"lwsPoolId","type":"uint16"},{"internalType":"uint16","name":"hgsPoolId","type":"uint16"},{"internalType":"contract IERC20","name":"dstToken","type":"address"},{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"bool","name":"processed","type":"bool"},{"internalType":"uint256","name":"minHgsAmount","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"srcAggregatorAddress","type":"address"},{"internalType":"uint16","name":"l0ChainId","type":"uint16"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"internalType":"struct CashmereAggregatorUniswap.AggregatorInfo[]","name":"infos","type":"tuple[]"}],"name":"setAggregatorInfos","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"srcToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint16","name":"lwsPoolId","type":"uint16"},{"internalType":"uint16","name":"hgsPoolId","type":"uint16"},{"internalType":"contract IERC20","name":"dstToken","type":"address"},{"internalType":"uint16","name":"dstChain","type":"uint16"},{"internalType":"address","name":"dstAggregatorAddress","type":"address"},{"internalType":"uint256","name":"minHgsAmount","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct CashmereAggregatorUniswap.SwapParams","name":"params","type":"tuple"}],"name":"startSwap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uniswap","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IAssetRouter","name":"assetRouter_","type":"address"}],"name":"updateAssetRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IBridge","name":"bridge_","type":"address"}],"name":"updateBridge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wrappedNativeToken","outputs":[{"internalType":"contract IWrappedNativeToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

Deployed Bytecode

0x6080604052600436106101845760003560e01c806358f9edfc116100d6578063b2743fa71161007f578063d547741f11610059578063d547741f14610570578063e78cea9214610590578063f933e640146105b057600080fd5b8063b2743fa71461051d578063bc0aac1014610530578063bc97265b1461055057600080fd5b80637f44031e116100b05780637f44031e1461045157806391d14854146104c4578063a217fddf1461050857600080fd5b806358f9edfc146103dd5780635cd5cd4e146103fd5780636eb382121461043157600080fd5b8063248a9ca31161013857806331f7d9641161011257806331f7d9641461035a57806336568abe146103825780634ad7f678146103a257600080fd5b8063248a9ca3146102dc5780632681f7e41461031a5780632f2ff15d1461033a57600080fd5b80630f57864e116101695780630f57864e146102495780631459457a1461027f57806317fcb39b1461029f57600080fd5b806301ffc9a7146101f457806306b091f91461022957600080fd5b366101ef5760075461010090046001600160a01b031633146101ed5760405162461bcd60e51b815260206004820152600e60248201527f696e76616c69642073656e64657200000000000000000000000000000000000060448201526064015b60405180910390fd5b005b600080fd5b34801561020057600080fd5b5061021461020f3660046126be565b6105d0565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b506101ed61024436600461270d565b610607565b34801561025557600080fd5b50610269610264366004612739565b61062b565b6040516102209a999897969594939291906127a2565b34801561028b57600080fd5b506101ed61029a366004612819565b610720565b3480156102ab57600080fd5b506007546102c49061010090046001600160a01b031681565b6040516001600160a01b039091168152602001610220565b3480156102e857600080fd5b5061030c6102f7366004612739565b60009081526020819052604090206001015490565b604051908152602001610220565b34801561032657600080fd5b506005546102c4906001600160a01b031681565b34801561034657600080fd5b506101ed61035536600461288a565b610802565b34801561036657600080fd5b506102c473eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b34801561038e57600080fd5b506101ed61039d36600461288a565b610827565b3480156103ae57600080fd5b506102146103bd3660046128d5565b600960209081526000928352604080842090915290825290205460ff1681565b3480156103e957600080fd5b506101ed6103f8366004612988565b6108b3565b34801561040957600080fd5b5061030c7f9e7a659985ff60e88bae893a3fd5287022761d563f4077249c341daf2ac6e08581565b34801561043d57600080fd5b506101ed61044c3660046129e0565b611090565b34801561045d57600080fd5b5061049c61046c3660046129fd565b600860205260009081526040902080546001909101546001600160a01b03821691600160a01b900461ffff169083565b604080516001600160a01b03909416845261ffff909216602084015290820152606001610220565b3480156104d057600080fd5b506102146104df36600461288a565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561051457600080fd5b5061030c600081565b6101ed61052b366004612a98565b6110be565b34801561053c57600080fd5b506003546102c4906001600160a01b031681565b34801561055c57600080fd5b506101ed61056b3660046129e0565b6118e8565b34801561057c57600080fd5b506101ed61058b36600461288a565b611916565b34801561059c57600080fd5b506004546102c4906001600160a01b031681565b3480156105bc57600080fd5b506101ed6105cb366004612b84565b61193b565b60006001600160e01b03198216637965db0b60e01b148061060157506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000610612816119f9565b6106266001600160a01b0384163384611a06565b505050565b60066020526000908152604090208054600182015460028301546003840154600485015460058601805495966001600160a01b038087169761ffff600160a01b808a04821699600160b01b90048216988085169890829004909216969382169560ff9190920416939161069d90612bf9565b80601f01602080910402602001604051908101604052809291908181526020018280546106c990612bf9565b80156107165780601f106106eb57610100808354040283529160200191610716565b820191906000526020600020905b8154815290600101906020018083116106f957829003601f168201915b505050505090508a565b60075460ff16156107735760405162461bcd60e51b815260206004820152600b60248201527f696e697469616c697a656400000000000000000000000000000000000000000060448201526064016101e4565b600380546001600160a01b038088166001600160a01b0319928316179092556004805487841690831617905560058054868416921691909117905560078054918416610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff9092169190911790556107ee600082611a7e565b50506007805460ff19166001179055505050565b60008281526020819052604090206001015461081d816119f9565b6106268383611a7e565b6001600160a01b03811633146108a55760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016101e4565b6108af8282611b1c565b5050565b7f9e7a659985ff60e88bae893a3fd5287022761d563f4077249c341daf2ac6e0856108dd816119f9565b815161ffff16600090815260096020908152604080832082860151845290915290205460ff16156109505760405162461bcd60e51b815260206004820152601160248201527f616c726561647920636f6e74696e75656400000000000000000000000000000060448201526064016101e4565b600480548351602085015160405163671ecff360e11b81526000946001600160a01b039094169363ce3d9fe69361099a93909290910161ffff929092168252602082015260400190565b600060405180830381865afa1580156109b7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109df9190810190612c8e565b9050610a346040518060c00160405280600061ffff168152602001600061ffff16815260200160006001600160a01b031681526020016000815260200160006001600160a01b03168152602001606081525090565b610120820151805160208083015160f090811c85526022840151901c908401908152602480840151606090811c604080880191909152603886015182880152605886015190911c6080870152604b19909301604c90940193845260a0850184905260035491519251632ce1266960e01b815261ffff90931660048401526000926001600160a01b0390921691632ce12669910160a060405180830381865afa158015610ae4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b089190612d67565b602001516001600160a01b031663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6d9190612de9565b905082608001516001600160a01b0316610c5c8460a00151610c567f6a6e4c97c81ba29ef35730b2527a27bb8e01f6d7c18b8c2b09e835be33349e878760800151886000015189602001518a604001518b60600151604051602001610c0b969594939291909586526001600160a01b03948516602087015261ffff93841660408701529190921660608501529116608083015260a082015260c00190565b60408051601f1981840301815291815281516020928301208a5161ffff90811660009081526008909452828420600101548c51909116845291909220546001600160a01b0316611b9b565b90611bf3565b6001600160a01b031614610c9f5760405162461bcd60e51b815260206004820152600a602482015269217369676e617475726560b01b60448201526064016101e4565b60408301516001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee148015610ce05760075461010090046001600160a01b031660408501525b600084604001516001600160a01b0316836001600160a01b031614610f3f5760808601516040516370a0823160e01b8152306004820152600091906001600160a01b038616906370a0823190602401602060405180830381865afa158015610d4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d709190612e06565b610d7a9190612e35565b60408088015190516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610dca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dee9190612e06565b60055460808a0151919250610e0e9187916001600160a01b031690611c17565b610e218588604001518a60800151611c40565b6040516370a0823160e01b815230600482015260009083906001600160a01b038816906370a0823190602401602060405180830381865afa158015610e6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8e9190612e06565b610e989190612e35565b6040808a015190516370a0823160e01b815230600482015291925083916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610ee7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0b9190612e06565b610f159190612e35565b93508015610f37576080880151610f37906001600160a01b0388169083611a06565b505050610f46565b5060808501515b801561101d578115610ff757600754604051632e1a7d4d60e01b8152600481018390526101009091046001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015610f9c57600080fd5b505af1158015610fb0573d6000803e3d6000fd5b5050505084608001516001600160a01b03166108fc829081150290604051600060405180830381858888f19350505050158015610ff1573d6000803e3d6000fd5b5061101d565b61101d85608001518287604001516001600160a01b0316611a069092919063ffffffff16565b875161ffff166000908152600960209081526040808320828c0180518552925291829020805460ff191660011790555190517fb7f7a4b537e2e7b827edeafaae22ed03542b433bde89fa0c1199d39bce3f5b789161107e9190815260200190565b60405180910390a15050505050505050565b600061109b816119f9565b50600480546001600160a01b0319166001600160a01b0392909216919091179055565b6040810151349061ffff16158015906110de5750606082015161ffff1615155b61112a5760405162461bcd60e51b815260206004820152600860248201527f216c77732f68677300000000000000000000000000000000000000000000000060448201526064016101e4565b6003546040838101519051632ce1266960e01b815261ffff90911660048201526000916001600160a01b031690632ce126699060240160a060405180830381865afa15801561117d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a19190612d67565b602001516001600160a01b031663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112069190612de9565b9050336001600160a01b03166112ba846101000151610c567f6a6e4c97c81ba29ef35730b2527a27bb8e01f6d7c18b8c2b09e835be33349e8733886040015189606001518a608001518b60e0015160405160200161129d969594939291909586526001600160a01b03948516602087015261ffff93841660408701529190921660608501529116608083015260a082015260c00190565b604051602081830303815290604052805190602001204630611b9b565b6001600160a01b0316146112fd5760405162461bcd60e51b815260206004820152600a602482015269217369676e617475726560b01b60448201526064016101e4565b82516001600160a01b03167fffffffffffffffffffffffff1111111111111111111111111111111111111112016114195782602001518210156113825760405162461bcd60e51b815260206004820152601260248201527f696e73756666696369656e742076616c7565000000000000000000000000000060448201526064016101e4565b60208301516113919083612e35565b9150600760019054906101000a90046001600160a01b03166001600160a01b031663d0e30db084602001516040518263ffffffff1660e01b81526004016000604051808303818588803b1580156113e757600080fd5b505af11580156113fb573d6000803e3d6000fd5b505060075461010090046001600160a01b0316865250611439915050565b60208301518351611439916001600160a01b039091169033903090611d47565b6000816001600160a01b031684600001516001600160a01b03161461168e57602084015184516040516370a0823160e01b8152306004820152600092916001600160a01b0316906370a0823190602401602060405180830381865afa1580156114a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ca9190612e06565b6114d49190612e35565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561151e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115429190612e06565b86516005546020890151929350611564926001600160a01b0390911690611c17565b6115778660000151858860200151611c40565b85516040516370a0823160e01b815230600482015260009184916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156115c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e79190612e06565b6115f19190612e35565b6040516370a0823160e01b815230600482015290915082906001600160a01b038716906370a0823190602401602060405180830381865afa15801561163a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165e9190612e06565b6116689190612e35565b93508015611686578651611686906001600160a01b03163383611a06565b505050611695565b5060208301515b6003546116ad9083906001600160a01b031683611c17565b60008460400151856060015186608001518760e00151338961010001516040516020016116df96959493929190612e48565b60408051601f19818403018152600354610100840183528883015161ffff90811685526060808b01518216602087015260a0808c015190921686860152850187905260e0808b01516080870152339186019190915260c0808b01516001600160a01b039081169187019190915290850183905292516391df699f60e01b81529194506000939216916391df699f91889161177b91600401612eb4565b60206040518083038185885af1158015611799573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906117be9190612e06565b60008181526006602052604090819020828155600181018054928a015160608b01516001600160a01b038a811675ffffffffffffffffffffffffffffffffffffffffffff1996871617600160a01b61ffff9485168102919091177fffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffffff16600160b01b938516939093029290921790935560808c015160028501805460a08f0151929095169490961693909317929091160217909155600381018054336001600160a01b031990911617905560e088015160048201556101008801519192509060058201906118ab9082612f95565b506040518281527f7b0a3fab2034d26e1d5ffb5ba60ca0c0121664bae47dcaf0b7424132746151679060200160405180910390a150505050505050565b60006118f3816119f9565b50600380546001600160a01b0319166001600160a01b0392909216919091179055565b600082815260208190526040902060010154611931816119f9565b6106268383611b1c565b6000611946816119f9565b60005b828110156119ca5783838281811061196357611963613055565b9050606002016008600086868581811061197f5761197f613055565b905060600201602001602081019061199791906129fd565b61ffff16815260208101919091526040016000206119b5828261306b565b508190506119c2816130ed565b915050611949565b506040517f2767c72a19a1f0d652c66656b5f22a4a985cb606d963aa1709c1b367940c941790600090a1505050565b611a038133611d85565b50565b6040516001600160a01b03831660248201526044810182905261062690849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990931692909217909152611df8565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166108af576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055611ad83390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16156108af576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000611beb611baa8484611edd565b8560405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b949350505050565b6000806000611c028585611fee565b91509150611c0f81612033565b509392505050565b611c2c6001600160a01b03841683600061217d565b6106266001600160a01b038416838361217d565b6040805160028082526060820183526000926020830190803683370190505090508381600081518110611c7557611c75613055565b60200260200101906001600160a01b031690816001600160a01b0316815250508281600181518110611ca957611ca9613055565b6001600160a01b039283166020918202929092010152600554166338ed17398360008430611cd9426103e8613106565b6040518663ffffffff1660e01b8152600401611cf9959493929190613119565b6000604051808303816000875af1158015611d18573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d40919081019061318a565b5050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611d7f9085906323b872dd60e01b90608401611a32565b50505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166108af57611db681612299565b611dc18360206122ab565b604051602001611dd2929190613230565b60408051601f198184030181529082905262461bcd60e51b82526101e4916004016132b1565b6000611e4d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661245b9092919063ffffffff16565b8051909150156106265780806020019051810190611e6b91906132c4565b6106265760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016101e4565b6001600160a01b0381166000908152600260209081526040808320858452909152812054611fc857604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527f22559d2b8a992a2cf613d2350829282861fc6625a2e7bd31b0f723037f6d39f7828401527fb30367effb941b728181f67f3bd24a38a4fff408ee7fb3b074425c9fb5e9be746060830152608082018690526001600160a01b03851660a08084018290528451808503909101815260c09093018452825192820192909220600092835260028252838320878452909152919020555b506001600160a01b03166000908152600260209081526040808320938352929052205490565b60008082516041036120245760208301516040840151606085015160001a6120188782858561246a565b9450945050505061202c565b506000905060025b9250929050565b6000816004811115612047576120476132e6565b0361204f5750565b6001816004811115612063576120636132e6565b036120b05760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016101e4565b60028160048111156120c4576120c46132e6565b036121115760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016101e4565b6003816004811115612125576121256132e6565b03611a035760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016101e4565b8015806121f75750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa1580156121d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121f59190612e06565b155b6122695760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084016101e4565b6040516001600160a01b03831660248201526044810182905261062690849063095ea7b360e01b90606401611a32565b60606106016001600160a01b03831660145b606060006122ba8360026132fc565b6122c5906002613106565b67ffffffffffffffff8111156122dd576122dd6128f3565b6040519080825280601f01601f191660200182016040528015612307576020820181803683370190505b509050600360fc1b8160008151811061232257612322613055565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061235157612351613055565b60200101906001600160f81b031916908160001a90535060006123758460026132fc565b612380906001613106565b90505b6001811115612405577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106123c1576123c1613055565b1a60f81b8282815181106123d7576123d7613055565b60200101906001600160f81b031916908160001a90535060049490941c936123fe81613313565b9050612383565b5083156124545760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016101e4565b9392505050565b6060611beb848460008561252e565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156124a15750600090506003612525565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156124f5573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661251e57600060019250925050612525565b9150600090505b94509492505050565b6060824710156125a65760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016101e4565b600080866001600160a01b031685876040516125c2919061332a565b60006040518083038185875af1925050503d80600081146125ff576040519150601f19603f3d011682016040523d82523d6000602084013e612604565b606091505b509150915061261587838387612620565b979650505050505050565b6060831561268f578251600003612688576001600160a01b0385163b6126885760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101e4565b5081611beb565b611beb83838151156126a45781518083602001fd5b8060405162461bcd60e51b81526004016101e491906132b1565b6000602082840312156126d057600080fd5b81356001600160e01b03198116811461245457600080fd5b6001600160a01b0381168114611a0357600080fd5b8035612708816126e8565b919050565b6000806040838503121561272057600080fd5b823561272b816126e8565b946020939093013593505050565b60006020828403121561274b57600080fd5b5035919050565b60005b8381101561276d578181015183820152602001612755565b50506000910152565b6000815180845261278e816020860160208601612752565b601f01601f19169290920160200192915050565b8a81526001600160a01b038a8116602083015261ffff8a8116604084015289811660608401528882166080840152871660a0830152851660c082015283151560e08201526101008101839052610140610120820181905260009061280883820185612776565b9d9c50505050505050505050505050565b600080600080600060a0868803121561283157600080fd5b853561283c816126e8565b9450602086013561284c816126e8565b9350604086013561285c816126e8565b9250606086013561286c816126e8565b9150608086013561287c816126e8565b809150509295509295909350565b6000806040838503121561289d57600080fd5b8235915060208301356128af816126e8565b809150509250929050565b61ffff81168114611a0357600080fd5b8035612708816128ba565b600080604083850312156128e857600080fd5b823561272b816128ba565b634e487b7160e01b600052604160045260246000fd5b604051610120810167ffffffffffffffff8111828210171561292d5761292d6128f3565b60405290565b604051610140810167ffffffffffffffff8111828210171561292d5761292d6128f3565b604051601f8201601f1916810167ffffffffffffffff81118282101715612980576129806128f3565b604052919050565b60006040828403121561299a57600080fd5b6040516040810181811067ffffffffffffffff821117156129bd576129bd6128f3565b60405282356129cb816128ba565b81526020928301359281019290925250919050565b6000602082840312156129f257600080fd5b8135612454816126e8565b600060208284031215612a0f57600080fd5b8135612454816128ba565b600067ffffffffffffffff821115612a3457612a346128f3565b50601f01601f191660200190565b600082601f830112612a5357600080fd5b8135612a66612a6182612a1a565b612957565b818152846020838601011115612a7b57600080fd5b816020850160208301376000918101602001919091529392505050565b600060208284031215612aaa57600080fd5b813567ffffffffffffffff80821115612ac257600080fd5b908301906101208286031215612ad757600080fd5b612adf612909565b612ae8836126fd565b815260208301356020820152612b00604084016128ca565b6040820152612b11606084016128ca565b6060820152612b22608084016126fd565b6080820152612b3360a084016128ca565b60a0820152612b4460c084016126fd565b60c082015260e083013560e08201526101008084013583811115612b6757600080fd5b612b7388828701612a42565b918301919091525095945050505050565b60008060208385031215612b9757600080fd5b823567ffffffffffffffff80821115612baf57600080fd5b818501915085601f830112612bc357600080fd5b813581811115612bd257600080fd5b866020606083028501011115612be757600080fd5b60209290920196919550909350505050565b600181811c90821680612c0d57607f821691505b602082108103612c2d57634e487b7160e01b600052602260045260246000fd5b50919050565b8051612708816128ba565b8051612708816126e8565b600082601f830112612c5a57600080fd5b8151612c68612a6182612a1a565b818152846020838601011115612c7d57600080fd5b611beb826020830160208701612752565b600060208284031215612ca057600080fd5b815167ffffffffffffffff80821115612cb857600080fd5b908301906101408286031215612ccd57600080fd5b612cd5612933565b612cde83612c33565b8152612cec60208401612c33565b6020820152612cfd60408401612c33565b6040820152612d0e60608401612c3e565b60608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015183811115612d5b57600080fd5b612b7388828701612c49565b600060a08284031215612d7957600080fd5b60405160a0810181811067ffffffffffffffff82111715612d9c57612d9c6128f3565b6040528251612daa816128ba565b81526020830151612dba816126e8565b806020830152506040830151604082015260608301516060820152608083015160808201528091505092915050565b600060208284031215612dfb57600080fd5b8151612454816126e8565b600060208284031215612e1857600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561060157610601612e1f565b600061ffff60f01b808960f01b168352808860f01b166002840152506bffffffffffffffffffffffff19808760601b166004840152856018840152808560601b166038840152508251612ea281604c850160208701612752565b91909101604c01979650505050505050565b60208152600061ffff808451166020840152806020850151166040840152506040830151612ee8606084018261ffff169052565b5060608301516080830152608083015160a083015260a0830151612f1760c08401826001600160a01b03169052565b5060c08301516001600160a01b03811660e08401525060e083015161010083810152611beb610120840182612776565b601f82111561062657600081815260208120601f850160051c81016020861015612f6e5750805b601f850160051c820191505b81811015612f8d57828155600101612f7a565b505050505050565b815167ffffffffffffffff811115612faf57612faf6128f3565b612fc381612fbd8454612bf9565b84612f47565b602080601f831160018114612ff85760008415612fe05750858301515b600019600386901b1c1916600185901b178555612f8d565b600085815260208120601f198616915b8281101561302757888601518255948401946001909101908401613008565b50858210156130455787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052603260045260246000fd5b8135613076816126e8565b6001600160a01b03811690508154816001600160a01b0319821617835560208401356130a1816128ba565b75ffff00000000000000000000000000000000000000008160a01b168375ffffffffffffffffffffffffffffffffffffffffffff19841617178455505050604082013560018201555050565b6000600182016130ff576130ff612e1f565b5060010190565b8082018082111561060157610601612e1f565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156131695784516001600160a01b031683529383019391830191600101613144565b50506001600160a01b03969096166060850152505050608001529392505050565b6000602080838503121561319d57600080fd5b825167ffffffffffffffff808211156131b557600080fd5b818501915085601f8301126131c957600080fd5b8151818111156131db576131db6128f3565b8060051b91506131ec848301612957565b818152918301840191848101908884111561320657600080fd5b938501935b838510156132245784518252938501939085019061320b565b98975050505050505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613268816017850160208801612752565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516132a5816028840160208801612752565b01602801949350505050565b6020815260006124546020830184612776565b6000602082840312156132d657600080fd5b8151801515811461245457600080fd5b634e487b7160e01b600052602160045260246000fd5b808202811582820484141761060157610601612e1f565b60008161332257613322612e1f565b506000190190565b6000825161333c818460208701612752565b919091019291505056fea2646970667358221220a0fd4716445bfb92caf2f65065c36b9a644c3f69f20cd2b631fe749f47788a9f64736f6c63430008130033

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading