ETH Price: $2,556.39 (+0.51%)

Transaction Decoder

Block:
16207695 at Dec-17-2022 11:27:35 PM +UTC
Transaction Fee:
0.005180131318760604 ETH $13.24
Gas Used:
211,788 Gas / 24.459040733 Gwei

Emitted Events:

89 TransparentUpgradeableProxy.0xf28044030a28cf7d3fb8e8f7bbaa42aee92214081fd522b3a38afb279577db89( 0xf28044030a28cf7d3fb8e8f7bbaa42aee92214081fd522b3a38afb279577db89, 0x000000000000000000000000f17e65822b568b3903685a7c9f496cf7656cc6c2, 0x000000000000000000000000000000000000000000005d0ddd07a215908e1daf )
90 BicoTokenProxy.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x0000000000000000000000002a5c2568b10a0e826bfa892cf21ba7218310180b, 0x000000000000000000000000b681e94cadf59bb445dd30439912e3e8e6c8ea32, 0000000000000000000000000000000000000000000000092c053a2168469f9e )
91 TransparentUpgradeableProxy.0x70516e69d9b3069ff3184583d867f7a832772e850ba89b554ae06ff752474f9e( 0x70516e69d9b3069ff3184583d867f7a832772e850ba89b554ae06ff752474f9e, 0x000000000000000000000000f17e65822b568b3903685a7c9f496cf7656cc6c2, 0x0000000000000000000000000000000000000000000000092c053a2168469f9e, 0x000000000000000000000000b681e94cadf59bb445dd30439912e3e8e6c8ea32 )

Account State Difference:

  Address   Before After State Difference Code
(builder0x69)
1.977614977648830282 Eth1.977932659648830282 Eth0.000317682
0xb681e94c...8e6C8eA32
0.009748607658914354 Eth
Nonce: 192
0.00456847634015375 Eth
Nonce: 193
0.005180131318760604
0xc49B65e5...2668717c2
0xebaB24F1...54e15F7b9
(Biconomy: Liquidity Providers)
0xF17e6582...7656Cc6C2

Execution Trace

TransparentUpgradeableProxy.9d7de6b3( )
  • LiquidityProviders.removeLiquidity( _nftId=940, _amount=168099000000000000000 )
    • TransparentUpgradeableProxy.6914db60( )
      • LPToken.tokenMetadata( 940 ) => ( token=0xF17e65822b568B3903685a7c9F496CF7656Cc6C2, suppliedLiquidity=168099000000000000000, shares=168092092624251120856787041551708710066 )
      • TransparentUpgradeableProxy.4f558e79( )
        • LPToken.exists( _tokenId=940 ) => ( True )
        • TransparentUpgradeableProxy.6352211e( )
          • LPToken.ownerOf( tokenId=940 ) => ( 0xb681e94cadf59bb445Dd30439912E3e8e6C8eA32 )
          • TransparentUpgradeableProxy.6914db60( )
            • LPToken.tokenMetadata( 940 ) => ( token=0xF17e65822b568B3903685a7c9F496CF7656Cc6C2, suppliedLiquidity=168099000000000000000, shares=168092092624251120856787041551708710066 )
            • TransparentUpgradeableProxy.fa5e2abc( )
              • TokenManager.getTokensInfo( tokenAddress=0xF17e65822b568B3903685a7c9F496CF7656Cc6C2 ) => ( [{name:transferOverhead, type:uint256, order:1, indexed:false, value:85949, valueString:85949}, {name:supportedToken, type:bool, order:2, indexed:false, value:true, valueString:True}, {name:equilibriumFee, type:uint256, order:3, indexed:false, value:7500000, valueString:7500000}, {name:maxFee, type:uint256, order:4, indexed:false, value:50000000, valueString:50000000}, {name:tokenConfig, type:tuple, order:5, indexed:false, value:[{name:min, type:uint256, order:1, indexed:false, value:50000000000000000000, valueString:50000000000000000000}, {name:max, type:uint256, order:2, indexed:false, value:550000000000000000000000, valueString:550000000000000000000000}], valueString:[{name:min, type:uint256, order:1, indexed:false, value:50000000000000000000, valueString:50000000000000000000}, {name:max, type:uint256, order:2, indexed:false, value:550000000000000000000000, valueString:550000000000000000000000}]}] )
              • TransparentUpgradeableProxy.e23fec91( )
                • WhitelistPeriodManager.beforeLiquidityRemoval( _lp=0xb681e94cadf59bb445Dd30439912E3e8e6C8eA32, _token=0xF17e65822b568B3903685a7c9F496CF7656Cc6C2, _amount=168099000000000000000 )
                • TransparentUpgradeableProxy.6914db60( )
                  • LPToken.tokenMetadata( 940 ) => ( token=0xF17e65822b568B3903685a7c9F496CF7656Cc6C2, suppliedLiquidity=168099000000000000000, shares=168092092624251120856787041551708710066 )
                  • TransparentUpgradeableProxy.4810f4ae( )
                    • LPToken.updateTokenMetadata( _tokenId=940, _lpTokenMetadata=[{name:token, type:address, order:1, indexed:false, value:0xF17e65822b568B3903685a7c9F496CF7656Cc6C2, valueString:0xF17e65822b568B3903685a7c9F496CF7656Cc6C2}, {name:suppliedLiquidity, type:uint256, order:2, indexed:false, value:0, valueString:0}, {name:shares, type:uint256, order:3, indexed:false, value:157869009198802082436, valueString:157869009198802082436}] )
                    • TransparentUpgradeableProxy.beabacc8( )
                      • LiquidityPool.transfer( _tokenAddress=0xF17e65822b568B3903685a7c9F496CF7656Cc6C2, receiver=0xb681e94cadf59bb445Dd30439912E3e8e6C8eA32, _tokenAmount=169192702091096137630 )
                        • BicoTokenProxy.70a08231( )
                          • BicoTokenImplementation.balanceOf( account=0x2A5c2568b10A0E826BfA892Cf21BA7218310180b ) => ( 430713878617830032788695 )
                          • BicoTokenProxy.a9059cbb( )
                            • BicoTokenImplementation.transfer( recipient=0xb681e94cadf59bb445Dd30439912E3e8e6C8eA32, amount=169192702091096137630 ) => ( True )
                              File 1 of 12: TransparentUpgradeableProxy
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
                              import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
                              import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
                              // Kept for backwards compatibility with older versions of Hardhat and Truffle plugins.
                              contract AdminUpgradeabilityProxy is TransparentUpgradeableProxy {
                                  constructor(address logic, address admin, bytes memory data) payable TransparentUpgradeableProxy(logic, admin, data) {}
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../Proxy.sol";
                              import "./ERC1967Upgrade.sol";
                              /**
                               * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
                               * implementation address that can be changed. This address is stored in storage in the location specified by
                               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
                               * implementation behind the proxy.
                               */
                              contract ERC1967Proxy is Proxy, ERC1967Upgrade {
                                  /**
                                   * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
                                   *
                                   * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
                                   * function call, and allows initializating the storage of the proxy like a Solidity constructor.
                                   */
                                  constructor(address _logic, bytes memory _data) payable {
                                      assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
                                      _upgradeToAndCall(_logic, _data, false);
                                  }
                                  /**
                                   * @dev Returns the current implementation address.
                                   */
                                  function _implementation() internal view virtual override returns (address impl) {
                                      return ERC1967Upgrade._getImplementation();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../ERC1967/ERC1967Proxy.sol";
                              /**
                               * @dev This contract implements a proxy that is upgradeable by an admin.
                               *
                               * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
                               * clashing], which can potentially be used in an attack, this contract uses the
                               * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
                               * things that go hand in hand:
                               *
                               * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
                               * that call matches one of the admin functions exposed by the proxy itself.
                               * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
                               * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
                               * "admin cannot fallback to proxy target".
                               *
                               * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
                               * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
                               * to sudden errors when trying to call a function from the proxy implementation.
                               *
                               * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
                               * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
                               */
                              contract TransparentUpgradeableProxy is ERC1967Proxy {
                                  /**
                                   * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
                                   * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
                                   */
                                  constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
                                      assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
                                      _changeAdmin(admin_);
                                  }
                                  /**
                                   * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
                                   */
                                  modifier ifAdmin() {
                                      if (msg.sender == _getAdmin()) {
                                          _;
                                      } else {
                                          _fallback();
                                      }
                                  }
                                  /**
                                   * @dev Returns the current admin.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
                                   *
                                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                                   * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
                                   */
                                  function admin() external ifAdmin returns (address admin_) {
                                      admin_ = _getAdmin();
                                  }
                                  /**
                                   * @dev Returns the current implementation.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
                                   *
                                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                                   * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
                                   */
                                  function implementation() external ifAdmin returns (address implementation_) {
                                      implementation_ = _implementation();
                                  }
                                  /**
                                   * @dev Changes the admin of the proxy.
                                   *
                                   * Emits an {AdminChanged} event.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
                                   */
                                  function changeAdmin(address newAdmin) external virtual ifAdmin {
                                      _changeAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev Upgrade the implementation of the proxy.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
                                   */
                                  function upgradeTo(address newImplementation) external ifAdmin {
                                      _upgradeToAndCall(newImplementation, bytes(""), false);
                                  }
                                  /**
                                   * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
                                   * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
                                   * proxied contract.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
                                   */
                                  function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
                                      _upgradeToAndCall(newImplementation, data, true);
                                  }
                                  /**
                                   * @dev Returns the current admin.
                                   */
                                  function _admin() internal view virtual returns (address) {
                                      return _getAdmin();
                                  }
                                  /**
                                   * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
                                   */
                                  function _beforeFallback() internal virtual override {
                                      require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
                                      super._beforeFallback();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "./TransparentUpgradeableProxy.sol";
                              import "../../access/Ownable.sol";
                              /**
                               * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
                               * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
                               */
                              contract ProxyAdmin is Ownable {
                                  /**
                                   * @dev Returns the current implementation of `proxy`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
                                      // We need to manually run the static call since the getter cannot be flagged as view
                                      // bytes4(keccak256("implementation()")) == 0x5c60da1b
                                      (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
                                      require(success);
                                      return abi.decode(returndata, (address));
                                  }
                                  /**
                                   * @dev Returns the current admin of `proxy`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
                                      // We need to manually run the static call since the getter cannot be flagged as view
                                      // bytes4(keccak256("admin()")) == 0xf851a440
                                      (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
                                      require(success);
                                      return abi.decode(returndata, (address));
                                  }
                                  /**
                                   * @dev Changes the admin of `proxy` to `newAdmin`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the current admin of `proxy`.
                                   */
                                  function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {
                                      proxy.changeAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {
                                      proxy.upgradeTo(implementation);
                                  }
                                  /**
                                   * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See
                                   * {TransparentUpgradeableProxy-upgradeToAndCall}.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable virtual onlyOwner {
                                      proxy.upgradeToAndCall{value: msg.value}(implementation, data);
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
                               * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
                               * be specified by overriding the virtual {_implementation} function.
                               *
                               * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
                               * different contract through the {_delegate} function.
                               *
                               * The success and return data of the delegated call will be returned back to the caller of the proxy.
                               */
                              abstract contract Proxy {
                                  /**
                                   * @dev Delegates the current call to `implementation`.
                                   *
                                   * This function does not return to its internall call site, it will return directly to the external caller.
                                   */
                                  function _delegate(address implementation) internal virtual {
                                      // solhint-disable-next-line no-inline-assembly
                                      assembly {
                                          // Copy msg.data. We take full control of memory in this inline assembly
                                          // block because it will not return to Solidity code. We overwrite the
                                          // Solidity scratch pad at memory position 0.
                                          calldatacopy(0, 0, calldatasize())
                                          // Call the implementation.
                                          // out and outsize are 0 because we don't know the size yet.
                                          let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
                                          // Copy the returned data.
                                          returndatacopy(0, 0, returndatasize())
                                          switch result
                                          // delegatecall returns 0 on error.
                                          case 0 { revert(0, returndatasize()) }
                                          default { return(0, returndatasize()) }
                                      }
                                  }
                                  /**
                                   * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
                                   * and {_fallback} should delegate.
                                   */
                                  function _implementation() internal view virtual returns (address);
                                  /**
                                   * @dev Delegates the current call to the address returned by `_implementation()`.
                                   *
                                   * This function does not return to its internall call site, it will return directly to the external caller.
                                   */
                                  function _fallback() internal virtual {
                                      _beforeFallback();
                                      _delegate(_implementation());
                                  }
                                  /**
                                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
                                   * function in the contract matches the call data.
                                   */
                                  fallback () external payable virtual {
                                      _fallback();
                                  }
                                  /**
                                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
                                   * is empty.
                                   */
                                  receive () external payable virtual {
                                      _fallback();
                                  }
                                  /**
                                   * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
                                   * call, or as part of the Solidity `fallback` or `receive` functions.
                                   *
                                   * If overriden should call `super._beforeFallback()`.
                                   */
                                  function _beforeFallback() internal virtual {
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.2;
                              import "../beacon/IBeacon.sol";
                              import "../../utils/Address.sol";
                              import "../../utils/StorageSlot.sol";
                              /**
                               * @dev This abstract contract provides getters and event emitting update functions for
                               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
                               *
                               * _Available since v4.1._
                               *
                               * @custom:oz-upgrades-unsafe-allow delegatecall
                               */
                              abstract contract ERC1967Upgrade {
                                  // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
                                  bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
                                  /**
                                   * @dev Storage slot with the address of the current implementation.
                                   * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
                                   * validated in the constructor.
                                   */
                                  bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                                  /**
                                   * @dev Emitted when the implementation is upgraded.
                                   */
                                  event Upgraded(address indexed implementation);
                                  /**
                                   * @dev Returns the current implementation address.
                                   */
                                  function _getImplementation() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new address in the EIP1967 implementation slot.
                                   */
                                  function _setImplementation(address newImplementation) private {
                                      require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                                      StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                                  }
                                  /**
                                   * @dev Perform implementation upgrade
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeTo(address newImplementation) internal {
                                      _setImplementation(newImplementation);
                                      emit Upgraded(newImplementation);
                                  }
                                  /**
                                   * @dev Perform implementation upgrade with additional setup call.
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
                                      _setImplementation(newImplementation);
                                      emit Upgraded(newImplementation);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(newImplementation, data);
                                      }
                                  }
                                  /**
                                   * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeToAndCallSecure(address newImplementation, bytes memory data, bool forceCall) internal {
                                      address oldImplementation = _getImplementation();
                                      // Initial upgrade and setup call
                                      _setImplementation(newImplementation);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(newImplementation, data);
                                      }
                                      // Perform rollback test if not already in progress
                                      StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT);
                                      if (!rollbackTesting.value) {
                                          // Trigger rollback using upgradeTo from the new implementation
                                          rollbackTesting.value = true;
                                          Address.functionDelegateCall(
                                              newImplementation,
                                              abi.encodeWithSignature(
                                                  "upgradeTo(address)",
                                                  oldImplementation
                                              )
                                          );
                                          rollbackTesting.value = false;
                                          // Check rollback was effective
                                          require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
                                          // Finally reset to the new implementation and log the upgrade
                                          _setImplementation(newImplementation);
                                          emit Upgraded(newImplementation);
                                      }
                                  }
                                  /**
                                   * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
                                   * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
                                   *
                                   * Emits a {BeaconUpgraded} event.
                                   */
                                  function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
                                      _setBeacon(newBeacon);
                                      emit BeaconUpgraded(newBeacon);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
                                      }
                                  }
                                  /**
                                   * @dev Storage slot with the admin of the contract.
                                   * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
                                   * validated in the constructor.
                                   */
                                  bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                                  /**
                                   * @dev Emitted when the admin account has changed.
                                   */
                                  event AdminChanged(address previousAdmin, address newAdmin);
                                  /**
                                   * @dev Returns the current admin.
                                   */
                                  function _getAdmin() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new address in the EIP1967 admin slot.
                                   */
                                  function _setAdmin(address newAdmin) private {
                                      require(newAdmin != address(0), "ERC1967: new admin is the zero address");
                                      StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
                                  }
                                  /**
                                   * @dev Changes the admin of the proxy.
                                   *
                                   * Emits an {AdminChanged} event.
                                   */
                                  function _changeAdmin(address newAdmin) internal {
                                      emit AdminChanged(_getAdmin(), newAdmin);
                                      _setAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
                                   * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
                                   */
                                  bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
                                  /**
                                   * @dev Emitted when the beacon is upgraded.
                                   */
                                  event BeaconUpgraded(address indexed beacon);
                                  /**
                                   * @dev Returns the current beacon.
                                   */
                                  function _getBeacon() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new beacon in the EIP1967 beacon slot.
                                   */
                                  function _setBeacon(address newBeacon) private {
                                      require(
                                          Address.isContract(newBeacon),
                                          "ERC1967: new beacon is not a contract"
                                      );
                                      require(
                                          Address.isContract(IBeacon(newBeacon).implementation()),
                                          "ERC1967: beacon implementation is not a contract"
                                      );
                                      StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This is the interface that {BeaconProxy} expects of its beacon.
                               */
                              interface IBeacon {
                                  /**
                                   * @dev Must return an address that can be used as a delegate call target.
                                   *
                                   * {BeaconProxy} will check that this address is a contract.
                                   */
                                  function implementation() external view returns (address);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @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
                                   * ====
                                   */
                                  function isContract(address account) internal view returns (bool) {
                                      // This method relies on extcodesize, which returns 0 for contracts in
                                      // construction, since the code is only stored at the end of the
                                      // constructor execution.
                                      uint256 size;
                                      // solhint-disable-next-line no-inline-assembly
                                      assembly { size := extcodesize(account) }
                                      return size > 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");
                                      // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
                                      (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 functionCall(target, data, "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");
                                      require(isContract(target), "Address: call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.call{ value: value }(data);
                                      return _verifyCallResult(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) {
                                      require(isContract(target), "Address: static call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.staticcall(data);
                                      return _verifyCallResult(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) {
                                      require(isContract(target), "Address: delegate call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.delegatecall(data);
                                      return _verifyCallResult(success, returndata, errorMessage);
                                  }
                                  function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
                                      if (success) {
                                          return returndata;
                                      } else {
                                          // 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
                                              // solhint-disable-next-line no-inline-assembly
                                              assembly {
                                                  let returndata_size := mload(returndata)
                                                  revert(add(32, returndata), returndata_size)
                                              }
                                          } else {
                                              revert(errorMessage);
                                          }
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev Library for reading and writing primitive types to specific storage slots.
                               *
                               * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
                               * This library helps with reading and writing to such slots without the need for inline assembly.
                               *
                               * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
                               *
                               * Example usage to set ERC1967 implementation slot:
                               * ```
                               * contract ERC1967 {
                               *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                               *
                               *     function _getImplementation() internal view returns (address) {
                               *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                               *     }
                               *
                               *     function _setImplementation(address newImplementation) internal {
                               *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                               *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                               *     }
                               * }
                               * ```
                               *
                               * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
                               */
                              library StorageSlot {
                                  struct AddressSlot {
                                      address value;
                                  }
                                  struct BooleanSlot {
                                      bool value;
                                  }
                                  struct Bytes32Slot {
                                      bytes32 value;
                                  }
                                  struct Uint256Slot {
                                      uint256 value;
                                  }
                                  /**
                                   * @dev Returns an `AddressSlot` with member `value` located at `slot`.
                                   */
                                  function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
                                   */
                                  function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
                                   */
                                  function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
                                   */
                                  function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/Context.sol";
                              /**
                               * @dev Contract module which provides a basic access control mechanism, where
                               * there is an account (an owner) that can be granted exclusive access to
                               * specific functions.
                               *
                               * By default, the owner account will be the one that deploys the contract. This
                               * can later be changed with {transferOwnership}.
                               *
                               * This module is used through inheritance. It will make available the modifier
                               * `onlyOwner`, which can be applied to your functions to restrict their use to
                               * the owner.
                               */
                              abstract contract Ownable is Context {
                                  address private _owner;
                                  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                                  /**
                                   * @dev Initializes the contract setting the deployer as the initial owner.
                                   */
                                  constructor () {
                                      address msgSender = _msgSender();
                                      _owner = msgSender;
                                      emit OwnershipTransferred(address(0), msgSender);
                                  }
                                  /**
                                   * @dev Returns the address of the current owner.
                                   */
                                  function owner() public view virtual returns (address) {
                                      return _owner;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the owner.
                                   */
                                  modifier onlyOwner() {
                                      require(owner() == _msgSender(), "Ownable: caller is not the owner");
                                      _;
                                  }
                                  /**
                                   * @dev Leaves the contract without owner. It will not be possible to call
                                   * `onlyOwner` functions anymore. Can only be called by the current owner.
                                   *
                                   * NOTE: Renouncing ownership will leave the contract without an owner,
                                   * thereby removing any functionality that is only available to the owner.
                                   */
                                  function renounceOwnership() public virtual onlyOwner {
                                      emit OwnershipTransferred(_owner, address(0));
                                      _owner = address(0);
                                  }
                                  /**
                                   * @dev Transfers ownership of the contract to a new account (`newOwner`).
                                   * Can only be called by the current owner.
                                   */
                                  function transferOwnership(address newOwner) public virtual onlyOwner {
                                      require(newOwner != address(0), "Ownable: new owner is the zero address");
                                      emit OwnershipTransferred(_owner, newOwner);
                                      _owner = newOwner;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              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) {
                                      this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
                                      return msg.data;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../ERC1967/ERC1967Upgrade.sol";
                              /**
                               * @dev Base contract for building openzeppelin-upgrades compatible implementations for the {ERC1967Proxy}. It includes
                               * publicly available upgrade functions that are called by the plugin and by the secure upgrade mechanism to verify
                               * continuation of the upgradability.
                               *
                               * The {_authorizeUpgrade} function MUST be overridden to include access restriction to the upgrade mechanism.
                               *
                               * _Available since v4.1._
                               */
                              abstract contract UUPSUpgradeable is ERC1967Upgrade {
                                  function upgradeTo(address newImplementation) external virtual {
                                      _authorizeUpgrade(newImplementation);
                                      _upgradeToAndCallSecure(newImplementation, bytes(""), false);
                                  }
                                  function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual {
                                      _authorizeUpgrade(newImplementation);
                                      _upgradeToAndCallSecure(newImplementation, data, true);
                                  }
                                  function _authorizeUpgrade(address newImplementation) internal virtual;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.2;
                              import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
                              abstract contract Proxiable is UUPSUpgradeable {
                                  function _authorizeUpgrade(address newImplementation) internal override {
                                      _beforeUpgrade(newImplementation);
                                  }
                                  function _beforeUpgrade(address newImplementation) internal virtual;
                              }
                              contract ChildOfProxiable is Proxiable {
                                  function _beforeUpgrade(address newImplementation) internal virtual override {}
                              }
                              

                              File 2 of 12: BicoTokenProxy
                              // Sources flattened with hardhat v2.6.4 https://hardhat.org
                              
                              // File @openzeppelin/contracts/proxy/[email protected]
                              
                              // SPDX-License-Identifier: MIT
                              
                              pragma solidity ^0.8.0;
                              
                              /**
                               * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
                               * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
                               * be specified by overriding the virtual {_implementation} function.
                               *
                               * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
                               * different contract through the {_delegate} function.
                               *
                               * The success and return data of the delegated call will be returned back to the caller of the proxy.
                               */
                              abstract contract Proxy {
                                  /**
                                   * @dev Delegates the current call to `implementation`.
                                   *
                                   * This function does not return to its internall call site, it will return directly to the external caller.
                                   */
                                  function _delegate(address implementation) internal virtual {
                                      assembly {
                                          // Copy msg.data. We take full control of memory in this inline assembly
                                          // block because it will not return to Solidity code. We overwrite the
                                          // Solidity scratch pad at memory position 0.
                                          calldatacopy(0, 0, calldatasize())
                              
                                          // Call the implementation.
                                          // out and outsize are 0 because we don't know the size yet.
                                          let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
                              
                                          // Copy the returned data.
                                          returndatacopy(0, 0, returndatasize())
                              
                                          switch result
                                          // delegatecall returns 0 on error.
                                          case 0 {
                                              revert(0, returndatasize())
                                          }
                                          default {
                                              return(0, returndatasize())
                                          }
                                      }
                                  }
                              
                                  /**
                                   * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
                                   * and {_fallback} should delegate.
                                   */
                                  function _implementation() internal view virtual returns (address);
                              
                                  /**
                                   * @dev Delegates the current call to the address returned by `_implementation()`.
                                   *
                                   * This function does not return to its internall call site, it will return directly to the external caller.
                                   */
                                  function _fallback() internal virtual {
                                      _beforeFallback();
                                      _delegate(_implementation());
                                  }
                              
                                  /**
                                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
                                   * function in the contract matches the call data.
                                   */
                                  fallback() external payable virtual {
                                      _fallback();
                                  }
                              
                                  /**
                                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
                                   * is empty.
                                   */
                                  receive() external payable virtual {
                                      _fallback();
                                  }
                              
                                  /**
                                   * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
                                   * call, or as part of the Solidity `fallback` or `receive` functions.
                                   *
                                   * If overriden should call `super._beforeFallback()`.
                                   */
                                  function _beforeFallback() internal virtual {}
                              }
                              
                              
                              // File @openzeppelin/contracts/proxy/beacon/[email protected]
                              
                              
                              
                              pragma solidity ^0.8.0;
                              
                              /**
                               * @dev This is the interface that {BeaconProxy} expects of its beacon.
                               */
                              interface IBeacon {
                                  /**
                                   * @dev Must return an address that can be used as a delegate call target.
                                   *
                                   * {BeaconProxy} will check that this address is a contract.
                                   */
                                  function implementation() external view returns (address);
                              }
                              
                              
                              // File @openzeppelin/contracts/utils/[email protected]
                              
                              
                              
                              pragma solidity ^0.8.0;
                              
                              /**
                               * @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
                                   * ====
                                   */
                                  function isContract(address account) internal view returns (bool) {
                                      // This method relies on extcodesize, which returns 0 for contracts in
                                      // construction, since the code is only stored at the end of the
                                      // constructor execution.
                              
                                      uint256 size;
                                      assembly {
                                          size := extcodesize(account)
                                      }
                                      return size > 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 functionCall(target, data, "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");
                                      require(isContract(target), "Address: call to non-contract");
                              
                                      (bool success, bytes memory returndata) = target.call{value: value}(data);
                                      return verifyCallResult(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) {
                                      require(isContract(target), "Address: static call to non-contract");
                              
                                      (bool success, bytes memory returndata) = target.staticcall(data);
                                      return verifyCallResult(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) {
                                      require(isContract(target), "Address: delegate call to non-contract");
                              
                                      (bool success, bytes memory returndata) = target.delegatecall(data);
                                      return verifyCallResult(success, returndata, errorMessage);
                                  }
                              
                                  /**
                                   * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
                                   * revert reason 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 {
                                          // 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
                              
                                              assembly {
                                                  let returndata_size := mload(returndata)
                                                  revert(add(32, returndata), returndata_size)
                                              }
                                          } else {
                                              revert(errorMessage);
                                          }
                                      }
                                  }
                              }
                              
                              
                              // File @openzeppelin/contracts/utils/[email protected]
                              
                              
                              
                              pragma solidity ^0.8.0;
                              
                              /**
                               * @dev Library for reading and writing primitive types to specific storage slots.
                               *
                               * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
                               * This library helps with reading and writing to such slots without the need for inline assembly.
                               *
                               * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
                               *
                               * Example usage to set ERC1967 implementation slot:
                               * ```
                               * contract ERC1967 {
                               *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                               *
                               *     function _getImplementation() internal view returns (address) {
                               *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                               *     }
                               *
                               *     function _setImplementation(address newImplementation) internal {
                               *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                               *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                               *     }
                               * }
                               * ```
                               *
                               * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
                               */
                              library StorageSlot {
                                  struct AddressSlot {
                                      address value;
                                  }
                              
                                  struct BooleanSlot {
                                      bool value;
                                  }
                              
                                  struct Bytes32Slot {
                                      bytes32 value;
                                  }
                              
                                  struct Uint256Slot {
                                      uint256 value;
                                  }
                              
                                  /**
                                   * @dev Returns an `AddressSlot` with member `value` located at `slot`.
                                   */
                                  function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                              
                                  /**
                                   * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
                                   */
                                  function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                              
                                  /**
                                   * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
                                   */
                                  function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                              
                                  /**
                                   * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
                                   */
                                  function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                              }
                              
                              
                              // File @openzeppelin/contracts/proxy/ERC1967/[email protected]
                              
                              
                              
                              pragma solidity ^0.8.2;
                              
                              
                              
                              /**
                               * @dev This abstract contract provides getters and event emitting update functions for
                               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
                               *
                               * _Available since v4.1._
                               *
                               * @custom:oz-upgrades-unsafe-allow delegatecall
                               */
                              abstract contract ERC1967Upgrade {
                                  // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
                                  bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
                              
                                  /**
                                   * @dev Storage slot with the address of the current implementation.
                                   * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
                                   * validated in the constructor.
                                   */
                                  bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                              
                                  /**
                                   * @dev Emitted when the implementation is upgraded.
                                   */
                                  event Upgraded(address indexed implementation);
                              
                                  /**
                                   * @dev Returns the current implementation address.
                                   */
                                  function _getImplementation() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                                  }
                              
                                  /**
                                   * @dev Stores a new address in the EIP1967 implementation slot.
                                   */
                                  function _setImplementation(address newImplementation) private {
                                      require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                                      StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                                  }
                              
                                  /**
                                   * @dev Perform implementation upgrade
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeTo(address newImplementation) internal {
                                      _setImplementation(newImplementation);
                                      emit Upgraded(newImplementation);
                                  }
                              
                                  /**
                                   * @dev Perform implementation upgrade with additional setup call.
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeToAndCall(
                                      address newImplementation,
                                      bytes memory data,
                                      bool forceCall
                                  ) internal {
                                      _upgradeTo(newImplementation);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(newImplementation, data);
                                      }
                                  }
                              
                                  /**
                                   * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeToAndCallSecure(
                                      address newImplementation,
                                      bytes memory data,
                                      bool forceCall
                                  ) internal {
                                      address oldImplementation = _getImplementation();
                              
                                      // Initial upgrade and setup call
                                      _setImplementation(newImplementation);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(newImplementation, data);
                                      }
                              
                                      // Perform rollback test if not already in progress
                                      StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT);
                                      if (!rollbackTesting.value) {
                                          // Trigger rollback using upgradeTo from the new implementation
                                          rollbackTesting.value = true;
                                          Address.functionDelegateCall(
                                              newImplementation,
                                              abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
                                          );
                                          rollbackTesting.value = false;
                                          // Check rollback was effective
                                          require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
                                          // Finally reset to the new implementation and log the upgrade
                                          _upgradeTo(newImplementation);
                                      }
                                  }
                              
                                  /**
                                   * @dev Storage slot with the admin of the contract.
                                   * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
                                   * validated in the constructor.
                                   */
                                  bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                              
                                  /**
                                   * @dev Emitted when the admin account has changed.
                                   */
                                  event AdminChanged(address previousAdmin, address newAdmin);
                              
                                  /**
                                   * @dev Returns the current admin.
                                   */
                                  function _getAdmin() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
                                  }
                              
                                  /**
                                   * @dev Stores a new address in the EIP1967 admin slot.
                                   */
                                  function _setAdmin(address newAdmin) private {
                                      require(newAdmin != address(0), "ERC1967: new admin is the zero address");
                                      StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
                                  }
                              
                                  /**
                                   * @dev Changes the admin of the proxy.
                                   *
                                   * Emits an {AdminChanged} event.
                                   */
                                  function _changeAdmin(address newAdmin) internal {
                                      emit AdminChanged(_getAdmin(), newAdmin);
                                      _setAdmin(newAdmin);
                                  }
                              
                                  /**
                                   * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
                                   * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
                                   */
                                  bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
                              
                                  /**
                                   * @dev Emitted when the beacon is upgraded.
                                   */
                                  event BeaconUpgraded(address indexed beacon);
                              
                                  /**
                                   * @dev Returns the current beacon.
                                   */
                                  function _getBeacon() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
                                  }
                              
                                  /**
                                   * @dev Stores a new beacon in the EIP1967 beacon slot.
                                   */
                                  function _setBeacon(address newBeacon) private {
                                      require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
                                      require(
                                          Address.isContract(IBeacon(newBeacon).implementation()),
                                          "ERC1967: beacon implementation is not a contract"
                                      );
                                      StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
                                  }
                              
                                  /**
                                   * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
                                   * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
                                   *
                                   * Emits a {BeaconUpgraded} event.
                                   */
                                  function _upgradeBeaconToAndCall(
                                      address newBeacon,
                                      bytes memory data,
                                      bool forceCall
                                  ) internal {
                                      _setBeacon(newBeacon);
                                      emit BeaconUpgraded(newBeacon);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
                                      }
                                  }
                              }
                              
                              
                              // File @openzeppelin/contracts/proxy/ERC1967/[email protected]
                              
                              
                              
                              pragma solidity ^0.8.0;
                              
                              
                              /**
                               * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
                               * implementation address that can be changed. This address is stored in storage in the location specified by
                               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
                               * implementation behind the proxy.
                               */
                              contract ERC1967Proxy is Proxy, ERC1967Upgrade {
                                  /**
                                   * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
                                   *
                                   * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
                                   * function call, and allows initializating the storage of the proxy like a Solidity constructor.
                                   */
                                  constructor(address _logic, bytes memory _data) payable {
                                      assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
                                      _upgradeToAndCall(_logic, _data, false);
                                  }
                              
                                  /**
                                   * @dev Returns the current implementation address.
                                   */
                                  function _implementation() internal view virtual override returns (address impl) {
                                      return ERC1967Upgrade._getImplementation();
                                  }
                              }
                              
                              
                              // File @openzeppelin/contracts/proxy/transparent/[email protected]
                              
                              
                              
                              pragma solidity ^0.8.0;
                              
                              /**
                               * @dev This contract implements a proxy that is upgradeable by an admin.
                               *
                               * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
                               * clashing], which can potentially be used in an attack, this contract uses the
                               * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
                               * things that go hand in hand:
                               *
                               * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
                               * that call matches one of the admin functions exposed by the proxy itself.
                               * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
                               * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
                               * "admin cannot fallback to proxy target".
                               *
                               * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
                               * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
                               * to sudden errors when trying to call a function from the proxy implementation.
                               *
                               * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
                               * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
                               */
                              contract TransparentUpgradeableProxy is ERC1967Proxy {
                                  /**
                                   * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
                                   * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
                                   */
                                  constructor(
                                      address _logic,
                                      address admin_,
                                      bytes memory _data
                                  ) payable ERC1967Proxy(_logic, _data) {
                                      assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
                                      _changeAdmin(admin_);
                                  }
                              
                                  /**
                                   * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
                                   */
                                  modifier ifAdmin() {
                                      if (msg.sender == _getAdmin()) {
                                          _;
                                      } else {
                                          _fallback();
                                      }
                                  }
                              
                                  /**
                                   * @dev Returns the current admin.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
                                   *
                                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                                   * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
                                   */
                                  function admin() external ifAdmin returns (address admin_) {
                                      admin_ = _getAdmin();
                                  }
                              
                                  /**
                                   * @dev Returns the current implementation.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
                                   *
                                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                                   * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
                                   */
                                  function implementation() external ifAdmin returns (address implementation_) {
                                      implementation_ = _implementation();
                                  }
                              
                                  /**
                                   * @dev Changes the admin of the proxy.
                                   *
                                   * Emits an {AdminChanged} event.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
                                   */
                                  function changeAdmin(address newAdmin) external virtual ifAdmin {
                                      _changeAdmin(newAdmin);
                                  }
                              
                                  /**
                                   * @dev Upgrade the implementation of the proxy.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
                                   */
                                  function upgradeTo(address newImplementation) external ifAdmin {
                                      _upgradeToAndCall(newImplementation, bytes(""), false);
                                  }
                              
                                  /**
                                   * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
                                   * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
                                   * proxied contract.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
                                   */
                                  function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
                                      _upgradeToAndCall(newImplementation, data, true);
                                  }
                              
                                  /**
                                   * @dev Returns the current admin.
                                   */
                                  function _admin() internal view virtual returns (address) {
                                      return _getAdmin();
                                  }
                              
                                  /**
                                   * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
                                   */
                                  function _beforeFallback() internal virtual override {
                                      require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
                                      super._beforeFallback();
                                  }
                              }
                              
                              
                              // File contracts/bico-token/bico/BicoTokenProxy.sol
                              
                              // contracts/bico-token/bico/BicoToken.sol
                              
                              
                              pragma solidity ^0.8.0;
                              
                              /**
                               * @dev This contract implements a proxy that is upgradeable by an admin.
                               *
                               * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
                               * clashing], which can potentially be used in an attack, this contract uses the
                               * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
                               * things that go hand in hand:
                               *
                               * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
                               * that call matches one of the admin functions exposed by the proxy itself.
                               * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
                               * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
                               * "admin cannot fallback to proxy target".
                               *
                               * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
                               * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
                               * to sudden errors when trying to call a function from the proxy implementation.
                               *
                               * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
                               * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
                               */
                              contract BicoTokenProxy is TransparentUpgradeableProxy {
                                  constructor (address _implementation,address _admin)
                                  TransparentUpgradeableProxy(_implementation,_admin,bytes("")) {
                                  }
                              
                                  function getAdmin() external view returns (address adm) {
                                    bytes32 slot = _ADMIN_SLOT;
                                    assembly {
                                      adm := sload(slot)
                                    }
                                  }
                              
                                  function getImplementation() external view returns (address impl) {
                                    bytes32 slot = _IMPLEMENTATION_SLOT;
                                    assembly {
                                      impl := sload(slot)
                                    }
                                  }    
                              }

                              File 3 of 12: LiquidityProviders
                              // $$\\       $$\\                     $$\\       $$\\ $$\\   $$\\                     $$$$$$$\\                                $$\\       $$\\
                              // $$ |      \\__|                    \\__|      $$ |\\__|  $$ |                    $$  __$$\\                               \\__|      $$ |
                              // $$ |      $$\\  $$$$$$\\  $$\\   $$\\ $$\\  $$$$$$$ |$$\\ $$$$$$\\   $$\\   $$\\       $$ |  $$ | $$$$$$\\   $$$$$$\\ $$\\    $$\\ $$\\  $$$$$$$ | $$$$$$\\   $$$$$$\\   $$$$$$$\\
                              // $$ |      $$ |$$  __$$\\ $$ |  $$ |$$ |$$  __$$ |$$ |\\_$$  _|  $$ |  $$ |      $$$$$$$  |$$  __$$\\ $$  __$$\\\\$$\\  $$  |$$ |$$  __$$ |$$  __$$\\ $$  __$$\\ $$  _____|
                              // $$ |      $$ |$$ /  $$ |$$ |  $$ |$$ |$$ /  $$ |$$ |  $$ |    $$ |  $$ |      $$  ____/ $$ |  \\__|$$ /  $$ |\\$$\\$$  / $$ |$$ /  $$ |$$$$$$$$ |$$ |  \\__|\\$$$$$$\\
                              // $$ |      $$ |$$ |  $$ |$$ |  $$ |$$ |$$ |  $$ |$$ |  $$ |$$\\ $$ |  $$ |      $$ |      $$ |      $$ |  $$ | \\$$$  /  $$ |$$ |  $$ |$$   ____|$$ |       \\____$$\\
                              // $$$$$$$$\\ $$ |\\$$$$$$$ |\\$$$$$$  |$$ |\\$$$$$$$ |$$ |  \\$$$$  |\\$$$$$$$ |      $$ |      $$ |      \\$$$$$$  |  \\$  /   $$ |\\$$$$$$$ |\\$$$$$$$\\ $$ |      $$$$$$$  |
                              // \\________|\\__| \\____$$ | \\______/ \\__| \\_______|\\__|   \\____/  \\____$$ |      \\__|      \\__|       \\______/    \\_/    \\__| \\_______| \\_______|\\__|      \\_______/
                              //                     $$ |                                      $$\\   $$ |
                              //                     $$ |                                      \\$$$$$$  |
                              //                     \\__|                                       \\______/
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                              import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
                              import "./metatx/ERC2771ContextUpgradeable.sol";
                              import "../security/Pausable.sol";
                              import "./interfaces/ILPToken.sol";
                              import "./interfaces/ITokenManager.sol";
                              import "./interfaces/IWhiteListPeriodManager.sol";
                              import "./interfaces/ILiquidityPool.sol";
                              contract LiquidityProviders is
                                  Initializable,
                                  ReentrancyGuardUpgradeable,
                                  ERC2771ContextUpgradeable,
                                  OwnableUpgradeable,
                                  Pausable
                              {
                                  using SafeERC20Upgradeable for IERC20Upgradeable;
                                  address internal constant NATIVE = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
                                  uint256 public constant BASE_DIVISOR = 10**18;
                                  ILPToken internal lpToken;
                                  ILiquidityPool internal liquidityPool;
                                  ITokenManager internal tokenManager;
                                  IWhiteListPeriodManager internal whiteListPeriodManager;
                                  event LiquidityAdded(address indexed tokenAddress, uint256 indexed amount, address indexed lp);
                                  event LiquidityRemoved(address indexed tokenAddress, uint256 indexed amount, address indexed lp);
                                  event FeeClaimed(address indexed tokenAddress, uint256 indexed fee, address indexed lp, uint256 sharesBurnt);
                                  event FeeAdded(address indexed tokenAddress, uint256 indexed fee);
                                  event EthReceived(address indexed sender, uint256 value);
                                  event CurrentLiquidityChanged(address indexed token, uint256 indexed newValue);
                                  // LP Fee Distribution
                                  mapping(address => uint256) public totalReserve; // Include Liquidity + Fee accumulated
                                  mapping(address => uint256) public totalLiquidity; // Include Liquidity only
                                  mapping(address => uint256) public currentLiquidity; // Include current liquidity, updated on every in and out transfer
                                  mapping(address => uint256) public totalLPFees;
                                  mapping(address => uint256) public totalSharesMinted;
                                  /**
                                   * @dev Modifier for checking to validate a NFTId and it's ownership
                                   * @param _tokenId token id to validate
                                   * @param _transactor typically msgSender(), passed to verify against owner of _tokenId
                                   */
                                  modifier onlyValidLpToken(uint256 _tokenId, address _transactor) {
                                      (address token, , ) = lpToken.tokenMetadata(_tokenId);
                                      require(lpToken.exists(_tokenId), "ERR__TOKEN_DOES_NOT_EXIST");
                                      require(lpToken.ownerOf(_tokenId) == _transactor, "ERR__TRANSACTOR_DOES_NOT_OWN_NFT");
                                      _;
                                  }
                                  /**
                                   * @dev Modifier for checking if msg.sender in liquiditypool
                                   */
                                  modifier onlyLiquidityPool() {
                                      require(_msgSender() == address(liquidityPool), "ERR__UNAUTHORIZED");
                                      _;
                                  }
                                  modifier tokenChecks(address tokenAddress) {
                                      require(tokenAddress != address(0), "Token address cannot be 0");
                                      require(_isSupportedToken(tokenAddress), "Token not supported");
                                      _;
                                  }
                                  /**
                                   * @dev initalizes the contract, acts as constructor
                                   * @param _trustedForwarder address of trusted forwarder
                                   */
                                  function initialize(
                                      address _trustedForwarder,
                                      address _lpToken,
                                      address _tokenManager,
                                      address _pauser
                                  ) public initializer {
                                      __ERC2771Context_init(_trustedForwarder);
                                      __Ownable_init();
                                      __Pausable_init(_pauser);
                                      __ReentrancyGuard_init();
                                      _setLPToken(_lpToken);
                                      _setTokenManager(_tokenManager);
                                  }
                                  function _isSupportedToken(address _token) internal view returns (bool) {
                                      return tokenManager.getTokensInfo(_token).supportedToken;
                                  }
                                  function getTotalReserveByToken(address tokenAddress) public view returns (uint256) {
                                      return totalReserve[tokenAddress];
                                  }
                                  function getSuppliedLiquidityByToken(address tokenAddress) public view returns (uint256) {
                                      return totalLiquidity[tokenAddress];
                                  }
                                  function getTotalLPFeeByToken(address tokenAddress) public view returns (uint256) {
                                      return totalLPFees[tokenAddress];
                                  }
                                  function getCurrentLiquidity(address tokenAddress) public view returns (uint256) {
                                      return currentLiquidity[tokenAddress];
                                  }
                                  /**
                                   * @dev To be called post initialization, used to set address of NFT Contract
                                   * @param _lpToken address of lpToken
                                   */
                                  function setLpToken(address _lpToken) external onlyOwner {
                                      _setLPToken(_lpToken);
                                  }
                                  /**
                                   * Internal method to set LP token contract.
                                   */
                                  function _setLPToken(address _lpToken) internal {
                                      lpToken = ILPToken(_lpToken);
                                  }
                                  function increaseCurrentLiquidity(address tokenAddress, uint256 amount) public onlyLiquidityPool {
                                      _increaseCurrentLiquidity(tokenAddress, amount);
                                  }
                                  function decreaseCurrentLiquidity(address tokenAddress, uint256 amount) public onlyLiquidityPool {
                                      _decreaseCurrentLiquidity(tokenAddress, amount);
                                  }
                                  function _increaseCurrentLiquidity(address tokenAddress, uint256 amount) private {
                                      currentLiquidity[tokenAddress] += amount;
                                      emit CurrentLiquidityChanged(tokenAddress, currentLiquidity[tokenAddress]);
                                  }
                                  function _decreaseCurrentLiquidity(address tokenAddress, uint256 amount) private {
                                      currentLiquidity[tokenAddress] -= amount;
                                      emit CurrentLiquidityChanged(tokenAddress, currentLiquidity[tokenAddress]);
                                  }
                                  /**
                                   * Public method to set TokenManager contract.
                                   */
                                  function setTokenManager(address _tokenManager) external onlyOwner {
                                      _setTokenManager(_tokenManager);
                                  }
                                  /**
                                   * Internal method to set TokenManager contract.
                                   */
                                  function _setTokenManager(address _tokenManager) internal {
                                      tokenManager = ITokenManager(_tokenManager);
                                  }
                                  function setTrustedForwarder(address _tf) external onlyOwner {
                                      _setTrustedForwarder(_tf);
                                  }
                                  /**
                                   * @dev To be called post initialization, used to set address of WhiteListPeriodManager Contract
                                   * @param _whiteListPeriodManager address of WhiteListPeriodManager
                                   */
                                  function setWhiteListPeriodManager(address _whiteListPeriodManager) external onlyOwner {
                                      whiteListPeriodManager = IWhiteListPeriodManager(_whiteListPeriodManager);
                                  }
                                  /**
                                   * @dev To be called post initialization, used to set address of LiquidityPool Contract
                                   * @param _liquidityPool address of LiquidityPool
                                   */
                                  function setLiquidityPool(address _liquidityPool) external onlyOwner {
                                      liquidityPool = ILiquidityPool(_liquidityPool);
                                  }
                                  /**
                                   * @dev Returns price of Base token in terms of LP Shares
                                   * @param _baseToken address of baseToken
                                   * @return Price of Base token in terms of LP Shares
                                   */
                                  function getTokenPriceInLPShares(address _baseToken) public view returns (uint256) {
                                      uint256 reserve = totalReserve[_baseToken];
                                      if (reserve > 0) {
                                          return totalSharesMinted[_baseToken] / totalReserve[_baseToken];
                                      }
                                      return BASE_DIVISOR;
                                  }
                                  /**
                                   * @dev Converts shares to token amount
                                   */
                                  function sharesToTokenAmount(uint256 _shares, address _tokenAddress) public view returns (uint256) {
                                      return (_shares * totalReserve[_tokenAddress]) / totalSharesMinted[_tokenAddress];
                                  }
                                  /**
                                   * @dev Returns the fee accumulated on a given NFT
                                   * @param _nftId Id of NFT
                                   * @return accumulated fee
                                   */
                                  function getFeeAccumulatedOnNft(uint256 _nftId) public view returns (uint256) {
                                      require(lpToken.exists(_nftId), "ERR__INVALID_NFT");
                                      (address _tokenAddress, uint256 nftSuppliedLiquidity, uint256 totalNFTShares) = lpToken.tokenMetadata(_nftId);
                                      if (totalNFTShares == 0) {
                                          return 0;
                                      }
                                      // Calculate rewards accumulated
                                      uint256 eligibleLiquidity = sharesToTokenAmount(totalNFTShares, _tokenAddress);
                                      uint256 lpFeeAccumulated;
                                      // Handle edge cases where eligibleLiquidity is less than what was supplied by very small amount
                                      if (nftSuppliedLiquidity > eligibleLiquidity) {
                                          lpFeeAccumulated = 0;
                                      } else {
                                          unchecked {
                                              lpFeeAccumulated = eligibleLiquidity - nftSuppliedLiquidity;
                                          }
                                      }
                                      return lpFeeAccumulated;
                                  }
                                  /**
                                   * @dev Records fee being added to total reserve
                                   * @param _token Address of Token for which LP fee is being added
                                   * @param _amount Amount being added
                                   */
                                  function addLPFee(address _token, uint256 _amount) external onlyLiquidityPool tokenChecks(_token) whenNotPaused {
                                      totalReserve[_token] += _amount;
                                      totalLPFees[_token] += _amount;
                                      emit FeeAdded(_token, _amount);
                                  }
                                  /**
                                   * @dev Internal function to add liquidity to a new NFT
                                   */
                                  function _addLiquidity(address _token, uint256 _amount) internal {
                                      require(_amount > 0, "ERR__AMOUNT_IS_0");
                                      uint256 nftId = lpToken.mint(_msgSender());
                                      LpTokenMetadata memory data = LpTokenMetadata(_token, 0, 0);
                                      lpToken.updateTokenMetadata(nftId, data);
                                      _increaseLiquidity(nftId, _amount);
                                  }
                                  /**
                                   * @dev Function to mint a new NFT for a user, add native liquidity and store the
                                   *      record in the newly minted NFT
                                   */
                                  function addNativeLiquidity() external payable nonReentrant tokenChecks(NATIVE) whenNotPaused {
                                      require(address(liquidityPool) != address(0), "ERR__LIQUIDITY_POOL_NOT_SET");
                                      (bool success, ) = address(liquidityPool).call{value: msg.value}("");
                                      require(success, "ERR__NATIVE_TRANSFER_FAILED");
                                      _addLiquidity(NATIVE, msg.value);
                                  }
                                  /**
                                   * @dev Function to mint a new NFT for a user, add token liquidity and store the
                                   *      record in the newly minted NFT
                                   * @param _token Address of token for which liquidity is to be added
                                   * @param _amount Amount of liquidity added
                                   */
                                  function addTokenLiquidity(address _token, uint256 _amount)
                                      external
                                      nonReentrant
                                      tokenChecks(_token)
                                      whenNotPaused
                                  {
                                      require(_token != NATIVE, "ERR__WRONG_FUNCTION");
                                      require(
                                          IERC20Upgradeable(_token).allowance(_msgSender(), address(this)) >= _amount,
                                          "ERR__INSUFFICIENT_ALLOWANCE"
                                      );
                                      SafeERC20Upgradeable.safeTransferFrom(IERC20Upgradeable(_token), _msgSender(), address(liquidityPool), _amount);
                                      _addLiquidity(_token, _amount);
                                  }
                                  /**
                                   * @dev Internal helper function to increase liquidity in a given NFT
                                   */
                                  function _increaseLiquidity(uint256 _nftId, uint256 _amount) internal onlyValidLpToken(_nftId, _msgSender()) {
                                      (address token, uint256 totalSuppliedLiquidity, uint256 totalShares) = lpToken.tokenMetadata(_nftId);
                                      require(_amount != 0, "ERR__AMOUNT_IS_0");
                                      whiteListPeriodManager.beforeLiquidityAddition(_msgSender(), token, _amount);
                                      uint256 mintedSharesAmount;
                                      // Adding liquidity in the pool for the first time
                                      if (totalReserve[token] == 0 || totalSharesMinted[token] == 0) {
                                          mintedSharesAmount = BASE_DIVISOR * _amount;
                                      } else {
                                          mintedSharesAmount = (_amount * totalSharesMinted[token]) / totalReserve[token];
                                      }
                                      require(mintedSharesAmount >= BASE_DIVISOR, "ERR__AMOUNT_BELOW_MIN_LIQUIDITY");
                                      totalLiquidity[token] += _amount;
                                      totalReserve[token] += _amount;
                                      totalSharesMinted[token] += mintedSharesAmount;
                                      LpTokenMetadata memory data = LpTokenMetadata(
                                          token,
                                          totalSuppliedLiquidity + _amount,
                                          totalShares + mintedSharesAmount
                                      );
                                      lpToken.updateTokenMetadata(_nftId, data);
                                      // Increase the current liquidity
                                      _increaseCurrentLiquidity(token, _amount);
                                      emit LiquidityAdded(token, _amount, _msgSender());
                                  }
                                  /**
                                   * @dev Function to allow LPs to add ERC20 token liquidity to existing NFT
                                   * @param _nftId ID of NFT for updating the balances
                                   * @param _amount Token amount to be added
                                   */
                                  function increaseTokenLiquidity(uint256 _nftId, uint256 _amount) external nonReentrant whenNotPaused {
                                      (address token, , ) = lpToken.tokenMetadata(_nftId);
                                      require(_isSupportedToken(token), "ERR__TOKEN_NOT_SUPPORTED");
                                      require(token != NATIVE, "ERR__WRONG_FUNCTION");
                                      require(
                                          IERC20Upgradeable(token).allowance(_msgSender(), address(this)) >= _amount,
                                          "ERR__INSUFFICIENT_ALLOWANCE"
                                      );
                                      SafeERC20Upgradeable.safeTransferFrom(IERC20Upgradeable(token), _msgSender(), address(liquidityPool), _amount);
                                      _increaseLiquidity(_nftId, _amount);
                                  }
                                  /**
                                   * @dev Function to allow LPs to add native token liquidity to existing NFT
                                   */
                                  function increaseNativeLiquidity(uint256 _nftId) external payable nonReentrant whenNotPaused {
                                      (address token, , ) = lpToken.tokenMetadata(_nftId);
                                      require(_isSupportedToken(NATIVE), "ERR__TOKEN_NOT_SUPPORTED");
                                      require(token == NATIVE, "ERR__WRONG_FUNCTION");
                                      require(address(liquidityPool) != address(0), "ERR__LIQUIDITY_POOL_NOT_SET");
                                      (bool success, ) = address(liquidityPool).call{value: msg.value}("");
                                      require(success, "ERR__NATIVE_TRANSFER_FAILED");
                                      _increaseLiquidity(_nftId, msg.value);
                                  }
                                  /**
                                   * @dev Function to allow LPs to remove their liquidity from an existing NFT
                                   *      Also automatically redeems any earned fee
                                   */
                                  function removeLiquidity(uint256 _nftId, uint256 _amount)
                                      external
                                      nonReentrant
                                      onlyValidLpToken(_nftId, _msgSender())
                                      whenNotPaused
                                  {
                                      (address _tokenAddress, uint256 nftSuppliedLiquidity, uint256 totalNFTShares) = lpToken.tokenMetadata(_nftId);
                                      require(_isSupportedToken(_tokenAddress), "ERR__TOKEN_NOT_SUPPORTED");
                                      require(_amount != 0, "ERR__INVALID_AMOUNT");
                                      require(nftSuppliedLiquidity >= _amount, "ERR__INSUFFICIENT_LIQUIDITY");
                                      whiteListPeriodManager.beforeLiquidityRemoval(_msgSender(), _tokenAddress, _amount);
                                      // Calculate how much shares represent input amount
                                      uint256 lpSharesForInputAmount = _amount * getTokenPriceInLPShares(_tokenAddress);
                                      // Calculate rewards accumulated
                                      uint256 eligibleLiquidity = sharesToTokenAmount(totalNFTShares, _tokenAddress);
                                      uint256 lpFeeAccumulated;
                                      // Handle edge cases where eligibleLiquidity is less than what was supplied by very small amount
                                      if (nftSuppliedLiquidity > eligibleLiquidity) {
                                          lpFeeAccumulated = 0;
                                      } else {
                                          unchecked {
                                              lpFeeAccumulated = eligibleLiquidity - nftSuppliedLiquidity;
                                          }
                                      }
                                      // Calculate amount of lp shares that represent accumulated Fee
                                      uint256 lpSharesRepresentingFee = lpFeeAccumulated * getTokenPriceInLPShares(_tokenAddress);
                                      totalLPFees[_tokenAddress] -= lpFeeAccumulated;
                                      uint256 amountToWithdraw = _amount + lpFeeAccumulated;
                                      uint256 lpSharesToBurn = lpSharesForInputAmount + lpSharesRepresentingFee;
                                      // Handle round off errors to avoid dust lp token in contract
                                      if (totalNFTShares - lpSharesToBurn < BASE_DIVISOR) {
                                          lpSharesToBurn = totalNFTShares;
                                      }
                                      totalReserve[_tokenAddress] -= amountToWithdraw;
                                      totalLiquidity[_tokenAddress] -= _amount;
                                      totalSharesMinted[_tokenAddress] -= lpSharesToBurn;
                                      _decreaseCurrentLiquidity(_tokenAddress, _amount);
                                      _burnSharesFromNft(_nftId, lpSharesToBurn, _amount, _tokenAddress);
                                      _transferFromLiquidityPool(_tokenAddress, _msgSender(), amountToWithdraw);
                                      emit LiquidityRemoved(_tokenAddress, amountToWithdraw, _msgSender());
                                  }
                                  /**
                                   * @dev Function to allow LPs to claim the fee earned on their NFT
                                   * @param _nftId ID of NFT where liquidity is recorded
                                   */
                                  function claimFee(uint256 _nftId) external onlyValidLpToken(_nftId, _msgSender()) whenNotPaused nonReentrant {
                                      (address _tokenAddress, uint256 nftSuppliedLiquidity, uint256 totalNFTShares) = lpToken.tokenMetadata(_nftId);
                                      require(_isSupportedToken(_tokenAddress), "ERR__TOKEN_NOT_SUPPORTED");
                                      uint256 lpSharesForSuppliedLiquidity = nftSuppliedLiquidity * getTokenPriceInLPShares(_tokenAddress);
                                      // Calculate rewards accumulated
                                      uint256 eligibleLiquidity = sharesToTokenAmount(totalNFTShares, _tokenAddress);
                                      uint256 lpFeeAccumulated = eligibleLiquidity - nftSuppliedLiquidity;
                                      require(lpFeeAccumulated > 0, "ERR__NO_REWARDS_TO_CLAIM");
                                      // Calculate amount of lp shares that represent accumulated Fee
                                      uint256 lpSharesRepresentingFee = totalNFTShares - lpSharesForSuppliedLiquidity;
                                      totalReserve[_tokenAddress] -= lpFeeAccumulated;
                                      totalSharesMinted[_tokenAddress] -= lpSharesRepresentingFee;
                                      totalLPFees[_tokenAddress] -= lpFeeAccumulated;
                                      _burnSharesFromNft(_nftId, lpSharesRepresentingFee, 0, _tokenAddress);
                                      _transferFromLiquidityPool(_tokenAddress, _msgSender(), lpFeeAccumulated);
                                      emit FeeClaimed(_tokenAddress, lpFeeAccumulated, _msgSender(), lpSharesRepresentingFee);
                                  }
                                  /**
                                   * @dev Internal Function to burn LP shares and remove liquidity from existing NFT
                                   */
                                  function _burnSharesFromNft(
                                      uint256 _nftId,
                                      uint256 _shares,
                                      uint256 _tokenAmount,
                                      address _tokenAddress
                                  ) internal {
                                      (, uint256 nftSuppliedLiquidity, uint256 nftShares) = lpToken.tokenMetadata(_nftId);
                                      nftShares -= _shares;
                                      nftSuppliedLiquidity -= _tokenAmount;
                                      lpToken.updateTokenMetadata(_nftId, LpTokenMetadata(_tokenAddress, nftSuppliedLiquidity, nftShares));
                                  }
                                  function _transferFromLiquidityPool(
                                      address _tokenAddress,
                                      address _receiver,
                                      uint256 _tokenAmount
                                  ) internal {
                                      liquidityPool.transfer(_tokenAddress, _receiver, _tokenAmount);
                                  }
                                  function getSuppliedLiquidity(uint256 _nftId) external view returns (uint256) {
                                      (, uint256 totalSuppliedLiquidity, ) = lpToken.tokenMetadata(_nftId);
                                      return totalSuppliedLiquidity;
                                  }
                                  function _msgSender()
                                      internal
                                      view
                                      virtual
                                      override(ContextUpgradeable, ERC2771ContextUpgradeable)
                                      returns (address sender)
                                  {
                                      return ERC2771ContextUpgradeable._msgSender();
                                  }
                                  function _msgData()
                                      internal
                                      view
                                      virtual
                                      override(ContextUpgradeable, ERC2771ContextUpgradeable)
                                      returns (bytes calldata)
                                  {
                                      return ERC2771ContextUpgradeable._msgData();
                                  }
                                  receive() external payable {
                                      emit EthReceived(_msgSender(), msg.value);
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
                               * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
                               * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
                               * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
                               *
                               * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
                               * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
                               *
                               * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
                               * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
                               */
                              abstract contract Initializable {
                                  /**
                                   * @dev Indicates that the contract has been initialized.
                                   */
                                  bool private _initialized;
                                  /**
                                   * @dev Indicates that the contract is in the process of being initialized.
                                   */
                                  bool private _initializing;
                                  /**
                                   * @dev Modifier to protect an initializer function from being invoked twice.
                                   */
                                  modifier initializer() {
                                      require(_initializing || !_initialized, "Initializable: contract is already initialized");
                                      bool isTopLevelCall = !_initializing;
                                      if (isTopLevelCall) {
                                          _initializing = true;
                                          _initialized = true;
                                      }
                                      _;
                                      if (isTopLevelCall) {
                                          _initializing = false;
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module that helps prevent reentrant calls to a function.
                               *
                               * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
                               * available, which can be applied to functions to make sure there are no nested
                               * (reentrant) calls to them.
                               *
                               * Note that because there is a single `nonReentrant` guard, functions marked as
                               * `nonReentrant` may not call one another. This can be worked around by making
                               * those functions `private`, and then adding `external` `nonReentrant` entry
                               * points to them.
                               *
                               * TIP: If you would like to learn more about reentrancy and alternative ways
                               * to protect against it, check out our blog post
                               * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
                               */
                              abstract contract ReentrancyGuardUpgradeable is Initializable {
                                  // Booleans are more expensive than uint256 or any type that takes up a full
                                  // word because each write operation emits an extra SLOAD to first read the
                                  // slot's contents, replace the bits taken up by the boolean, and then write
                                  // back. This is the compiler's defense against contract upgrades and
                                  // pointer aliasing, and it cannot be disabled.
                                  // The values being non-zero value makes deployment a bit more expensive,
                                  // but in exchange the refund on every call to nonReentrant will be lower in
                                  // amount. Since refunds are capped to a percentage of the total
                                  // transaction's gas, it is best to keep them low in cases like this one, to
                                  // increase the likelihood of the full refund coming into effect.
                                  uint256 private constant _NOT_ENTERED = 1;
                                  uint256 private constant _ENTERED = 2;
                                  uint256 private _status;
                                  function __ReentrancyGuard_init() internal initializer {
                                      __ReentrancyGuard_init_unchained();
                                  }
                                  function __ReentrancyGuard_init_unchained() internal initializer {
                                      _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 make it call a
                                   * `private` function that does the actual work.
                                   */
                                  modifier nonReentrant() {
                                      // On the first call to nonReentrant, _notEntered will be true
                                      require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
                                      // Any calls to nonReentrant after this point will fail
                                      _status = _ENTERED;
                                      _;
                                      // By storing the original value once again, a refund is triggered (see
                                      // https://eips.ethereum.org/EIPS/eip-2200)
                                      _status = _NOT_ENTERED;
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/ContextUpgradeable.sol";
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module which provides a basic access control mechanism, where
                               * there is an account (an owner) that can be granted exclusive access to
                               * specific functions.
                               *
                               * By default, the owner account will be the one that deploys the contract. This
                               * can later be changed with {transferOwnership}.
                               *
                               * This module is used through inheritance. It will make available the modifier
                               * `onlyOwner`, which can be applied to your functions to restrict their use to
                               * the owner.
                               */
                              abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
                                  address private _owner;
                                  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                                  /**
                                   * @dev Initializes the contract setting the deployer as the initial owner.
                                   */
                                  function __Ownable_init() internal initializer {
                                      __Context_init_unchained();
                                      __Ownable_init_unchained();
                                  }
                                  function __Ownable_init_unchained() internal initializer {
                                      _setOwner(_msgSender());
                                  }
                                  /**
                                   * @dev Returns the address of the current owner.
                                   */
                                  function owner() public view virtual returns (address) {
                                      return _owner;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the owner.
                                   */
                                  modifier onlyOwner() {
                                      require(owner() == _msgSender(), "Ownable: caller is not the owner");
                                      _;
                                  }
                                  /**
                                   * @dev Leaves the contract without owner. It will not be possible to call
                                   * `onlyOwner` functions anymore. Can only be called by the current owner.
                                   *
                                   * NOTE: Renouncing ownership will leave the contract without an owner,
                                   * thereby removing any functionality that is only available to the owner.
                                   */
                                  function renounceOwnership() public virtual onlyOwner {
                                      _setOwner(address(0));
                                  }
                                  /**
                                   * @dev Transfers ownership of the contract to a new account (`newOwner`).
                                   * Can only be called by the current owner.
                                   */
                                  function transferOwnership(address newOwner) public virtual onlyOwner {
                                      require(newOwner != address(0), "Ownable: new owner is the zero address");
                                      _setOwner(newOwner);
                                  }
                                  function _setOwner(address newOwner) private {
                                      address oldOwner = _owner;
                                      _owner = newOwner;
                                      emit OwnershipTransferred(oldOwner, newOwner);
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev Interface of the ERC20 standard as defined in the EIP.
                               */
                              interface IERC20Upgradeable {
                                  /**
                                   * @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 `recipient`.
                                   *
                                   * Returns a boolean value indicating whether the operation succeeded.
                                   *
                                   * Emits a {Transfer} event.
                                   */
                                  function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
                                      address recipient,
                                      uint256 amount
                                  ) external returns (bool);
                                  /**
                                   * @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);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../IERC20Upgradeable.sol";
                              import "../../../utils/AddressUpgradeable.sol";
                              /**
                               * @title SafeERC20
                               * @dev Wrappers around ERC20 operations that throw on failure (when the token
                               * contract returns false). Tokens that return no value (and instead revert or
                               * throw on failure) are also supported, non-reverting calls are assumed to be
                               * successful.
                               * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
                               * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
                               */
                              library SafeERC20Upgradeable {
                                  using AddressUpgradeable for address;
                                  function safeTransfer(
                                      IERC20Upgradeable token,
                                      address to,
                                      uint256 value
                                  ) internal {
                                      _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
                                  }
                                  function safeTransferFrom(
                                      IERC20Upgradeable token,
                                      address from,
                                      address to,
                                      uint256 value
                                  ) internal {
                                      _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
                                  }
                                  /**
                                   * @dev Deprecated. This function has issues similar to the ones found in
                                   * {IERC20-approve}, and its usage is discouraged.
                                   *
                                   * Whenever possible, use {safeIncreaseAllowance} and
                                   * {safeDecreaseAllowance} instead.
                                   */
                                  function safeApprove(
                                      IERC20Upgradeable token,
                                      address spender,
                                      uint256 value
                                  ) internal {
                                      // safeApprove should only be called when setting an initial allowance,
                                      // or when resetting it to zero. To increase and decrease it, use
                                      // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
                                      require(
                                          (value == 0) || (token.allowance(address(this), spender) == 0),
                                          "SafeERC20: approve from non-zero to non-zero allowance"
                                      );
                                      _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
                                  }
                                  function safeIncreaseAllowance(
                                      IERC20Upgradeable token,
                                      address spender,
                                      uint256 value
                                  ) internal {
                                      uint256 newAllowance = token.allowance(address(this), spender) + value;
                                      _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
                                  }
                                  function safeDecreaseAllowance(
                                      IERC20Upgradeable token,
                                      address spender,
                                      uint256 value
                                  ) internal {
                                      unchecked {
                                          uint256 oldAllowance = token.allowance(address(this), spender);
                                          require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
                                          uint256 newAllowance = oldAllowance - value;
                                          _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
                                      }
                                  }
                                  /**
                                   * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
                                   * on the return value: the return value is optional (but if data is returned, it must not be false).
                                   * @param token The token targeted by the call.
                                   * @param data The call data (encoded using abi.encode or one of its variants).
                                   */
                                  function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
                                      // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
                                      // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
                                      // the target address contains contract code and also asserts for success in the low-level call.
                                      bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
                                      if (returndata.length > 0) {
                                          // Return data is optional
                                          require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                              /**
                               * @dev Context variant with ERC2771 support.
                               * Here _trustedForwarder is made internal instead of private
                               * so it can be changed via Child contracts with a setter method.
                               */
                              abstract contract ERC2771ContextUpgradeable is Initializable, ContextUpgradeable {
                                  event TrustedForwarderChanged(address indexed _tf);
                                  address internal _trustedForwarder;
                                  function __ERC2771Context_init(address trustedForwarder) internal initializer {
                                      __Context_init_unchained();
                                      __ERC2771Context_init_unchained(trustedForwarder);
                                  }
                                  function __ERC2771Context_init_unchained(address trustedForwarder) internal initializer {
                                      _trustedForwarder = trustedForwarder;
                                  }
                                  function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
                                      return forwarder == _trustedForwarder;
                                  }
                                  function _msgSender() internal view virtual override returns (address sender) {
                                      if (isTrustedForwarder(msg.sender)) {
                                          // The assembly code is more direct than the Solidity version using `abi.decode`.
                                          assembly {
                                              sender := shr(96, calldataload(sub(calldatasize(), 20)))
                                          }
                                      } else {
                                          return super._msgSender();
                                      }
                                  }
                                  function _msgData() internal view virtual override returns (bytes calldata) {
                                      if (isTrustedForwarder(msg.sender)) {
                                          return msg.data[:msg.data.length - 20];
                                      } else {
                                          return super._msgData();
                                      }
                                  }
                                  function _setTrustedForwarder(address _tf) internal virtual {
                                      require(_tf != address(0), "TrustedForwarder can't be 0");
                                      _trustedForwarder = _tf;
                                      emit TrustedForwarderChanged(_tf);
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                              import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
                              /**
                               * @dev Contract module which allows children to implement an emergency stop
                               * mechanism that can be triggered by an authorized account.
                               *
                               * This module is used through inheritance. It will make available the
                               * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
                               * the functions of your contract. Note that they will not be pausable by
                               * simply including this module, only once the modifiers are put in place.
                               */
                              abstract contract Pausable is Initializable, PausableUpgradeable {
                                  address private _pauser;
                                  event PauserChanged(address indexed previousPauser, address indexed newPauser);
                                  /**
                                   * @dev The pausable constructor sets the original `pauser` of the contract to the sender
                                   * account & Initializes the contract in unpaused state..
                                   */
                                  function __Pausable_init(address pauser) internal initializer {
                                      require(pauser != address(0), "Pauser Address cannot be 0");
                                      __Pausable_init();
                                      _pauser = pauser;
                                  }
                                  /**
                                   * @return true if `msg.sender` is the owner of the contract.
                                   */
                                  function isPauser(address pauser) public view returns (bool) {
                                      return pauser == _pauser;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the pauser.
                                   */
                                  modifier onlyPauser() {
                                      require(isPauser(msg.sender), "Only pauser is allowed to perform this operation");
                                      _;
                                  }
                                  /**
                                   * @dev Allows the current pauser to transfer control of the contract to a newPauser.
                                   * @param newPauser The address to transfer pauserShip to.
                                   */
                                  function changePauser(address newPauser) public onlyPauser whenNotPaused {
                                      _changePauser(newPauser);
                                  }
                                  /**
                                   * @dev Transfers control of the contract to a newPauser.
                                   * @param newPauser The address to transfer ownership to.
                                   */
                                  function _changePauser(address newPauser) internal {
                                      require(newPauser != address(0));
                                      emit PauserChanged(_pauser, newPauser);
                                      _pauser = newPauser;
                                  }
                                  function renouncePauser() external virtual onlyPauser whenNotPaused {
                                      emit PauserChanged(_pauser, address(0));
                                      _pauser = address(0);
                                  }
                                  function pause() public onlyPauser {
                                      _pause();
                                  }
                                  function unpause() public onlyPauser {
                                      _unpause();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "../structures/LpTokenMetadata.sol";
                              interface ILPToken {
                                  function approve(address to, uint256 tokenId) external;
                                  function balanceOf(address _owner) external view returns (uint256);
                                  function exists(uint256 _tokenId) external view returns (bool);
                                  function getAllNftIdsByUser(address _owner) external view returns (uint256[] memory);
                                  function getApproved(uint256 tokenId) external view returns (address);
                                  function initialize(
                                      string memory _name,
                                      string memory _symbol,
                                      address _trustedForwarder
                                  ) external;
                                  function isApprovedForAll(address _owner, address operator) external view returns (bool);
                                  function isTrustedForwarder(address forwarder) external view returns (bool);
                                  function liquidityPoolAddress() external view returns (address);
                                  function mint(address _to) external returns (uint256);
                                  function name() external view returns (string memory);
                                  function owner() external view returns (address);
                                  function ownerOf(uint256 tokenId) external view returns (address);
                                  function paused() external view returns (bool);
                                  function renounceOwnership() external;
                                  function safeTransferFrom(
                                      address from,
                                      address to,
                                      uint256 tokenId
                                  ) external;
                                  function safeTransferFrom(
                                      address from,
                                      address to,
                                      uint256 tokenId,
                                      bytes memory _data
                                  ) external;
                                  function setApprovalForAll(address operator, bool approved) external;
                                  function setLiquidityPool(address _lpm) external;
                                  function setWhiteListPeriodManager(address _whiteListPeriodManager) external;
                                  function supportsInterface(bytes4 interfaceId) external view returns (bool);
                                  function symbol() external view returns (string memory);
                                  function tokenByIndex(uint256 index) external view returns (uint256);
                                  function tokenMetadata(uint256)
                                      external
                                      view
                                      returns (
                                          address token,
                                          uint256 totalSuppliedLiquidity,
                                          uint256 totalShares
                                      );
                                  function tokenOfOwnerByIndex(address _owner, uint256 index) external view returns (uint256);
                                  function tokenURI(uint256 tokenId) external view returns (string memory);
                                  function totalSupply() external view returns (uint256);
                                  function transferFrom(
                                      address from,
                                      address to,
                                      uint256 tokenId
                                  ) external;
                                  function transferOwnership(address newOwner) external;
                                  function updateTokenMetadata(uint256 _tokenId, LpTokenMetadata memory _lpTokenMetadata) external;
                                  function whiteListPeriodManager() external view returns (address);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "../structures/TokenConfig.sol";
                              interface ITokenManager {
                                  function getEquilibriumFee(address tokenAddress) external view returns (uint256);
                                  function getMaxFee(address tokenAddress) external view returns (uint256);
                                  function changeFee(
                                      address tokenAddress,
                                      uint256 _equilibriumFee,
                                      uint256 _maxFee
                                  ) external;
                                  function tokensInfo(address tokenAddress)
                                      external
                                      view
                                      returns (
                                          uint256 transferOverhead,
                                          bool supportedToken,
                                          uint256 equilibriumFee,
                                          uint256 maxFee,
                                          TokenConfig memory config
                                      );
                                  function excessStateTransferFeePerc(address tokenAddress) external view returns (uint256);
                                  function getTokensInfo(address tokenAddress) external view returns (TokenInfo memory);
                                  function getDepositConfig(uint256 toChainId, address tokenAddress) external view returns (TokenConfig memory);
                                  function getTransferConfig(address tokenAddress) external view returns (TokenConfig memory);
                                  function changeExcessStateFee(address _tokenAddress, uint256 _excessStateFeePer) external;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              interface IWhiteListPeriodManager {
                                  function areWhiteListRestrictionsEnabled() external view returns (bool);
                                  function beforeLiquidityAddition(
                                      address _lp,
                                      address _token,
                                      uint256 _amount
                                  ) external;
                                  function beforeLiquidityRemoval(
                                      address _lp,
                                      address _token,
                                      uint256 _amount
                                  ) external;
                                  function beforeLiquidityTransfer(
                                      address _from,
                                      address _to,
                                      address _token,
                                      uint256 _amount
                                  ) external;
                                  function getMaxCommunityLpPositon(address _token) external view returns (uint256);
                                  function initialize(
                                      address _trustedForwarder,
                                      address _liquidityProviders,
                                      address _tokenManager
                                  ) external;
                                  function isExcludedAddress(address) external view returns (bool);
                                  function isTrustedForwarder(address forwarder) external view returns (bool);
                                  function owner() external view returns (address);
                                  function paused() external view returns (bool);
                                  function perTokenTotalCap(address) external view returns (uint256);
                                  function perTokenWalletCap(address) external view returns (uint256);
                                  function renounceOwnership() external;
                                  function setAreWhiteListRestrictionsEnabled(bool _status) external;
                                  function setCap(
                                      address _token,
                                      uint256 _totalCap,
                                      uint256 _perTokenWalletCap
                                  ) external;
                                  function setCaps(
                                      address[] memory _tokens,
                                      uint256[] memory _totalCaps,
                                      uint256[] memory _perTokenWalletCaps
                                  ) external;
                                  function setIsExcludedAddressStatus(address[] memory _addresses, bool[] memory _status) external;
                                  function setLiquidityProviders(address _liquidityProviders) external;
                                  function setPerTokenWalletCap(address _token, uint256 _perTokenWalletCap) external;
                                  function setTokenManager(address _tokenManager) external;
                                  function setTotalCap(address _token, uint256 _totalCap) external;
                                  function transferOwnership(address newOwner) external;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              interface ILiquidityPool {
                                  function baseGas() external view returns (uint256);
                                  function changePauser(address newPauser) external;
                                  function checkHashStatus(
                                      address tokenAddress,
                                      uint256 amount,
                                      address receiver,
                                      bytes memory depositHash
                                  ) external view returns (bytes32 hashSendTransaction, bool status);
                                  function depositConfig(uint256, address) external view returns (uint256 min, uint256 max);
                                  function depositErc20(
                                      uint256 toChainId,
                                      address tokenAddress,
                                      address receiver,
                                      uint256 amount,
                                      string memory tag
                                  ) external;
                                  function depositNative(
                                      address receiver,
                                      uint256 toChainId,
                                      string memory tag
                                  ) external;
                                  function gasFeeAccumulated(address, address) external view returns (uint256);
                                  function gasFeeAccumulatedByToken(address) external view returns (uint256);
                                  function getCurrentLiquidity(address tokenAddress) external view returns (uint256 currentLiquidity);
                                  function getExecutorManager() external view returns (address);
                                  function getRewardAmount(uint256 amount, address tokenAddress) external view returns (uint256 rewardAmount);
                                  function getTransferFee(address tokenAddress, uint256 amount) external view returns (uint256 fee);
                                  function incentivePool(address) external view returns (uint256);
                                  function initialize(
                                      address _executorManagerAddress,
                                      address pauser,
                                      address _trustedForwarder,
                                      address _tokenManager,
                                      address _liquidityProviders
                                  ) external;
                                  function isPauser(address pauser) external view returns (bool);
                                  function isTrustedForwarder(address forwarder) external view returns (bool);
                                  function owner() external view returns (address);
                                  function paused() external view returns (bool);
                                  function processedHash(bytes32) external view returns (bool);
                                  function renounceOwnership() external;
                                  function renouncePauser() external;
                                  function transfer(address _tokenAddress, address receiver, uint256 _tokenAmount) external;
                                  function sendFundsToUser(
                                      address tokenAddress,
                                      uint256 amount,
                                      address receiver,
                                      bytes memory depositHash,
                                      uint256 tokenGasPrice,
                                      uint256 fromChainId
                                  ) external;
                                  function setBaseGas(uint128 gas) external;
                                  function setExecutorManager(address _executorManagerAddress) external;
                                  function setLiquidityProviders(address _liquidityProviders) external;
                                  function setTrustedForwarder(address trustedForwarder) external;
                                  function transferConfig(address) external view returns (uint256 min, uint256 max);
                                  function transferOwnership(address newOwner) external;
                                  function withdrawErc20GasFee(address tokenAddress) external;
                                  function withdrawNativeGasFee() external;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Provides information about the current execution context, including the
                               * sender of the transaction and its data. While these are generally available
                               * via msg.sender and msg.data, they should not be accessed in such a direct
                               * manner, since when dealing with meta-transactions the account sending and
                               * paying for execution may not be the actual sender (as far as an application
                               * is concerned).
                               *
                               * This contract is only required for intermediate, library-like contracts.
                               */
                              abstract contract ContextUpgradeable is Initializable {
                                  function __Context_init() internal initializer {
                                      __Context_init_unchained();
                                  }
                                  function __Context_init_unchained() internal initializer {
                                  }
                                  function _msgSender() internal view virtual returns (address) {
                                      return msg.sender;
                                  }
                                  function _msgData() internal view virtual returns (bytes calldata) {
                                      return msg.data;
                                  }
                                  uint256[50] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev Collection of functions related to the address type
                               */
                              library AddressUpgradeable {
                                  /**
                                   * @dev Returns true if `account` is a contract.
                                   *
                                   * [IMPORTANT]
                                   * ====
                                   * It is unsafe to assume that an address for which this function returns
                                   * false is an externally-owned account (EOA) and not a contract.
                                   *
                                   * Among others, `isContract` will return false for the following
                                   * types of addresses:
                                   *
                                   *  - an externally-owned account
                                   *  - a contract in construction
                                   *  - an address where a contract will be created
                                   *  - an address where a contract lived, but was destroyed
                                   * ====
                                   */
                                  function isContract(address account) internal view returns (bool) {
                                      // This method relies on extcodesize, which returns 0 for contracts in
                                      // construction, since the code is only stored at the end of the
                                      // constructor execution.
                                      uint256 size;
                                      assembly {
                                          size := extcodesize(account)
                                      }
                                      return size > 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 functionCall(target, data, "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");
                                      require(isContract(target), "Address: call to non-contract");
                                      (bool success, bytes memory returndata) = target.call{value: value}(data);
                                      return verifyCallResult(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) {
                                      require(isContract(target), "Address: static call to non-contract");
                                      (bool success, bytes memory returndata) = target.staticcall(data);
                                      return verifyCallResult(success, returndata, errorMessage);
                                  }
                                  /**
                                   * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
                                   * revert reason 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 {
                                          // 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
                                              assembly {
                                                  let returndata_size := mload(returndata)
                                                  revert(add(32, returndata), returndata_size)
                                              }
                                          } else {
                                              revert(errorMessage);
                                          }
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/ContextUpgradeable.sol";
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module which allows children to implement an emergency stop
                               * mechanism that can be triggered by an authorized account.
                               *
                               * This module is used through inheritance. It will make available the
                               * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
                               * the functions of your contract. Note that they will not be pausable by
                               * simply including this module, only once the modifiers are put in place.
                               */
                              abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
                                  /**
                                   * @dev Emitted when the pause is triggered by `account`.
                                   */
                                  event Paused(address account);
                                  /**
                                   * @dev Emitted when the pause is lifted by `account`.
                                   */
                                  event Unpaused(address account);
                                  bool private _paused;
                                  /**
                                   * @dev Initializes the contract in unpaused state.
                                   */
                                  function __Pausable_init() internal initializer {
                                      __Context_init_unchained();
                                      __Pausable_init_unchained();
                                  }
                                  function __Pausable_init_unchained() internal initializer {
                                      _paused = false;
                                  }
                                  /**
                                   * @dev Returns true if the contract is paused, and false otherwise.
                                   */
                                  function paused() public view virtual returns (bool) {
                                      return _paused;
                                  }
                                  /**
                                   * @dev Modifier to make a function callable only when the contract is not paused.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must not be paused.
                                   */
                                  modifier whenNotPaused() {
                                      require(!paused(), "Pausable: paused");
                                      _;
                                  }
                                  /**
                                   * @dev Modifier to make a function callable only when the contract is paused.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must be paused.
                                   */
                                  modifier whenPaused() {
                                      require(paused(), "Pausable: not paused");
                                      _;
                                  }
                                  /**
                                   * @dev Triggers stopped state.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must not be paused.
                                   */
                                  function _pause() internal virtual whenNotPaused {
                                      _paused = true;
                                      emit Paused(_msgSender());
                                  }
                                  /**
                                   * @dev Returns to normal state.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must be paused.
                                   */
                                  function _unpause() internal virtual whenPaused {
                                      _paused = false;
                                      emit Unpaused(_msgSender());
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              struct LpTokenMetadata {
                                  address token;
                                  uint256 suppliedLiquidity;
                                  uint256 shares;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              struct TokenInfo {
                                  uint256 transferOverhead;
                                  bool supportedToken;
                                  uint256 equilibriumFee; // Percentage fee Represented in basis points
                                  uint256 maxFee; // Percentage fee Represented in basis points
                                  TokenConfig tokenConfig;
                              }
                              struct TokenConfig {
                                  uint256 min;
                                  uint256 max;
                              }
                              

                              File 4 of 12: TransparentUpgradeableProxy
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
                              import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
                              import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
                              // Kept for backwards compatibility with older versions of Hardhat and Truffle plugins.
                              contract AdminUpgradeabilityProxy is TransparentUpgradeableProxy {
                                  constructor(address logic, address admin, bytes memory data) payable TransparentUpgradeableProxy(logic, admin, data) {}
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../Proxy.sol";
                              import "./ERC1967Upgrade.sol";
                              /**
                               * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
                               * implementation address that can be changed. This address is stored in storage in the location specified by
                               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
                               * implementation behind the proxy.
                               */
                              contract ERC1967Proxy is Proxy, ERC1967Upgrade {
                                  /**
                                   * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
                                   *
                                   * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
                                   * function call, and allows initializating the storage of the proxy like a Solidity constructor.
                                   */
                                  constructor(address _logic, bytes memory _data) payable {
                                      assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
                                      _upgradeToAndCall(_logic, _data, false);
                                  }
                                  /**
                                   * @dev Returns the current implementation address.
                                   */
                                  function _implementation() internal view virtual override returns (address impl) {
                                      return ERC1967Upgrade._getImplementation();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../ERC1967/ERC1967Proxy.sol";
                              /**
                               * @dev This contract implements a proxy that is upgradeable by an admin.
                               *
                               * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
                               * clashing], which can potentially be used in an attack, this contract uses the
                               * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
                               * things that go hand in hand:
                               *
                               * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
                               * that call matches one of the admin functions exposed by the proxy itself.
                               * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
                               * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
                               * "admin cannot fallback to proxy target".
                               *
                               * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
                               * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
                               * to sudden errors when trying to call a function from the proxy implementation.
                               *
                               * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
                               * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
                               */
                              contract TransparentUpgradeableProxy is ERC1967Proxy {
                                  /**
                                   * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
                                   * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
                                   */
                                  constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
                                      assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
                                      _changeAdmin(admin_);
                                  }
                                  /**
                                   * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
                                   */
                                  modifier ifAdmin() {
                                      if (msg.sender == _getAdmin()) {
                                          _;
                                      } else {
                                          _fallback();
                                      }
                                  }
                                  /**
                                   * @dev Returns the current admin.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
                                   *
                                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                                   * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
                                   */
                                  function admin() external ifAdmin returns (address admin_) {
                                      admin_ = _getAdmin();
                                  }
                                  /**
                                   * @dev Returns the current implementation.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
                                   *
                                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                                   * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
                                   */
                                  function implementation() external ifAdmin returns (address implementation_) {
                                      implementation_ = _implementation();
                                  }
                                  /**
                                   * @dev Changes the admin of the proxy.
                                   *
                                   * Emits an {AdminChanged} event.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
                                   */
                                  function changeAdmin(address newAdmin) external virtual ifAdmin {
                                      _changeAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev Upgrade the implementation of the proxy.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
                                   */
                                  function upgradeTo(address newImplementation) external ifAdmin {
                                      _upgradeToAndCall(newImplementation, bytes(""), false);
                                  }
                                  /**
                                   * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
                                   * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
                                   * proxied contract.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
                                   */
                                  function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
                                      _upgradeToAndCall(newImplementation, data, true);
                                  }
                                  /**
                                   * @dev Returns the current admin.
                                   */
                                  function _admin() internal view virtual returns (address) {
                                      return _getAdmin();
                                  }
                                  /**
                                   * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
                                   */
                                  function _beforeFallback() internal virtual override {
                                      require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
                                      super._beforeFallback();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "./TransparentUpgradeableProxy.sol";
                              import "../../access/Ownable.sol";
                              /**
                               * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
                               * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
                               */
                              contract ProxyAdmin is Ownable {
                                  /**
                                   * @dev Returns the current implementation of `proxy`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
                                      // We need to manually run the static call since the getter cannot be flagged as view
                                      // bytes4(keccak256("implementation()")) == 0x5c60da1b
                                      (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
                                      require(success);
                                      return abi.decode(returndata, (address));
                                  }
                                  /**
                                   * @dev Returns the current admin of `proxy`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
                                      // We need to manually run the static call since the getter cannot be flagged as view
                                      // bytes4(keccak256("admin()")) == 0xf851a440
                                      (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
                                      require(success);
                                      return abi.decode(returndata, (address));
                                  }
                                  /**
                                   * @dev Changes the admin of `proxy` to `newAdmin`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the current admin of `proxy`.
                                   */
                                  function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {
                                      proxy.changeAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {
                                      proxy.upgradeTo(implementation);
                                  }
                                  /**
                                   * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See
                                   * {TransparentUpgradeableProxy-upgradeToAndCall}.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable virtual onlyOwner {
                                      proxy.upgradeToAndCall{value: msg.value}(implementation, data);
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
                               * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
                               * be specified by overriding the virtual {_implementation} function.
                               *
                               * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
                               * different contract through the {_delegate} function.
                               *
                               * The success and return data of the delegated call will be returned back to the caller of the proxy.
                               */
                              abstract contract Proxy {
                                  /**
                                   * @dev Delegates the current call to `implementation`.
                                   *
                                   * This function does not return to its internall call site, it will return directly to the external caller.
                                   */
                                  function _delegate(address implementation) internal virtual {
                                      // solhint-disable-next-line no-inline-assembly
                                      assembly {
                                          // Copy msg.data. We take full control of memory in this inline assembly
                                          // block because it will not return to Solidity code. We overwrite the
                                          // Solidity scratch pad at memory position 0.
                                          calldatacopy(0, 0, calldatasize())
                                          // Call the implementation.
                                          // out and outsize are 0 because we don't know the size yet.
                                          let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
                                          // Copy the returned data.
                                          returndatacopy(0, 0, returndatasize())
                                          switch result
                                          // delegatecall returns 0 on error.
                                          case 0 { revert(0, returndatasize()) }
                                          default { return(0, returndatasize()) }
                                      }
                                  }
                                  /**
                                   * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
                                   * and {_fallback} should delegate.
                                   */
                                  function _implementation() internal view virtual returns (address);
                                  /**
                                   * @dev Delegates the current call to the address returned by `_implementation()`.
                                   *
                                   * This function does not return to its internall call site, it will return directly to the external caller.
                                   */
                                  function _fallback() internal virtual {
                                      _beforeFallback();
                                      _delegate(_implementation());
                                  }
                                  /**
                                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
                                   * function in the contract matches the call data.
                                   */
                                  fallback () external payable virtual {
                                      _fallback();
                                  }
                                  /**
                                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
                                   * is empty.
                                   */
                                  receive () external payable virtual {
                                      _fallback();
                                  }
                                  /**
                                   * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
                                   * call, or as part of the Solidity `fallback` or `receive` functions.
                                   *
                                   * If overriden should call `super._beforeFallback()`.
                                   */
                                  function _beforeFallback() internal virtual {
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.2;
                              import "../beacon/IBeacon.sol";
                              import "../../utils/Address.sol";
                              import "../../utils/StorageSlot.sol";
                              /**
                               * @dev This abstract contract provides getters and event emitting update functions for
                               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
                               *
                               * _Available since v4.1._
                               *
                               * @custom:oz-upgrades-unsafe-allow delegatecall
                               */
                              abstract contract ERC1967Upgrade {
                                  // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
                                  bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
                                  /**
                                   * @dev Storage slot with the address of the current implementation.
                                   * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
                                   * validated in the constructor.
                                   */
                                  bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                                  /**
                                   * @dev Emitted when the implementation is upgraded.
                                   */
                                  event Upgraded(address indexed implementation);
                                  /**
                                   * @dev Returns the current implementation address.
                                   */
                                  function _getImplementation() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new address in the EIP1967 implementation slot.
                                   */
                                  function _setImplementation(address newImplementation) private {
                                      require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                                      StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                                  }
                                  /**
                                   * @dev Perform implementation upgrade
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeTo(address newImplementation) internal {
                                      _setImplementation(newImplementation);
                                      emit Upgraded(newImplementation);
                                  }
                                  /**
                                   * @dev Perform implementation upgrade with additional setup call.
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
                                      _setImplementation(newImplementation);
                                      emit Upgraded(newImplementation);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(newImplementation, data);
                                      }
                                  }
                                  /**
                                   * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeToAndCallSecure(address newImplementation, bytes memory data, bool forceCall) internal {
                                      address oldImplementation = _getImplementation();
                                      // Initial upgrade and setup call
                                      _setImplementation(newImplementation);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(newImplementation, data);
                                      }
                                      // Perform rollback test if not already in progress
                                      StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT);
                                      if (!rollbackTesting.value) {
                                          // Trigger rollback using upgradeTo from the new implementation
                                          rollbackTesting.value = true;
                                          Address.functionDelegateCall(
                                              newImplementation,
                                              abi.encodeWithSignature(
                                                  "upgradeTo(address)",
                                                  oldImplementation
                                              )
                                          );
                                          rollbackTesting.value = false;
                                          // Check rollback was effective
                                          require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
                                          // Finally reset to the new implementation and log the upgrade
                                          _setImplementation(newImplementation);
                                          emit Upgraded(newImplementation);
                                      }
                                  }
                                  /**
                                   * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
                                   * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
                                   *
                                   * Emits a {BeaconUpgraded} event.
                                   */
                                  function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
                                      _setBeacon(newBeacon);
                                      emit BeaconUpgraded(newBeacon);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
                                      }
                                  }
                                  /**
                                   * @dev Storage slot with the admin of the contract.
                                   * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
                                   * validated in the constructor.
                                   */
                                  bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                                  /**
                                   * @dev Emitted when the admin account has changed.
                                   */
                                  event AdminChanged(address previousAdmin, address newAdmin);
                                  /**
                                   * @dev Returns the current admin.
                                   */
                                  function _getAdmin() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new address in the EIP1967 admin slot.
                                   */
                                  function _setAdmin(address newAdmin) private {
                                      require(newAdmin != address(0), "ERC1967: new admin is the zero address");
                                      StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
                                  }
                                  /**
                                   * @dev Changes the admin of the proxy.
                                   *
                                   * Emits an {AdminChanged} event.
                                   */
                                  function _changeAdmin(address newAdmin) internal {
                                      emit AdminChanged(_getAdmin(), newAdmin);
                                      _setAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
                                   * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
                                   */
                                  bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
                                  /**
                                   * @dev Emitted when the beacon is upgraded.
                                   */
                                  event BeaconUpgraded(address indexed beacon);
                                  /**
                                   * @dev Returns the current beacon.
                                   */
                                  function _getBeacon() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new beacon in the EIP1967 beacon slot.
                                   */
                                  function _setBeacon(address newBeacon) private {
                                      require(
                                          Address.isContract(newBeacon),
                                          "ERC1967: new beacon is not a contract"
                                      );
                                      require(
                                          Address.isContract(IBeacon(newBeacon).implementation()),
                                          "ERC1967: beacon implementation is not a contract"
                                      );
                                      StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This is the interface that {BeaconProxy} expects of its beacon.
                               */
                              interface IBeacon {
                                  /**
                                   * @dev Must return an address that can be used as a delegate call target.
                                   *
                                   * {BeaconProxy} will check that this address is a contract.
                                   */
                                  function implementation() external view returns (address);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @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
                                   * ====
                                   */
                                  function isContract(address account) internal view returns (bool) {
                                      // This method relies on extcodesize, which returns 0 for contracts in
                                      // construction, since the code is only stored at the end of the
                                      // constructor execution.
                                      uint256 size;
                                      // solhint-disable-next-line no-inline-assembly
                                      assembly { size := extcodesize(account) }
                                      return size > 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");
                                      // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
                                      (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 functionCall(target, data, "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");
                                      require(isContract(target), "Address: call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.call{ value: value }(data);
                                      return _verifyCallResult(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) {
                                      require(isContract(target), "Address: static call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.staticcall(data);
                                      return _verifyCallResult(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) {
                                      require(isContract(target), "Address: delegate call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.delegatecall(data);
                                      return _verifyCallResult(success, returndata, errorMessage);
                                  }
                                  function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
                                      if (success) {
                                          return returndata;
                                      } else {
                                          // 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
                                              // solhint-disable-next-line no-inline-assembly
                                              assembly {
                                                  let returndata_size := mload(returndata)
                                                  revert(add(32, returndata), returndata_size)
                                              }
                                          } else {
                                              revert(errorMessage);
                                          }
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev Library for reading and writing primitive types to specific storage slots.
                               *
                               * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
                               * This library helps with reading and writing to such slots without the need for inline assembly.
                               *
                               * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
                               *
                               * Example usage to set ERC1967 implementation slot:
                               * ```
                               * contract ERC1967 {
                               *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                               *
                               *     function _getImplementation() internal view returns (address) {
                               *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                               *     }
                               *
                               *     function _setImplementation(address newImplementation) internal {
                               *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                               *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                               *     }
                               * }
                               * ```
                               *
                               * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
                               */
                              library StorageSlot {
                                  struct AddressSlot {
                                      address value;
                                  }
                                  struct BooleanSlot {
                                      bool value;
                                  }
                                  struct Bytes32Slot {
                                      bytes32 value;
                                  }
                                  struct Uint256Slot {
                                      uint256 value;
                                  }
                                  /**
                                   * @dev Returns an `AddressSlot` with member `value` located at `slot`.
                                   */
                                  function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
                                   */
                                  function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
                                   */
                                  function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
                                   */
                                  function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/Context.sol";
                              /**
                               * @dev Contract module which provides a basic access control mechanism, where
                               * there is an account (an owner) that can be granted exclusive access to
                               * specific functions.
                               *
                               * By default, the owner account will be the one that deploys the contract. This
                               * can later be changed with {transferOwnership}.
                               *
                               * This module is used through inheritance. It will make available the modifier
                               * `onlyOwner`, which can be applied to your functions to restrict their use to
                               * the owner.
                               */
                              abstract contract Ownable is Context {
                                  address private _owner;
                                  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                                  /**
                                   * @dev Initializes the contract setting the deployer as the initial owner.
                                   */
                                  constructor () {
                                      address msgSender = _msgSender();
                                      _owner = msgSender;
                                      emit OwnershipTransferred(address(0), msgSender);
                                  }
                                  /**
                                   * @dev Returns the address of the current owner.
                                   */
                                  function owner() public view virtual returns (address) {
                                      return _owner;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the owner.
                                   */
                                  modifier onlyOwner() {
                                      require(owner() == _msgSender(), "Ownable: caller is not the owner");
                                      _;
                                  }
                                  /**
                                   * @dev Leaves the contract without owner. It will not be possible to call
                                   * `onlyOwner` functions anymore. Can only be called by the current owner.
                                   *
                                   * NOTE: Renouncing ownership will leave the contract without an owner,
                                   * thereby removing any functionality that is only available to the owner.
                                   */
                                  function renounceOwnership() public virtual onlyOwner {
                                      emit OwnershipTransferred(_owner, address(0));
                                      _owner = address(0);
                                  }
                                  /**
                                   * @dev Transfers ownership of the contract to a new account (`newOwner`).
                                   * Can only be called by the current owner.
                                   */
                                  function transferOwnership(address newOwner) public virtual onlyOwner {
                                      require(newOwner != address(0), "Ownable: new owner is the zero address");
                                      emit OwnershipTransferred(_owner, newOwner);
                                      _owner = newOwner;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              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) {
                                      this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
                                      return msg.data;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../ERC1967/ERC1967Upgrade.sol";
                              /**
                               * @dev Base contract for building openzeppelin-upgrades compatible implementations for the {ERC1967Proxy}. It includes
                               * publicly available upgrade functions that are called by the plugin and by the secure upgrade mechanism to verify
                               * continuation of the upgradability.
                               *
                               * The {_authorizeUpgrade} function MUST be overridden to include access restriction to the upgrade mechanism.
                               *
                               * _Available since v4.1._
                               */
                              abstract contract UUPSUpgradeable is ERC1967Upgrade {
                                  function upgradeTo(address newImplementation) external virtual {
                                      _authorizeUpgrade(newImplementation);
                                      _upgradeToAndCallSecure(newImplementation, bytes(""), false);
                                  }
                                  function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual {
                                      _authorizeUpgrade(newImplementation);
                                      _upgradeToAndCallSecure(newImplementation, data, true);
                                  }
                                  function _authorizeUpgrade(address newImplementation) internal virtual;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.2;
                              import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
                              abstract contract Proxiable is UUPSUpgradeable {
                                  function _authorizeUpgrade(address newImplementation) internal override {
                                      _beforeUpgrade(newImplementation);
                                  }
                                  function _beforeUpgrade(address newImplementation) internal virtual;
                              }
                              contract ChildOfProxiable is Proxiable {
                                  function _beforeUpgrade(address newImplementation) internal virtual override {}
                              }
                              

                              File 5 of 12: LPToken
                              // $$\\       $$\\                     $$\\       $$\\ $$\\   $$\\                     $$\\   $$\\ $$$$$$$$\\ $$$$$$$$\\
                              // $$ |      \\__|                    \\__|      $$ |\\__|  $$ |                    $$$\\  $$ |$$  _____|\\__$$  __|
                              // $$ |      $$\\  $$$$$$\\  $$\\   $$\\ $$\\  $$$$$$$ |$$\\ $$$$$$\\   $$\\   $$\\       $$$$\\ $$ |$$ |         $$ |
                              // $$ |      $$ |$$  __$$\\ $$ |  $$ |$$ |$$  __$$ |$$ |\\_$$  _|  $$ |  $$ |      $$ $$\\$$ |$$$$$\\       $$ |
                              // $$ |      $$ |$$ /  $$ |$$ |  $$ |$$ |$$ /  $$ |$$ |  $$ |    $$ |  $$ |      $$ \\$$$$ |$$  __|      $$ |
                              // $$ |      $$ |$$ |  $$ |$$ |  $$ |$$ |$$ |  $$ |$$ |  $$ |$$\\ $$ |  $$ |      $$ |\\$$$ |$$ |         $$ |
                              // $$$$$$$$\\ $$ |\\$$$$$$$ |\\$$$$$$  |$$ |\\$$$$$$$ |$$ |  \\$$$$  |\\$$$$$$$ |      $$ | \\$$ |$$ |         $$ |
                              // \\________|\\__| \\____$$ | \\______/ \\__| \\_______|\\__|   \\____/  \\____$$ |      \\__|  \\__|\\__|         \\__|
                              //                     $$ |                                      $$\\   $$ |
                              //                     $$ |                                      \\$$$$$$  |
                              //                     \\__|                                       \\______/
                              // SPDX-License-Identifier: MI
                              pragma solidity 0.8.0;
                              pragma abicoder v2;
                              import "@openzeppelin/contracts-upgradeable/metatx/ERC2771ContextUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol";
                              import "base64-sol/base64.sol";
                              import "../interfaces/ISvgHelper.sol";
                              import "../interfaces/IWhiteListPeriodManager.sol";
                              import "../interfaces/ILiquidityProviders.sol";
                              import "../../security/Pausable.sol";
                              import "../structures/LpTokenMetadata.sol";
                              contract LPToken is
                                  OwnableUpgradeable,
                                  ReentrancyGuardUpgradeable,
                                  ERC721EnumerableUpgradeable,
                                  ERC721URIStorageUpgradeable,
                                  ERC2771ContextUpgradeable,
                                  Pausable
                              {
                                  address public liquidityProvidersAddress;
                                  IWhiteListPeriodManager public whiteListPeriodManager;
                                  mapping(uint256 => LpTokenMetadata) public tokenMetadata;
                                  mapping(address => ISvgHelper) public svgHelpers;
                                  event LiquidityProvidersUpdated(address indexed lpm);
                                  event WhiteListPeriodManagerUpdated(address indexed manager);
                                  event SvgHelperUpdated(address indexed tokenAddress, ISvgHelper indexed svgHelper);
                                  function initialize(
                                      string calldata _name,
                                      string calldata _symbol,
                                      address _trustedForwarder,
                                      address _pauser
                                  ) external initializer {
                                      __Ownable_init();
                                      __ERC721_init(_name, _symbol);
                                      __ERC721Enumerable_init();
                                      __Pausable_init(_pauser);
                                      __ERC721URIStorage_init();
                                      __ReentrancyGuard_init();
                                      __ERC2771Context_init(_trustedForwarder);
                                  }
                                  modifier onlyHyphenPools() {
                                      require(_msgSender() == liquidityProvidersAddress, "ERR_UNAUTHORIZED");
                                      _;
                                  }
                                  function setSvgHelper(address _tokenAddress, ISvgHelper _svgHelper) public onlyOwner {
                                      require(_svgHelper != ISvgHelper(address(0)), "ERR_INVALID_SVG_HELPER");
                                      require(_tokenAddress != address(0), "ERR_INVALID_TOKEN_ADDRESS");
                                      svgHelpers[_tokenAddress] = _svgHelper;
                                      emit SvgHelperUpdated(_tokenAddress, _svgHelper);
                                  }
                                  function setLiquidityProviders(address _liquidityProviders) external onlyOwner {
                                      require(_liquidityProviders != address(0), "ERR_INVALID_LIQUIDITY_PROVIDERS");
                                      liquidityProvidersAddress = _liquidityProviders;
                                      emit LiquidityProvidersUpdated(_liquidityProviders);
                                  }
                                  function setWhiteListPeriodManager(address _whiteListPeriodManager) external onlyOwner {
                                      require(_whiteListPeriodManager != address(0), "ERR_INVALID_WHITELIST_PERIOD_MANAGER");
                                      whiteListPeriodManager = IWhiteListPeriodManager(_whiteListPeriodManager);
                                      emit WhiteListPeriodManagerUpdated(_whiteListPeriodManager);
                                  }
                                  function getAllNftIdsByUser(address _owner) public view returns (uint256[] memory) {
                                      uint256[] memory nftIds = new uint256[](balanceOf(_owner));
                                      uint256 length = nftIds.length;
                                      for (uint256 i; i < length; ) {
                                          nftIds[i] = tokenOfOwnerByIndex(_owner, i);
                                          unchecked {
                                              ++i;
                                          }
                                      }
                                      return nftIds;
                                  }
                                  function mint(address _to) external onlyHyphenPools whenNotPaused nonReentrant returns (uint256) {
                                      uint256 tokenId = totalSupply() + 1;
                                      _safeMint(_to, tokenId);
                                      return tokenId;
                                  }
                                  function updateTokenMetadata(uint256 _tokenId, LpTokenMetadata calldata _lpTokenMetadata)
                                      external
                                      onlyHyphenPools
                                      whenNotPaused
                                  {
                                      require(_exists(_tokenId), "ERR__TOKEN_DOES_NOT_EXIST");
                                      tokenMetadata[_tokenId] = _lpTokenMetadata;
                                  }
                                  function exists(uint256 _tokenId) external view returns (bool) {
                                      return _exists(_tokenId);
                                  }
                                  function supportsInterface(bytes4 interfaceId)
                                      public
                                      view
                                      virtual
                                      override(ERC721Upgradeable, ERC721EnumerableUpgradeable)
                                      returns (bool)
                                  {
                                      return super.supportsInterface(interfaceId);
                                  }
                                  function tokenURI(uint256 tokenId)
                                      public
                                      view
                                      virtual
                                      override(ERC721Upgradeable, ERC721URIStorageUpgradeable)
                                      returns (string memory)
                                  {
                                      address tokenAddress = tokenMetadata[tokenId].token;
                                      require(svgHelpers[tokenAddress] != ISvgHelper(address(0)), "ERR__SVG_HELPER_NOT_REGISTERED");
                                      ISvgHelper svgHelper = ISvgHelper(svgHelpers[tokenAddress]);
                                      string memory svgData = svgHelper.getTokenSvg(
                                          tokenId,
                                          tokenMetadata[tokenId].suppliedLiquidity,
                                          ILiquidityProviders(liquidityProvidersAddress).totalReserve(tokenAddress)
                                      );
                                      string memory description = svgHelper.getDescription(
                                          tokenMetadata[tokenId].suppliedLiquidity,
                                          ILiquidityProviders(liquidityProvidersAddress).totalReserve(tokenAddress)
                                      );
                                      string memory attributes = svgHelper.getAttributes(
                                          tokenMetadata[tokenId].suppliedLiquidity,
                                          ILiquidityProviders(liquidityProvidersAddress).totalReserve(tokenAddress)
                                      );
                                      string memory json = Base64.encode(
                                          bytes(
                                              string(
                                                  abi.encodePacked(
                                                      '{"name": "',
                                                      name(),
                                                      '", "description": "',
                                                      description,
                                                      '", "image": "data:image/svg+xml;base64,',
                                                      Base64.encode(bytes(svgData)),
                                                      '", "attributes": ',
                                                      attributes,
                                                      "}"
                                                  )
                                              )
                                          )
                                      );
                                      return string(abi.encodePacked("data:application/json;base64,", json));
                                  }
                                  function _msgSender()
                                      internal
                                      view
                                      virtual
                                      override(ContextUpgradeable, ERC2771ContextUpgradeable)
                                      returns (address)
                                  {
                                      return ERC2771ContextUpgradeable._msgSender();
                                  }
                                  function _msgData()
                                      internal
                                      view
                                      virtual
                                      override(ContextUpgradeable, ERC2771ContextUpgradeable)
                                      returns (bytes calldata)
                                  {
                                      return ERC2771ContextUpgradeable._msgData();
                                  }
                                  function _beforeTokenTransfer(
                                      address from,
                                      address to,
                                      uint256 tokenId
                                  ) internal virtual override(ERC721EnumerableUpgradeable, ERC721Upgradeable) whenNotPaused {
                                      super._beforeTokenTransfer(from, to, tokenId);
                                      // Only call whitelist period manager for NFT Transfers, not mint and burns
                                      if (from != address(0) && to != address(0)) {
                                          whiteListPeriodManager.beforeLiquidityTransfer(
                                              from,
                                              to,
                                              tokenMetadata[tokenId].token,
                                              tokenMetadata[tokenId].suppliedLiquidity
                                          );
                                      }
                                  }
                                  function _burn(uint256 tokenId) internal virtual override(ERC721URIStorageUpgradeable, ERC721Upgradeable) {
                                      ERC721URIStorageUpgradeable._burn(tokenId);
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/ContextUpgradeable.sol";
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Context variant with ERC2771 support.
                               */
                              abstract contract ERC2771ContextUpgradeable is Initializable, ContextUpgradeable {
                                  address private _trustedForwarder;
                                  function __ERC2771Context_init(address trustedForwarder) internal initializer {
                                      __Context_init_unchained();
                                      __ERC2771Context_init_unchained(trustedForwarder);
                                  }
                                  function __ERC2771Context_init_unchained(address trustedForwarder) internal initializer {
                                      _trustedForwarder = trustedForwarder;
                                  }
                                  function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
                                      return forwarder == _trustedForwarder;
                                  }
                                  function _msgSender() internal view virtual override returns (address sender) {
                                      if (isTrustedForwarder(msg.sender)) {
                                          // The assembly code is more direct than the Solidity version using `abi.decode`.
                                          assembly {
                                              sender := shr(96, calldataload(sub(calldatasize(), 20)))
                                          }
                                      } else {
                                          return super._msgSender();
                                      }
                                  }
                                  function _msgData() internal view virtual override returns (bytes calldata) {
                                      if (isTrustedForwarder(msg.sender)) {
                                          return msg.data[:msg.data.length - 20];
                                      } else {
                                          return super._msgData();
                                      }
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/ContextUpgradeable.sol";
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module which provides a basic access control mechanism, where
                               * there is an account (an owner) that can be granted exclusive access to
                               * specific functions.
                               *
                               * By default, the owner account will be the one that deploys the contract. This
                               * can later be changed with {transferOwnership}.
                               *
                               * This module is used through inheritance. It will make available the modifier
                               * `onlyOwner`, which can be applied to your functions to restrict their use to
                               * the owner.
                               */
                              abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
                                  address private _owner;
                                  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                                  /**
                                   * @dev Initializes the contract setting the deployer as the initial owner.
                                   */
                                  function __Ownable_init() internal initializer {
                                      __Context_init_unchained();
                                      __Ownable_init_unchained();
                                  }
                                  function __Ownable_init_unchained() internal initializer {
                                      _setOwner(_msgSender());
                                  }
                                  /**
                                   * @dev Returns the address of the current owner.
                                   */
                                  function owner() public view virtual returns (address) {
                                      return _owner;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the owner.
                                   */
                                  modifier onlyOwner() {
                                      require(owner() == _msgSender(), "Ownable: caller is not the owner");
                                      _;
                                  }
                                  /**
                                   * @dev Leaves the contract without owner. It will not be possible to call
                                   * `onlyOwner` functions anymore. Can only be called by the current owner.
                                   *
                                   * NOTE: Renouncing ownership will leave the contract without an owner,
                                   * thereby removing any functionality that is only available to the owner.
                                   */
                                  function renounceOwnership() public virtual onlyOwner {
                                      _setOwner(address(0));
                                  }
                                  /**
                                   * @dev Transfers ownership of the contract to a new account (`newOwner`).
                                   * Can only be called by the current owner.
                                   */
                                  function transferOwnership(address newOwner) public virtual onlyOwner {
                                      require(newOwner != address(0), "Ownable: new owner is the zero address");
                                      _setOwner(newOwner);
                                  }
                                  function _setOwner(address newOwner) private {
                                      address oldOwner = _owner;
                                      _owner = newOwner;
                                      emit OwnershipTransferred(oldOwner, newOwner);
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module that helps prevent reentrant calls to a function.
                               *
                               * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
                               * available, which can be applied to functions to make sure there are no nested
                               * (reentrant) calls to them.
                               *
                               * Note that because there is a single `nonReentrant` guard, functions marked as
                               * `nonReentrant` may not call one another. This can be worked around by making
                               * those functions `private`, and then adding `external` `nonReentrant` entry
                               * points to them.
                               *
                               * TIP: If you would like to learn more about reentrancy and alternative ways
                               * to protect against it, check out our blog post
                               * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
                               */
                              abstract contract ReentrancyGuardUpgradeable is Initializable {
                                  // Booleans are more expensive than uint256 or any type that takes up a full
                                  // word because each write operation emits an extra SLOAD to first read the
                                  // slot's contents, replace the bits taken up by the boolean, and then write
                                  // back. This is the compiler's defense against contract upgrades and
                                  // pointer aliasing, and it cannot be disabled.
                                  // The values being non-zero value makes deployment a bit more expensive,
                                  // but in exchange the refund on every call to nonReentrant will be lower in
                                  // amount. Since refunds are capped to a percentage of the total
                                  // transaction's gas, it is best to keep them low in cases like this one, to
                                  // increase the likelihood of the full refund coming into effect.
                                  uint256 private constant _NOT_ENTERED = 1;
                                  uint256 private constant _ENTERED = 2;
                                  uint256 private _status;
                                  function __ReentrancyGuard_init() internal initializer {
                                      __ReentrancyGuard_init_unchained();
                                  }
                                  function __ReentrancyGuard_init_unchained() internal initializer {
                                      _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 make it call a
                                   * `private` function that does the actual work.
                                   */
                                  modifier nonReentrant() {
                                      // On the first call to nonReentrant, _notEntered will be true
                                      require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
                                      // Any calls to nonReentrant after this point will fail
                                      _status = _ENTERED;
                                      _;
                                      // By storing the original value once again, a refund is triggered (see
                                      // https://eips.ethereum.org/EIPS/eip-2200)
                                      _status = _NOT_ENTERED;
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../ERC721Upgradeable.sol";
                              import "./IERC721EnumerableUpgradeable.sol";
                              import "../../../proxy/utils/Initializable.sol";
                              /**
                               * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
                               * enumerability of all the token ids in the contract as well as all token ids owned by each
                               * account.
                               */
                              abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable {
                                  function __ERC721Enumerable_init() internal initializer {
                                      __Context_init_unchained();
                                      __ERC165_init_unchained();
                                      __ERC721Enumerable_init_unchained();
                                  }
                                  function __ERC721Enumerable_init_unchained() internal initializer {
                                  }
                                  // Mapping from owner to list of owned token IDs
                                  mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
                                  // Mapping from token ID to index of the owner tokens list
                                  mapping(uint256 => uint256) private _ownedTokensIndex;
                                  // Array with all token ids, used for enumeration
                                  uint256[] private _allTokens;
                                  // Mapping from token id to position in the allTokens array
                                  mapping(uint256 => uint256) private _allTokensIndex;
                                  /**
                                   * @dev See {IERC165-supportsInterface}.
                                   */
                                  function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165Upgradeable, ERC721Upgradeable) returns (bool) {
                                      return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);
                                  }
                                  /**
                                   * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
                                   */
                                  function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
                                      require(index < ERC721Upgradeable.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
                                      return _ownedTokens[owner][index];
                                  }
                                  /**
                                   * @dev See {IERC721Enumerable-totalSupply}.
                                   */
                                  function totalSupply() public view virtual override returns (uint256) {
                                      return _allTokens.length;
                                  }
                                  /**
                                   * @dev See {IERC721Enumerable-tokenByIndex}.
                                   */
                                  function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
                                      require(index < ERC721EnumerableUpgradeable.totalSupply(), "ERC721Enumerable: global index out of bounds");
                                      return _allTokens[index];
                                  }
                                  /**
                                   * @dev Hook that is called before any token transfer. This includes minting
                                   * and burning.
                                   *
                                   * Calling conditions:
                                   *
                                   * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
                                   * transferred to `to`.
                                   * - When `from` is zero, `tokenId` will be minted for `to`.
                                   * - When `to` is zero, ``from``'s `tokenId` will be burned.
                                   * - `from` cannot be the zero address.
                                   * - `to` cannot be the zero address.
                                   *
                                   * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
                                   */
                                  function _beforeTokenTransfer(
                                      address from,
                                      address to,
                                      uint256 tokenId
                                  ) internal virtual override {
                                      super._beforeTokenTransfer(from, to, tokenId);
                                      if (from == address(0)) {
                                          _addTokenToAllTokensEnumeration(tokenId);
                                      } else if (from != to) {
                                          _removeTokenFromOwnerEnumeration(from, tokenId);
                                      }
                                      if (to == address(0)) {
                                          _removeTokenFromAllTokensEnumeration(tokenId);
                                      } else if (to != from) {
                                          _addTokenToOwnerEnumeration(to, tokenId);
                                      }
                                  }
                                  /**
                                   * @dev Private function to add a token to this extension's ownership-tracking data structures.
                                   * @param to address representing the new owner of the given token ID
                                   * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
                                   */
                                  function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
                                      uint256 length = ERC721Upgradeable.balanceOf(to);
                                      _ownedTokens[to][length] = tokenId;
                                      _ownedTokensIndex[tokenId] = length;
                                  }
                                  /**
                                   * @dev Private function to add a token to this extension's token tracking data structures.
                                   * @param tokenId uint256 ID of the token to be added to the tokens list
                                   */
                                  function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
                                      _allTokensIndex[tokenId] = _allTokens.length;
                                      _allTokens.push(tokenId);
                                  }
                                  /**
                                   * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
                                   * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
                                   * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
                                   * This has O(1) time complexity, but alters the order of the _ownedTokens array.
                                   * @param from address representing the previous owner of the given token ID
                                   * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
                                   */
                                  function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
                                      // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
                                      // then delete the last slot (swap and pop).
                                      uint256 lastTokenIndex = ERC721Upgradeable.balanceOf(from) - 1;
                                      uint256 tokenIndex = _ownedTokensIndex[tokenId];
                                      // When the token to delete is the last token, the swap operation is unnecessary
                                      if (tokenIndex != lastTokenIndex) {
                                          uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
                                          _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
                                          _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
                                      }
                                      // This also deletes the contents at the last position of the array
                                      delete _ownedTokensIndex[tokenId];
                                      delete _ownedTokens[from][lastTokenIndex];
                                  }
                                  /**
                                   * @dev Private function to remove a token from this extension's token tracking data structures.
                                   * This has O(1) time complexity, but alters the order of the _allTokens array.
                                   * @param tokenId uint256 ID of the token to be removed from the tokens list
                                   */
                                  function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
                                      // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
                                      // then delete the last slot (swap and pop).
                                      uint256 lastTokenIndex = _allTokens.length - 1;
                                      uint256 tokenIndex = _allTokensIndex[tokenId];
                                      // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
                                      // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
                                      // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
                                      uint256 lastTokenId = _allTokens[lastTokenIndex];
                                      _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
                                      _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
                                      // This also deletes the contents at the last position of the array
                                      delete _allTokensIndex[tokenId];
                                      _allTokens.pop();
                                  }
                                  uint256[46] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../ERC721Upgradeable.sol";
                              import "../../../proxy/utils/Initializable.sol";
                              /**
                               * @dev ERC721 token with storage based token URI management.
                               */
                              abstract contract ERC721URIStorageUpgradeable is Initializable, ERC721Upgradeable {
                                  function __ERC721URIStorage_init() internal initializer {
                                      __Context_init_unchained();
                                      __ERC165_init_unchained();
                                      __ERC721URIStorage_init_unchained();
                                  }
                                  function __ERC721URIStorage_init_unchained() internal initializer {
                                  }
                                  using StringsUpgradeable for uint256;
                                  // Optional mapping for token URIs
                                  mapping(uint256 => string) private _tokenURIs;
                                  /**
                                   * @dev See {IERC721Metadata-tokenURI}.
                                   */
                                  function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
                                      require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token");
                                      string memory _tokenURI = _tokenURIs[tokenId];
                                      string memory base = _baseURI();
                                      // If there is no base URI, return the token URI.
                                      if (bytes(base).length == 0) {
                                          return _tokenURI;
                                      }
                                      // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
                                      if (bytes(_tokenURI).length > 0) {
                                          return string(abi.encodePacked(base, _tokenURI));
                                      }
                                      return super.tokenURI(tokenId);
                                  }
                                  /**
                                   * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
                                   *
                                   * Requirements:
                                   *
                                   * - `tokenId` must exist.
                                   */
                                  function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
                                      require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token");
                                      _tokenURIs[tokenId] = _tokenURI;
                                  }
                                  /**
                                   * @dev Destroys `tokenId`.
                                   * The approval is cleared when the token is burned.
                                   *
                                   * Requirements:
                                   *
                                   * - `tokenId` must exist.
                                   *
                                   * Emits a {Transfer} event.
                                   */
                                  function _burn(uint256 tokenId) internal virtual override {
                                      super._burn(tokenId);
                                      if (bytes(_tokenURIs[tokenId]).length != 0) {
                                          delete _tokenURIs[tokenId];
                                      }
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity >=0.6.0;
                              /// @title Base64
                              /// @author Brecht Devos - <[email protected]>
                              /// @notice Provides functions for encoding/decoding base64
                              library Base64 {
                                  string internal constant TABLE_ENCODE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
                                  bytes  internal constant TABLE_DECODE = hex"0000000000000000000000000000000000000000000000000000000000000000"
                                                                          hex"00000000000000000000003e0000003f3435363738393a3b3c3d000000000000"
                                                                          hex"00000102030405060708090a0b0c0d0e0f101112131415161718190000000000"
                                                                          hex"001a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132330000000000";
                                  function encode(bytes memory data) internal pure returns (string memory) {
                                      if (data.length == 0) return '';
                                      // load the table into memory
                                      string memory table = TABLE_ENCODE;
                                      // multiply by 4/3 rounded up
                                      uint256 encodedLen = 4 * ((data.length + 2) / 3);
                                      // add some extra buffer at the end required for the writing
                                      string memory result = new string(encodedLen + 32);
                                      assembly {
                                          // set the actual output length
                                          mstore(result, encodedLen)
                                          // prepare the lookup table
                                          let tablePtr := add(table, 1)
                                          // input ptr
                                          let dataPtr := data
                                          let endPtr := add(dataPtr, mload(data))
                                          // result ptr, jump over length
                                          let resultPtr := add(result, 32)
                                          // run over the input, 3 bytes at a time
                                          for {} lt(dataPtr, endPtr) {}
                                          {
                                              // read 3 bytes
                                              dataPtr := add(dataPtr, 3)
                                              let input := mload(dataPtr)
                                              // write 4 characters
                                              mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
                                              resultPtr := add(resultPtr, 1)
                                              mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
                                              resultPtr := add(resultPtr, 1)
                                              mstore8(resultPtr, mload(add(tablePtr, and(shr( 6, input), 0x3F))))
                                              resultPtr := add(resultPtr, 1)
                                              mstore8(resultPtr, mload(add(tablePtr, and(        input,  0x3F))))
                                              resultPtr := add(resultPtr, 1)
                                          }
                                          // padding with '='
                                          switch mod(mload(data), 3)
                                          case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) }
                                          case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) }
                                      }
                                      return result;
                                  }
                                  function decode(string memory _data) internal pure returns (bytes memory) {
                                      bytes memory data = bytes(_data);
                                      if (data.length == 0) return new bytes(0);
                                      require(data.length % 4 == 0, "invalid base64 decoder input");
                                      // load the table into memory
                                      bytes memory table = TABLE_DECODE;
                                      // every 4 characters represent 3 bytes
                                      uint256 decodedLen = (data.length / 4) * 3;
                                      // add some extra buffer at the end required for the writing
                                      bytes memory result = new bytes(decodedLen + 32);
                                      assembly {
                                          // padding with '='
                                          let lastBytes := mload(add(data, mload(data)))
                                          if eq(and(lastBytes, 0xFF), 0x3d) {
                                              decodedLen := sub(decodedLen, 1)
                                              if eq(and(lastBytes, 0xFFFF), 0x3d3d) {
                                                  decodedLen := sub(decodedLen, 1)
                                              }
                                          }
                                          // set the actual output length
                                          mstore(result, decodedLen)
                                          // prepare the lookup table
                                          let tablePtr := add(table, 1)
                                          // input ptr
                                          let dataPtr := data
                                          let endPtr := add(dataPtr, mload(data))
                                          // result ptr, jump over length
                                          let resultPtr := add(result, 32)
                                          // run over the input, 4 characters at a time
                                          for {} lt(dataPtr, endPtr) {}
                                          {
                                             // read 4 characters
                                             dataPtr := add(dataPtr, 4)
                                             let input := mload(dataPtr)
                                             // write 3 bytes
                                             let output := add(
                                                 add(
                                                     shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)),
                                                     shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))),
                                                 add(
                                                     shl( 6, and(mload(add(tablePtr, and(shr( 8, input), 0xFF))), 0xFF)),
                                                             and(mload(add(tablePtr, and(        input , 0xFF))), 0xFF)
                                                  )
                                              )
                                              mstore(resultPtr, shl(232, output))
                                              resultPtr := add(resultPtr, 3)
                                          }
                                      }
                                      return result;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              interface ISvgHelper {
                                  function backgroundUrl() external view returns (string memory);
                                  function getTokenSvg(
                                      uint256 _tokenId,
                                      uint256 _suppliedLiquidity,
                                      uint256 _totalSuppliedLiquidity
                                  ) external view returns (string memory);
                                  function getAttributes(uint256 _suppliedLiquidity, uint256 _totalSuppliedLiquidity)
                                      external
                                      view
                                      returns (string memory);
                                  function getDescription(uint256 _suppliedLiquidity, uint256 _totalSuppliedLiquidity)
                                      external
                                      view
                                      returns (string memory);
                                  function getChainName() external view returns (string memory);
                                  function owner() external view returns (address);
                                  function renounceOwnership() external;
                                  function setBackgroundPngUrl(string memory _backgroundPngUrl) external;
                                  function transferOwnership(address newOwner) external;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              interface IWhiteListPeriodManager {
                                  function areWhiteListRestrictionsEnabled() external view returns (bool);
                                  function beforeLiquidityAddition(
                                      address _lp,
                                      address _token,
                                      uint256 _amount
                                  ) external;
                                  function beforeLiquidityRemoval(
                                      address _lp,
                                      address _token,
                                      uint256 _amount
                                  ) external;
                                  function beforeLiquidityTransfer(
                                      address _from,
                                      address _to,
                                      address _token,
                                      uint256 _amount
                                  ) external;
                                  function getMaxCommunityLpPositon(address _token) external view returns (uint256);
                                  function initialize(
                                      address _trustedForwarder,
                                      address _liquidityProviders,
                                      address _tokenManager
                                  ) external;
                                  function isExcludedAddress(address) external view returns (bool);
                                  function isTrustedForwarder(address forwarder) external view returns (bool);
                                  function owner() external view returns (address);
                                  function paused() external view returns (bool);
                                  function perTokenTotalCap(address) external view returns (uint256);
                                  function perTokenWalletCap(address) external view returns (uint256);
                                  function renounceOwnership() external;
                                  function setAreWhiteListRestrictionsEnabled(bool _status) external;
                                  function setCap(
                                      address _token,
                                      uint256 _totalCap,
                                      uint256 _perTokenWalletCap
                                  ) external;
                                  function setCaps(
                                      address[] memory _tokens,
                                      uint256[] memory _totalCaps,
                                      uint256[] memory _perTokenWalletCaps
                                  ) external;
                                  function setIsExcludedAddressStatus(address[] memory _addresses, bool[] memory _status) external;
                                  function setLiquidityProviders(address _liquidityProviders) external;
                                  function setPerTokenWalletCap(address _token, uint256 _perTokenWalletCap) external;
                                  function setTokenManager(address _tokenManager) external;
                                  function setTotalCap(address _token, uint256 _totalCap) external;
                                  function transferOwnership(address newOwner) external;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              interface ILiquidityProviders {
                                  function BASE_DIVISOR() external view returns (uint256);
                                  function initialize(address _trustedForwarder, address _lpToken) external;
                                  function addLPFee(address _token, uint256 _amount) external;
                                  function addNativeLiquidity() external;
                                  function addTokenLiquidity(address _token, uint256 _amount) external;
                                  function claimFee(uint256 _nftId) external;
                                  function getFeeAccumulatedOnNft(uint256 _nftId) external view returns (uint256);
                                  function getSuppliedLiquidityByToken(address tokenAddress) external view returns (uint256);
                                  function getTokenPriceInLPShares(address _baseToken) external view returns (uint256);
                                  function getTotalLPFeeByToken(address tokenAddress) external view returns (uint256);
                                  function getTotalReserveByToken(address tokenAddress) external view returns (uint256);
                                  function getSuppliedLiquidity(uint256 _nftId) external view returns (uint256);
                                  function increaseNativeLiquidity(uint256 _nftId) external;
                                  function increaseTokenLiquidity(uint256 _nftId, uint256 _amount) external;
                                  function isTrustedForwarder(address forwarder) external view returns (bool);
                                  function owner() external view returns (address);
                                  function paused() external view returns (bool);
                                  function removeLiquidity(uint256 _nftId, uint256 amount) external;
                                  function renounceOwnership() external;
                                  function setLiquidityPool(address _liquidityPool) external;
                                  function setLpToken(address _lpToken) external;
                                  function setWhiteListPeriodManager(address _whiteListPeriodManager) external;
                                  function sharesToTokenAmount(uint256 _shares, address _tokenAddress) external view returns (uint256);
                                  function totalLPFees(address) external view returns (uint256);
                                  function totalLiquidity(address) external view returns (uint256);
                                  function totalReserve(address) external view returns (uint256);
                                  function totalSharesMinted(address) external view returns (uint256);
                                  function transferOwnership(address newOwner) external;
                                  function whiteListPeriodManager() external view returns (address);
                                  function increaseCurrentLiquidity(address tokenAddress, uint256 amount) external;
                                  function decreaseCurrentLiquidity(address tokenAddress, uint256 amount) external;
                                  function getCurrentLiquidity(address tokenAddress) external view returns (uint256);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                              import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
                              /**
                               * @dev Contract module which allows children to implement an emergency stop
                               * mechanism that can be triggered by an authorized account.
                               *
                               * This module is used through inheritance. It will make available the
                               * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
                               * the functions of your contract. Note that they will not be pausable by
                               * simply including this module, only once the modifiers are put in place.
                               */
                              abstract contract Pausable is Initializable, PausableUpgradeable {
                                  address private _pauser;
                                  event PauserChanged(address indexed previousPauser, address indexed newPauser);
                                  /**
                                   * @dev The pausable constructor sets the original `pauser` of the contract to the sender
                                   * account & Initializes the contract in unpaused state..
                                   */
                                  function __Pausable_init(address pauser) internal initializer {
                                      require(pauser != address(0), "Pauser Address cannot be 0");
                                      __Pausable_init();
                                      _pauser = pauser;
                                  }
                                  /**
                                   * @return true if `msg.sender` is the owner of the contract.
                                   */
                                  function isPauser(address pauser) public view returns (bool) {
                                      return pauser == _pauser;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the pauser.
                                   */
                                  modifier onlyPauser() {
                                      require(isPauser(msg.sender), "Only pauser is allowed to perform this operation");
                                      _;
                                  }
                                  /**
                                   * @dev Allows the current pauser to transfer control of the contract to a newPauser.
                                   * @param newPauser The address to transfer pauserShip to.
                                   */
                                  function changePauser(address newPauser) public onlyPauser {
                                      _changePauser(newPauser);
                                  }
                                  /**
                                   * @dev Transfers control of the contract to a newPauser.
                                   * @param newPauser The address to transfer ownership to.
                                   */
                                  function _changePauser(address newPauser) internal {
                                      require(newPauser != address(0));
                                      emit PauserChanged(_pauser, newPauser);
                                      _pauser = newPauser;
                                  }
                                  function renouncePauser() external virtual onlyPauser {
                                      emit PauserChanged(_pauser, address(0));
                                      _pauser = address(0);
                                  }
                                  function pause() public onlyPauser {
                                      _pause();
                                  }
                                  function unpause() public onlyPauser {
                                      _unpause();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              struct LpTokenMetadata {
                                  address token;
                                  uint256 suppliedLiquidity;
                                  uint256 shares;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Provides information about the current execution context, including the
                               * sender of the transaction and its data. While these are generally available
                               * via msg.sender and msg.data, they should not be accessed in such a direct
                               * manner, since when dealing with meta-transactions the account sending and
                               * paying for execution may not be the actual sender (as far as an application
                               * is concerned).
                               *
                               * This contract is only required for intermediate, library-like contracts.
                               */
                              abstract contract ContextUpgradeable is Initializable {
                                  function __Context_init() internal initializer {
                                      __Context_init_unchained();
                                  }
                                  function __Context_init_unchained() internal initializer {
                                  }
                                  function _msgSender() internal view virtual returns (address) {
                                      return msg.sender;
                                  }
                                  function _msgData() internal view virtual returns (bytes calldata) {
                                      return msg.data;
                                  }
                                  uint256[50] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
                               * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
                               * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
                               * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
                               *
                               * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
                               * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
                               *
                               * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
                               * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
                               */
                              abstract contract Initializable {
                                  /**
                                   * @dev Indicates that the contract has been initialized.
                                   */
                                  bool private _initialized;
                                  /**
                                   * @dev Indicates that the contract is in the process of being initialized.
                                   */
                                  bool private _initializing;
                                  /**
                                   * @dev Modifier to protect an initializer function from being invoked twice.
                                   */
                                  modifier initializer() {
                                      require(_initializing || !_initialized, "Initializable: contract is already initialized");
                                      bool isTopLevelCall = !_initializing;
                                      if (isTopLevelCall) {
                                          _initializing = true;
                                          _initialized = true;
                                      }
                                      _;
                                      if (isTopLevelCall) {
                                          _initializing = false;
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "./IERC721Upgradeable.sol";
                              import "./IERC721ReceiverUpgradeable.sol";
                              import "./extensions/IERC721MetadataUpgradeable.sol";
                              import "../../utils/AddressUpgradeable.sol";
                              import "../../utils/ContextUpgradeable.sol";
                              import "../../utils/StringsUpgradeable.sol";
                              import "../../utils/introspection/ERC165Upgradeable.sol";
                              import "../../proxy/utils/Initializable.sol";
                              /**
                               * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
                               * the Metadata extension, but not including the Enumerable extension, which is available separately as
                               * {ERC721Enumerable}.
                               */
                              contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
                                  using AddressUpgradeable for address;
                                  using StringsUpgradeable for uint256;
                                  // Token name
                                  string private _name;
                                  // Token symbol
                                  string private _symbol;
                                  // Mapping from token ID to owner address
                                  mapping(uint256 => address) private _owners;
                                  // Mapping owner address to token count
                                  mapping(address => uint256) private _balances;
                                  // Mapping from token ID to approved address
                                  mapping(uint256 => address) private _tokenApprovals;
                                  // Mapping from owner to operator approvals
                                  mapping(address => mapping(address => bool)) private _operatorApprovals;
                                  /**
                                   * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
                                   */
                                  function __ERC721_init(string memory name_, string memory symbol_) internal initializer {
                                      __Context_init_unchained();
                                      __ERC165_init_unchained();
                                      __ERC721_init_unchained(name_, symbol_);
                                  }
                                  function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer {
                                      _name = name_;
                                      _symbol = symbol_;
                                  }
                                  /**
                                   * @dev See {IERC165-supportsInterface}.
                                   */
                                  function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
                                      return
                                          interfaceId == type(IERC721Upgradeable).interfaceId ||
                                          interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||
                                          super.supportsInterface(interfaceId);
                                  }
                                  /**
                                   * @dev See {IERC721-balanceOf}.
                                   */
                                  function balanceOf(address owner) public view virtual override returns (uint256) {
                                      require(owner != address(0), "ERC721: balance query for the zero address");
                                      return _balances[owner];
                                  }
                                  /**
                                   * @dev See {IERC721-ownerOf}.
                                   */
                                  function ownerOf(uint256 tokenId) public view virtual override returns (address) {
                                      address owner = _owners[tokenId];
                                      require(owner != address(0), "ERC721: owner query for nonexistent token");
                                      return owner;
                                  }
                                  /**
                                   * @dev See {IERC721Metadata-name}.
                                   */
                                  function name() public view virtual override returns (string memory) {
                                      return _name;
                                  }
                                  /**
                                   * @dev See {IERC721Metadata-symbol}.
                                   */
                                  function symbol() public view virtual override returns (string memory) {
                                      return _symbol;
                                  }
                                  /**
                                   * @dev See {IERC721Metadata-tokenURI}.
                                   */
                                  function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
                                      require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
                                      string memory baseURI = _baseURI();
                                      return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
                                  }
                                  /**
                                   * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
                                   * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
                                   * by default, can be overriden in child contracts.
                                   */
                                  function _baseURI() internal view virtual returns (string memory) {
                                      return "";
                                  }
                                  /**
                                   * @dev See {IERC721-approve}.
                                   */
                                  function approve(address to, uint256 tokenId) public virtual override {
                                      address owner = ERC721Upgradeable.ownerOf(tokenId);
                                      require(to != owner, "ERC721: approval to current owner");
                                      require(
                                          _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
                                          "ERC721: approve caller is not owner nor approved for all"
                                      );
                                      _approve(to, tokenId);
                                  }
                                  /**
                                   * @dev See {IERC721-getApproved}.
                                   */
                                  function getApproved(uint256 tokenId) public view virtual override returns (address) {
                                      require(_exists(tokenId), "ERC721: approved query for nonexistent token");
                                      return _tokenApprovals[tokenId];
                                  }
                                  /**
                                   * @dev See {IERC721-setApprovalForAll}.
                                   */
                                  function setApprovalForAll(address operator, bool approved) public virtual override {
                                      require(operator != _msgSender(), "ERC721: approve to caller");
                                      _operatorApprovals[_msgSender()][operator] = approved;
                                      emit ApprovalForAll(_msgSender(), operator, approved);
                                  }
                                  /**
                                   * @dev See {IERC721-isApprovedForAll}.
                                   */
                                  function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
                                      return _operatorApprovals[owner][operator];
                                  }
                                  /**
                                   * @dev See {IERC721-transferFrom}.
                                   */
                                  function transferFrom(
                                      address from,
                                      address to,
                                      uint256 tokenId
                                  ) public virtual override {
                                      //solhint-disable-next-line max-line-length
                                      require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
                                      _transfer(from, to, tokenId);
                                  }
                                  /**
                                   * @dev See {IERC721-safeTransferFrom}.
                                   */
                                  function safeTransferFrom(
                                      address from,
                                      address to,
                                      uint256 tokenId
                                  ) public virtual override {
                                      safeTransferFrom(from, to, tokenId, "");
                                  }
                                  /**
                                   * @dev See {IERC721-safeTransferFrom}.
                                   */
                                  function safeTransferFrom(
                                      address from,
                                      address to,
                                      uint256 tokenId,
                                      bytes memory _data
                                  ) public virtual override {
                                      require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
                                      _safeTransfer(from, to, tokenId, _data);
                                  }
                                  /**
                                   * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
                                   * are aware of the ERC721 protocol to prevent tokens from being forever locked.
                                   *
                                   * `_data` is additional data, it has no specified format and it is sent in call to `to`.
                                   *
                                   * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
                                   * implement alternative mechanisms to perform token transfer, such as signature-based.
                                   *
                                   * Requirements:
                                   *
                                   * - `from` cannot be the zero address.
                                   * - `to` cannot be the zero address.
                                   * - `tokenId` token must exist and be owned by `from`.
                                   * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
                                   *
                                   * Emits a {Transfer} event.
                                   */
                                  function _safeTransfer(
                                      address from,
                                      address to,
                                      uint256 tokenId,
                                      bytes memory _data
                                  ) internal virtual {
                                      _transfer(from, to, tokenId);
                                      require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
                                  }
                                  /**
                                   * @dev Returns whether `tokenId` exists.
                                   *
                                   * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
                                   *
                                   * Tokens start existing when they are minted (`_mint`),
                                   * and stop existing when they are burned (`_burn`).
                                   */
                                  function _exists(uint256 tokenId) internal view virtual returns (bool) {
                                      return _owners[tokenId] != address(0);
                                  }
                                  /**
                                   * @dev Returns whether `spender` is allowed to manage `tokenId`.
                                   *
                                   * Requirements:
                                   *
                                   * - `tokenId` must exist.
                                   */
                                  function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
                                      require(_exists(tokenId), "ERC721: operator query for nonexistent token");
                                      address owner = ERC721Upgradeable.ownerOf(tokenId);
                                      return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
                                  }
                                  /**
                                   * @dev Safely mints `tokenId` and transfers it to `to`.
                                   *
                                   * Requirements:
                                   *
                                   * - `tokenId` must not exist.
                                   * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
                                   *
                                   * Emits a {Transfer} event.
                                   */
                                  function _safeMint(address to, uint256 tokenId) internal virtual {
                                      _safeMint(to, tokenId, "");
                                  }
                                  /**
                                   * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
                                   * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
                                   */
                                  function _safeMint(
                                      address to,
                                      uint256 tokenId,
                                      bytes memory _data
                                  ) internal virtual {
                                      _mint(to, tokenId);
                                      require(
                                          _checkOnERC721Received(address(0), to, tokenId, _data),
                                          "ERC721: transfer to non ERC721Receiver implementer"
                                      );
                                  }
                                  /**
                                   * @dev Mints `tokenId` and transfers it to `to`.
                                   *
                                   * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
                                   *
                                   * Requirements:
                                   *
                                   * - `tokenId` must not exist.
                                   * - `to` cannot be the zero address.
                                   *
                                   * Emits a {Transfer} event.
                                   */
                                  function _mint(address to, uint256 tokenId) internal virtual {
                                      require(to != address(0), "ERC721: mint to the zero address");
                                      require(!_exists(tokenId), "ERC721: token already minted");
                                      _beforeTokenTransfer(address(0), to, tokenId);
                                      _balances[to] += 1;
                                      _owners[tokenId] = to;
                                      emit Transfer(address(0), to, tokenId);
                                  }
                                  /**
                                   * @dev Destroys `tokenId`.
                                   * The approval is cleared when the token is burned.
                                   *
                                   * Requirements:
                                   *
                                   * - `tokenId` must exist.
                                   *
                                   * Emits a {Transfer} event.
                                   */
                                  function _burn(uint256 tokenId) internal virtual {
                                      address owner = ERC721Upgradeable.ownerOf(tokenId);
                                      _beforeTokenTransfer(owner, address(0), tokenId);
                                      // Clear approvals
                                      _approve(address(0), tokenId);
                                      _balances[owner] -= 1;
                                      delete _owners[tokenId];
                                      emit Transfer(owner, address(0), tokenId);
                                  }
                                  /**
                                   * @dev Transfers `tokenId` from `from` to `to`.
                                   *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
                                   *
                                   * Requirements:
                                   *
                                   * - `to` cannot be the zero address.
                                   * - `tokenId` token must be owned by `from`.
                                   *
                                   * Emits a {Transfer} event.
                                   */
                                  function _transfer(
                                      address from,
                                      address to,
                                      uint256 tokenId
                                  ) internal virtual {
                                      require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
                                      require(to != address(0), "ERC721: transfer to the zero address");
                                      _beforeTokenTransfer(from, to, tokenId);
                                      // Clear approvals from the previous owner
                                      _approve(address(0), tokenId);
                                      _balances[from] -= 1;
                                      _balances[to] += 1;
                                      _owners[tokenId] = to;
                                      emit Transfer(from, to, tokenId);
                                  }
                                  /**
                                   * @dev Approve `to` to operate on `tokenId`
                                   *
                                   * Emits a {Approval} event.
                                   */
                                  function _approve(address to, uint256 tokenId) internal virtual {
                                      _tokenApprovals[tokenId] = to;
                                      emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);
                                  }
                                  /**
                                   * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
                                   * The call is not executed if the target address is not a contract.
                                   *
                                   * @param from address representing the previous owner of the given token ID
                                   * @param to target address that will receive the tokens
                                   * @param tokenId uint256 ID of the token to be transferred
                                   * @param _data bytes optional data to send along with the call
                                   * @return bool whether the call correctly returned the expected magic value
                                   */
                                  function _checkOnERC721Received(
                                      address from,
                                      address to,
                                      uint256 tokenId,
                                      bytes memory _data
                                  ) private returns (bool) {
                                      if (to.isContract()) {
                                          try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                                              return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;
                                          } catch (bytes memory reason) {
                                              if (reason.length == 0) {
                                                  revert("ERC721: transfer to non ERC721Receiver implementer");
                                              } else {
                                                  assembly {
                                                      revert(add(32, reason), mload(reason))
                                                  }
                                              }
                                          }
                                      } else {
                                          return true;
                                      }
                                  }
                                  /**
                                   * @dev Hook that is called before any token transfer. This includes minting
                                   * and burning.
                                   *
                                   * Calling conditions:
                                   *
                                   * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
                                   * transferred to `to`.
                                   * - When `from` is zero, `tokenId` will be minted for `to`.
                                   * - When `to` is zero, ``from``'s `tokenId` will be burned.
                                   * - `from` and `to` are never both zero.
                                   *
                                   * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
                                   */
                                  function _beforeTokenTransfer(
                                      address from,
                                      address to,
                                      uint256 tokenId
                                  ) internal virtual {}
                                  uint256[44] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../IERC721Upgradeable.sol";
                              /**
                               * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
                               * @dev See https://eips.ethereum.org/EIPS/eip-721
                               */
                              interface IERC721EnumerableUpgradeable is IERC721Upgradeable {
                                  /**
                                   * @dev Returns the total amount of tokens stored by the contract.
                                   */
                                  function totalSupply() external view returns (uint256);
                                  /**
                                   * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
                                   * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
                                   */
                                  function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
                                  /**
                                   * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
                                   * Use along with {totalSupply} to enumerate all tokens.
                                   */
                                  function tokenByIndex(uint256 index) external view returns (uint256);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../../utils/introspection/IERC165Upgradeable.sol";
                              /**
                               * @dev Required interface of an ERC721 compliant contract.
                               */
                              interface IERC721Upgradeable is IERC165Upgradeable {
                                  /**
                                   * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
                                   */
                                  event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
                                  /**
                                   * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
                                   */
                                  event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
                                  /**
                                   * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
                                   */
                                  event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
                                  /**
                                   * @dev Returns the number of tokens in ``owner``'s account.
                                   */
                                  function balanceOf(address owner) external view returns (uint256 balance);
                                  /**
                                   * @dev Returns the owner of the `tokenId` token.
                                   *
                                   * Requirements:
                                   *
                                   * - `tokenId` must exist.
                                   */
                                  function ownerOf(uint256 tokenId) external view returns (address owner);
                                  /**
                                   * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
                                   * are aware of the ERC721 protocol to prevent tokens from being forever locked.
                                   *
                                   * Requirements:
                                   *
                                   * - `from` cannot be the zero address.
                                   * - `to` cannot be the zero address.
                                   * - `tokenId` token must exist and be owned by `from`.
                                   * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
                                   * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
                                   *
                                   * Emits a {Transfer} event.
                                   */
                                  function safeTransferFrom(
                                      address from,
                                      address to,
                                      uint256 tokenId
                                  ) external;
                                  /**
                                   * @dev Transfers `tokenId` token from `from` to `to`.
                                   *
                                   * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
                                   *
                                   * Requirements:
                                   *
                                   * - `from` cannot be the zero address.
                                   * - `to` cannot be the zero address.
                                   * - `tokenId` token must be owned by `from`.
                                   * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
                                   *
                                   * Emits a {Transfer} event.
                                   */
                                  function transferFrom(
                                      address from,
                                      address to,
                                      uint256 tokenId
                                  ) external;
                                  /**
                                   * @dev Gives permission to `to` to transfer `tokenId` token to another account.
                                   * The approval is cleared when the token is transferred.
                                   *
                                   * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
                                   *
                                   * Requirements:
                                   *
                                   * - The caller must own the token or be an approved operator.
                                   * - `tokenId` must exist.
                                   *
                                   * Emits an {Approval} event.
                                   */
                                  function approve(address to, uint256 tokenId) external;
                                  /**
                                   * @dev Returns the account approved for `tokenId` token.
                                   *
                                   * Requirements:
                                   *
                                   * - `tokenId` must exist.
                                   */
                                  function getApproved(uint256 tokenId) external view returns (address operator);
                                  /**
                                   * @dev Approve or remove `operator` as an operator for the caller.
                                   * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
                                   *
                                   * Requirements:
                                   *
                                   * - The `operator` cannot be the caller.
                                   *
                                   * Emits an {ApprovalForAll} event.
                                   */
                                  function setApprovalForAll(address operator, bool _approved) external;
                                  /**
                                   * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
                                   *
                                   * See {setApprovalForAll}
                                   */
                                  function isApprovedForAll(address owner, address operator) external view returns (bool);
                                  /**
                                   * @dev Safely transfers `tokenId` token from `from` to `to`.
                                   *
                                   * Requirements:
                                   *
                                   * - `from` cannot be the zero address.
                                   * - `to` cannot be the zero address.
                                   * - `tokenId` token must exist and be owned by `from`.
                                   * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
                                   * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
                                   *
                                   * Emits a {Transfer} event.
                                   */
                                  function safeTransferFrom(
                                      address from,
                                      address to,
                                      uint256 tokenId,
                                      bytes calldata data
                                  ) external;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @title ERC721 token receiver interface
                               * @dev Interface for any contract that wants to support safeTransfers
                               * from ERC721 asset contracts.
                               */
                              interface IERC721ReceiverUpgradeable {
                                  /**
                                   * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
                                   * by `operator` from `from`, this function is called.
                                   *
                                   * It must return its Solidity selector to confirm the token transfer.
                                   * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
                                   *
                                   * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
                                   */
                                  function onERC721Received(
                                      address operator,
                                      address from,
                                      uint256 tokenId,
                                      bytes calldata data
                                  ) external returns (bytes4);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../IERC721Upgradeable.sol";
                              /**
                               * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
                               * @dev See https://eips.ethereum.org/EIPS/eip-721
                               */
                              interface IERC721MetadataUpgradeable is IERC721Upgradeable {
                                  /**
                                   * @dev Returns the token collection name.
                                   */
                                  function name() external view returns (string memory);
                                  /**
                                   * @dev Returns the token collection symbol.
                                   */
                                  function symbol() external view returns (string memory);
                                  /**
                                   * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
                                   */
                                  function tokenURI(uint256 tokenId) external view returns (string memory);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev Collection of functions related to the address type
                               */
                              library AddressUpgradeable {
                                  /**
                                   * @dev Returns true if `account` is a contract.
                                   *
                                   * [IMPORTANT]
                                   * ====
                                   * It is unsafe to assume that an address for which this function returns
                                   * false is an externally-owned account (EOA) and not a contract.
                                   *
                                   * Among others, `isContract` will return false for the following
                                   * types of addresses:
                                   *
                                   *  - an externally-owned account
                                   *  - a contract in construction
                                   *  - an address where a contract will be created
                                   *  - an address where a contract lived, but was destroyed
                                   * ====
                                   */
                                  function isContract(address account) internal view returns (bool) {
                                      // This method relies on extcodesize, which returns 0 for contracts in
                                      // construction, since the code is only stored at the end of the
                                      // constructor execution.
                                      uint256 size;
                                      assembly {
                                          size := extcodesize(account)
                                      }
                                      return size > 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 functionCall(target, data, "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");
                                      require(isContract(target), "Address: call to non-contract");
                                      (bool success, bytes memory returndata) = target.call{value: value}(data);
                                      return verifyCallResult(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) {
                                      require(isContract(target), "Address: static call to non-contract");
                                      (bool success, bytes memory returndata) = target.staticcall(data);
                                      return verifyCallResult(success, returndata, errorMessage);
                                  }
                                  /**
                                   * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
                                   * revert reason 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 {
                                          // 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
                                              assembly {
                                                  let returndata_size := mload(returndata)
                                                  revert(add(32, returndata), returndata_size)
                                              }
                                          } else {
                                              revert(errorMessage);
                                          }
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev String operations.
                               */
                              library StringsUpgradeable {
                                  bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
                                  /**
                                   * @dev Converts a `uint256` to its ASCII `string` decimal representation.
                                   */
                                  function toString(uint256 value) internal pure returns (string memory) {
                                      // Inspired by OraclizeAPI's implementation - MIT licence
                                      // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
                                      if (value == 0) {
                                          return "0";
                                      }
                                      uint256 temp = value;
                                      uint256 digits;
                                      while (temp != 0) {
                                          digits++;
                                          temp /= 10;
                                      }
                                      bytes memory buffer = new bytes(digits);
                                      while (value != 0) {
                                          digits -= 1;
                                          buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
                                          value /= 10;
                                      }
                                      return string(buffer);
                                  }
                                  /**
                                   * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
                                   */
                                  function toHexString(uint256 value) internal pure returns (string memory) {
                                      if (value == 0) {
                                          return "0x00";
                                      }
                                      uint256 temp = value;
                                      uint256 length = 0;
                                      while (temp != 0) {
                                          length++;
                                          temp >>= 8;
                                      }
                                      return toHexString(value, length);
                                  }
                                  /**
                                   * @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] = _HEX_SYMBOLS[value & 0xf];
                                          value >>= 4;
                                      }
                                      require(value == 0, "Strings: hex length insufficient");
                                      return string(buffer);
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "./IERC165Upgradeable.sol";
                              import "../../proxy/utils/Initializable.sol";
                              /**
                               * @dev Implementation of the {IERC165} interface.
                               *
                               * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
                               * for the additional interface id that will be supported. For example:
                               *
                               * ```solidity
                               * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
                               *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
                               * }
                               * ```
                               *
                               * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
                               */
                              abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
                                  function __ERC165_init() internal initializer {
                                      __ERC165_init_unchained();
                                  }
                                  function __ERC165_init_unchained() internal initializer {
                                  }
                                  /**
                                   * @dev See {IERC165-supportsInterface}.
                                   */
                                  function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
                                      return interfaceId == type(IERC165Upgradeable).interfaceId;
                                  }
                                  uint256[50] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev Interface of the ERC165 standard, as defined in the
                               * https://eips.ethereum.org/EIPS/eip-165[EIP].
                               *
                               * Implementers can declare support of contract interfaces, which can then be
                               * queried by others ({ERC165Checker}).
                               *
                               * For an implementation, see {ERC165}.
                               */
                              interface IERC165Upgradeable {
                                  /**
                                   * @dev Returns true if this contract implements the interface defined by
                                   * `interfaceId`. See the corresponding
                                   * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
                                   * to learn more about how these ids are created.
                                   *
                                   * This function call must use less than 30 000 gas.
                                   */
                                  function supportsInterface(bytes4 interfaceId) external view returns (bool);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/ContextUpgradeable.sol";
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module which allows children to implement an emergency stop
                               * mechanism that can be triggered by an authorized account.
                               *
                               * This module is used through inheritance. It will make available the
                               * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
                               * the functions of your contract. Note that they will not be pausable by
                               * simply including this module, only once the modifiers are put in place.
                               */
                              abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
                                  /**
                                   * @dev Emitted when the pause is triggered by `account`.
                                   */
                                  event Paused(address account);
                                  /**
                                   * @dev Emitted when the pause is lifted by `account`.
                                   */
                                  event Unpaused(address account);
                                  bool private _paused;
                                  /**
                                   * @dev Initializes the contract in unpaused state.
                                   */
                                  function __Pausable_init() internal initializer {
                                      __Context_init_unchained();
                                      __Pausable_init_unchained();
                                  }
                                  function __Pausable_init_unchained() internal initializer {
                                      _paused = false;
                                  }
                                  /**
                                   * @dev Returns true if the contract is paused, and false otherwise.
                                   */
                                  function paused() public view virtual returns (bool) {
                                      return _paused;
                                  }
                                  /**
                                   * @dev Modifier to make a function callable only when the contract is not paused.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must not be paused.
                                   */
                                  modifier whenNotPaused() {
                                      require(!paused(), "Pausable: paused");
                                      _;
                                  }
                                  /**
                                   * @dev Modifier to make a function callable only when the contract is paused.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must be paused.
                                   */
                                  modifier whenPaused() {
                                      require(paused(), "Pausable: not paused");
                                      _;
                                  }
                                  /**
                                   * @dev Triggers stopped state.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must not be paused.
                                   */
                                  function _pause() internal virtual whenNotPaused {
                                      _paused = true;
                                      emit Paused(_msgSender());
                                  }
                                  /**
                                   * @dev Returns to normal state.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must be paused.
                                   */
                                  function _unpause() internal virtual whenPaused {
                                      _paused = false;
                                      emit Unpaused(_msgSender());
                                  }
                                  uint256[49] private __gap;
                              }
                              

                              File 6 of 12: TransparentUpgradeableProxy
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
                              import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
                              import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
                              // Kept for backwards compatibility with older versions of Hardhat and Truffle plugins.
                              contract AdminUpgradeabilityProxy is TransparentUpgradeableProxy {
                                  constructor(address logic, address admin, bytes memory data) payable TransparentUpgradeableProxy(logic, admin, data) {}
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../Proxy.sol";
                              import "./ERC1967Upgrade.sol";
                              /**
                               * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
                               * implementation address that can be changed. This address is stored in storage in the location specified by
                               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
                               * implementation behind the proxy.
                               */
                              contract ERC1967Proxy is Proxy, ERC1967Upgrade {
                                  /**
                                   * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
                                   *
                                   * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
                                   * function call, and allows initializating the storage of the proxy like a Solidity constructor.
                                   */
                                  constructor(address _logic, bytes memory _data) payable {
                                      assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
                                      _upgradeToAndCall(_logic, _data, false);
                                  }
                                  /**
                                   * @dev Returns the current implementation address.
                                   */
                                  function _implementation() internal view virtual override returns (address impl) {
                                      return ERC1967Upgrade._getImplementation();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../ERC1967/ERC1967Proxy.sol";
                              /**
                               * @dev This contract implements a proxy that is upgradeable by an admin.
                               *
                               * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
                               * clashing], which can potentially be used in an attack, this contract uses the
                               * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
                               * things that go hand in hand:
                               *
                               * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
                               * that call matches one of the admin functions exposed by the proxy itself.
                               * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
                               * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
                               * "admin cannot fallback to proxy target".
                               *
                               * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
                               * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
                               * to sudden errors when trying to call a function from the proxy implementation.
                               *
                               * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
                               * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
                               */
                              contract TransparentUpgradeableProxy is ERC1967Proxy {
                                  /**
                                   * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
                                   * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
                                   */
                                  constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
                                      assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
                                      _changeAdmin(admin_);
                                  }
                                  /**
                                   * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
                                   */
                                  modifier ifAdmin() {
                                      if (msg.sender == _getAdmin()) {
                                          _;
                                      } else {
                                          _fallback();
                                      }
                                  }
                                  /**
                                   * @dev Returns the current admin.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
                                   *
                                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                                   * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
                                   */
                                  function admin() external ifAdmin returns (address admin_) {
                                      admin_ = _getAdmin();
                                  }
                                  /**
                                   * @dev Returns the current implementation.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
                                   *
                                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                                   * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
                                   */
                                  function implementation() external ifAdmin returns (address implementation_) {
                                      implementation_ = _implementation();
                                  }
                                  /**
                                   * @dev Changes the admin of the proxy.
                                   *
                                   * Emits an {AdminChanged} event.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
                                   */
                                  function changeAdmin(address newAdmin) external virtual ifAdmin {
                                      _changeAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev Upgrade the implementation of the proxy.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
                                   */
                                  function upgradeTo(address newImplementation) external ifAdmin {
                                      _upgradeToAndCall(newImplementation, bytes(""), false);
                                  }
                                  /**
                                   * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
                                   * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
                                   * proxied contract.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
                                   */
                                  function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
                                      _upgradeToAndCall(newImplementation, data, true);
                                  }
                                  /**
                                   * @dev Returns the current admin.
                                   */
                                  function _admin() internal view virtual returns (address) {
                                      return _getAdmin();
                                  }
                                  /**
                                   * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
                                   */
                                  function _beforeFallback() internal virtual override {
                                      require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
                                      super._beforeFallback();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "./TransparentUpgradeableProxy.sol";
                              import "../../access/Ownable.sol";
                              /**
                               * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
                               * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
                               */
                              contract ProxyAdmin is Ownable {
                                  /**
                                   * @dev Returns the current implementation of `proxy`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
                                      // We need to manually run the static call since the getter cannot be flagged as view
                                      // bytes4(keccak256("implementation()")) == 0x5c60da1b
                                      (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
                                      require(success);
                                      return abi.decode(returndata, (address));
                                  }
                                  /**
                                   * @dev Returns the current admin of `proxy`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
                                      // We need to manually run the static call since the getter cannot be flagged as view
                                      // bytes4(keccak256("admin()")) == 0xf851a440
                                      (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
                                      require(success);
                                      return abi.decode(returndata, (address));
                                  }
                                  /**
                                   * @dev Changes the admin of `proxy` to `newAdmin`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the current admin of `proxy`.
                                   */
                                  function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {
                                      proxy.changeAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {
                                      proxy.upgradeTo(implementation);
                                  }
                                  /**
                                   * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See
                                   * {TransparentUpgradeableProxy-upgradeToAndCall}.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable virtual onlyOwner {
                                      proxy.upgradeToAndCall{value: msg.value}(implementation, data);
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
                               * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
                               * be specified by overriding the virtual {_implementation} function.
                               *
                               * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
                               * different contract through the {_delegate} function.
                               *
                               * The success and return data of the delegated call will be returned back to the caller of the proxy.
                               */
                              abstract contract Proxy {
                                  /**
                                   * @dev Delegates the current call to `implementation`.
                                   *
                                   * This function does not return to its internall call site, it will return directly to the external caller.
                                   */
                                  function _delegate(address implementation) internal virtual {
                                      // solhint-disable-next-line no-inline-assembly
                                      assembly {
                                          // Copy msg.data. We take full control of memory in this inline assembly
                                          // block because it will not return to Solidity code. We overwrite the
                                          // Solidity scratch pad at memory position 0.
                                          calldatacopy(0, 0, calldatasize())
                                          // Call the implementation.
                                          // out and outsize are 0 because we don't know the size yet.
                                          let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
                                          // Copy the returned data.
                                          returndatacopy(0, 0, returndatasize())
                                          switch result
                                          // delegatecall returns 0 on error.
                                          case 0 { revert(0, returndatasize()) }
                                          default { return(0, returndatasize()) }
                                      }
                                  }
                                  /**
                                   * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
                                   * and {_fallback} should delegate.
                                   */
                                  function _implementation() internal view virtual returns (address);
                                  /**
                                   * @dev Delegates the current call to the address returned by `_implementation()`.
                                   *
                                   * This function does not return to its internall call site, it will return directly to the external caller.
                                   */
                                  function _fallback() internal virtual {
                                      _beforeFallback();
                                      _delegate(_implementation());
                                  }
                                  /**
                                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
                                   * function in the contract matches the call data.
                                   */
                                  fallback () external payable virtual {
                                      _fallback();
                                  }
                                  /**
                                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
                                   * is empty.
                                   */
                                  receive () external payable virtual {
                                      _fallback();
                                  }
                                  /**
                                   * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
                                   * call, or as part of the Solidity `fallback` or `receive` functions.
                                   *
                                   * If overriden should call `super._beforeFallback()`.
                                   */
                                  function _beforeFallback() internal virtual {
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.2;
                              import "../beacon/IBeacon.sol";
                              import "../../utils/Address.sol";
                              import "../../utils/StorageSlot.sol";
                              /**
                               * @dev This abstract contract provides getters and event emitting update functions for
                               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
                               *
                               * _Available since v4.1._
                               *
                               * @custom:oz-upgrades-unsafe-allow delegatecall
                               */
                              abstract contract ERC1967Upgrade {
                                  // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
                                  bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
                                  /**
                                   * @dev Storage slot with the address of the current implementation.
                                   * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
                                   * validated in the constructor.
                                   */
                                  bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                                  /**
                                   * @dev Emitted when the implementation is upgraded.
                                   */
                                  event Upgraded(address indexed implementation);
                                  /**
                                   * @dev Returns the current implementation address.
                                   */
                                  function _getImplementation() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new address in the EIP1967 implementation slot.
                                   */
                                  function _setImplementation(address newImplementation) private {
                                      require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                                      StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                                  }
                                  /**
                                   * @dev Perform implementation upgrade
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeTo(address newImplementation) internal {
                                      _setImplementation(newImplementation);
                                      emit Upgraded(newImplementation);
                                  }
                                  /**
                                   * @dev Perform implementation upgrade with additional setup call.
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
                                      _setImplementation(newImplementation);
                                      emit Upgraded(newImplementation);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(newImplementation, data);
                                      }
                                  }
                                  /**
                                   * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeToAndCallSecure(address newImplementation, bytes memory data, bool forceCall) internal {
                                      address oldImplementation = _getImplementation();
                                      // Initial upgrade and setup call
                                      _setImplementation(newImplementation);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(newImplementation, data);
                                      }
                                      // Perform rollback test if not already in progress
                                      StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT);
                                      if (!rollbackTesting.value) {
                                          // Trigger rollback using upgradeTo from the new implementation
                                          rollbackTesting.value = true;
                                          Address.functionDelegateCall(
                                              newImplementation,
                                              abi.encodeWithSignature(
                                                  "upgradeTo(address)",
                                                  oldImplementation
                                              )
                                          );
                                          rollbackTesting.value = false;
                                          // Check rollback was effective
                                          require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
                                          // Finally reset to the new implementation and log the upgrade
                                          _setImplementation(newImplementation);
                                          emit Upgraded(newImplementation);
                                      }
                                  }
                                  /**
                                   * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
                                   * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
                                   *
                                   * Emits a {BeaconUpgraded} event.
                                   */
                                  function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
                                      _setBeacon(newBeacon);
                                      emit BeaconUpgraded(newBeacon);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
                                      }
                                  }
                                  /**
                                   * @dev Storage slot with the admin of the contract.
                                   * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
                                   * validated in the constructor.
                                   */
                                  bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                                  /**
                                   * @dev Emitted when the admin account has changed.
                                   */
                                  event AdminChanged(address previousAdmin, address newAdmin);
                                  /**
                                   * @dev Returns the current admin.
                                   */
                                  function _getAdmin() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new address in the EIP1967 admin slot.
                                   */
                                  function _setAdmin(address newAdmin) private {
                                      require(newAdmin != address(0), "ERC1967: new admin is the zero address");
                                      StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
                                  }
                                  /**
                                   * @dev Changes the admin of the proxy.
                                   *
                                   * Emits an {AdminChanged} event.
                                   */
                                  function _changeAdmin(address newAdmin) internal {
                                      emit AdminChanged(_getAdmin(), newAdmin);
                                      _setAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
                                   * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
                                   */
                                  bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
                                  /**
                                   * @dev Emitted when the beacon is upgraded.
                                   */
                                  event BeaconUpgraded(address indexed beacon);
                                  /**
                                   * @dev Returns the current beacon.
                                   */
                                  function _getBeacon() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new beacon in the EIP1967 beacon slot.
                                   */
                                  function _setBeacon(address newBeacon) private {
                                      require(
                                          Address.isContract(newBeacon),
                                          "ERC1967: new beacon is not a contract"
                                      );
                                      require(
                                          Address.isContract(IBeacon(newBeacon).implementation()),
                                          "ERC1967: beacon implementation is not a contract"
                                      );
                                      StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This is the interface that {BeaconProxy} expects of its beacon.
                               */
                              interface IBeacon {
                                  /**
                                   * @dev Must return an address that can be used as a delegate call target.
                                   *
                                   * {BeaconProxy} will check that this address is a contract.
                                   */
                                  function implementation() external view returns (address);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @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
                                   * ====
                                   */
                                  function isContract(address account) internal view returns (bool) {
                                      // This method relies on extcodesize, which returns 0 for contracts in
                                      // construction, since the code is only stored at the end of the
                                      // constructor execution.
                                      uint256 size;
                                      // solhint-disable-next-line no-inline-assembly
                                      assembly { size := extcodesize(account) }
                                      return size > 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");
                                      // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
                                      (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 functionCall(target, data, "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");
                                      require(isContract(target), "Address: call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.call{ value: value }(data);
                                      return _verifyCallResult(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) {
                                      require(isContract(target), "Address: static call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.staticcall(data);
                                      return _verifyCallResult(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) {
                                      require(isContract(target), "Address: delegate call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.delegatecall(data);
                                      return _verifyCallResult(success, returndata, errorMessage);
                                  }
                                  function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
                                      if (success) {
                                          return returndata;
                                      } else {
                                          // 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
                                              // solhint-disable-next-line no-inline-assembly
                                              assembly {
                                                  let returndata_size := mload(returndata)
                                                  revert(add(32, returndata), returndata_size)
                                              }
                                          } else {
                                              revert(errorMessage);
                                          }
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev Library for reading and writing primitive types to specific storage slots.
                               *
                               * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
                               * This library helps with reading and writing to such slots without the need for inline assembly.
                               *
                               * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
                               *
                               * Example usage to set ERC1967 implementation slot:
                               * ```
                               * contract ERC1967 {
                               *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                               *
                               *     function _getImplementation() internal view returns (address) {
                               *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                               *     }
                               *
                               *     function _setImplementation(address newImplementation) internal {
                               *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                               *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                               *     }
                               * }
                               * ```
                               *
                               * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
                               */
                              library StorageSlot {
                                  struct AddressSlot {
                                      address value;
                                  }
                                  struct BooleanSlot {
                                      bool value;
                                  }
                                  struct Bytes32Slot {
                                      bytes32 value;
                                  }
                                  struct Uint256Slot {
                                      uint256 value;
                                  }
                                  /**
                                   * @dev Returns an `AddressSlot` with member `value` located at `slot`.
                                   */
                                  function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
                                   */
                                  function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
                                   */
                                  function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
                                   */
                                  function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/Context.sol";
                              /**
                               * @dev Contract module which provides a basic access control mechanism, where
                               * there is an account (an owner) that can be granted exclusive access to
                               * specific functions.
                               *
                               * By default, the owner account will be the one that deploys the contract. This
                               * can later be changed with {transferOwnership}.
                               *
                               * This module is used through inheritance. It will make available the modifier
                               * `onlyOwner`, which can be applied to your functions to restrict their use to
                               * the owner.
                               */
                              abstract contract Ownable is Context {
                                  address private _owner;
                                  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                                  /**
                                   * @dev Initializes the contract setting the deployer as the initial owner.
                                   */
                                  constructor () {
                                      address msgSender = _msgSender();
                                      _owner = msgSender;
                                      emit OwnershipTransferred(address(0), msgSender);
                                  }
                                  /**
                                   * @dev Returns the address of the current owner.
                                   */
                                  function owner() public view virtual returns (address) {
                                      return _owner;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the owner.
                                   */
                                  modifier onlyOwner() {
                                      require(owner() == _msgSender(), "Ownable: caller is not the owner");
                                      _;
                                  }
                                  /**
                                   * @dev Leaves the contract without owner. It will not be possible to call
                                   * `onlyOwner` functions anymore. Can only be called by the current owner.
                                   *
                                   * NOTE: Renouncing ownership will leave the contract without an owner,
                                   * thereby removing any functionality that is only available to the owner.
                                   */
                                  function renounceOwnership() public virtual onlyOwner {
                                      emit OwnershipTransferred(_owner, address(0));
                                      _owner = address(0);
                                  }
                                  /**
                                   * @dev Transfers ownership of the contract to a new account (`newOwner`).
                                   * Can only be called by the current owner.
                                   */
                                  function transferOwnership(address newOwner) public virtual onlyOwner {
                                      require(newOwner != address(0), "Ownable: new owner is the zero address");
                                      emit OwnershipTransferred(_owner, newOwner);
                                      _owner = newOwner;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              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) {
                                      this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
                                      return msg.data;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../ERC1967/ERC1967Upgrade.sol";
                              /**
                               * @dev Base contract for building openzeppelin-upgrades compatible implementations for the {ERC1967Proxy}. It includes
                               * publicly available upgrade functions that are called by the plugin and by the secure upgrade mechanism to verify
                               * continuation of the upgradability.
                               *
                               * The {_authorizeUpgrade} function MUST be overridden to include access restriction to the upgrade mechanism.
                               *
                               * _Available since v4.1._
                               */
                              abstract contract UUPSUpgradeable is ERC1967Upgrade {
                                  function upgradeTo(address newImplementation) external virtual {
                                      _authorizeUpgrade(newImplementation);
                                      _upgradeToAndCallSecure(newImplementation, bytes(""), false);
                                  }
                                  function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual {
                                      _authorizeUpgrade(newImplementation);
                                      _upgradeToAndCallSecure(newImplementation, data, true);
                                  }
                                  function _authorizeUpgrade(address newImplementation) internal virtual;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.2;
                              import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
                              abstract contract Proxiable is UUPSUpgradeable {
                                  function _authorizeUpgrade(address newImplementation) internal override {
                                      _beforeUpgrade(newImplementation);
                                  }
                                  function _beforeUpgrade(address newImplementation) internal virtual;
                              }
                              contract ChildOfProxiable is Proxiable {
                                  function _beforeUpgrade(address newImplementation) internal virtual override {}
                              }
                              

                              File 7 of 12: TokenManager
                              // $$$$$$$$\\        $$\\                                 $$\\      $$\\
                              // \\__$$  __|       $$ |                                $$$\\    $$$ |
                              //    $$ | $$$$$$\\  $$ |  $$\\  $$$$$$\\  $$$$$$$\\        $$$$\\  $$$$ | $$$$$$\\  $$$$$$$\\   $$$$$$\\   $$$$$$\\   $$$$$$\\   $$$$$$\\
                              //    $$ |$$  __$$\\ $$ | $$  |$$  __$$\\ $$  __$$\\       $$\\$$\\$$ $$ | \\____$$\\ $$  __$$\\  \\____$$\\ $$  __$$\\ $$  __$$\\ $$  __$$\\
                              //    $$ |$$ /  $$ |$$$$$$  / $$$$$$$$ |$$ |  $$ |      $$ \\$$$  $$ | $$$$$$$ |$$ |  $$ | $$$$$$$ |$$ /  $$ |$$$$$$$$ |$$ |  \\__|
                              //    $$ |$$ |  $$ |$$  _$$<  $$   ____|$$ |  $$ |      $$ |\\$  /$$ |$$  __$$ |$$ |  $$ |$$  __$$ |$$ |  $$ |$$   ____|$$ |
                              //    $$ |\\$$$$$$  |$$ | \\$$\\ \\$$$$$$$\\ $$ |  $$ |      $$ | \\_/ $$ |\\$$$$$$$ |$$ |  $$ |\\$$$$$$$ |\\$$$$$$$ |\\$$$$$$$\\ $$ |
                              //    \\__| \\______/ \\__|  \\__| \\_______|\\__|  \\__|      \\__|     \\__| \\_______|\\__|  \\__| \\_______| \\____$$ | \\_______|\\__|
                              //                                                                                                 $$\\   $$ |
                              //                                                                                                 \\$$$$$$  |
                              //                                                                                                  \\______/
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
                              import "../../security/Pausable.sol";
                              import "../metatx/ERC2771ContextUpgradeable.sol";
                              import "../interfaces/ITokenManager.sol";
                              contract TokenManager is ITokenManager, ERC2771ContextUpgradeable, OwnableUpgradeable, Pausable {
                                  mapping(address => TokenInfo) public override tokensInfo;
                                  // Excess State Transfer Fee Percentage
                                  mapping(address => uint256) public override excessStateTransferFeePerc;
                                  event FeeChanged(address indexed tokenAddress, uint256 indexed equilibriumFee, uint256 indexed maxFee);
                                  event ExcessStateTransferFeePercChanged(address indexed tokenAddress, uint256 indexed fee);
                                  modifier tokenChecks(address tokenAddress) {
                                      require(tokenAddress != address(0), "Token address cannot be 0");
                                      require(tokensInfo[tokenAddress].supportedToken, "Token not supported");
                                      _;
                                  }
                                  /**
                                   * First key is toChainId and second key is token address being deposited on current chain
                                   */
                                  mapping(uint256 => mapping(address => TokenConfig)) public depositConfig;
                                  /**
                                   * Store min/max amount of token to transfer based on token address
                                   */
                                  mapping(address => TokenConfig) public transferConfig;
                                  function initialize(address trustedForwarder, address pauser) external initializer {
                                      __ERC2771Context_init(trustedForwarder);
                                      __Ownable_init();
                                      __Pausable_init(pauser);
                                  }
                                  function getEquilibriumFee(address tokenAddress) public view override returns (uint256) {
                                      return tokensInfo[tokenAddress].equilibriumFee;
                                  }
                                  function getMaxFee(address tokenAddress) public view override returns (uint256) {
                                      return tokensInfo[tokenAddress].maxFee;
                                  }
                                  function changeFee(
                                      address tokenAddress,
                                      uint256 _equilibriumFee,
                                      uint256 _maxFee
                                  ) external override onlyOwner whenNotPaused {
                                      require(_equilibriumFee != 0, "Equilibrium Fee cannot be 0");
                                      require(_maxFee != 0, "Max Fee cannot be 0");
                                      require(_equilibriumFee <= _maxFee && _maxFee <= 10000000000, "Max Fee cannot be greater than 100%");
                                      tokensInfo[tokenAddress].equilibriumFee = _equilibriumFee;
                                      tokensInfo[tokenAddress].maxFee = _maxFee;
                                      emit FeeChanged(tokenAddress, tokensInfo[tokenAddress].equilibriumFee, tokensInfo[tokenAddress].maxFee);
                                  }
                                  function changeExcessStateFee(address _tokenAddress, uint256 _excessStateFeePer)
                                      external
                                      override
                                      onlyOwner
                                      whenNotPaused
                                  {
                                      require(_tokenAddress != address(0), "Token address cannot be 0");
                                      require(_excessStateFeePer != 0, "Excess State Fee Percentage cannot be 0");
                                      excessStateTransferFeePerc[_tokenAddress] = _excessStateFeePer;
                                      emit ExcessStateTransferFeePercChanged(_tokenAddress, _excessStateFeePer);
                                  }
                                  function setTokenTransferOverhead(address tokenAddress, uint256 gasOverhead)
                                      external
                                      tokenChecks(tokenAddress)
                                      onlyOwner
                                  {
                                      tokensInfo[tokenAddress].transferOverhead = gasOverhead;
                                  }
                                  /**
                                   * Set DepositConfig for the given combination of toChainId, tokenAddress.
                                   * This is used while depositing token in Liquidity Pool. Based on the destination chainid
                                   * min and max deposit amount is checked.
                                   */
                                  function setDepositConfig(
                                      uint256[] memory toChainId,
                                      address[] memory tokenAddresses,
                                      TokenConfig[] memory tokenConfig
                                  ) external onlyOwner {
                                      require(
                                          (toChainId.length == tokenAddresses.length) && (tokenAddresses.length == tokenConfig.length),
                                          " ERR_ARRAY_LENGTH_MISMATCH"
                                      );
                                      uint256 length = tokenConfig.length;
                                      for (uint256 index; index < length; ) {
                                          depositConfig[toChainId[index]][tokenAddresses[index]].min = tokenConfig[index].min;
                                          depositConfig[toChainId[index]][tokenAddresses[index]].max = tokenConfig[index].max;
                                          unchecked {
                                              ++index;
                                          }
                                      }
                                  }
                                  function addSupportedToken(
                                      address tokenAddress,
                                      uint256 minCapLimit,
                                      uint256 maxCapLimit,
                                      uint256 equilibriumFee,
                                      uint256 maxFee,
                                      uint256 transferOverhead
                                  ) external onlyOwner {
                                      require(tokenAddress != address(0), "Token address cannot be 0");
                                      require(maxCapLimit > minCapLimit, "maxCapLimit > minCapLimit");
                                      tokensInfo[tokenAddress].supportedToken = true;
                                      transferConfig[tokenAddress].min = minCapLimit;
                                      transferConfig[tokenAddress].max = maxCapLimit;
                                      tokensInfo[tokenAddress].tokenConfig = transferConfig[tokenAddress];
                                      tokensInfo[tokenAddress].equilibriumFee = equilibriumFee;
                                      tokensInfo[tokenAddress].maxFee = maxFee;
                                      tokensInfo[tokenAddress].transferOverhead = transferOverhead;
                                  }
                                  function removeSupportedToken(address tokenAddress) external tokenChecks(tokenAddress) onlyOwner {
                                      tokensInfo[tokenAddress].supportedToken = false;
                                  }
                                  function updateTokenCap(
                                      address tokenAddress,
                                      uint256 minCapLimit,
                                      uint256 maxCapLimit
                                  ) external tokenChecks(tokenAddress) onlyOwner {
                                      require(maxCapLimit > minCapLimit, "maxCapLimit > minCapLimit");
                                      transferConfig[tokenAddress].min = minCapLimit;
                                      transferConfig[tokenAddress].max = maxCapLimit;
                                  }
                                  function getTokensInfo(address tokenAddress) public view override returns (TokenInfo memory) {
                                      TokenInfo memory tokenInfo = TokenInfo(
                                          tokensInfo[tokenAddress].transferOverhead,
                                          tokensInfo[tokenAddress].supportedToken,
                                          tokensInfo[tokenAddress].equilibriumFee,
                                          tokensInfo[tokenAddress].maxFee,
                                          transferConfig[tokenAddress]
                                      );
                                      return tokenInfo;
                                  }
                                  function getDepositConfig(uint256 toChainId, address tokenAddress)
                                      public
                                      view
                                      override
                                      returns (TokenConfig memory)
                                  {
                                      return depositConfig[toChainId][tokenAddress];
                                  }
                                  function getTransferConfig(address tokenAddress) public view override returns (TokenConfig memory) {
                                      return transferConfig[tokenAddress];
                                  }
                                  function _msgSender()
                                      internal
                                      view
                                      virtual
                                      override(ContextUpgradeable, ERC2771ContextUpgradeable)
                                      returns (address sender)
                                  {
                                      return ERC2771ContextUpgradeable._msgSender();
                                  }
                                  function _msgData()
                                      internal
                                      view
                                      virtual
                                      override(ContextUpgradeable, ERC2771ContextUpgradeable)
                                      returns (bytes calldata)
                                  {
                                      return ERC2771ContextUpgradeable._msgData();
                                  }
                                  function setTrustedForwarder(address _tf) external onlyOwner {
                                      _setTrustedForwarder(_tf);
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/ContextUpgradeable.sol";
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module which provides a basic access control mechanism, where
                               * there is an account (an owner) that can be granted exclusive access to
                               * specific functions.
                               *
                               * By default, the owner account will be the one that deploys the contract. This
                               * can later be changed with {transferOwnership}.
                               *
                               * This module is used through inheritance. It will make available the modifier
                               * `onlyOwner`, which can be applied to your functions to restrict their use to
                               * the owner.
                               */
                              abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
                                  address private _owner;
                                  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                                  /**
                                   * @dev Initializes the contract setting the deployer as the initial owner.
                                   */
                                  function __Ownable_init() internal initializer {
                                      __Context_init_unchained();
                                      __Ownable_init_unchained();
                                  }
                                  function __Ownable_init_unchained() internal initializer {
                                      _setOwner(_msgSender());
                                  }
                                  /**
                                   * @dev Returns the address of the current owner.
                                   */
                                  function owner() public view virtual returns (address) {
                                      return _owner;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the owner.
                                   */
                                  modifier onlyOwner() {
                                      require(owner() == _msgSender(), "Ownable: caller is not the owner");
                                      _;
                                  }
                                  /**
                                   * @dev Leaves the contract without owner. It will not be possible to call
                                   * `onlyOwner` functions anymore. Can only be called by the current owner.
                                   *
                                   * NOTE: Renouncing ownership will leave the contract without an owner,
                                   * thereby removing any functionality that is only available to the owner.
                                   */
                                  function renounceOwnership() public virtual onlyOwner {
                                      _setOwner(address(0));
                                  }
                                  /**
                                   * @dev Transfers ownership of the contract to a new account (`newOwner`).
                                   * Can only be called by the current owner.
                                   */
                                  function transferOwnership(address newOwner) public virtual onlyOwner {
                                      require(newOwner != address(0), "Ownable: new owner is the zero address");
                                      _setOwner(newOwner);
                                  }
                                  function _setOwner(address newOwner) private {
                                      address oldOwner = _owner;
                                      _owner = newOwner;
                                      emit OwnershipTransferred(oldOwner, newOwner);
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                              import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
                              /**
                               * @dev Contract module which allows children to implement an emergency stop
                               * mechanism that can be triggered by an authorized account.
                               *
                               * This module is used through inheritance. It will make available the
                               * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
                               * the functions of your contract. Note that they will not be pausable by
                               * simply including this module, only once the modifiers are put in place.
                               */
                              abstract contract Pausable is Initializable, PausableUpgradeable {
                                  address private _pauser;
                                  event PauserChanged(address indexed previousPauser, address indexed newPauser);
                                  /**
                                   * @dev The pausable constructor sets the original `pauser` of the contract to the sender
                                   * account & Initializes the contract in unpaused state..
                                   */
                                  function __Pausable_init(address pauser) internal initializer {
                                      require(pauser != address(0), "Pauser Address cannot be 0");
                                      __Pausable_init();
                                      _pauser = pauser;
                                  }
                                  /**
                                   * @return true if `msg.sender` is the owner of the contract.
                                   */
                                  function isPauser(address pauser) public view returns (bool) {
                                      return pauser == _pauser;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the pauser.
                                   */
                                  modifier onlyPauser() {
                                      require(isPauser(msg.sender), "Only pauser is allowed to perform this operation");
                                      _;
                                  }
                                  /**
                                   * @dev Allows the current pauser to transfer control of the contract to a newPauser.
                                   * @param newPauser The address to transfer pauserShip to.
                                   */
                                  function changePauser(address newPauser) public onlyPauser whenNotPaused {
                                      _changePauser(newPauser);
                                  }
                                  /**
                                   * @dev Transfers control of the contract to a newPauser.
                                   * @param newPauser The address to transfer ownership to.
                                   */
                                  function _changePauser(address newPauser) internal {
                                      require(newPauser != address(0));
                                      emit PauserChanged(_pauser, newPauser);
                                      _pauser = newPauser;
                                  }
                                  function renouncePauser() external virtual onlyPauser whenNotPaused {
                                      emit PauserChanged(_pauser, address(0));
                                      _pauser = address(0);
                                  }
                                  function pause() public onlyPauser {
                                      _pause();
                                  }
                                  function unpause() public onlyPauser {
                                      _unpause();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                              /**
                               * @dev Context variant with ERC2771 support.
                               * Here _trustedForwarder is made internal instead of private
                               * so it can be changed via Child contracts with a setter method.
                               */
                              abstract contract ERC2771ContextUpgradeable is Initializable, ContextUpgradeable {
                                  event TrustedForwarderChanged(address indexed _tf);
                                  address internal _trustedForwarder;
                                  function __ERC2771Context_init(address trustedForwarder) internal initializer {
                                      __Context_init_unchained();
                                      __ERC2771Context_init_unchained(trustedForwarder);
                                  }
                                  function __ERC2771Context_init_unchained(address trustedForwarder) internal initializer {
                                      _trustedForwarder = trustedForwarder;
                                  }
                                  function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
                                      return forwarder == _trustedForwarder;
                                  }
                                  function _msgSender() internal view virtual override returns (address sender) {
                                      if (isTrustedForwarder(msg.sender)) {
                                          // The assembly code is more direct than the Solidity version using `abi.decode`.
                                          assembly {
                                              sender := shr(96, calldataload(sub(calldatasize(), 20)))
                                          }
                                      } else {
                                          return super._msgSender();
                                      }
                                  }
                                  function _msgData() internal view virtual override returns (bytes calldata) {
                                      if (isTrustedForwarder(msg.sender)) {
                                          return msg.data[:msg.data.length - 20];
                                      } else {
                                          return super._msgData();
                                      }
                                  }
                                  function _setTrustedForwarder(address _tf) internal virtual {
                                      require(_tf != address(0), "TrustedForwarder can't be 0");
                                      _trustedForwarder = _tf;
                                      emit TrustedForwarderChanged(_tf);
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "../structures/TokenConfig.sol";
                              interface ITokenManager {
                                  function getEquilibriumFee(address tokenAddress) external view returns (uint256);
                                  function getMaxFee(address tokenAddress) external view returns (uint256);
                                  function changeFee(
                                      address tokenAddress,
                                      uint256 _equilibriumFee,
                                      uint256 _maxFee
                                  ) external;
                                  function tokensInfo(address tokenAddress)
                                      external
                                      view
                                      returns (
                                          uint256 transferOverhead,
                                          bool supportedToken,
                                          uint256 equilibriumFee,
                                          uint256 maxFee,
                                          TokenConfig memory config
                                      );
                                  function excessStateTransferFeePerc(address tokenAddress) external view returns (uint256);
                                  function getTokensInfo(address tokenAddress) external view returns (TokenInfo memory);
                                  function getDepositConfig(uint256 toChainId, address tokenAddress) external view returns (TokenConfig memory);
                                  function getTransferConfig(address tokenAddress) external view returns (TokenConfig memory);
                                  function changeExcessStateFee(address _tokenAddress, uint256 _excessStateFeePer) external;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Provides information about the current execution context, including the
                               * sender of the transaction and its data. While these are generally available
                               * via msg.sender and msg.data, they should not be accessed in such a direct
                               * manner, since when dealing with meta-transactions the account sending and
                               * paying for execution may not be the actual sender (as far as an application
                               * is concerned).
                               *
                               * This contract is only required for intermediate, library-like contracts.
                               */
                              abstract contract ContextUpgradeable is Initializable {
                                  function __Context_init() internal initializer {
                                      __Context_init_unchained();
                                  }
                                  function __Context_init_unchained() internal initializer {
                                  }
                                  function _msgSender() internal view virtual returns (address) {
                                      return msg.sender;
                                  }
                                  function _msgData() internal view virtual returns (bytes calldata) {
                                      return msg.data;
                                  }
                                  uint256[50] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
                               * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
                               * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
                               * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
                               *
                               * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
                               * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
                               *
                               * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
                               * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
                               */
                              abstract contract Initializable {
                                  /**
                                   * @dev Indicates that the contract has been initialized.
                                   */
                                  bool private _initialized;
                                  /**
                                   * @dev Indicates that the contract is in the process of being initialized.
                                   */
                                  bool private _initializing;
                                  /**
                                   * @dev Modifier to protect an initializer function from being invoked twice.
                                   */
                                  modifier initializer() {
                                      require(_initializing || !_initialized, "Initializable: contract is already initialized");
                                      bool isTopLevelCall = !_initializing;
                                      if (isTopLevelCall) {
                                          _initializing = true;
                                          _initialized = true;
                                      }
                                      _;
                                      if (isTopLevelCall) {
                                          _initializing = false;
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/ContextUpgradeable.sol";
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module which allows children to implement an emergency stop
                               * mechanism that can be triggered by an authorized account.
                               *
                               * This module is used through inheritance. It will make available the
                               * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
                               * the functions of your contract. Note that they will not be pausable by
                               * simply including this module, only once the modifiers are put in place.
                               */
                              abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
                                  /**
                                   * @dev Emitted when the pause is triggered by `account`.
                                   */
                                  event Paused(address account);
                                  /**
                                   * @dev Emitted when the pause is lifted by `account`.
                                   */
                                  event Unpaused(address account);
                                  bool private _paused;
                                  /**
                                   * @dev Initializes the contract in unpaused state.
                                   */
                                  function __Pausable_init() internal initializer {
                                      __Context_init_unchained();
                                      __Pausable_init_unchained();
                                  }
                                  function __Pausable_init_unchained() internal initializer {
                                      _paused = false;
                                  }
                                  /**
                                   * @dev Returns true if the contract is paused, and false otherwise.
                                   */
                                  function paused() public view virtual returns (bool) {
                                      return _paused;
                                  }
                                  /**
                                   * @dev Modifier to make a function callable only when the contract is not paused.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must not be paused.
                                   */
                                  modifier whenNotPaused() {
                                      require(!paused(), "Pausable: paused");
                                      _;
                                  }
                                  /**
                                   * @dev Modifier to make a function callable only when the contract is paused.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must be paused.
                                   */
                                  modifier whenPaused() {
                                      require(paused(), "Pausable: not paused");
                                      _;
                                  }
                                  /**
                                   * @dev Triggers stopped state.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must not be paused.
                                   */
                                  function _pause() internal virtual whenNotPaused {
                                      _paused = true;
                                      emit Paused(_msgSender());
                                  }
                                  /**
                                   * @dev Returns to normal state.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must be paused.
                                   */
                                  function _unpause() internal virtual whenPaused {
                                      _paused = false;
                                      emit Unpaused(_msgSender());
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              struct TokenInfo {
                                  uint256 transferOverhead;
                                  bool supportedToken;
                                  uint256 equilibriumFee; // Percentage fee Represented in basis points
                                  uint256 maxFee; // Percentage fee Represented in basis points
                                  TokenConfig tokenConfig;
                              }
                              struct TokenConfig {
                                  uint256 min;
                                  uint256 max;
                              }
                              

                              File 8 of 12: TransparentUpgradeableProxy
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
                              import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
                              import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
                              // Kept for backwards compatibility with older versions of Hardhat and Truffle plugins.
                              contract AdminUpgradeabilityProxy is TransparentUpgradeableProxy {
                                  constructor(address logic, address admin, bytes memory data) payable TransparentUpgradeableProxy(logic, admin, data) {}
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../Proxy.sol";
                              import "./ERC1967Upgrade.sol";
                              /**
                               * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
                               * implementation address that can be changed. This address is stored in storage in the location specified by
                               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
                               * implementation behind the proxy.
                               */
                              contract ERC1967Proxy is Proxy, ERC1967Upgrade {
                                  /**
                                   * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
                                   *
                                   * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
                                   * function call, and allows initializating the storage of the proxy like a Solidity constructor.
                                   */
                                  constructor(address _logic, bytes memory _data) payable {
                                      assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
                                      _upgradeToAndCall(_logic, _data, false);
                                  }
                                  /**
                                   * @dev Returns the current implementation address.
                                   */
                                  function _implementation() internal view virtual override returns (address impl) {
                                      return ERC1967Upgrade._getImplementation();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../ERC1967/ERC1967Proxy.sol";
                              /**
                               * @dev This contract implements a proxy that is upgradeable by an admin.
                               *
                               * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
                               * clashing], which can potentially be used in an attack, this contract uses the
                               * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
                               * things that go hand in hand:
                               *
                               * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
                               * that call matches one of the admin functions exposed by the proxy itself.
                               * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
                               * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
                               * "admin cannot fallback to proxy target".
                               *
                               * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
                               * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
                               * to sudden errors when trying to call a function from the proxy implementation.
                               *
                               * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
                               * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
                               */
                              contract TransparentUpgradeableProxy is ERC1967Proxy {
                                  /**
                                   * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
                                   * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
                                   */
                                  constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
                                      assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
                                      _changeAdmin(admin_);
                                  }
                                  /**
                                   * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
                                   */
                                  modifier ifAdmin() {
                                      if (msg.sender == _getAdmin()) {
                                          _;
                                      } else {
                                          _fallback();
                                      }
                                  }
                                  /**
                                   * @dev Returns the current admin.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
                                   *
                                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                                   * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
                                   */
                                  function admin() external ifAdmin returns (address admin_) {
                                      admin_ = _getAdmin();
                                  }
                                  /**
                                   * @dev Returns the current implementation.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
                                   *
                                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                                   * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
                                   */
                                  function implementation() external ifAdmin returns (address implementation_) {
                                      implementation_ = _implementation();
                                  }
                                  /**
                                   * @dev Changes the admin of the proxy.
                                   *
                                   * Emits an {AdminChanged} event.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
                                   */
                                  function changeAdmin(address newAdmin) external virtual ifAdmin {
                                      _changeAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev Upgrade the implementation of the proxy.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
                                   */
                                  function upgradeTo(address newImplementation) external ifAdmin {
                                      _upgradeToAndCall(newImplementation, bytes(""), false);
                                  }
                                  /**
                                   * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
                                   * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
                                   * proxied contract.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
                                   */
                                  function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
                                      _upgradeToAndCall(newImplementation, data, true);
                                  }
                                  /**
                                   * @dev Returns the current admin.
                                   */
                                  function _admin() internal view virtual returns (address) {
                                      return _getAdmin();
                                  }
                                  /**
                                   * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
                                   */
                                  function _beforeFallback() internal virtual override {
                                      require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
                                      super._beforeFallback();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "./TransparentUpgradeableProxy.sol";
                              import "../../access/Ownable.sol";
                              /**
                               * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
                               * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
                               */
                              contract ProxyAdmin is Ownable {
                                  /**
                                   * @dev Returns the current implementation of `proxy`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
                                      // We need to manually run the static call since the getter cannot be flagged as view
                                      // bytes4(keccak256("implementation()")) == 0x5c60da1b
                                      (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
                                      require(success);
                                      return abi.decode(returndata, (address));
                                  }
                                  /**
                                   * @dev Returns the current admin of `proxy`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
                                      // We need to manually run the static call since the getter cannot be flagged as view
                                      // bytes4(keccak256("admin()")) == 0xf851a440
                                      (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
                                      require(success);
                                      return abi.decode(returndata, (address));
                                  }
                                  /**
                                   * @dev Changes the admin of `proxy` to `newAdmin`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the current admin of `proxy`.
                                   */
                                  function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {
                                      proxy.changeAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {
                                      proxy.upgradeTo(implementation);
                                  }
                                  /**
                                   * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See
                                   * {TransparentUpgradeableProxy-upgradeToAndCall}.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable virtual onlyOwner {
                                      proxy.upgradeToAndCall{value: msg.value}(implementation, data);
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
                               * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
                               * be specified by overriding the virtual {_implementation} function.
                               *
                               * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
                               * different contract through the {_delegate} function.
                               *
                               * The success and return data of the delegated call will be returned back to the caller of the proxy.
                               */
                              abstract contract Proxy {
                                  /**
                                   * @dev Delegates the current call to `implementation`.
                                   *
                                   * This function does not return to its internall call site, it will return directly to the external caller.
                                   */
                                  function _delegate(address implementation) internal virtual {
                                      // solhint-disable-next-line no-inline-assembly
                                      assembly {
                                          // Copy msg.data. We take full control of memory in this inline assembly
                                          // block because it will not return to Solidity code. We overwrite the
                                          // Solidity scratch pad at memory position 0.
                                          calldatacopy(0, 0, calldatasize())
                                          // Call the implementation.
                                          // out and outsize are 0 because we don't know the size yet.
                                          let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
                                          // Copy the returned data.
                                          returndatacopy(0, 0, returndatasize())
                                          switch result
                                          // delegatecall returns 0 on error.
                                          case 0 { revert(0, returndatasize()) }
                                          default { return(0, returndatasize()) }
                                      }
                                  }
                                  /**
                                   * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
                                   * and {_fallback} should delegate.
                                   */
                                  function _implementation() internal view virtual returns (address);
                                  /**
                                   * @dev Delegates the current call to the address returned by `_implementation()`.
                                   *
                                   * This function does not return to its internall call site, it will return directly to the external caller.
                                   */
                                  function _fallback() internal virtual {
                                      _beforeFallback();
                                      _delegate(_implementation());
                                  }
                                  /**
                                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
                                   * function in the contract matches the call data.
                                   */
                                  fallback () external payable virtual {
                                      _fallback();
                                  }
                                  /**
                                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
                                   * is empty.
                                   */
                                  receive () external payable virtual {
                                      _fallback();
                                  }
                                  /**
                                   * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
                                   * call, or as part of the Solidity `fallback` or `receive` functions.
                                   *
                                   * If overriden should call `super._beforeFallback()`.
                                   */
                                  function _beforeFallback() internal virtual {
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.2;
                              import "../beacon/IBeacon.sol";
                              import "../../utils/Address.sol";
                              import "../../utils/StorageSlot.sol";
                              /**
                               * @dev This abstract contract provides getters and event emitting update functions for
                               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
                               *
                               * _Available since v4.1._
                               *
                               * @custom:oz-upgrades-unsafe-allow delegatecall
                               */
                              abstract contract ERC1967Upgrade {
                                  // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
                                  bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
                                  /**
                                   * @dev Storage slot with the address of the current implementation.
                                   * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
                                   * validated in the constructor.
                                   */
                                  bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                                  /**
                                   * @dev Emitted when the implementation is upgraded.
                                   */
                                  event Upgraded(address indexed implementation);
                                  /**
                                   * @dev Returns the current implementation address.
                                   */
                                  function _getImplementation() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new address in the EIP1967 implementation slot.
                                   */
                                  function _setImplementation(address newImplementation) private {
                                      require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                                      StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                                  }
                                  /**
                                   * @dev Perform implementation upgrade
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeTo(address newImplementation) internal {
                                      _setImplementation(newImplementation);
                                      emit Upgraded(newImplementation);
                                  }
                                  /**
                                   * @dev Perform implementation upgrade with additional setup call.
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
                                      _setImplementation(newImplementation);
                                      emit Upgraded(newImplementation);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(newImplementation, data);
                                      }
                                  }
                                  /**
                                   * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeToAndCallSecure(address newImplementation, bytes memory data, bool forceCall) internal {
                                      address oldImplementation = _getImplementation();
                                      // Initial upgrade and setup call
                                      _setImplementation(newImplementation);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(newImplementation, data);
                                      }
                                      // Perform rollback test if not already in progress
                                      StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT);
                                      if (!rollbackTesting.value) {
                                          // Trigger rollback using upgradeTo from the new implementation
                                          rollbackTesting.value = true;
                                          Address.functionDelegateCall(
                                              newImplementation,
                                              abi.encodeWithSignature(
                                                  "upgradeTo(address)",
                                                  oldImplementation
                                              )
                                          );
                                          rollbackTesting.value = false;
                                          // Check rollback was effective
                                          require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
                                          // Finally reset to the new implementation and log the upgrade
                                          _setImplementation(newImplementation);
                                          emit Upgraded(newImplementation);
                                      }
                                  }
                                  /**
                                   * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
                                   * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
                                   *
                                   * Emits a {BeaconUpgraded} event.
                                   */
                                  function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
                                      _setBeacon(newBeacon);
                                      emit BeaconUpgraded(newBeacon);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
                                      }
                                  }
                                  /**
                                   * @dev Storage slot with the admin of the contract.
                                   * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
                                   * validated in the constructor.
                                   */
                                  bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                                  /**
                                   * @dev Emitted when the admin account has changed.
                                   */
                                  event AdminChanged(address previousAdmin, address newAdmin);
                                  /**
                                   * @dev Returns the current admin.
                                   */
                                  function _getAdmin() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new address in the EIP1967 admin slot.
                                   */
                                  function _setAdmin(address newAdmin) private {
                                      require(newAdmin != address(0), "ERC1967: new admin is the zero address");
                                      StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
                                  }
                                  /**
                                   * @dev Changes the admin of the proxy.
                                   *
                                   * Emits an {AdminChanged} event.
                                   */
                                  function _changeAdmin(address newAdmin) internal {
                                      emit AdminChanged(_getAdmin(), newAdmin);
                                      _setAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
                                   * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
                                   */
                                  bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
                                  /**
                                   * @dev Emitted when the beacon is upgraded.
                                   */
                                  event BeaconUpgraded(address indexed beacon);
                                  /**
                                   * @dev Returns the current beacon.
                                   */
                                  function _getBeacon() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new beacon in the EIP1967 beacon slot.
                                   */
                                  function _setBeacon(address newBeacon) private {
                                      require(
                                          Address.isContract(newBeacon),
                                          "ERC1967: new beacon is not a contract"
                                      );
                                      require(
                                          Address.isContract(IBeacon(newBeacon).implementation()),
                                          "ERC1967: beacon implementation is not a contract"
                                      );
                                      StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This is the interface that {BeaconProxy} expects of its beacon.
                               */
                              interface IBeacon {
                                  /**
                                   * @dev Must return an address that can be used as a delegate call target.
                                   *
                                   * {BeaconProxy} will check that this address is a contract.
                                   */
                                  function implementation() external view returns (address);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @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
                                   * ====
                                   */
                                  function isContract(address account) internal view returns (bool) {
                                      // This method relies on extcodesize, which returns 0 for contracts in
                                      // construction, since the code is only stored at the end of the
                                      // constructor execution.
                                      uint256 size;
                                      // solhint-disable-next-line no-inline-assembly
                                      assembly { size := extcodesize(account) }
                                      return size > 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");
                                      // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
                                      (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 functionCall(target, data, "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");
                                      require(isContract(target), "Address: call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.call{ value: value }(data);
                                      return _verifyCallResult(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) {
                                      require(isContract(target), "Address: static call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.staticcall(data);
                                      return _verifyCallResult(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) {
                                      require(isContract(target), "Address: delegate call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.delegatecall(data);
                                      return _verifyCallResult(success, returndata, errorMessage);
                                  }
                                  function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
                                      if (success) {
                                          return returndata;
                                      } else {
                                          // 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
                                              // solhint-disable-next-line no-inline-assembly
                                              assembly {
                                                  let returndata_size := mload(returndata)
                                                  revert(add(32, returndata), returndata_size)
                                              }
                                          } else {
                                              revert(errorMessage);
                                          }
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev Library for reading and writing primitive types to specific storage slots.
                               *
                               * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
                               * This library helps with reading and writing to such slots without the need for inline assembly.
                               *
                               * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
                               *
                               * Example usage to set ERC1967 implementation slot:
                               * ```
                               * contract ERC1967 {
                               *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                               *
                               *     function _getImplementation() internal view returns (address) {
                               *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                               *     }
                               *
                               *     function _setImplementation(address newImplementation) internal {
                               *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                               *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                               *     }
                               * }
                               * ```
                               *
                               * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
                               */
                              library StorageSlot {
                                  struct AddressSlot {
                                      address value;
                                  }
                                  struct BooleanSlot {
                                      bool value;
                                  }
                                  struct Bytes32Slot {
                                      bytes32 value;
                                  }
                                  struct Uint256Slot {
                                      uint256 value;
                                  }
                                  /**
                                   * @dev Returns an `AddressSlot` with member `value` located at `slot`.
                                   */
                                  function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
                                   */
                                  function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
                                   */
                                  function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
                                   */
                                  function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/Context.sol";
                              /**
                               * @dev Contract module which provides a basic access control mechanism, where
                               * there is an account (an owner) that can be granted exclusive access to
                               * specific functions.
                               *
                               * By default, the owner account will be the one that deploys the contract. This
                               * can later be changed with {transferOwnership}.
                               *
                               * This module is used through inheritance. It will make available the modifier
                               * `onlyOwner`, which can be applied to your functions to restrict their use to
                               * the owner.
                               */
                              abstract contract Ownable is Context {
                                  address private _owner;
                                  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                                  /**
                                   * @dev Initializes the contract setting the deployer as the initial owner.
                                   */
                                  constructor () {
                                      address msgSender = _msgSender();
                                      _owner = msgSender;
                                      emit OwnershipTransferred(address(0), msgSender);
                                  }
                                  /**
                                   * @dev Returns the address of the current owner.
                                   */
                                  function owner() public view virtual returns (address) {
                                      return _owner;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the owner.
                                   */
                                  modifier onlyOwner() {
                                      require(owner() == _msgSender(), "Ownable: caller is not the owner");
                                      _;
                                  }
                                  /**
                                   * @dev Leaves the contract without owner. It will not be possible to call
                                   * `onlyOwner` functions anymore. Can only be called by the current owner.
                                   *
                                   * NOTE: Renouncing ownership will leave the contract without an owner,
                                   * thereby removing any functionality that is only available to the owner.
                                   */
                                  function renounceOwnership() public virtual onlyOwner {
                                      emit OwnershipTransferred(_owner, address(0));
                                      _owner = address(0);
                                  }
                                  /**
                                   * @dev Transfers ownership of the contract to a new account (`newOwner`).
                                   * Can only be called by the current owner.
                                   */
                                  function transferOwnership(address newOwner) public virtual onlyOwner {
                                      require(newOwner != address(0), "Ownable: new owner is the zero address");
                                      emit OwnershipTransferred(_owner, newOwner);
                                      _owner = newOwner;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              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) {
                                      this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
                                      return msg.data;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../ERC1967/ERC1967Upgrade.sol";
                              /**
                               * @dev Base contract for building openzeppelin-upgrades compatible implementations for the {ERC1967Proxy}. It includes
                               * publicly available upgrade functions that are called by the plugin and by the secure upgrade mechanism to verify
                               * continuation of the upgradability.
                               *
                               * The {_authorizeUpgrade} function MUST be overridden to include access restriction to the upgrade mechanism.
                               *
                               * _Available since v4.1._
                               */
                              abstract contract UUPSUpgradeable is ERC1967Upgrade {
                                  function upgradeTo(address newImplementation) external virtual {
                                      _authorizeUpgrade(newImplementation);
                                      _upgradeToAndCallSecure(newImplementation, bytes(""), false);
                                  }
                                  function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual {
                                      _authorizeUpgrade(newImplementation);
                                      _upgradeToAndCallSecure(newImplementation, data, true);
                                  }
                                  function _authorizeUpgrade(address newImplementation) internal virtual;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.2;
                              import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
                              abstract contract Proxiable is UUPSUpgradeable {
                                  function _authorizeUpgrade(address newImplementation) internal override {
                                      _beforeUpgrade(newImplementation);
                                  }
                                  function _beforeUpgrade(address newImplementation) internal virtual;
                              }
                              contract ChildOfProxiable is Proxiable {
                                  function _beforeUpgrade(address newImplementation) internal virtual override {}
                              }
                              

                              File 9 of 12: WhitelistPeriodManager
                              // $$\\      $$\\                                                         $$\\       $$\\       $$\\                     $$\\       $$\\ $$\\   $$\\
                              // $$$\\    $$$ |                                                        $$ |      $$ |      \\__|                    \\__|      $$ |\\__|  $$ |
                              // $$$$\\  $$$$ | $$$$$$\\  $$$$$$$\\   $$$$$$\\   $$$$$$\\   $$$$$$\\   $$$$$$$ |      $$ |      $$\\  $$$$$$\\  $$\\   $$\\ $$\\  $$$$$$$ |$$\\ $$$$$$\\   $$\\   $$\\
                              // $$\\$$\\$$ $$ | \\____$$\\ $$  __$$\\  \\____$$\\ $$  __$$\\ $$  __$$\\ $$  __$$ |      $$ |      $$ |$$  __$$\\ $$ |  $$ |$$ |$$  __$$ |$$ |\\_$$  _|  $$ |  $$ |
                              // $$ \\$$$  $$ | $$$$$$$ |$$ |  $$ | $$$$$$$ |$$ /  $$ |$$$$$$$$ |$$ /  $$ |      $$ |      $$ |$$ /  $$ |$$ |  $$ |$$ |$$ /  $$ |$$ |  $$ |    $$ |  $$ |
                              // $$ |\\$  /$$ |$$  __$$ |$$ |  $$ |$$  __$$ |$$ |  $$ |$$   ____|$$ |  $$ |      $$ |      $$ |$$ |  $$ |$$ |  $$ |$$ |$$ |  $$ |$$ |  $$ |$$\\ $$ |  $$ |
                              // $$ | \\_/ $$ |\\$$$$$$$ |$$ |  $$ |\\$$$$$$$ |\\$$$$$$$ |\\$$$$$$$\\ \\$$$$$$$ |      $$$$$$$$\\ $$ |\\$$$$$$$ |\\$$$$$$  |$$ |\\$$$$$$$ |$$ |  \\$$$$  |\\$$$$$$$ |
                              // \\__|     \\__| \\_______|\\__|  \\__| \\_______| \\____$$ | \\_______| \\_______|      \\________|\\__| \\____$$ | \\______/ \\__| \\_______|\\__|   \\____/  \\____$$ |
                              //                                            $$\\   $$ |                                              $$ |                                      $$\\   $$ |
                              //                                            \\$$$$$$  |                                              $$ |                                      \\$$$$$$  |
                              //                                             \\______/                                               \\__|                                       \\______/
                              //
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                              import "../security/Pausable.sol";
                              import "./metatx/ERC2771ContextUpgradeable.sol";
                              import "./interfaces/ILiquidityProviders.sol";
                              import "./interfaces/ITokenManager.sol";
                              import "./interfaces/ILPToken.sol";
                              contract WhitelistPeriodManager is Initializable, OwnableUpgradeable, Pausable, ERC2771ContextUpgradeable {
                                  ILiquidityProviders private liquidityProviders;
                                  ITokenManager private tokenManager;
                                  ILPToken private lpToken;
                                  bool public areWhiteListRestrictionsEnabled;
                                  /* LP Status */
                                  // EOA? -> status, stores addresses that we want to ignore, like staking contracts.
                                  mapping(address => bool) public isExcludedAddress;
                                  // WARNING: DEPRECIATED, DO NOT USE
                                  // Token -> TVL
                                  mapping(address => uint256) private totalLiquidity;
                                  // WARNING: DEPRECIATED, DO NOT USE
                                  // Token -> TVL
                                  mapping(address => mapping(address => uint256)) public totalLiquidityByLp;
                                  /* Caps */
                                  // Token Address -> Limit
                                  mapping(address => uint256) public perTokenTotalCap;
                                  // Token Address -> Limit
                                  mapping(address => uint256) public perTokenWalletCap;
                                  event ExcludedAddressStatusUpdated(address indexed lp, bool indexed status);
                                  event TotalCapUpdated(address indexed token, uint256 totalCap);
                                  event PerTokenWalletCap(address indexed token, uint256 perCommunityWalletCap);
                                  event WhiteListStatusUpdated(bool status);
                                  modifier onlyLiquidityPool() {
                                      require(_msgSender() == address(liquidityProviders), "ERR__UNAUTHORIZED");
                                      _;
                                  }
                                  modifier onlyLpNft() {
                                      require(_msgSender() == address(lpToken), "ERR__UNAUTHORIZED");
                                      _;
                                  }
                                  modifier tokenChecks(address tokenAddress) {
                                      require(tokenAddress != address(0), "Token address cannot be 0");
                                      require(_isSupportedToken(tokenAddress), "Token not supported");
                                      _;
                                  }
                                  /**
                                   * @dev initalizes the contract, acts as constructor
                                   * @param _trustedForwarder address of trusted forwarder
                                   */
                                  function initialize(
                                      address _trustedForwarder,
                                      address _liquidityProviders,
                                      address _tokenManager,
                                      address _lpToken,
                                      address _pauser
                                  ) external initializer {
                                      __ERC2771Context_init(_trustedForwarder);
                                      __Ownable_init();
                                      __Pausable_init(_pauser);
                                      areWhiteListRestrictionsEnabled = true;
                                      _setLiquidityProviders(_liquidityProviders);
                                      _setTokenManager(_tokenManager);
                                      _setLpToken(_lpToken);
                                  }
                                  function _isSupportedToken(address _token) private view returns (bool) {
                                      return tokenManager.getTokensInfo(_token).supportedToken;
                                  }
                                  /**
                                   * @dev Internal Function which checks for various caps before allowing LP to add liqudity
                                   */
                                  function _beforeLiquidityAddition(
                                      address,
                                      address _token,
                                      uint256 _amount
                                  ) internal {
                                      // Per Token Total Cap or PTTC
                                      require(
                                          ifEnabled(liquidityProviders.getSuppliedLiquidityByToken(_token) + _amount <= perTokenTotalCap[_token]),
                                          "ERR__LIQUIDITY_EXCEEDS_PTTC"
                                      );
                                  }
                                  /**
                                   * @dev External Function which checks for various caps before allowing LP to add liqudity. Only callable by LiquidityPoolManager
                                   */
                                  function beforeLiquidityAddition(
                                      address _lp,
                                      address _token,
                                      uint256 _amount
                                  ) external onlyLiquidityPool whenNotPaused {
                                      _beforeLiquidityAddition(_lp, _token, _amount);
                                  }
                                  /**
                                   * @dev Internal Function which checks for various caps before allowing LP to remove liqudity
                                   */
                                  function _beforeLiquidityRemoval(
                                      address,
                                      address,
                                      uint256
                                  ) internal pure {
                                      return;
                                  }
                                  /**
                                   * @dev External Function which checks for various caps before allowing LP to remove liqudity. Only callable by LiquidityPoolManager
                                   */
                                  function beforeLiquidityRemoval(
                                      address _lp,
                                      address _token,
                                      uint256 _amount
                                  ) external view onlyLiquidityPool whenNotPaused {
                                      _beforeLiquidityRemoval(_lp, _token, _amount);
                                  }
                                  /**
                                   * @dev External Function which checks for various caps before allowing LP to transfer their LpNFT. Only callable by LpNFT contract
                                   */
                                  function beforeLiquidityTransfer(
                                      address,
                                      address,
                                      address,
                                      uint256
                                  ) external view onlyLpNft whenNotPaused {
                                      return;
                                  }
                                  function _setTokenManager(address _tokenManager) internal {
                                      tokenManager = ITokenManager(_tokenManager);
                                  }
                                  function setTokenManager(address _tokenManager) external onlyOwner {
                                      _setTokenManager(_tokenManager);
                                  }
                                  function _setLiquidityProviders(address _liquidityProviders) internal {
                                      liquidityProviders = ILiquidityProviders(_liquidityProviders);
                                  }
                                  function setLiquidityProviders(address _liquidityProviders) external onlyOwner {
                                      _setLiquidityProviders(_liquidityProviders);
                                  }
                                  function _setLpToken(address _lpToken) internal {
                                      lpToken = ILPToken(_lpToken);
                                  }
                                  function setLpToken(address _lpToken) external onlyOwner {
                                      _setLpToken(_lpToken);
                                  }
                                  function setIsExcludedAddressStatus(address[] memory _addresses, bool[] memory _status) external onlyOwner {
                                      require(_addresses.length == _status.length, "ERR__LENGTH_MISMATCH");
                                      uint256 length = _addresses.length;
                                      for (uint256 i; i < length; ) {
                                          isExcludedAddress[_addresses[i]] = _status[i];
                                          emit ExcludedAddressStatusUpdated(_addresses[i], _status[i]);
                                          unchecked {
                                              ++i;
                                          }
                                      }
                                  }
                                  function setTotalCap(address _token, uint256 _totalCap) public tokenChecks(_token) onlyOwner {
                                      require(liquidityProviders.getSuppliedLiquidityByToken(_token) <= _totalCap, "ERR__TOTAL_CAP_LESS_THAN_SL");
                                      require(_totalCap >= perTokenWalletCap[_token], "ERR__TOTAL_CAP_LT_PTWC");
                                      if (perTokenTotalCap[_token] != _totalCap) {
                                          perTokenTotalCap[_token] = _totalCap;
                                          emit TotalCapUpdated(_token, _totalCap);
                                      }
                                  }
                                  /**
                                   * @dev Special care must be taken when calling this function
                                   *      There are no checks for _perTokenWalletCap (since it's onlyOwner), but it's essential that it
                                   *      should be >= max lp provided by an lp.
                                   *      Checking this on chain will probably require implementing a bbst, which needs more bandwidth
                                   *      Call the view function getMaxCommunityLpPositon() separately before changing this value
                                   */
                                  function setPerTokenWalletCap(address _token, uint256 _perTokenWalletCap) public tokenChecks(_token) onlyOwner {
                                      require(_perTokenWalletCap <= perTokenTotalCap[_token], "ERR__PWC_GT_PTTC");
                                      if (perTokenWalletCap[_token] != _perTokenWalletCap) {
                                          perTokenWalletCap[_token] = _perTokenWalletCap;
                                          emit PerTokenWalletCap(_token, _perTokenWalletCap);
                                      }
                                  }
                                  function setCap(
                                      address _token,
                                      uint256 _totalCap,
                                      uint256 _perTokenWalletCap
                                  ) public onlyOwner {
                                      setTotalCap(_token, _totalCap);
                                      setPerTokenWalletCap(_token, _perTokenWalletCap);
                                  }
                                  function setCaps(
                                      address[] memory _tokens,
                                      uint256[] memory _totalCaps,
                                      uint256[] memory _perTokenWalletCaps
                                  ) external onlyOwner {
                                      require(
                                          _tokens.length == _totalCaps.length && _totalCaps.length == _perTokenWalletCaps.length,
                                          "ERR__LENGTH_MISMACH"
                                      );
                                      uint256 length = _tokens.length;
                                      for (uint256 i; i < length; ) {
                                          setCap(_tokens[i], _totalCaps[i], _perTokenWalletCaps[i]);
                                          unchecked {
                                              ++i;
                                          }
                                      }
                                  }
                                  /**
                                   * @dev Enables (or disables) reverts if liquidity exceeds caps.
                                   *      Even if this is disabled, the contract will continue to track LP's positions
                                   */
                                  function setAreWhiteListRestrictionsEnabled(bool _status) external onlyOwner {
                                      areWhiteListRestrictionsEnabled = _status;
                                      emit WhiteListStatusUpdated(_status);
                                  }
                                  /**
                                   * @dev Returns the maximum amount a single community LP has provided
                                   */
                                  function getMaxCommunityLpPositon(address _token) external view returns (uint256) {
                                      uint256 totalSupply = lpToken.totalSupply();
                                      uint256 maxLp = 0;
                                      for (uint256 i = 1; i <= totalSupply; ++i) {
                                          uint256 liquidity = totalLiquidityByLp[_token][lpToken.ownerOf(i)];
                                          if (liquidity > maxLp) {
                                              maxLp = liquidity;
                                          }
                                      }
                                      return maxLp;
                                  }
                                  /**
                                   * @dev returns the value of if (areWhiteListEnabled) then (_cond)
                                   */
                                  function ifEnabled(bool _cond) private view returns (bool) {
                                      return !areWhiteListRestrictionsEnabled || (areWhiteListRestrictionsEnabled && _cond);
                                  }
                                  /**
                                   * @dev Meta-Transaction Helper, returns msgSender
                                   */
                                  function _msgSender()
                                      internal
                                      view
                                      virtual
                                      override(ContextUpgradeable, ERC2771ContextUpgradeable)
                                      returns (address)
                                  {
                                      return ERC2771ContextUpgradeable._msgSender();
                                  }
                                  /**
                                   * @dev Meta-Transaction Helper, returns msgData
                                   */
                                  function _msgData()
                                      internal
                                      view
                                      virtual
                                      override(ContextUpgradeable, ERC2771ContextUpgradeable)
                                      returns (bytes calldata)
                                  {
                                      return ERC2771ContextUpgradeable._msgData();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/ContextUpgradeable.sol";
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module which provides a basic access control mechanism, where
                               * there is an account (an owner) that can be granted exclusive access to
                               * specific functions.
                               *
                               * By default, the owner account will be the one that deploys the contract. This
                               * can later be changed with {transferOwnership}.
                               *
                               * This module is used through inheritance. It will make available the modifier
                               * `onlyOwner`, which can be applied to your functions to restrict their use to
                               * the owner.
                               */
                              abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
                                  address private _owner;
                                  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                                  /**
                                   * @dev Initializes the contract setting the deployer as the initial owner.
                                   */
                                  function __Ownable_init() internal initializer {
                                      __Context_init_unchained();
                                      __Ownable_init_unchained();
                                  }
                                  function __Ownable_init_unchained() internal initializer {
                                      _setOwner(_msgSender());
                                  }
                                  /**
                                   * @dev Returns the address of the current owner.
                                   */
                                  function owner() public view virtual returns (address) {
                                      return _owner;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the owner.
                                   */
                                  modifier onlyOwner() {
                                      require(owner() == _msgSender(), "Ownable: caller is not the owner");
                                      _;
                                  }
                                  /**
                                   * @dev Leaves the contract without owner. It will not be possible to call
                                   * `onlyOwner` functions anymore. Can only be called by the current owner.
                                   *
                                   * NOTE: Renouncing ownership will leave the contract without an owner,
                                   * thereby removing any functionality that is only available to the owner.
                                   */
                                  function renounceOwnership() public virtual onlyOwner {
                                      _setOwner(address(0));
                                  }
                                  /**
                                   * @dev Transfers ownership of the contract to a new account (`newOwner`).
                                   * Can only be called by the current owner.
                                   */
                                  function transferOwnership(address newOwner) public virtual onlyOwner {
                                      require(newOwner != address(0), "Ownable: new owner is the zero address");
                                      _setOwner(newOwner);
                                  }
                                  function _setOwner(address newOwner) private {
                                      address oldOwner = _owner;
                                      _owner = newOwner;
                                      emit OwnershipTransferred(oldOwner, newOwner);
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
                               * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
                               * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
                               * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
                               *
                               * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
                               * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
                               *
                               * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
                               * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
                               */
                              abstract contract Initializable {
                                  /**
                                   * @dev Indicates that the contract has been initialized.
                                   */
                                  bool private _initialized;
                                  /**
                                   * @dev Indicates that the contract is in the process of being initialized.
                                   */
                                  bool private _initializing;
                                  /**
                                   * @dev Modifier to protect an initializer function from being invoked twice.
                                   */
                                  modifier initializer() {
                                      require(_initializing || !_initialized, "Initializable: contract is already initialized");
                                      bool isTopLevelCall = !_initializing;
                                      if (isTopLevelCall) {
                                          _initializing = true;
                                          _initialized = true;
                                      }
                                      _;
                                      if (isTopLevelCall) {
                                          _initializing = false;
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                              import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
                              /**
                               * @dev Contract module which allows children to implement an emergency stop
                               * mechanism that can be triggered by an authorized account.
                               *
                               * This module is used through inheritance. It will make available the
                               * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
                               * the functions of your contract. Note that they will not be pausable by
                               * simply including this module, only once the modifiers are put in place.
                               */
                              abstract contract Pausable is Initializable, PausableUpgradeable {
                                  address private _pauser;
                                  event PauserChanged(address indexed previousPauser, address indexed newPauser);
                                  /**
                                   * @dev The pausable constructor sets the original `pauser` of the contract to the sender
                                   * account & Initializes the contract in unpaused state..
                                   */
                                  function __Pausable_init(address pauser) internal initializer {
                                      require(pauser != address(0), "Pauser Address cannot be 0");
                                      __Pausable_init();
                                      _pauser = pauser;
                                  }
                                  /**
                                   * @return true if `msg.sender` is the owner of the contract.
                                   */
                                  function isPauser(address pauser) public view returns (bool) {
                                      return pauser == _pauser;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the pauser.
                                   */
                                  modifier onlyPauser() {
                                      require(isPauser(msg.sender), "Only pauser is allowed to perform this operation");
                                      _;
                                  }
                                  /**
                                   * @dev Allows the current pauser to transfer control of the contract to a newPauser.
                                   * @param newPauser The address to transfer pauserShip to.
                                   */
                                  function changePauser(address newPauser) public onlyPauser {
                                      _changePauser(newPauser);
                                  }
                                  /**
                                   * @dev Transfers control of the contract to a newPauser.
                                   * @param newPauser The address to transfer ownership to.
                                   */
                                  function _changePauser(address newPauser) internal {
                                      require(newPauser != address(0));
                                      emit PauserChanged(_pauser, newPauser);
                                      _pauser = newPauser;
                                  }
                                  function renouncePauser() external virtual onlyPauser {
                                      emit PauserChanged(_pauser, address(0));
                                      _pauser = address(0);
                                  }
                                  function pause() public onlyPauser {
                                      _pause();
                                  }
                                  function unpause() public onlyPauser {
                                      _unpause();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                              /**
                               * @dev Context variant with ERC2771 support. 
                               * Here _trustedForwarder is made internal instead of private
                               * so it can be changed via Child contracts with a setter method.
                               */
                              abstract contract ERC2771ContextUpgradeable is Initializable, ContextUpgradeable {
                                  address internal _trustedForwarder;
                                  function __ERC2771Context_init(address trustedForwarder) internal initializer {
                                      __Context_init_unchained();
                                      __ERC2771Context_init_unchained(trustedForwarder);
                                  }
                                  function __ERC2771Context_init_unchained(address trustedForwarder) internal initializer {
                                      _trustedForwarder = trustedForwarder;
                                  }
                                  function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
                                      return forwarder == _trustedForwarder;
                                  }
                                  function _msgSender() internal view virtual override returns (address sender) {
                                      if (isTrustedForwarder(msg.sender)) {
                                          // The assembly code is more direct than the Solidity version using `abi.decode`.
                                          assembly {
                                              sender := shr(96, calldataload(sub(calldatasize(), 20)))
                                          }
                                      } else {
                                          return super._msgSender();
                                      }
                                  }
                                  function _msgData() internal view virtual override returns (bytes calldata) {
                                      if (isTrustedForwarder(msg.sender)) {
                                          return msg.data[:msg.data.length - 20];
                                      } else {
                                          return super._msgData();
                                      }
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              interface ILiquidityProviders {
                                  function BASE_DIVISOR() external view returns (uint256);
                                  function initialize(address _trustedForwarder, address _lpToken) external;
                                  function addLPFee(address _token, uint256 _amount) external;
                                  function addNativeLiquidity() external;
                                  function addTokenLiquidity(address _token, uint256 _amount) external;
                                  function claimFee(uint256 _nftId) external;
                                  function getFeeAccumulatedOnNft(uint256 _nftId) external view returns (uint256);
                                  function getSuppliedLiquidityByToken(address tokenAddress) external view returns (uint256);
                                  function getTokenPriceInLPShares(address _baseToken) external view returns (uint256);
                                  function getTotalLPFeeByToken(address tokenAddress) external view returns (uint256);
                                  function getTotalReserveByToken(address tokenAddress) external view returns (uint256);
                                  function getSuppliedLiquidity(uint256 _nftId) external view returns (uint256);
                                  function increaseNativeLiquidity(uint256 _nftId) external;
                                  function increaseTokenLiquidity(uint256 _nftId, uint256 _amount) external;
                                  function isTrustedForwarder(address forwarder) external view returns (bool);
                                  function owner() external view returns (address);
                                  function paused() external view returns (bool);
                                  function removeLiquidity(uint256 _nftId, uint256 amount) external;
                                  function renounceOwnership() external;
                                  function setLiquidityPool(address _liquidityPool) external;
                                  function setLpToken(address _lpToken) external;
                                  function setWhiteListPeriodManager(address _whiteListPeriodManager) external;
                                  function sharesToTokenAmount(uint256 _shares, address _tokenAddress) external view returns (uint256);
                                  function totalLPFees(address) external view returns (uint256);
                                  function totalLiquidity(address) external view returns (uint256);
                                  function totalReserve(address) external view returns (uint256);
                                  function totalSharesMinted(address) external view returns (uint256);
                                  function transferOwnership(address newOwner) external;
                                  function whiteListPeriodManager() external view returns (address);
                                  function increaseCurrentLiquidity(address tokenAddress, uint256 amount) external;
                                  function decreaseCurrentLiquidity(address tokenAddress, uint256 amount) external;
                                  function getCurrentLiquidity(address tokenAddress) external view returns (uint256);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "../structures/TokenConfig.sol";
                              interface ITokenManager {
                                  function getEquilibriumFee(address tokenAddress) external view returns (uint256);
                                  function getMaxFee(address tokenAddress) external view returns (uint256);
                                  function changeFee(
                                      address tokenAddress,
                                      uint256 _equilibriumFee,
                                      uint256 _maxFee
                                  ) external;
                                  function tokensInfo(address tokenAddress)
                                      external
                                      view
                                      returns (
                                          uint256 transferOverhead,
                                          bool supportedToken,
                                          uint256 equilibriumFee,
                                          uint256 maxFee,
                                          TokenConfig memory config
                                      );
                                  function getTokensInfo(address tokenAddress) external view returns (TokenInfo memory);
                                  function getDepositConfig(uint256 toChainId, address tokenAddress) external view returns (TokenConfig memory);
                                  function getTransferConfig(address tokenAddress) external view returns (TokenConfig memory);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "../structures/LpTokenMetadata.sol";
                              interface ILPToken {
                                  function approve(address to, uint256 tokenId) external;
                                  function balanceOf(address _owner) external view returns (uint256);
                                  function exists(uint256 _tokenId) external view returns (bool);
                                  function getAllNftIdsByUser(address _owner) external view returns (uint256[] memory);
                                  function getApproved(uint256 tokenId) external view returns (address);
                                  function initialize(
                                      string memory _name,
                                      string memory _symbol,
                                      address _trustedForwarder
                                  ) external;
                                  function isApprovedForAll(address _owner, address operator) external view returns (bool);
                                  function isTrustedForwarder(address forwarder) external view returns (bool);
                                  function liquidityPoolAddress() external view returns (address);
                                  function mint(address _to) external returns (uint256);
                                  function name() external view returns (string memory);
                                  function owner() external view returns (address);
                                  function ownerOf(uint256 tokenId) external view returns (address);
                                  function paused() external view returns (bool);
                                  function renounceOwnership() external;
                                  function safeTransferFrom(
                                      address from,
                                      address to,
                                      uint256 tokenId
                                  ) external;
                                  function safeTransferFrom(
                                      address from,
                                      address to,
                                      uint256 tokenId,
                                      bytes memory _data
                                  ) external;
                                  function setApprovalForAll(address operator, bool approved) external;
                                  function setLiquidityPool(address _lpm) external;
                                  function setWhiteListPeriodManager(address _whiteListPeriodManager) external;
                                  function supportsInterface(bytes4 interfaceId) external view returns (bool);
                                  function symbol() external view returns (string memory);
                                  function tokenByIndex(uint256 index) external view returns (uint256);
                                  function tokenMetadata(uint256)
                                      external
                                      view
                                      returns (
                                          address token,
                                          uint256 totalSuppliedLiquidity,
                                          uint256 totalShares
                                      );
                                  function tokenOfOwnerByIndex(address _owner, uint256 index) external view returns (uint256);
                                  function tokenURI(uint256 tokenId) external view returns (string memory);
                                  function totalSupply() external view returns (uint256);
                                  function transferFrom(
                                      address from,
                                      address to,
                                      uint256 tokenId
                                  ) external;
                                  function transferOwnership(address newOwner) external;
                                  function updateTokenMetadata(uint256 _tokenId, LpTokenMetadata memory _lpTokenMetadata) external;
                                  function whiteListPeriodManager() external view returns (address);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Provides information about the current execution context, including the
                               * sender of the transaction and its data. While these are generally available
                               * via msg.sender and msg.data, they should not be accessed in such a direct
                               * manner, since when dealing with meta-transactions the account sending and
                               * paying for execution may not be the actual sender (as far as an application
                               * is concerned).
                               *
                               * This contract is only required for intermediate, library-like contracts.
                               */
                              abstract contract ContextUpgradeable is Initializable {
                                  function __Context_init() internal initializer {
                                      __Context_init_unchained();
                                  }
                                  function __Context_init_unchained() internal initializer {
                                  }
                                  function _msgSender() internal view virtual returns (address) {
                                      return msg.sender;
                                  }
                                  function _msgData() internal view virtual returns (bytes calldata) {
                                      return msg.data;
                                  }
                                  uint256[50] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/ContextUpgradeable.sol";
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module which allows children to implement an emergency stop
                               * mechanism that can be triggered by an authorized account.
                               *
                               * This module is used through inheritance. It will make available the
                               * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
                               * the functions of your contract. Note that they will not be pausable by
                               * simply including this module, only once the modifiers are put in place.
                               */
                              abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
                                  /**
                                   * @dev Emitted when the pause is triggered by `account`.
                                   */
                                  event Paused(address account);
                                  /**
                                   * @dev Emitted when the pause is lifted by `account`.
                                   */
                                  event Unpaused(address account);
                                  bool private _paused;
                                  /**
                                   * @dev Initializes the contract in unpaused state.
                                   */
                                  function __Pausable_init() internal initializer {
                                      __Context_init_unchained();
                                      __Pausable_init_unchained();
                                  }
                                  function __Pausable_init_unchained() internal initializer {
                                      _paused = false;
                                  }
                                  /**
                                   * @dev Returns true if the contract is paused, and false otherwise.
                                   */
                                  function paused() public view virtual returns (bool) {
                                      return _paused;
                                  }
                                  /**
                                   * @dev Modifier to make a function callable only when the contract is not paused.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must not be paused.
                                   */
                                  modifier whenNotPaused() {
                                      require(!paused(), "Pausable: paused");
                                      _;
                                  }
                                  /**
                                   * @dev Modifier to make a function callable only when the contract is paused.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must be paused.
                                   */
                                  modifier whenPaused() {
                                      require(paused(), "Pausable: not paused");
                                      _;
                                  }
                                  /**
                                   * @dev Triggers stopped state.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must not be paused.
                                   */
                                  function _pause() internal virtual whenNotPaused {
                                      _paused = true;
                                      emit Paused(_msgSender());
                                  }
                                  /**
                                   * @dev Returns to normal state.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must be paused.
                                   */
                                  function _unpause() internal virtual whenPaused {
                                      _paused = false;
                                      emit Unpaused(_msgSender());
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              struct TokenInfo {
                                  uint256 transferOverhead;
                                  bool supportedToken;
                                  uint256 equilibriumFee; // Percentage fee Represented in basis points
                                  uint256 maxFee; // Percentage fee Represented in basis points
                                  TokenConfig tokenConfig;
                              }
                              struct TokenConfig {
                                  uint256 min;
                                  uint256 max;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              struct LpTokenMetadata {
                                  address token;
                                  uint256 suppliedLiquidity;
                                  uint256 shares;
                              }
                              

                              File 10 of 12: TransparentUpgradeableProxy
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
                              import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
                              import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
                              // Kept for backwards compatibility with older versions of Hardhat and Truffle plugins.
                              contract AdminUpgradeabilityProxy is TransparentUpgradeableProxy {
                                  constructor(address logic, address admin, bytes memory data) payable TransparentUpgradeableProxy(logic, admin, data) {}
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../Proxy.sol";
                              import "./ERC1967Upgrade.sol";
                              /**
                               * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
                               * implementation address that can be changed. This address is stored in storage in the location specified by
                               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
                               * implementation behind the proxy.
                               */
                              contract ERC1967Proxy is Proxy, ERC1967Upgrade {
                                  /**
                                   * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
                                   *
                                   * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
                                   * function call, and allows initializating the storage of the proxy like a Solidity constructor.
                                   */
                                  constructor(address _logic, bytes memory _data) payable {
                                      assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
                                      _upgradeToAndCall(_logic, _data, false);
                                  }
                                  /**
                                   * @dev Returns the current implementation address.
                                   */
                                  function _implementation() internal view virtual override returns (address impl) {
                                      return ERC1967Upgrade._getImplementation();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../ERC1967/ERC1967Proxy.sol";
                              /**
                               * @dev This contract implements a proxy that is upgradeable by an admin.
                               *
                               * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
                               * clashing], which can potentially be used in an attack, this contract uses the
                               * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
                               * things that go hand in hand:
                               *
                               * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
                               * that call matches one of the admin functions exposed by the proxy itself.
                               * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
                               * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
                               * "admin cannot fallback to proxy target".
                               *
                               * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
                               * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
                               * to sudden errors when trying to call a function from the proxy implementation.
                               *
                               * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
                               * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
                               */
                              contract TransparentUpgradeableProxy is ERC1967Proxy {
                                  /**
                                   * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
                                   * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
                                   */
                                  constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
                                      assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
                                      _changeAdmin(admin_);
                                  }
                                  /**
                                   * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
                                   */
                                  modifier ifAdmin() {
                                      if (msg.sender == _getAdmin()) {
                                          _;
                                      } else {
                                          _fallback();
                                      }
                                  }
                                  /**
                                   * @dev Returns the current admin.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
                                   *
                                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                                   * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
                                   */
                                  function admin() external ifAdmin returns (address admin_) {
                                      admin_ = _getAdmin();
                                  }
                                  /**
                                   * @dev Returns the current implementation.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
                                   *
                                   * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
                                   * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
                                   * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
                                   */
                                  function implementation() external ifAdmin returns (address implementation_) {
                                      implementation_ = _implementation();
                                  }
                                  /**
                                   * @dev Changes the admin of the proxy.
                                   *
                                   * Emits an {AdminChanged} event.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
                                   */
                                  function changeAdmin(address newAdmin) external virtual ifAdmin {
                                      _changeAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev Upgrade the implementation of the proxy.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
                                   */
                                  function upgradeTo(address newImplementation) external ifAdmin {
                                      _upgradeToAndCall(newImplementation, bytes(""), false);
                                  }
                                  /**
                                   * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
                                   * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
                                   * proxied contract.
                                   *
                                   * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
                                   */
                                  function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
                                      _upgradeToAndCall(newImplementation, data, true);
                                  }
                                  /**
                                   * @dev Returns the current admin.
                                   */
                                  function _admin() internal view virtual returns (address) {
                                      return _getAdmin();
                                  }
                                  /**
                                   * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
                                   */
                                  function _beforeFallback() internal virtual override {
                                      require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
                                      super._beforeFallback();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "./TransparentUpgradeableProxy.sol";
                              import "../../access/Ownable.sol";
                              /**
                               * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
                               * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
                               */
                              contract ProxyAdmin is Ownable {
                                  /**
                                   * @dev Returns the current implementation of `proxy`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
                                      // We need to manually run the static call since the getter cannot be flagged as view
                                      // bytes4(keccak256("implementation()")) == 0x5c60da1b
                                      (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
                                      require(success);
                                      return abi.decode(returndata, (address));
                                  }
                                  /**
                                   * @dev Returns the current admin of `proxy`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
                                      // We need to manually run the static call since the getter cannot be flagged as view
                                      // bytes4(keccak256("admin()")) == 0xf851a440
                                      (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
                                      require(success);
                                      return abi.decode(returndata, (address));
                                  }
                                  /**
                                   * @dev Changes the admin of `proxy` to `newAdmin`.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the current admin of `proxy`.
                                   */
                                  function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {
                                      proxy.changeAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {
                                      proxy.upgradeTo(implementation);
                                  }
                                  /**
                                   * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See
                                   * {TransparentUpgradeableProxy-upgradeToAndCall}.
                                   *
                                   * Requirements:
                                   *
                                   * - This contract must be the admin of `proxy`.
                                   */
                                  function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable virtual onlyOwner {
                                      proxy.upgradeToAndCall{value: msg.value}(implementation, data);
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
                               * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
                               * be specified by overriding the virtual {_implementation} function.
                               *
                               * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
                               * different contract through the {_delegate} function.
                               *
                               * The success and return data of the delegated call will be returned back to the caller of the proxy.
                               */
                              abstract contract Proxy {
                                  /**
                                   * @dev Delegates the current call to `implementation`.
                                   *
                                   * This function does not return to its internall call site, it will return directly to the external caller.
                                   */
                                  function _delegate(address implementation) internal virtual {
                                      // solhint-disable-next-line no-inline-assembly
                                      assembly {
                                          // Copy msg.data. We take full control of memory in this inline assembly
                                          // block because it will not return to Solidity code. We overwrite the
                                          // Solidity scratch pad at memory position 0.
                                          calldatacopy(0, 0, calldatasize())
                                          // Call the implementation.
                                          // out and outsize are 0 because we don't know the size yet.
                                          let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
                                          // Copy the returned data.
                                          returndatacopy(0, 0, returndatasize())
                                          switch result
                                          // delegatecall returns 0 on error.
                                          case 0 { revert(0, returndatasize()) }
                                          default { return(0, returndatasize()) }
                                      }
                                  }
                                  /**
                                   * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
                                   * and {_fallback} should delegate.
                                   */
                                  function _implementation() internal view virtual returns (address);
                                  /**
                                   * @dev Delegates the current call to the address returned by `_implementation()`.
                                   *
                                   * This function does not return to its internall call site, it will return directly to the external caller.
                                   */
                                  function _fallback() internal virtual {
                                      _beforeFallback();
                                      _delegate(_implementation());
                                  }
                                  /**
                                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
                                   * function in the contract matches the call data.
                                   */
                                  fallback () external payable virtual {
                                      _fallback();
                                  }
                                  /**
                                   * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
                                   * is empty.
                                   */
                                  receive () external payable virtual {
                                      _fallback();
                                  }
                                  /**
                                   * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
                                   * call, or as part of the Solidity `fallback` or `receive` functions.
                                   *
                                   * If overriden should call `super._beforeFallback()`.
                                   */
                                  function _beforeFallback() internal virtual {
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.2;
                              import "../beacon/IBeacon.sol";
                              import "../../utils/Address.sol";
                              import "../../utils/StorageSlot.sol";
                              /**
                               * @dev This abstract contract provides getters and event emitting update functions for
                               * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
                               *
                               * _Available since v4.1._
                               *
                               * @custom:oz-upgrades-unsafe-allow delegatecall
                               */
                              abstract contract ERC1967Upgrade {
                                  // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
                                  bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
                                  /**
                                   * @dev Storage slot with the address of the current implementation.
                                   * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
                                   * validated in the constructor.
                                   */
                                  bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                                  /**
                                   * @dev Emitted when the implementation is upgraded.
                                   */
                                  event Upgraded(address indexed implementation);
                                  /**
                                   * @dev Returns the current implementation address.
                                   */
                                  function _getImplementation() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new address in the EIP1967 implementation slot.
                                   */
                                  function _setImplementation(address newImplementation) private {
                                      require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                                      StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                                  }
                                  /**
                                   * @dev Perform implementation upgrade
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeTo(address newImplementation) internal {
                                      _setImplementation(newImplementation);
                                      emit Upgraded(newImplementation);
                                  }
                                  /**
                                   * @dev Perform implementation upgrade with additional setup call.
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
                                      _setImplementation(newImplementation);
                                      emit Upgraded(newImplementation);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(newImplementation, data);
                                      }
                                  }
                                  /**
                                   * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
                                   *
                                   * Emits an {Upgraded} event.
                                   */
                                  function _upgradeToAndCallSecure(address newImplementation, bytes memory data, bool forceCall) internal {
                                      address oldImplementation = _getImplementation();
                                      // Initial upgrade and setup call
                                      _setImplementation(newImplementation);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(newImplementation, data);
                                      }
                                      // Perform rollback test if not already in progress
                                      StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT);
                                      if (!rollbackTesting.value) {
                                          // Trigger rollback using upgradeTo from the new implementation
                                          rollbackTesting.value = true;
                                          Address.functionDelegateCall(
                                              newImplementation,
                                              abi.encodeWithSignature(
                                                  "upgradeTo(address)",
                                                  oldImplementation
                                              )
                                          );
                                          rollbackTesting.value = false;
                                          // Check rollback was effective
                                          require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
                                          // Finally reset to the new implementation and log the upgrade
                                          _setImplementation(newImplementation);
                                          emit Upgraded(newImplementation);
                                      }
                                  }
                                  /**
                                   * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
                                   * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
                                   *
                                   * Emits a {BeaconUpgraded} event.
                                   */
                                  function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
                                      _setBeacon(newBeacon);
                                      emit BeaconUpgraded(newBeacon);
                                      if (data.length > 0 || forceCall) {
                                          Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
                                      }
                                  }
                                  /**
                                   * @dev Storage slot with the admin of the contract.
                                   * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
                                   * validated in the constructor.
                                   */
                                  bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                                  /**
                                   * @dev Emitted when the admin account has changed.
                                   */
                                  event AdminChanged(address previousAdmin, address newAdmin);
                                  /**
                                   * @dev Returns the current admin.
                                   */
                                  function _getAdmin() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new address in the EIP1967 admin slot.
                                   */
                                  function _setAdmin(address newAdmin) private {
                                      require(newAdmin != address(0), "ERC1967: new admin is the zero address");
                                      StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
                                  }
                                  /**
                                   * @dev Changes the admin of the proxy.
                                   *
                                   * Emits an {AdminChanged} event.
                                   */
                                  function _changeAdmin(address newAdmin) internal {
                                      emit AdminChanged(_getAdmin(), newAdmin);
                                      _setAdmin(newAdmin);
                                  }
                                  /**
                                   * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
                                   * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
                                   */
                                  bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
                                  /**
                                   * @dev Emitted when the beacon is upgraded.
                                   */
                                  event BeaconUpgraded(address indexed beacon);
                                  /**
                                   * @dev Returns the current beacon.
                                   */
                                  function _getBeacon() internal view returns (address) {
                                      return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
                                  }
                                  /**
                                   * @dev Stores a new beacon in the EIP1967 beacon slot.
                                   */
                                  function _setBeacon(address newBeacon) private {
                                      require(
                                          Address.isContract(newBeacon),
                                          "ERC1967: new beacon is not a contract"
                                      );
                                      require(
                                          Address.isContract(IBeacon(newBeacon).implementation()),
                                          "ERC1967: beacon implementation is not a contract"
                                      );
                                      StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This is the interface that {BeaconProxy} expects of its beacon.
                               */
                              interface IBeacon {
                                  /**
                                   * @dev Must return an address that can be used as a delegate call target.
                                   *
                                   * {BeaconProxy} will check that this address is a contract.
                                   */
                                  function implementation() external view returns (address);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @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
                                   * ====
                                   */
                                  function isContract(address account) internal view returns (bool) {
                                      // This method relies on extcodesize, which returns 0 for contracts in
                                      // construction, since the code is only stored at the end of the
                                      // constructor execution.
                                      uint256 size;
                                      // solhint-disable-next-line no-inline-assembly
                                      assembly { size := extcodesize(account) }
                                      return size > 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");
                                      // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
                                      (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 functionCall(target, data, "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");
                                      require(isContract(target), "Address: call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.call{ value: value }(data);
                                      return _verifyCallResult(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) {
                                      require(isContract(target), "Address: static call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.staticcall(data);
                                      return _verifyCallResult(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) {
                                      require(isContract(target), "Address: delegate call to non-contract");
                                      // solhint-disable-next-line avoid-low-level-calls
                                      (bool success, bytes memory returndata) = target.delegatecall(data);
                                      return _verifyCallResult(success, returndata, errorMessage);
                                  }
                                  function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
                                      if (success) {
                                          return returndata;
                                      } else {
                                          // 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
                                              // solhint-disable-next-line no-inline-assembly
                                              assembly {
                                                  let returndata_size := mload(returndata)
                                                  revert(add(32, returndata), returndata_size)
                                              }
                                          } else {
                                              revert(errorMessage);
                                          }
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev Library for reading and writing primitive types to specific storage slots.
                               *
                               * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
                               * This library helps with reading and writing to such slots without the need for inline assembly.
                               *
                               * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
                               *
                               * Example usage to set ERC1967 implementation slot:
                               * ```
                               * contract ERC1967 {
                               *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                               *
                               *     function _getImplementation() internal view returns (address) {
                               *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
                               *     }
                               *
                               *     function _setImplementation(address newImplementation) internal {
                               *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
                               *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
                               *     }
                               * }
                               * ```
                               *
                               * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
                               */
                              library StorageSlot {
                                  struct AddressSlot {
                                      address value;
                                  }
                                  struct BooleanSlot {
                                      bool value;
                                  }
                                  struct Bytes32Slot {
                                      bytes32 value;
                                  }
                                  struct Uint256Slot {
                                      uint256 value;
                                  }
                                  /**
                                   * @dev Returns an `AddressSlot` with member `value` located at `slot`.
                                   */
                                  function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
                                   */
                                  function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
                                   */
                                  function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                                  /**
                                   * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
                                   */
                                  function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
                                      assembly {
                                          r.slot := slot
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/Context.sol";
                              /**
                               * @dev Contract module which provides a basic access control mechanism, where
                               * there is an account (an owner) that can be granted exclusive access to
                               * specific functions.
                               *
                               * By default, the owner account will be the one that deploys the contract. This
                               * can later be changed with {transferOwnership}.
                               *
                               * This module is used through inheritance. It will make available the modifier
                               * `onlyOwner`, which can be applied to your functions to restrict their use to
                               * the owner.
                               */
                              abstract contract Ownable is Context {
                                  address private _owner;
                                  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                                  /**
                                   * @dev Initializes the contract setting the deployer as the initial owner.
                                   */
                                  constructor () {
                                      address msgSender = _msgSender();
                                      _owner = msgSender;
                                      emit OwnershipTransferred(address(0), msgSender);
                                  }
                                  /**
                                   * @dev Returns the address of the current owner.
                                   */
                                  function owner() public view virtual returns (address) {
                                      return _owner;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the owner.
                                   */
                                  modifier onlyOwner() {
                                      require(owner() == _msgSender(), "Ownable: caller is not the owner");
                                      _;
                                  }
                                  /**
                                   * @dev Leaves the contract without owner. It will not be possible to call
                                   * `onlyOwner` functions anymore. Can only be called by the current owner.
                                   *
                                   * NOTE: Renouncing ownership will leave the contract without an owner,
                                   * thereby removing any functionality that is only available to the owner.
                                   */
                                  function renounceOwnership() public virtual onlyOwner {
                                      emit OwnershipTransferred(_owner, address(0));
                                      _owner = address(0);
                                  }
                                  /**
                                   * @dev Transfers ownership of the contract to a new account (`newOwner`).
                                   * Can only be called by the current owner.
                                   */
                                  function transferOwnership(address newOwner) public virtual onlyOwner {
                                      require(newOwner != address(0), "Ownable: new owner is the zero address");
                                      emit OwnershipTransferred(_owner, newOwner);
                                      _owner = newOwner;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              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) {
                                      this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
                                      return msg.data;
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../ERC1967/ERC1967Upgrade.sol";
                              /**
                               * @dev Base contract for building openzeppelin-upgrades compatible implementations for the {ERC1967Proxy}. It includes
                               * publicly available upgrade functions that are called by the plugin and by the secure upgrade mechanism to verify
                               * continuation of the upgradability.
                               *
                               * The {_authorizeUpgrade} function MUST be overridden to include access restriction to the upgrade mechanism.
                               *
                               * _Available since v4.1._
                               */
                              abstract contract UUPSUpgradeable is ERC1967Upgrade {
                                  function upgradeTo(address newImplementation) external virtual {
                                      _authorizeUpgrade(newImplementation);
                                      _upgradeToAndCallSecure(newImplementation, bytes(""), false);
                                  }
                                  function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual {
                                      _authorizeUpgrade(newImplementation);
                                      _upgradeToAndCallSecure(newImplementation, data, true);
                                  }
                                  function _authorizeUpgrade(address newImplementation) internal virtual;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.2;
                              import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
                              abstract contract Proxiable is UUPSUpgradeable {
                                  function _authorizeUpgrade(address newImplementation) internal override {
                                      _beforeUpgrade(newImplementation);
                                  }
                                  function _beforeUpgrade(address newImplementation) internal virtual;
                              }
                              contract ChildOfProxiable is Proxiable {
                                  function _beforeUpgrade(address newImplementation) internal virtual override {}
                              }
                              

                              File 11 of 12: LiquidityPool
                              // $$\\   $$\\                     $$\\                                 $$$$$$$\\                      $$\\
                              // $$ |  $$ |                    $$ |                                $$  __$$\\                     $$ |
                              // $$ |  $$ |$$\\   $$\\  $$$$$$\\  $$$$$$$\\   $$$$$$\\  $$$$$$$\\        $$ |  $$ | $$$$$$\\   $$$$$$\\  $$ |
                              // $$$$$$$$ |$$ |  $$ |$$  __$$\\ $$  __$$\\ $$  __$$\\ $$  __$$\\       $$$$$$$  |$$  __$$\\ $$  __$$\\ $$ |
                              // $$  __$$ |$$ |  $$ |$$ /  $$ |$$ |  $$ |$$$$$$$$ |$$ |  $$ |      $$  ____/ $$ /  $$ |$$ /  $$ |$$ |
                              // $$ |  $$ |$$ |  $$ |$$ |  $$ |$$ |  $$ |$$   ____|$$ |  $$ |      $$ |      $$ |  $$ |$$ |  $$ |$$ |
                              // $$ |  $$ |\\$$$$$$$ |$$$$$$$  |$$ |  $$ |\\$$$$$$$\\ $$ |  $$ |      $$ |      \\$$$$$$  |\\$$$$$$  |$$ |
                              // \\__|  \\__| \\____$$ |$$  ____/ \\__|  \\__| \\_______|\\__|  \\__|      \\__|       \\______/  \\______/ \\__|
                              //           $$\\   $$ |$$ |
                              //           \\$$$$$$  |$$ |
                              //            \\______/ \\__|
                              //
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              pragma abicoder v2;
                              import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                              import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
                              import "./metatx/ERC2771ContextUpgradeable.sol";
                              import "../security/Pausable.sol";
                              import "./structures/TokenConfig.sol";
                              import "./interfaces/IExecutorManager.sol";
                              import "./interfaces/ILiquidityProviders.sol";
                              import "../interfaces/IERC20Permit.sol";
                              import "./interfaces/ITokenManager.sol";
                              import "./interfaces/ISwapAdaptor.sol";
                              contract LiquidityPool is
                                  Initializable,
                                  ReentrancyGuardUpgradeable,
                                  Pausable,
                                  OwnableUpgradeable,
                                  ERC2771ContextUpgradeable
                              {
                                  address private constant NATIVE = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
                                  uint256 private constant BASE_DIVISOR = 10000000000; // Basis Points * 100 for better accuracy
                                  uint256 private constant TOKEN_PRICE_BASE_DIVISOR = 10**28;
                                  uint256 public baseGas;
                                  IExecutorManager private executorManager;
                                  ITokenManager public tokenManager;
                                  ILiquidityProviders public liquidityProviders;
                                  struct PermitRequest {
                                      uint256 nonce;
                                      uint256 expiry;
                                      bool allowed;
                                      uint8 v;
                                      bytes32 r;
                                      bytes32 s;
                                  }
                                  mapping(bytes32 => bool) public processedHash;
                                  mapping(address => uint256) public gasFeeAccumulatedByToken;
                                  // Gas fee accumulated by token address => executor address
                                  mapping(address => mapping(address => uint256)) public gasFeeAccumulated;
                                  // Incentive Pool amount per token address
                                  mapping(address => uint256) public incentivePool;
                                  mapping(string => address) public swapAdaptorMap;
                                  event AssetSent(
                                      address indexed asset,
                                      uint256 indexed amount,
                                      uint256 indexed transferredAmount,
                                      address target,
                                      bytes depositHash,
                                      uint256 fromChainId,
                                      uint256 lpFee,
                                      uint256 transferFee,
                                      uint256 gasFee
                                  );
                                  event Received(address indexed from, uint256 indexed amount);
                                  event Deposit(
                                      address indexed from,
                                      address indexed tokenAddress,
                                      address indexed receiver,
                                      uint256 toChainId,
                                      uint256 amount,
                                      uint256 reward,
                                      string tag
                                  );
                                  event GasFeeWithdraw(address indexed tokenAddress, address indexed owner, uint256 indexed amount);
                                  event LiquidityProvidersChanged(address indexed liquidityProvidersAddress);
                                  event TokenManagerChanged(address indexed tokenManagerAddress);
                                  event BaseGasUpdated(uint256 indexed baseGas);
                                  event EthReceived(address, uint256);
                                  event DepositAndSwap(
                                      address indexed from,
                                      address indexed tokenAddress,
                                      address indexed receiver,
                                      uint256 toChainId,
                                      uint256 amount,
                                      uint256 reward,
                                      string tag,
                                      SwapRequest[] swapRequests
                                  );
                                  event SwapAdaptorChanged(string indexed name, address indexed liquidityProvidersAddress);
                                  event GasFeeCalculated(
                                      uint256 indexed gasUsed,
                                      uint256 indexed gasPrice,
                                      uint256 indexed nativeTokenPriceInTransferredToken,
                                      uint256 tokenGasBaseFee,
                                      uint256 gasFeeInTransferredToken
                                  );
                                  // MODIFIERS
                                  modifier onlyExecutor() {
                                      require(executorManager.getExecutorStatus(_msgSender()), "Only executor is allowed");
                                      _;
                                  }
                                  modifier onlyLiquidityProviders() {
                                      require(_msgSender() == address(liquidityProviders), "Only liquidityProviders is allowed");
                                      _;
                                  }
                                  modifier tokenChecks(address tokenAddress) {
                                      (, bool supportedToken, , , ) = tokenManager.tokensInfo(tokenAddress);
                                      require(supportedToken, "Token not supported");
                                      _;
                                  }
                                  function initialize(
                                      address _executorManagerAddress,
                                      address _pauser,
                                      address _trustedForwarder,
                                      address _tokenManager,
                                      address _liquidityProviders
                                  ) public initializer {
                                      require(_executorManagerAddress != address(0), "ExecutorManager cannot be 0x0");
                                      require(_trustedForwarder != address(0), "TrustedForwarder cannot be 0x0");
                                      require(_liquidityProviders != address(0), "LiquidityProviders cannot be 0x0");
                                      __ERC2771Context_init(_trustedForwarder);
                                      __ReentrancyGuard_init();
                                      __Ownable_init();
                                      __Pausable_init(_pauser);
                                      executorManager = IExecutorManager(_executorManagerAddress);
                                      tokenManager = ITokenManager(_tokenManager);
                                      liquidityProviders = ILiquidityProviders(_liquidityProviders);
                                      baseGas = 21000;
                                  }
                                  function setSwapAdaptor(string calldata name, address _swapAdaptor) external onlyOwner {
                                      swapAdaptorMap[name] = _swapAdaptor;
                                      emit SwapAdaptorChanged(name, _swapAdaptor);
                                  }
                                  function setTrustedForwarder(address trustedForwarder) external onlyOwner {
                                      _setTrustedForwarder(trustedForwarder);
                                  }
                                  function setLiquidityProviders(address _liquidityProviders) external onlyOwner {
                                      require(_liquidityProviders != address(0), "LiquidityProviders can't be 0");
                                      liquidityProviders = ILiquidityProviders(_liquidityProviders);
                                      emit LiquidityProvidersChanged(_liquidityProviders);
                                  }
                                  function setTokenManager(address _tokenManager) external onlyOwner {
                                      require(_tokenManager != address(0), "TokenManager can't be 0");
                                      tokenManager = ITokenManager(_tokenManager);
                                      emit TokenManagerChanged(_tokenManager);
                                  }
                                  function setBaseGas(uint128 gas) external onlyOwner {
                                      baseGas = gas;
                                      emit BaseGasUpdated(baseGas);
                                  }
                                  function getExecutorManager() external view returns (address) {
                                      return address(executorManager);
                                  }
                                  function setExecutorManager(address _executorManagerAddress) external onlyOwner {
                                      require(_executorManagerAddress != address(0), "Executor Manager cannot be 0");
                                      executorManager = IExecutorManager(_executorManagerAddress);
                                  }
                                  function getCurrentLiquidity(address tokenAddress) public view returns (uint256 currentLiquidity) {
                                      uint256 liquidityPoolBalance = liquidityProviders.getCurrentLiquidity(tokenAddress);
                                      currentLiquidity =
                                          liquidityPoolBalance -
                                          liquidityProviders.totalLPFees(tokenAddress) -
                                          gasFeeAccumulatedByToken[tokenAddress] -
                                          incentivePool[tokenAddress];
                                  }
                                  /**
                                   * @dev Function used to deposit tokens into pool to initiate a cross chain token transfer.
                                   * @param toChainId Chain id where funds needs to be transfered
                                   * @param tokenAddress ERC20 Token address that needs to be transfered
                                   * @param receiver Address on toChainId where tokens needs to be transfered
                                   * @param amount Amount of token being transfered
                                   */
                                  function depositErc20(
                                      uint256 toChainId,
                                      address tokenAddress,
                                      address receiver,
                                      uint256 amount,
                                      string calldata tag
                                  ) public tokenChecks(tokenAddress) whenNotPaused nonReentrant {
                                      address sender = _msgSender();
                                      uint256 rewardAmount = _depositErc20(sender, toChainId, tokenAddress, receiver, amount);
                                      // Emit (amount + reward amount) in event
                                      emit Deposit(sender, tokenAddress, receiver, toChainId, amount + rewardAmount, rewardAmount, tag);
                                  }
                                  /**
                                   * @dev Function used to deposit tokens into pool to initiate a cross chain token swap And transfer .
                                   * @param toChainId Chain id where funds needs to be transfered
                                   * @param tokenAddress ERC20 Token address that needs to be transfered
                                   * @param receiver Address on toChainId where tokens needs to be transfered
                                   * @param amount Amount of token being transfered
                                   * @param tag Dapp unique identifier
                                   * @param swapRequest information related to token swap on exit chain
                                   */
                                  function depositAndSwapErc20(
                                      address tokenAddress,
                                      address receiver,
                                      uint256 toChainId,
                                      uint256 amount,
                                      string calldata tag,
                                      SwapRequest[] calldata swapRequest
                                  ) external tokenChecks(tokenAddress) whenNotPaused nonReentrant {
                                      uint256 totalPercentage = 0;
                                      {
                                          uint256 swapArrayLength = swapRequest.length;
                                          unchecked {
                                              for (uint256 index = 0; index < swapArrayLength; ++index) {
                                                  totalPercentage += swapRequest[index].percentage;
                                              }
                                          }
                                      }
                                      require(totalPercentage <= 100 * BASE_DIVISOR, "Total percentage cannot be > 100");
                                      address sender = _msgSender();
                                      uint256 rewardAmount = _depositErc20(sender, toChainId, tokenAddress, receiver, amount);
                                      // Emit (amount + reward amount) in event
                                      emit DepositAndSwap(
                                          sender,
                                          tokenAddress,
                                          receiver,
                                          toChainId,
                                          amount + rewardAmount,
                                          rewardAmount,
                                          tag,
                                          swapRequest
                                      );
                                  }
                                  function _depositErc20(
                                      address sender,
                                      uint256 toChainId,
                                      address tokenAddress,
                                      address receiver,
                                      uint256 amount
                                  ) internal returns (uint256) {
                                      require(toChainId != block.chainid, "To chain must be different than current chain");
                                      require(tokenAddress != NATIVE, "wrong function");
                                      TokenConfig memory config = tokenManager.getDepositConfig(toChainId, tokenAddress);
                                      require(config.min <= amount && config.max >= amount, "Deposit amount not in Cap limit");
                                      require(receiver != address(0), "Receiver address cannot be 0");
                                      require(amount != 0, "Amount cannot be 0");
                                      uint256 rewardAmount = getRewardAmount(amount, tokenAddress);
                                      if (rewardAmount != 0) {
                                          incentivePool[tokenAddress] = incentivePool[tokenAddress] - rewardAmount;
                                      }
                                      liquidityProviders.increaseCurrentLiquidity(tokenAddress, amount);
                                      SafeERC20Upgradeable.safeTransferFrom(IERC20Upgradeable(tokenAddress), sender, address(this), amount);
                                      return rewardAmount;
                                  }
                                  function getRewardAmount(uint256 amount, address tokenAddress) public view returns (uint256 rewardAmount) {
                                      uint256 currentLiquidity = getCurrentLiquidity(tokenAddress);
                                      uint256 providedLiquidity = liquidityProviders.getSuppliedLiquidityByToken(tokenAddress);
                                      if (currentLiquidity < providedLiquidity) {
                                          uint256 liquidityDifference = providedLiquidity - currentLiquidity;
                                          if (amount >= liquidityDifference) {
                                              rewardAmount = incentivePool[tokenAddress];
                                          } else {
                                              // Multiply by 10000000000 to avoid 0 reward amount for small amount and liquidity difference
                                              rewardAmount = (amount * incentivePool[tokenAddress] * 10000000000) / liquidityDifference;
                                              rewardAmount = rewardAmount / 10000000000;
                                          }
                                      }
                                  }
                                  /**
                                   * DAI permit and Deposit.
                                   */
                                  function permitAndDepositErc20(
                                      address tokenAddress,
                                      address receiver,
                                      uint256 amount,
                                      uint256 toChainId,
                                      PermitRequest calldata permitOptions,
                                      string calldata tag
                                  ) external {
                                      IERC20Permit(tokenAddress).permit(
                                          _msgSender(),
                                          address(this),
                                          permitOptions.nonce,
                                          permitOptions.expiry,
                                          permitOptions.allowed,
                                          permitOptions.v,
                                          permitOptions.r,
                                          permitOptions.s
                                      );
                                      depositErc20(toChainId, tokenAddress, receiver, amount, tag);
                                  }
                                  /**
                                   * EIP2612 and Deposit.
                                   */
                                  function permitEIP2612AndDepositErc20(
                                      address tokenAddress,
                                      address receiver,
                                      uint256 amount,
                                      uint256 toChainId,
                                      PermitRequest calldata permitOptions,
                                      string calldata tag
                                  ) external {
                                      IERC20Permit(tokenAddress).permit(
                                          _msgSender(),
                                          address(this),
                                          amount,
                                          permitOptions.expiry,
                                          permitOptions.v,
                                          permitOptions.r,
                                          permitOptions.s
                                      );
                                      depositErc20(toChainId, tokenAddress, receiver, amount, tag);
                                  }
                                  /**
                                   * @dev Function used to deposit native token into pool to initiate a cross chain token transfer.
                                   * @param receiver Address on toChainId where tokens needs to be transfered
                                   * @param toChainId Chain id where funds needs to be transfered
                                   */
                                  function depositNative(
                                      address receiver,
                                      uint256 toChainId,
                                      string calldata tag
                                  ) external payable whenNotPaused nonReentrant {
                                      uint256 rewardAmount = _depositNative(receiver, toChainId);
                                      emit Deposit(_msgSender(), NATIVE, receiver, toChainId, msg.value + rewardAmount, rewardAmount, tag);
                                  }
                                  function depositNativeAndSwap(
                                      address receiver,
                                      uint256 toChainId,
                                      string calldata tag,
                                      SwapRequest[] calldata swapRequest
                                  ) external payable whenNotPaused nonReentrant {
                                      uint256 totalPercentage = 0;
                                      {
                                          uint256 swapArrayLength = swapRequest.length;
                                          unchecked {
                                              for (uint256 index = 0; index < swapArrayLength; ++index) {
                                                  totalPercentage += swapRequest[index].percentage;
                                              }
                                          }
                                      }
                                      require(totalPercentage <= 100 * BASE_DIVISOR, "Total percentage cannot be > 100");
                                      uint256 rewardAmount = _depositNative(receiver, toChainId); // TODO: check if need to pass msg.value
                                      emit DepositAndSwap(
                                          _msgSender(),
                                          NATIVE,
                                          receiver,
                                          toChainId,
                                          msg.value + rewardAmount,
                                          rewardAmount,
                                          tag,
                                          swapRequest
                                      );
                                  }
                                  function _depositNative(address receiver, uint256 toChainId) internal returns (uint256) {
                                      require(toChainId != block.chainid, "To chain must be different than current chain");
                                      require(
                                          tokenManager.getDepositConfig(toChainId, NATIVE).min <= msg.value &&
                                              tokenManager.getDepositConfig(toChainId, NATIVE).max >= msg.value,
                                          "Deposit amount not in Cap limit"
                                      );
                                      require(receiver != address(0), "Receiver address cannot be 0");
                                      require(msg.value != 0, "Amount cannot be 0");
                                      uint256 rewardAmount = getRewardAmount(msg.value, NATIVE);
                                      if (rewardAmount != 0) {
                                          incentivePool[NATIVE] = incentivePool[NATIVE] - rewardAmount;
                                      }
                                      liquidityProviders.increaseCurrentLiquidity(NATIVE, msg.value);
                                      return rewardAmount;
                                  }
                                  function sendFundsToUser(
                                      address tokenAddress,
                                      uint256 amount,
                                      address payable receiver,
                                      bytes calldata depositHash,
                                      uint256 tokenGasPrice,
                                      uint256 fromChainId
                                  ) external nonReentrant onlyExecutor whenNotPaused {
                                      uint256 initialGas = gasleft();
                                      TokenConfig memory config = tokenManager.getTransferConfig(tokenAddress);
                                      require(config.min <= amount && config.max >= amount, "Withdraw amount not in Cap limit");
                                      require(receiver != address(0), "Bad receiver address");
                                      (bytes32 hashSendTransaction, bool status) = checkHashStatus(tokenAddress, amount, receiver, depositHash);
                                      require(!status, "Already Processed");
                                      processedHash[hashSendTransaction] = true;
                                      // uint256 amountToTransfer, uint256 lpFee, uint256 transferFeeAmount, uint256 gasFee
                                      uint256[4] memory transferDetails = getAmountToTransfer(initialGas, tokenAddress, amount, tokenGasPrice);
                                      liquidityProviders.decreaseCurrentLiquidity(tokenAddress, transferDetails[0]);
                                      if (tokenAddress == NATIVE) {
                                          (bool success, ) = receiver.call{value: transferDetails[0]}("");
                                          require(success, "Native Transfer Failed");
                                      } else {
                                          SafeERC20Upgradeable.safeTransfer(IERC20Upgradeable(tokenAddress), receiver, transferDetails[0]);
                                      }
                                      emit AssetSent(
                                          tokenAddress,
                                          amount,
                                          transferDetails[0],
                                          receiver,
                                          depositHash,
                                          fromChainId,
                                          transferDetails[1],
                                          transferDetails[2],
                                          transferDetails[3]
                                      );
                                  }
                                  /**
                                   * @dev Internal function to calculate amount of token that needs to be transfered afetr deducting all required fees.
                                   * Fee to be deducted includes gas fee, lp fee and incentive pool amount if needed.
                                   * @param initialGas Gas provided initially before any calculations began
                                   * @param tokenAddress Token address for which calculation needs to be done
                                   * @param amount Amount of token to be transfered before deducting the fee
                                   * @param tokenGasPrice Gas price in the token being transfered to be used to calculate gas fee
                                   * @return [ amountToTransfer, lpFee, transferFeeAmount, gasFee ]
                                   */
                                  function getAmountToTransfer(
                                      uint256 initialGas,
                                      address tokenAddress,
                                      uint256 amount,
                                      uint256 tokenGasPrice
                                  ) internal returns (uint256[4] memory) {
                                      TokenInfo memory tokenInfo = tokenManager.getTokensInfo(tokenAddress);
                                      uint256 transferFeePerc = _getTransferFee(tokenAddress, amount, tokenInfo);
                                      uint256 lpFee;
                                      if (transferFeePerc > tokenInfo.equilibriumFee) {
                                          // Here add some fee to incentive pool also
                                          lpFee = (amount * tokenInfo.equilibriumFee) / BASE_DIVISOR;
                                          unchecked {
                                              incentivePool[tokenAddress] += (amount * (transferFeePerc - tokenInfo.equilibriumFee)) / BASE_DIVISOR;
                                          }
                                      } else {
                                          lpFee = (amount * transferFeePerc) / BASE_DIVISOR;
                                      }
                                      uint256 transferFeeAmount = (amount * transferFeePerc) / BASE_DIVISOR;
                                      liquidityProviders.addLPFee(tokenAddress, lpFee);
                                      uint256 totalGasUsed = initialGas + tokenInfo.transferOverhead + baseGas - gasleft();
                                      uint256 gasFee = totalGasUsed * tokenGasPrice;
                                      gasFeeAccumulatedByToken[tokenAddress] += gasFee;
                                      gasFeeAccumulated[tokenAddress][_msgSender()] += gasFee;
                                      uint256 amountToTransfer = amount - (transferFeeAmount + gasFee);
                                      return [amountToTransfer, lpFee, transferFeeAmount, gasFee];
                                  }
                                  function sendFundsToUserV2(
                                      address tokenAddress,
                                      uint256 amount,
                                      address payable receiver,
                                      bytes calldata depositHash,
                                      uint256 nativeTokenPriceInTransferredToken,
                                      uint256 fromChainId,
                                      uint256 tokenGasBaseFee
                                  ) external nonReentrant onlyExecutor whenNotPaused {
                                      uint256[4] memory transferDetails = _calculateAmountAndDecreaseAvailableLiquidity(
                                          tokenAddress,
                                          amount,
                                          receiver,
                                          depositHash,
                                          nativeTokenPriceInTransferredToken,
                                          tokenGasBaseFee
                                      );
                                      if (tokenAddress == NATIVE) {
                                          (bool success, ) = receiver.call{value: transferDetails[0]}("");
                                          require(success, "Native Transfer Failed");
                                      } else {
                                          SafeERC20Upgradeable.safeTransfer(IERC20Upgradeable(tokenAddress), receiver, transferDetails[0]);
                                      }
                                      emit AssetSent(
                                          tokenAddress,
                                          amount,
                                          transferDetails[0],
                                          receiver,
                                          depositHash,
                                          fromChainId,
                                          transferDetails[1],
                                          transferDetails[2],
                                          transferDetails[3]
                                      );
                                  }
                                  function swapAndSendFundsToUser(
                                      address tokenAddress,
                                      uint256 amount,
                                      address payable receiver,
                                      bytes calldata depositHash,
                                      uint256 nativeTokenPriceInTransferredToken,
                                      uint256 tokenGasBaseFee,
                                      uint256 fromChainId,
                                      uint256 swapGasOverhead,
                                      SwapRequest[] calldata swapRequests,
                                      string memory swapAdaptor
                                  ) external nonReentrant onlyExecutor whenNotPaused {
                                      require(swapRequests.length > 0, "Wrong method call");
                                      require(swapAdaptorMap[swapAdaptor] != address(0), "Swap adaptor not found");
                                      uint256[4] memory transferDetails = _calculateAmountAndDecreaseAvailableLiquidity(
                                          tokenAddress,
                                          amount,
                                          receiver,
                                          depositHash,
                                          nativeTokenPriceInTransferredToken,
                                          tokenGasBaseFee
                                      );
                                      if (tokenAddress == NATIVE) {
                                          (bool success, ) = swapAdaptorMap[swapAdaptor].call{value: transferDetails[0]}("");
                                          require(success, "Native Transfer to Adaptor Failed");
                                          ISwapAdaptor(swapAdaptorMap[swapAdaptor]).swapNative(transferDetails[0], receiver, swapRequests);
                                      } else {
                                          {
                                              uint256 gasBeforeApproval = gasleft();
                                              SafeERC20Upgradeable.safeApprove(
                                                  IERC20Upgradeable(tokenAddress),
                                                  address(swapAdaptorMap[swapAdaptor]),
                                                  0
                                              );
                                              SafeERC20Upgradeable.safeApprove(
                                                  IERC20Upgradeable(tokenAddress),
                                                  address(swapAdaptorMap[swapAdaptor]),
                                                  transferDetails[0]
                                              );
                                              swapGasOverhead += (gasBeforeApproval - gasleft());
                                          }
                                          {
                                              uint256 swapGasFee = calculateGasFee(
                                                  tokenAddress,
                                                  nativeTokenPriceInTransferredToken,
                                                  swapGasOverhead,
                                                  0,
                                                  _msgSender()
                                              );
                                              transferDetails[0] -= swapGasFee; // Deduct swap gas fee from amount to be sent
                                              transferDetails[3] += swapGasFee; // Add swap gas fee to gas fee
                                          }
                                          ISwapAdaptor(swapAdaptorMap[swapAdaptor]).swap(tokenAddress, transferDetails[0], receiver, swapRequests);
                                      }
                                      emit AssetSent(
                                          tokenAddress,
                                          amount,
                                          transferDetails[0],
                                          receiver,
                                          depositHash,
                                          fromChainId,
                                          transferDetails[1],
                                          transferDetails[2],
                                          transferDetails[3]
                                      );
                                  }
                                  function _calculateAmountAndDecreaseAvailableLiquidity(
                                      address tokenAddress,
                                      uint256 amount,
                                      address payable receiver,
                                      bytes calldata depositHash,
                                      uint256 nativeTokenPriceInTransferredToken,
                                      uint256 tokenGasBaseFee
                                  ) internal returns (uint256[4] memory) {
                                      uint256 initialGas = gasleft();
                                      TokenConfig memory config = tokenManager.getTransferConfig(tokenAddress);
                                      require(config.min <= amount && config.max >= amount, "Withdraw amount not in Cap limit");
                                      require(receiver != address(0), "Bad receiver address");
                                      (bytes32 hashSendTransaction, bool status) = checkHashStatus(tokenAddress, amount, receiver, depositHash);
                                      require(!status, "Already Processed");
                                      processedHash[hashSendTransaction] = true;
                                      // uint256 amountToTransfer, uint256 lpFee, uint256 transferFeeAmount, uint256 gasFee
                                      uint256[4] memory transferDetails = getAmountToTransferV2(
                                          initialGas,
                                          tokenAddress,
                                          amount,
                                          nativeTokenPriceInTransferredToken,
                                          tokenGasBaseFee
                                      );
                                      liquidityProviders.decreaseCurrentLiquidity(tokenAddress, transferDetails[0]);
                                      return transferDetails;
                                  }
                                  /**
                                   * @dev Internal function to calculate amount of token that needs to be transfered afetr deducting all required fees.
                                   * Fee to be deducted includes gas fee, lp fee and incentive pool amount if needed.
                                   * @param initialGas Gas provided initially before any calculations began
                                   * @param tokenAddress Token address for which calculation needs to be done
                                   * @param amount Amount of token to be transfered before deducting the fee
                                   * @param nativeTokenPriceInTransferredToken Price of native token in terms of the token being transferred (multiplied base div), used to calculate gas fee
                                   * @return [ amountToTransfer, lpFee, transferFeeAmount, gasFee ]
                                   */
                                  function getAmountToTransferV2(
                                      uint256 initialGas,
                                      address tokenAddress,
                                      uint256 amount,
                                      uint256 nativeTokenPriceInTransferredToken,
                                      uint256 tokenGasBaseFee
                                  ) internal returns (uint256[4] memory) {
                                      TokenInfo memory tokenInfo = tokenManager.getTokensInfo(tokenAddress);
                                      uint256 transferFeePerc = _getTransferFee(tokenAddress, amount, tokenInfo);
                                      uint256 lpFee;
                                      if (transferFeePerc > tokenInfo.equilibriumFee) {
                                          // Here add some fee to incentive pool also
                                          lpFee = (amount * tokenInfo.equilibriumFee) / BASE_DIVISOR;
                                          unchecked {
                                              incentivePool[tokenAddress] += (amount * (transferFeePerc - tokenInfo.equilibriumFee)) / BASE_DIVISOR;
                                          }
                                      } else {
                                          lpFee = (amount * transferFeePerc) / BASE_DIVISOR;
                                      }
                                      uint256 transferFeeAmount = (amount * transferFeePerc) / BASE_DIVISOR;
                                      liquidityProviders.addLPFee(tokenAddress, lpFee);
                                      uint256 totalGasUsed = initialGas + tokenInfo.transferOverhead + baseGas - gasleft();
                                      uint256 gasFee = calculateGasFee(
                                          tokenAddress,
                                          nativeTokenPriceInTransferredToken,
                                          totalGasUsed,
                                          tokenGasBaseFee,
                                          _msgSender()
                                      );
                                      require(transferFeeAmount + gasFee <= amount, "Insufficient funds to cover transfer fee");
                                      unchecked {
                                          uint256 amountToTransfer = amount - (transferFeeAmount + gasFee);
                                          return [amountToTransfer, lpFee, transferFeeAmount, gasFee];
                                      }
                                  }
                                  function calculateGasFee(
                                      address tokenAddress,
                                      uint256 nativeTokenPriceInTransferredToken,
                                      uint256 gasUsed,
                                      uint256 tokenGasBaseFee,
                                      address sender
                                  ) internal returns (uint256) {
                                      uint256 gasFee = (gasUsed * nativeTokenPriceInTransferredToken * tx.gasprice) /
                                          TOKEN_PRICE_BASE_DIVISOR +
                                          tokenGasBaseFee;
                                      emit GasFeeCalculated(gasUsed, tx.gasprice, nativeTokenPriceInTransferredToken, tokenGasBaseFee, gasFee);
                                      gasFeeAccumulatedByToken[tokenAddress] += gasFee;
                                      gasFeeAccumulated[tokenAddress][sender] += gasFee;
                                      return gasFee;
                                  }
                                  function _getTransferFee(
                                      address tokenAddress,
                                      uint256 amount,
                                      TokenInfo memory tokenInfo
                                  ) private view returns (uint256) {
                                      uint256 currentLiquidity = getCurrentLiquidity(tokenAddress);
                                      uint256 providedLiquidity = liquidityProviders.getSuppliedLiquidityByToken(tokenAddress);
                                      uint256 resultingLiquidity = currentLiquidity - amount;
                                      // We return a constant value in excess state
                                      if (resultingLiquidity > providedLiquidity) {
                                          return tokenManager.excessStateTransferFeePerc(tokenAddress);
                                      }
                                      // Fee is represented in basis points * 10 for better accuracy
                                      uint256 numerator = providedLiquidity * providedLiquidity * tokenInfo.equilibriumFee * tokenInfo.maxFee; // F(max) * F(e) * L(e) ^ 2
                                      uint256 denominator = tokenInfo.equilibriumFee *
                                          providedLiquidity *
                                          providedLiquidity +
                                          (tokenInfo.maxFee - tokenInfo.equilibriumFee) *
                                          resultingLiquidity *
                                          resultingLiquidity; // F(e) * L(e) ^ 2 + (F(max) - F(e)) * L(r) ^ 2
                                      uint256 fee;
                                      if (denominator == 0) {
                                          fee = 0;
                                      } else {
                                          fee = numerator / denominator;
                                      }
                                      return fee;
                                  }
                                  function getTransferFee(address tokenAddress, uint256 amount) external view returns (uint256) {
                                      return _getTransferFee(tokenAddress, amount, tokenManager.getTokensInfo(tokenAddress));
                                  }
                                  function checkHashStatus(
                                      address tokenAddress,
                                      uint256 amount,
                                      address payable receiver,
                                      bytes calldata depositHash
                                  ) public view returns (bytes32 hashSendTransaction, bool status) {
                                      hashSendTransaction = keccak256(abi.encode(tokenAddress, amount, receiver, keccak256(depositHash)));
                                      status = processedHash[hashSendTransaction];
                                  }
                                  function withdrawErc20GasFee(address tokenAddress) external onlyExecutor whenNotPaused nonReentrant {
                                      require(tokenAddress != NATIVE, "Can't withdraw native token fee");
                                      // uint256 gasFeeAccumulated = gasFeeAccumulatedByToken[tokenAddress];
                                      uint256 _gasFeeAccumulated = gasFeeAccumulated[tokenAddress][_msgSender()];
                                      require(_gasFeeAccumulated != 0, "Gas Fee earned is 0");
                                      gasFeeAccumulatedByToken[tokenAddress] = gasFeeAccumulatedByToken[tokenAddress] - _gasFeeAccumulated;
                                      gasFeeAccumulated[tokenAddress][_msgSender()] = 0;
                                      SafeERC20Upgradeable.safeTransfer(IERC20Upgradeable(tokenAddress), _msgSender(), _gasFeeAccumulated);
                                      emit GasFeeWithdraw(tokenAddress, _msgSender(), _gasFeeAccumulated);
                                  }
                                  function withdrawNativeGasFee() external onlyExecutor whenNotPaused nonReentrant {
                                      uint256 _gasFeeAccumulated = gasFeeAccumulated[NATIVE][_msgSender()];
                                      require(_gasFeeAccumulated != 0, "Gas Fee earned is 0");
                                      gasFeeAccumulatedByToken[NATIVE] = gasFeeAccumulatedByToken[NATIVE] - _gasFeeAccumulated;
                                      gasFeeAccumulated[NATIVE][_msgSender()] = 0;
                                      (bool success, ) = payable(_msgSender()).call{value: _gasFeeAccumulated}("");
                                      require(success, "Native Transfer Failed");
                                      emit GasFeeWithdraw(address(this), _msgSender(), _gasFeeAccumulated);
                                  }
                                  function transfer(
                                      address _tokenAddress,
                                      address receiver,
                                      uint256 _tokenAmount
                                  ) external whenNotPaused onlyLiquidityProviders nonReentrant {
                                      require(receiver != address(0), "Invalid receiver");
                                      if (_tokenAddress == NATIVE) {
                                          require(address(this).balance >= _tokenAmount, "ERR__INSUFFICIENT_BALANCE");
                                          (bool success, ) = receiver.call{value: _tokenAmount}("");
                                          require(success, "ERR__NATIVE_TRANSFER_FAILED");
                                      } else {
                                          IERC20Upgradeable baseToken = IERC20Upgradeable(_tokenAddress);
                                          require(baseToken.balanceOf(address(this)) >= _tokenAmount, "ERR__INSUFFICIENT_BALANCE");
                                          SafeERC20Upgradeable.safeTransfer(baseToken, receiver, _tokenAmount);
                                      }
                                  }
                                  function _msgSender()
                                      internal
                                      view
                                      virtual
                                      override(ContextUpgradeable, ERC2771ContextUpgradeable)
                                      returns (address sender)
                                  {
                                      return ERC2771ContextUpgradeable._msgSender();
                                  }
                                  function _msgData()
                                      internal
                                      view
                                      virtual
                                      override(ContextUpgradeable, ERC2771ContextUpgradeable)
                                      returns (bytes calldata)
                                  {
                                      return ERC2771ContextUpgradeable._msgData();
                                  }
                                  receive() external payable {
                                      emit EthReceived(_msgSender(), msg.value);
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
                               * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
                               * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
                               * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
                               *
                               * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
                               * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
                               *
                               * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
                               * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
                               */
                              abstract contract Initializable {
                                  /**
                                   * @dev Indicates that the contract has been initialized.
                                   */
                                  bool private _initialized;
                                  /**
                                   * @dev Indicates that the contract is in the process of being initialized.
                                   */
                                  bool private _initializing;
                                  /**
                                   * @dev Modifier to protect an initializer function from being invoked twice.
                                   */
                                  modifier initializer() {
                                      require(_initializing || !_initialized, "Initializable: contract is already initialized");
                                      bool isTopLevelCall = !_initializing;
                                      if (isTopLevelCall) {
                                          _initializing = true;
                                          _initialized = true;
                                      }
                                      _;
                                      if (isTopLevelCall) {
                                          _initializing = false;
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/ContextUpgradeable.sol";
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module which provides a basic access control mechanism, where
                               * there is an account (an owner) that can be granted exclusive access to
                               * specific functions.
                               *
                               * By default, the owner account will be the one that deploys the contract. This
                               * can later be changed with {transferOwnership}.
                               *
                               * This module is used through inheritance. It will make available the modifier
                               * `onlyOwner`, which can be applied to your functions to restrict their use to
                               * the owner.
                               */
                              abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
                                  address private _owner;
                                  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                                  /**
                                   * @dev Initializes the contract setting the deployer as the initial owner.
                                   */
                                  function __Ownable_init() internal initializer {
                                      __Context_init_unchained();
                                      __Ownable_init_unchained();
                                  }
                                  function __Ownable_init_unchained() internal initializer {
                                      _setOwner(_msgSender());
                                  }
                                  /**
                                   * @dev Returns the address of the current owner.
                                   */
                                  function owner() public view virtual returns (address) {
                                      return _owner;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the owner.
                                   */
                                  modifier onlyOwner() {
                                      require(owner() == _msgSender(), "Ownable: caller is not the owner");
                                      _;
                                  }
                                  /**
                                   * @dev Leaves the contract without owner. It will not be possible to call
                                   * `onlyOwner` functions anymore. Can only be called by the current owner.
                                   *
                                   * NOTE: Renouncing ownership will leave the contract without an owner,
                                   * thereby removing any functionality that is only available to the owner.
                                   */
                                  function renounceOwnership() public virtual onlyOwner {
                                      _setOwner(address(0));
                                  }
                                  /**
                                   * @dev Transfers ownership of the contract to a new account (`newOwner`).
                                   * Can only be called by the current owner.
                                   */
                                  function transferOwnership(address newOwner) public virtual onlyOwner {
                                      require(newOwner != address(0), "Ownable: new owner is the zero address");
                                      _setOwner(newOwner);
                                  }
                                  function _setOwner(address newOwner) private {
                                      address oldOwner = _owner;
                                      _owner = newOwner;
                                      emit OwnershipTransferred(oldOwner, newOwner);
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module that helps prevent reentrant calls to a function.
                               *
                               * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
                               * available, which can be applied to functions to make sure there are no nested
                               * (reentrant) calls to them.
                               *
                               * Note that because there is a single `nonReentrant` guard, functions marked as
                               * `nonReentrant` may not call one another. This can be worked around by making
                               * those functions `private`, and then adding `external` `nonReentrant` entry
                               * points to them.
                               *
                               * TIP: If you would like to learn more about reentrancy and alternative ways
                               * to protect against it, check out our blog post
                               * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
                               */
                              abstract contract ReentrancyGuardUpgradeable is Initializable {
                                  // Booleans are more expensive than uint256 or any type that takes up a full
                                  // word because each write operation emits an extra SLOAD to first read the
                                  // slot's contents, replace the bits taken up by the boolean, and then write
                                  // back. This is the compiler's defense against contract upgrades and
                                  // pointer aliasing, and it cannot be disabled.
                                  // The values being non-zero value makes deployment a bit more expensive,
                                  // but in exchange the refund on every call to nonReentrant will be lower in
                                  // amount. Since refunds are capped to a percentage of the total
                                  // transaction's gas, it is best to keep them low in cases like this one, to
                                  // increase the likelihood of the full refund coming into effect.
                                  uint256 private constant _NOT_ENTERED = 1;
                                  uint256 private constant _ENTERED = 2;
                                  uint256 private _status;
                                  function __ReentrancyGuard_init() internal initializer {
                                      __ReentrancyGuard_init_unchained();
                                  }
                                  function __ReentrancyGuard_init_unchained() internal initializer {
                                      _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 make it call a
                                   * `private` function that does the actual work.
                                   */
                                  modifier nonReentrant() {
                                      // On the first call to nonReentrant, _notEntered will be true
                                      require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
                                      // Any calls to nonReentrant after this point will fail
                                      _status = _ENTERED;
                                      _;
                                      // By storing the original value once again, a refund is triggered (see
                                      // https://eips.ethereum.org/EIPS/eip-2200)
                                      _status = _NOT_ENTERED;
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../IERC20Upgradeable.sol";
                              import "../../../utils/AddressUpgradeable.sol";
                              /**
                               * @title SafeERC20
                               * @dev Wrappers around ERC20 operations that throw on failure (when the token
                               * contract returns false). Tokens that return no value (and instead revert or
                               * throw on failure) are also supported, non-reverting calls are assumed to be
                               * successful.
                               * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
                               * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
                               */
                              library SafeERC20Upgradeable {
                                  using AddressUpgradeable for address;
                                  function safeTransfer(
                                      IERC20Upgradeable token,
                                      address to,
                                      uint256 value
                                  ) internal {
                                      _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
                                  }
                                  function safeTransferFrom(
                                      IERC20Upgradeable token,
                                      address from,
                                      address to,
                                      uint256 value
                                  ) internal {
                                      _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
                                  }
                                  /**
                                   * @dev Deprecated. This function has issues similar to the ones found in
                                   * {IERC20-approve}, and its usage is discouraged.
                                   *
                                   * Whenever possible, use {safeIncreaseAllowance} and
                                   * {safeDecreaseAllowance} instead.
                                   */
                                  function safeApprove(
                                      IERC20Upgradeable token,
                                      address spender,
                                      uint256 value
                                  ) internal {
                                      // safeApprove should only be called when setting an initial allowance,
                                      // or when resetting it to zero. To increase and decrease it, use
                                      // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
                                      require(
                                          (value == 0) || (token.allowance(address(this), spender) == 0),
                                          "SafeERC20: approve from non-zero to non-zero allowance"
                                      );
                                      _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
                                  }
                                  function safeIncreaseAllowance(
                                      IERC20Upgradeable token,
                                      address spender,
                                      uint256 value
                                  ) internal {
                                      uint256 newAllowance = token.allowance(address(this), spender) + value;
                                      _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
                                  }
                                  function safeDecreaseAllowance(
                                      IERC20Upgradeable token,
                                      address spender,
                                      uint256 value
                                  ) internal {
                                      unchecked {
                                          uint256 oldAllowance = token.allowance(address(this), spender);
                                          require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
                                          uint256 newAllowance = oldAllowance - value;
                                          _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
                                      }
                                  }
                                  /**
                                   * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
                                   * on the return value: the return value is optional (but if data is returned, it must not be false).
                                   * @param token The token targeted by the call.
                                   * @param data The call data (encoded using abi.encode or one of its variants).
                                   */
                                  function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
                                      // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
                                      // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
                                      // the target address contains contract code and also asserts for success in the low-level call.
                                      bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
                                      if (returndata.length > 0) {
                                          // Return data is optional
                                          require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev Interface of the ERC20 standard as defined in the EIP.
                               */
                              interface IERC20Upgradeable {
                                  /**
                                   * @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 `recipient`.
                                   *
                                   * Returns a boolean value indicating whether the operation succeeded.
                                   *
                                   * Emits a {Transfer} event.
                                   */
                                  function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
                                      address recipient,
                                      uint256 amount
                                  ) external returns (bool);
                                  /**
                                   * @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);
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
                              import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                              /**
                               * @dev Context variant with ERC2771 support.
                               * Here _trustedForwarder is made internal instead of private
                               * so it can be changed via Child contracts with a setter method.
                               */
                              abstract contract ERC2771ContextUpgradeable is Initializable, ContextUpgradeable {
                                  event TrustedForwarderChanged(address indexed _tf);
                                  address internal _trustedForwarder;
                                  function __ERC2771Context_init(address trustedForwarder) internal initializer {
                                      __Context_init_unchained();
                                      __ERC2771Context_init_unchained(trustedForwarder);
                                  }
                                  function __ERC2771Context_init_unchained(address trustedForwarder) internal initializer {
                                      _trustedForwarder = trustedForwarder;
                                  }
                                  function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
                                      return forwarder == _trustedForwarder;
                                  }
                                  function _msgSender() internal view virtual override returns (address sender) {
                                      if (isTrustedForwarder(msg.sender)) {
                                          // The assembly code is more direct than the Solidity version using `abi.decode`.
                                          assembly {
                                              sender := shr(96, calldataload(sub(calldatasize(), 20)))
                                          }
                                      } else {
                                          return super._msgSender();
                                      }
                                  }
                                  function _msgData() internal view virtual override returns (bytes calldata) {
                                      if (isTrustedForwarder(msg.sender)) {
                                          return msg.data[:msg.data.length - 20];
                                      } else {
                                          return super._msgData();
                                      }
                                  }
                                  function _setTrustedForwarder(address _tf) internal virtual {
                                      require(_tf != address(0), "TrustedForwarder can't be 0");
                                      _trustedForwarder = _tf;
                                      emit TrustedForwarderChanged(_tf);
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                              import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
                              /**
                               * @dev Contract module which allows children to implement an emergency stop
                               * mechanism that can be triggered by an authorized account.
                               *
                               * This module is used through inheritance. It will make available the
                               * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
                               * the functions of your contract. Note that they will not be pausable by
                               * simply including this module, only once the modifiers are put in place.
                               */
                              abstract contract Pausable is Initializable, PausableUpgradeable {
                                  address private _pauser;
                                  event PauserChanged(address indexed previousPauser, address indexed newPauser);
                                  /**
                                   * @dev The pausable constructor sets the original `pauser` of the contract to the sender
                                   * account & Initializes the contract in unpaused state..
                                   */
                                  function __Pausable_init(address pauser) internal initializer {
                                      require(pauser != address(0), "Pauser Address cannot be 0");
                                      __Pausable_init();
                                      _pauser = pauser;
                                  }
                                  /**
                                   * @return true if `msg.sender` is the owner of the contract.
                                   */
                                  function isPauser(address pauser) public view returns (bool) {
                                      return pauser == _pauser;
                                  }
                                  /**
                                   * @dev Throws if called by any account other than the pauser.
                                   */
                                  modifier onlyPauser() {
                                      require(isPauser(msg.sender), "Only pauser is allowed to perform this operation");
                                      _;
                                  }
                                  /**
                                   * @dev Allows the current pauser to transfer control of the contract to a newPauser.
                                   * @param newPauser The address to transfer pauserShip to.
                                   */
                                  function changePauser(address newPauser) public onlyPauser whenNotPaused {
                                      _changePauser(newPauser);
                                  }
                                  /**
                                   * @dev Transfers control of the contract to a newPauser.
                                   * @param newPauser The address to transfer ownership to.
                                   */
                                  function _changePauser(address newPauser) internal {
                                      require(newPauser != address(0));
                                      emit PauserChanged(_pauser, newPauser);
                                      _pauser = newPauser;
                                  }
                                  function renouncePauser() external virtual onlyPauser whenNotPaused {
                                      emit PauserChanged(_pauser, address(0));
                                      _pauser = address(0);
                                  }
                                  function pause() public onlyPauser {
                                      _pause();
                                  }
                                  function unpause() public onlyPauser {
                                      _unpause();
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              struct TokenInfo {
                                  uint256 transferOverhead;
                                  bool supportedToken;
                                  uint256 equilibriumFee; // Percentage fee Represented in basis points
                                  uint256 maxFee; // Percentage fee Represented in basis points
                                  TokenConfig tokenConfig;
                              }
                              struct TokenConfig {
                                  uint256 min;
                                  uint256 max;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              interface IExecutorManager {
                                  function getExecutorStatus(address executor) external view returns (bool status);
                                  function getAllExecutors() external view returns (address[] memory);
                                  //Register new Executors
                                  function addExecutors(address[] calldata executorArray) external;
                                  // Register single executor
                                  function addExecutor(address executorAddress) external;
                                  //Remove registered Executors
                                  function removeExecutors(address[] calldata executorArray) external;
                                  // Remove Register single executor
                                  function removeExecutor(address executorAddress) external;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              interface ILiquidityProviders {
                                  function BASE_DIVISOR() external view returns (uint256);
                                  function initialize(address _trustedForwarder, address _lpToken) external;
                                  function addLPFee(address _token, uint256 _amount) external;
                                  function addNativeLiquidity() external;
                                  function addTokenLiquidity(address _token, uint256 _amount) external;
                                  function claimFee(uint256 _nftId) external;
                                  function getFeeAccumulatedOnNft(uint256 _nftId) external view returns (uint256);
                                  function getSuppliedLiquidityByToken(address tokenAddress) external view returns (uint256);
                                  function getTokenPriceInLPShares(address _baseToken) external view returns (uint256);
                                  function getTotalLPFeeByToken(address tokenAddress) external view returns (uint256);
                                  function getTotalReserveByToken(address tokenAddress) external view returns (uint256);
                                  function getSuppliedLiquidity(uint256 _nftId) external view returns (uint256);
                                  function increaseNativeLiquidity(uint256 _nftId) external;
                                  function increaseTokenLiquidity(uint256 _nftId, uint256 _amount) external;
                                  function isTrustedForwarder(address forwarder) external view returns (bool);
                                  function owner() external view returns (address);
                                  function paused() external view returns (bool);
                                  function removeLiquidity(uint256 _nftId, uint256 amount) external;
                                  function renounceOwnership() external;
                                  function setLiquidityPool(address _liquidityPool) external;
                                  function setLpToken(address _lpToken) external;
                                  function setWhiteListPeriodManager(address _whiteListPeriodManager) external;
                                  function sharesToTokenAmount(uint256 _shares, address _tokenAddress) external view returns (uint256);
                                  function totalLPFees(address) external view returns (uint256);
                                  function totalLiquidity(address) external view returns (uint256);
                                  function totalReserve(address) external view returns (uint256);
                                  function totalSharesMinted(address) external view returns (uint256);
                                  function transferOwnership(address newOwner) external;
                                  function whiteListPeriodManager() external view returns (address);
                                  function increaseCurrentLiquidity(address tokenAddress, uint256 amount) external;
                                  function decreaseCurrentLiquidity(address tokenAddress, uint256 amount) external;
                                  function getCurrentLiquidity(address tokenAddress) external view returns (uint256);
                              }
                              // SPDX-License-Identifier: Apache-2.0
                              pragma solidity 0.8.0;
                              import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
                              interface IERC20Detailed is IERC20Upgradeable {
                                function name() external view returns(string memory);
                                function decimals() external view returns(uint256);
                              }
                              interface IERC20Nonces is IERC20Detailed {
                                function nonces(address holder) external view returns(uint);
                              }
                              interface IERC20Permit is IERC20Nonces {
                                function permit(address holder, address spender, uint256 nonce, uint256 expiry,
                                                bool allowed, uint8 v, bytes32 r, bytes32 s) external;
                                function permit(address holder, address spender, uint256 value, uint256 expiry,
                                                uint8 v, bytes32 r, bytes32 s) external;
                              }// SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "../structures/TokenConfig.sol";
                              interface ITokenManager {
                                  function getEquilibriumFee(address tokenAddress) external view returns (uint256);
                                  function getMaxFee(address tokenAddress) external view returns (uint256);
                                  function changeFee(
                                      address tokenAddress,
                                      uint256 _equilibriumFee,
                                      uint256 _maxFee
                                  ) external;
                                  function tokensInfo(address tokenAddress)
                                      external
                                      view
                                      returns (
                                          uint256 transferOverhead,
                                          bool supportedToken,
                                          uint256 equilibriumFee,
                                          uint256 maxFee,
                                          TokenConfig memory config
                                      );
                                  function excessStateTransferFeePerc(address tokenAddress) external view returns (uint256);
                                  function getTokensInfo(address tokenAddress) external view returns (TokenInfo memory);
                                  function getDepositConfig(uint256 toChainId, address tokenAddress) external view returns (TokenConfig memory);
                                  function getTransferConfig(address tokenAddress) external view returns (TokenConfig memory);
                                  function changeExcessStateFee(address _tokenAddress, uint256 _excessStateFeePer) external;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              import "../structures/SwapRequest.sol";
                              interface ISwapAdaptor {
                                  function swap(
                                      address inputTokenAddress,
                                      uint256 amountInMaximum,
                                      address receiver,
                                      SwapRequest[] calldata swapRequests
                                  ) external returns (uint256 amountIn);
                                  function swapNative(
                                      uint256 amountInMaximum,
                                      address receiver,
                                      SwapRequest[] calldata swapRequests
                                  ) external returns (uint256 amountOut);
                              }// SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Provides information about the current execution context, including the
                               * sender of the transaction and its data. While these are generally available
                               * via msg.sender and msg.data, they should not be accessed in such a direct
                               * manner, since when dealing with meta-transactions the account sending and
                               * paying for execution may not be the actual sender (as far as an application
                               * is concerned).
                               *
                               * This contract is only required for intermediate, library-like contracts.
                               */
                              abstract contract ContextUpgradeable is Initializable {
                                  function __Context_init() internal initializer {
                                      __Context_init_unchained();
                                  }
                                  function __Context_init_unchained() internal initializer {
                                  }
                                  function _msgSender() internal view virtual returns (address) {
                                      return msg.sender;
                                  }
                                  function _msgData() internal view virtual returns (bytes calldata) {
                                      return msg.data;
                                  }
                                  uint256[50] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              /**
                               * @dev Collection of functions related to the address type
                               */
                              library AddressUpgradeable {
                                  /**
                                   * @dev Returns true if `account` is a contract.
                                   *
                                   * [IMPORTANT]
                                   * ====
                                   * It is unsafe to assume that an address for which this function returns
                                   * false is an externally-owned account (EOA) and not a contract.
                                   *
                                   * Among others, `isContract` will return false for the following
                                   * types of addresses:
                                   *
                                   *  - an externally-owned account
                                   *  - a contract in construction
                                   *  - an address where a contract will be created
                                   *  - an address where a contract lived, but was destroyed
                                   * ====
                                   */
                                  function isContract(address account) internal view returns (bool) {
                                      // This method relies on extcodesize, which returns 0 for contracts in
                                      // construction, since the code is only stored at the end of the
                                      // constructor execution.
                                      uint256 size;
                                      assembly {
                                          size := extcodesize(account)
                                      }
                                      return size > 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 functionCall(target, data, "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");
                                      require(isContract(target), "Address: call to non-contract");
                                      (bool success, bytes memory returndata) = target.call{value: value}(data);
                                      return verifyCallResult(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) {
                                      require(isContract(target), "Address: static call to non-contract");
                                      (bool success, bytes memory returndata) = target.staticcall(data);
                                      return verifyCallResult(success, returndata, errorMessage);
                                  }
                                  /**
                                   * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
                                   * revert reason 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 {
                                          // 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
                                              assembly {
                                                  let returndata_size := mload(returndata)
                                                  revert(add(32, returndata), returndata_size)
                                              }
                                          } else {
                                              revert(errorMessage);
                                          }
                                      }
                                  }
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity ^0.8.0;
                              import "../utils/ContextUpgradeable.sol";
                              import "../proxy/utils/Initializable.sol";
                              /**
                               * @dev Contract module which allows children to implement an emergency stop
                               * mechanism that can be triggered by an authorized account.
                               *
                               * This module is used through inheritance. It will make available the
                               * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
                               * the functions of your contract. Note that they will not be pausable by
                               * simply including this module, only once the modifiers are put in place.
                               */
                              abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
                                  /**
                                   * @dev Emitted when the pause is triggered by `account`.
                                   */
                                  event Paused(address account);
                                  /**
                                   * @dev Emitted when the pause is lifted by `account`.
                                   */
                                  event Unpaused(address account);
                                  bool private _paused;
                                  /**
                                   * @dev Initializes the contract in unpaused state.
                                   */
                                  function __Pausable_init() internal initializer {
                                      __Context_init_unchained();
                                      __Pausable_init_unchained();
                                  }
                                  function __Pausable_init_unchained() internal initializer {
                                      _paused = false;
                                  }
                                  /**
                                   * @dev Returns true if the contract is paused, and false otherwise.
                                   */
                                  function paused() public view virtual returns (bool) {
                                      return _paused;
                                  }
                                  /**
                                   * @dev Modifier to make a function callable only when the contract is not paused.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must not be paused.
                                   */
                                  modifier whenNotPaused() {
                                      require(!paused(), "Pausable: paused");
                                      _;
                                  }
                                  /**
                                   * @dev Modifier to make a function callable only when the contract is paused.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must be paused.
                                   */
                                  modifier whenPaused() {
                                      require(paused(), "Pausable: not paused");
                                      _;
                                  }
                                  /**
                                   * @dev Triggers stopped state.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must not be paused.
                                   */
                                  function _pause() internal virtual whenNotPaused {
                                      _paused = true;
                                      emit Paused(_msgSender());
                                  }
                                  /**
                                   * @dev Returns to normal state.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must be paused.
                                   */
                                  function _unpause() internal virtual whenPaused {
                                      _paused = false;
                                      emit Unpaused(_msgSender());
                                  }
                                  uint256[49] private __gap;
                              }
                              // SPDX-License-Identifier: MIT
                              pragma solidity 0.8.0;
                              enum SwapOperation {ExactOutput, ExactInput}
                              struct SwapRequest {
                                  address tokenAddress;
                                  uint256 percentage;
                                  uint256 amount;
                                  SwapOperation operation;
                                  bytes path;
                              }
                              

                              File 12 of 12: BicoTokenImplementation
                              // Sources flattened with hardhat v2.6.5 https://hardhat.org
                              
                              // File @openzeppelin/contracts-upgradeable/proxy/utils/[email protected]
                              
                              // SPDX-License-Identifier: MIT
                              
                              pragma solidity 0.8.4;
                              
                              /**
                               * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
                               * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
                               * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
                               * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
                               *
                               * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
                               * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
                               *
                               * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
                               * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
                               */
                              abstract contract Initializable {
                                  /**
                                   * @dev Indicates that the contract has been initialized.
                                   */
                                  bool private _initialized;
                              
                                  /**
                                   * @dev Indicates that the contract is in the process of being initialized.
                                   */
                                  bool private _initializing;
                              
                                  /**
                                   * @dev Modifier to protect an initializer function from being invoked twice.
                                   */
                                  modifier initializer() {
                                      require(_initializing || !_initialized, "Initializable: contract is already initialized");
                              
                                      bool isTopLevelCall = !_initializing;
                                      if (isTopLevelCall) {
                                          _initializing = true;
                                          _initialized = true;
                                      }
                              
                                      _;
                              
                                      if (isTopLevelCall) {
                                          _initializing = false;
                                      }
                                  }
                              }
                              
                              
                              // File @openzeppelin/contracts-upgradeable/security/[email protected]
                              
                              
                              
                              
                              
                              /**
                               * @dev Contract module that helps prevent reentrant calls to a function.
                               *
                               * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
                               * available, which can be applied to functions to make sure there are no nested
                               * (reentrant) calls to them.
                               *
                               * Note that because there is a single `nonReentrant` guard, functions marked as
                               * `nonReentrant` may not call one another. This can be worked around by making
                               * those functions `private`, and then adding `external` `nonReentrant` entry
                               * points to them.
                               *
                               * TIP: If you would like to learn more about reentrancy and alternative ways
                               * to protect against it, check out our blog post
                               * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
                               */
                              abstract contract ReentrancyGuardUpgradeable is Initializable {
                                  // Booleans are more expensive than uint256 or any type that takes up a full
                                  // word because each write operation emits an extra SLOAD to first read the
                                  // slot's contents, replace the bits taken up by the boolean, and then write
                                  // back. This is the compiler's defense against contract upgrades and
                                  // pointer aliasing, and it cannot be disabled.
                              
                                  // The values being non-zero value makes deployment a bit more expensive,
                                  // but in exchange the refund on every call to nonReentrant will be lower in
                                  // amount. Since refunds are capped to a percentage of the total
                                  // transaction's gas, it is best to keep them low in cases like this one, to
                                  // increase the likelihood of the full refund coming into effect.
                                  uint256 private constant _NOT_ENTERED = 1;
                                  uint256 private constant _ENTERED = 2;
                              
                                  uint256 private _status;
                              
                                  function __ReentrancyGuard_init() internal initializer {
                                      __ReentrancyGuard_init_unchained();
                                  }
                              
                                  function __ReentrancyGuard_init_unchained() internal initializer {
                                      _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 make it call a
                                   * `private` function that does the actual work.
                                   */
                                  modifier nonReentrant() {
                                      // On the first call to nonReentrant, _notEntered will be true
                                      require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
                              
                                      // Any calls to nonReentrant after this point will fail
                                      _status = _ENTERED;
                              
                                      _;
                              
                                      // By storing the original value once again, a refund is triggered (see
                                      // https://eips.ethereum.org/EIPS/eip-2200)
                                      _status = _NOT_ENTERED;
                                  }
                                  uint256[49] private __gap;
                              }
                              
                              
                              // File @openzeppelin/contracts-upgradeable/access/[email protected]
                              
                              
                              
                              
                              
                              /**
                               * @dev External interface of AccessControl declared to support ERC165 detection.
                               */
                              interface IAccessControlUpgradeable {
                                  /**
                                   * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
                                   *
                                   * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
                                   * {RoleAdminChanged} not being emitted signaling this.
                                   *
                                   * _Available since v3.1._
                                   */
                                  event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
                              
                                  /**
                                   * @dev Emitted when `account` is granted `role`.
                                   *
                                   * `sender` is the account that originated the contract call, an admin role
                                   * bearer except when using {AccessControl-_setupRole}.
                                   */
                                  event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
                              
                                  /**
                                   * @dev Emitted when `account` is revoked `role`.
                                   *
                                   * `sender` is the account that originated the contract call:
                                   *   - if using `revokeRole`, it is the admin role bearer
                                   *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
                                   */
                                  event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
                              
                                  /**
                                   * @dev Returns `true` if `account` has been granted `role`.
                                   */
                                  function hasRole(bytes32 role, address account) external view returns (bool);
                              
                                  /**
                                   * @dev Returns the admin role that controls `role`. See {grantRole} and
                                   * {revokeRole}.
                                   *
                                   * To change a role's admin, use {AccessControl-_setRoleAdmin}.
                                   */
                                  function getRoleAdmin(bytes32 role) external view returns (bytes32);
                              
                                  /**
                                   * @dev Grants `role` to `account`.
                                   *
                                   * If `account` had not been already granted `role`, emits a {RoleGranted}
                                   * event.
                                   *
                                   * Requirements:
                                   *
                                   * - the caller must have ``role``'s admin role.
                                   */
                                  function grantRole(bytes32 role, address account) external;
                              
                                  /**
                                   * @dev Revokes `role` from `account`.
                                   *
                                   * If `account` had been granted `role`, emits a {RoleRevoked} event.
                                   *
                                   * Requirements:
                                   *
                                   * - the caller must have ``role``'s admin role.
                                   */
                                  function revokeRole(bytes32 role, address account) external;
                              
                                  /**
                                   * @dev Revokes `role` from the calling account.
                                   *
                                   * Roles are often managed via {grantRole} and {revokeRole}: this function's
                                   * purpose is to provide a mechanism for accounts to lose their privileges
                                   * if they are compromised (such as when a trusted device is misplaced).
                                   *
                                   * If the calling account had been granted `role`, emits a {RoleRevoked}
                                   * event.
                                   *
                                   * Requirements:
                                   *
                                   * - the caller must be `account`.
                                   */
                                  function renounceRole(bytes32 role, address account) external;
                              }
                              
                              
                              // File @openzeppelin/contracts-upgradeable/utils/[email protected]
                              
                              
                              
                              
                              
                              /**
                               * @dev String operations.
                               */
                              library StringsUpgradeable {
                                  bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
                              
                                  /**
                                   * @dev Converts a `uint256` to its ASCII `string` decimal representation.
                                   */
                                  function toString(uint256 value) internal pure returns (string memory) {
                                      // Inspired by OraclizeAPI's implementation - MIT licence
                                      // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
                              
                                      if (value == 0) {
                                          return "0";
                                      }
                                      uint256 temp = value;
                                      uint256 digits;
                                      while (temp != 0) {
                                          digits++;
                                          temp /= 10;
                                      }
                                      bytes memory buffer = new bytes(digits);
                                      while (value != 0) {
                                          digits -= 1;
                                          buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
                                          value /= 10;
                                      }
                                      return string(buffer);
                                  }
                              
                                  /**
                                   * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
                                   */
                                  function toHexString(uint256 value) internal pure returns (string memory) {
                                      if (value == 0) {
                                          return "0x00";
                                      }
                                      uint256 temp = value;
                                      uint256 length = 0;
                                      while (temp != 0) {
                                          length++;
                                          temp >>= 8;
                                      }
                                      return toHexString(value, length);
                                  }
                              
                                  /**
                                   * @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] = _HEX_SYMBOLS[value & 0xf];
                                          value >>= 4;
                                      }
                                      require(value == 0, "Strings: hex length insufficient");
                                      return string(buffer);
                                  }
                              }
                              
                              
                              // File @openzeppelin/contracts-upgradeable/utils/introspection/[email protected]
                              
                              
                              
                              
                              
                              /**
                               * @dev Interface of the ERC165 standard, as defined in the
                               * https://eips.ethereum.org/EIPS/eip-165[EIP].
                               *
                               * Implementers can declare support of contract interfaces, which can then be
                               * queried by others ({ERC165Checker}).
                               *
                               * For an implementation, see {ERC165}.
                               */
                              interface IERC165Upgradeable {
                                  /**
                                   * @dev Returns true if this contract implements the interface defined by
                                   * `interfaceId`. See the corresponding
                                   * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
                                   * to learn more about how these ids are created.
                                   *
                                   * This function call must use less than 30 000 gas.
                                   */
                                  function supportsInterface(bytes4 interfaceId) external view returns (bool);
                              }
                              
                              
                              // File @openzeppelin/contracts-upgradeable/utils/introspection/[email protected]
                              
                              
                              
                              
                              
                              
                              /**
                               * @dev Implementation of the {IERC165} interface.
                               *
                               * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
                               * for the additional interface id that will be supported. For example:
                               *
                               * ```solidity
                               * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
                               *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
                               * }
                               * ```
                               *
                               * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
                               */
                              abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
                                  function __ERC165_init() internal initializer {
                                      __ERC165_init_unchained();
                                  }
                              
                                  function __ERC165_init_unchained() internal initializer {
                                  }
                                  /**
                                   * @dev See {IERC165-supportsInterface}.
                                   */
                                  function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
                                      return interfaceId == type(IERC165Upgradeable).interfaceId;
                                  }
                                  uint256[50] private __gap;
                              }
                              
                              
                              // File contracts/bico-token/bico/BicoTokenImplementation.sol
                              
                              
                              pragma solidity 0.8.4;
                              
                              
                              /**
                               * @dev Context variant with ERC2771 support.
                               */
                              abstract contract ERC2771ContextUpgradeable is Initializable {
                                  /*
                                   * Forwarder singleton we accept calls from
                                   */
                                  address public _trustedForwarder;
                              
                                  function __ERC2771Context_init(address trustedForwarder) internal initializer {
                                      __ERC2771Context_init_unchained(trustedForwarder);
                                  }
                              
                                  function __ERC2771Context_init_unchained(address trustedForwarder) internal initializer {
                                      _trustedForwarder = trustedForwarder;
                                  }
                                  
                                  function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
                                      return forwarder == _trustedForwarder;
                                  }
                              
                                  function _msgSender() internal view virtual returns (address sender) {
                                      if (isTrustedForwarder(msg.sender)) {
                                          // The assembly code is more direct than the Solidity version using `abi.decode`.
                                          assembly {
                                              sender := shr(96, calldataload(sub(calldatasize(), 20)))
                                          }
                                      } else {
                                          return msg.sender;
                                      }
                                  }
                              
                                  function _msgData() internal view virtual returns (bytes calldata) {
                                      if (isTrustedForwarder(msg.sender)) {
                                          return msg.data[:msg.data.length - 20];
                                      } else {
                                          return msg.data;
                                      }
                                  }
                                  uint256[49] private __gap;
                              }
                              
                              
                              
                              /**
                               * @dev Contract module which allows children to implement an emergency stop
                               * mechanism that can be triggered by an authorized account.
                               *
                               * This module is used through inheritance. It will make available the
                               * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
                               * the functions of your contract. Note that they will not be pausable by
                               * simply including this module, only once the modifiers are put in place.
                               */
                              abstract contract PausableUpgradeable is Initializable {
                                  /**
                                   * @dev Emitted when the pause is triggered by `account`.
                                   */
                                  event Paused(address account);
                              
                                  /**
                                   * @dev Emitted when the pause is lifted by `account`.
                                   */
                                  event Unpaused(address account);
                              
                                  bool private _paused;
                                
                                  /**
                                   * @dev Initializes the contract in unpaused state.
                                   */
                                  function __Pausable_init() internal initializer {
                                      __Pausable_init_unchained();
                                  }
                              
                                  function __Pausable_init_unchained() internal initializer {
                                      _paused = false;
                                  }
                              
                                  /**
                                   * @dev Returns true if the contract is paused, and false otherwise.
                                   */
                                  function paused() public view virtual returns (bool) {
                                      return _paused;
                                  }
                              
                                  /**
                                   * @dev Modifier to make a function callable only when the contract is not paused.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must not be paused.
                                   */
                                  modifier whenNotPaused() {
                                      require(!paused(), "BICO:: Pausable: paused");
                                      _;
                                  }
                              
                                  /**
                                   * @dev Modifier to make a function callable only when the contract is paused.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must be paused.
                                   */
                                  modifier whenPaused() {
                                      require(paused(), "BICO:: Pausable: not paused");
                                      _;
                                  }
                              
                                  /**
                                   * @dev Triggers stopped state.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must not be paused.
                                   */
                                  function _pause() internal virtual whenNotPaused {
                                      _paused = true;
                                      emit Paused(msg.sender);
                                  }
                              
                                  /**
                                   * @dev Returns to normal state.
                                   *
                                   * Requirements:
                                   *
                                   * - The contract must be paused.
                                   */
                                  function _unpause() internal virtual whenPaused {
                                      _paused = false;
                                      emit Unpaused(msg.sender);
                                  }
                                  uint256[49] private __gap;
                              }
                              
                              
                              
                              /**
                               * @dev Contract module that allows children to implement role-based access
                               * control mechanisms. This is a lightweight version that doesn't allow enumerating role
                               * members except through off-chain means by accessing the contract event logs. Some
                               * applications may benefit from on-chain enumerability, for those cases see
                               * {AccessControlEnumerable}.
                               *
                               * Roles are referred to by their `bytes32` identifier. These should be exposed
                               * in the external API and be unique. The best way to achieve this is by
                               * using `public constant` hash digests:
                               *
                               * ```
                               * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
                               * ```
                               *
                               * Roles can be used to represent a set of permissions. To restrict access to a
                               * function call, use {hasRole}:
                               *
                               * ```
                               * function foo() public {
                               *     require(hasRole(MY_ROLE, msg.sender));
                               *     ...
                               * }
                               * ```
                               *
                               * Roles can be granted and revoked dynamically via the {grantRole} and
                               * {revokeRole} functions. Each role has an associated admin role, and only
                               * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
                               *
                               * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
                               * that only accounts with this role will be able to grant or revoke other
                               * roles. More complex role relationships can be created by using
                               * {_setRoleAdmin}.
                               *
                               * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
                               * grant and revoke this role. Extra precautions should be taken to secure
                               * accounts that have been granted it.
                               */
                              abstract contract AccessControlUpgradeable is Initializable, IAccessControlUpgradeable, ERC165Upgradeable {
                                  function __AccessControl_init() internal initializer {
                                      __ERC165_init();
                                      __AccessControl_init_unchained();
                                  }
                              
                                  function __AccessControl_init_unchained() internal initializer {
                                  }
                                  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, msg.sender);
                                      _;
                                  }
                              
                                  /**
                                   * @dev See {IERC165-supportsInterface}.
                                   */
                                  function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
                                      return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
                                  }
                              
                                  /**
                                   * @dev Returns `true` if `account` has been granted `role`.
                                   */
                                  function hasRole(bytes32 role, address account) public view override returns (bool) {
                                      return _roles[role].members[account];
                                  }
                              
                                  /**
                                   * @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 {
                                      if (!hasRole(role, account)) {
                                          revert(
                                              string(
                                                  abi.encodePacked(
                                                      "BICO:: AccessControl: account ",
                                                      StringsUpgradeable.toHexString(uint160(account), 20),
                                                      " is missing role ",
                                                      StringsUpgradeable.toHexString(uint256(role), 32)
                                                  )
                                              )
                                          );
                                      }
                                  }
                              
                                  /**
                                   * @dev Returns the admin role that controls `role`. See {grantRole} and
                                   * {revokeRole}.
                                   *
                                   * To change a role's admin, use {_setRoleAdmin}.
                                   */
                                  function getRoleAdmin(bytes32 role) public view 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.
                                   */
                                  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.
                                   */
                                  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 granted `role`, emits a {RoleRevoked}
                                   * event.
                                   *
                                   * Requirements:
                                   *
                                   * - the caller must be `account`.
                                   */
                                  function renounceRole(bytes32 role, address account) public virtual override {
                                      require(account == msg.sender, "BICO:: 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.
                                   *
                                   * [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}.
                                   * ====
                                   */
                                  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);
                                  }
                              
                                  function _grantRole(bytes32 role, address account) private {
                                      if (!hasRole(role, account)) {
                                          _roles[role].members[account] = true;
                                          emit RoleGranted(role, account, msg.sender);
                                      }
                                  }
                              
                                  function _revokeRole(bytes32 role, address account) private {
                                      if (hasRole(role, account)) {
                                          _roles[role].members[account] = false;
                                          emit RoleRevoked(role, account, msg.sender);
                                      }
                                  }
                                  uint256[49] private __gap;
                              }
                              
                              
                              
                              /**
                               * @title Biconomy Protocol Governance contract
                               * @dev All contracts that will be owned by a Governor entity should extend this contract.
                               */
                              contract GovernedUpgradeable is Initializable {
                                  // -- State --
                              
                                  address public governor;
                                  address public pendingGovernor;
                              
                                  // -- Events --
                              
                                  event NewPendingOwnership(address indexed from, address indexed to);
                                  event NewOwnership(address indexed from, address indexed to);
                              
                                  /**
                                   * @dev Check if the caller is the governor.
                                   */
                                  modifier onlyGovernor {
                                      require(msg.sender == governor, "BICO:: Only Governor can call");
                                      _;
                                  }
                              
                                  /**
                                   * @dev Initialize the governor to the contract caller.
                                   */
                                  function __Governed_init(address _initGovernor) internal initializer {
                                      __Governed_init_unchained(_initGovernor);
                                  }
                              
                                  function __Governed_init_unchained(address _initGovernor) internal initializer {
                                      governor = _initGovernor;
                                  }
                              
                                  /**
                                   * @dev Admin function to begin change of governor. The `_newGovernor` must call
                                   * `acceptOwnership` to finalize the transfer.
                                   * @param _newGovernor Address of new `governor`
                                   */
                                  function transferOwnership(address _newGovernor) external onlyGovernor {
                                      require(_newGovernor != address(0), "BICO:: Governor must be set");
                              
                                      address oldPendingGovernor = pendingGovernor;
                                      pendingGovernor = _newGovernor;
                              
                                      emit NewPendingOwnership(oldPendingGovernor, pendingGovernor);
                                  }
                              
                                  /**
                                   * @dev Admin function for pending governor to accept role and update governor.
                                   * This function must called by the pending governor.
                                   */
                                  function acceptOwnership() external {
                                      require(
                                          pendingGovernor != address(0) && msg.sender == pendingGovernor,
                                          "Caller must be pending governor"
                                      );
                              
                                      address oldGovernor = governor;
                                      address oldPendingGovernor = pendingGovernor;
                              
                                      governor = pendingGovernor;
                                      pendingGovernor = address(0);
                              
                                      emit NewOwnership(oldGovernor, governor);
                                      emit NewPendingOwnership(oldPendingGovernor, pendingGovernor);
                                  }
                                  uint256[49] private __gap;
                              }
                              
                              
                              
                              /**
                               * @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 {
                                  /**
                                   * @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) {
                                      // Check the signature length
                                      if (signature.length != 65) {
                                          revert("BICO:: ECDSA: invalid signature length");
                                      }
                              
                                      // Divide the signature in r, s and v variables
                                      bytes32 r;
                                      bytes32 s;
                                      uint8 v;
                              
                                      // ecrecover takes the signature parameters, and the only way to get them
                                      // currently is to use assembly.
                                      // solhint-disable-next-line no-inline-assembly
                                      assembly {
                                          r := mload(add(signature, 0x20))
                                          s := mload(add(signature, 0x40))
                                          v := byte(0, mload(add(signature, 0x60)))
                                      }
                              
                                      // 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 (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): 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.
                                      require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "BICO:: ECDSA: invalid signature 's' value");
                                      require(v == 27 || v == 28, "BICO:: ECDSA: invalid signature 'v' value");
                              
                                      // If the signature is valid (and not malleable), return the signer address
                                      address signer = ecrecover(hash, v, r, s);
                                      require(signer != address(0), "BICO:: ECDSA: invalid signature");
                              
                                      return signer;
                                  }
                              
                                  /**
                                   * @dev Returns an Ethereum Signed Message, created from a `hash`. This
                                   * replicates the behavior of the
                                   * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`]
                                   * JSON-RPC method.
                                   *
                                   * 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));
                                  }
                              }
                              
                              
                              contract BicoTokenImplementation is Initializable, ERC2771ContextUpgradeable, PausableUpgradeable, AccessControlUpgradeable, GovernedUpgradeable, ReentrancyGuardUpgradeable {
                                  // -- State ERC20--
                                  mapping(address => uint256) private _balances;
                              
                                  uint8 internal _initializedVersion;
                              
                                  mapping(address => mapping(address => uint256)) private _allowances;
                              
                                  uint256 private _totalSupply;
                              
                                  string private _name;
                                  string private _symbol;
                              
                                  // -- State Access Control custom roles--
                                  bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
                                  bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
                              
                                  /// @notice The timestamp after which minting may occur
                                  uint public mintingAllowedAfter;
                              
                                  /// @notice Minimum time between mints
                                  uint32 public minimumTimeBetweenMints;
                              
                                  /// @notice Cap on the percentage of totalSupply that can be minted at each mint
                                  uint8 public mintCap;
                              
                                  // -- State Gas abstraction methods--
                              
                                  /// @notice The EIP-712 typehash for the contract's domain
                                  bytes32 public constant DOMAIN_TYPE_HASH = keccak256(
                                      "EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)"
                                  );
                                  bytes32 public constant APPROVE_TYPEHASH = keccak256(
                                      "Approve(address owner,address spender,uint256 value,uint256 batchId,uint256 batchNonce,uint256 deadline)"
                                  );
                                  bytes32 public constant TRANSFER_TYPEHASH = keccak256(
                                      "Transfer(address sender,address recipient,uint256 amount,uint256 batchId,uint256 batchNonce,uint256 deadline)"
                                  );
                                  bytes32 private DOMAIN_SEPARATOR;
                                  /// @notice A record of states for signing / validating signatures
                                  mapping(address => mapping(uint256 => uint256)) public nonces;
                              
                                  // -- Events--
                              
                                  /**
                                   * @dev Emitted when trusted forwarder is updated to 
                                   * another (`trustedForwarder`).
                                   *
                                   * Note that `trustedForwarder` may be zero. `actor` is msg.sender for this action.
                                   */
                                  event TrustedForwarderChanged(address indexed truestedForwarder, address indexed actor);
                              
                                  /**
                                   * @dev Emitted when minting allowed after timestamp is changed through governance
                                   *
                                   * Note that `_mintingAllowedAfter` may be zero. `actor` is msg.sender for this action.
                                   */
                                  event MintingAllowedAfterChanged(uint indexed _mintingAllowedAfter, address indexed actor);
                              
                                  /**
                                   * @dev Emitted when minimum time between mints is changed through governance
                                   *
                                   * Note that `_minimumTimeBetweenMints` may be zero. `actor` is msg.sender for this action.
                                   */
                                  event MinimumTimeBetweenMintsChanged(uint32 indexed _minimumTimeBetweenMints, address indexed actor);
                              
                                  /**
                                   * @dev Emitted when mint cap is changed through governance
                                   *
                                   * Note that `_mintCap` may be zero. `actor` is msg.sender for this action.
                                   */
                                  event MintCapChanged(uint8 indexed _mintCap, address indexed actor);
                              
                                  /**
                                   * @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 Initializes the contract
                                   */
                                  function initialize(address beneficiary, address trustedForwarder, address governor, address accessControlAdmin, address pauser, address minter) public initializer {
                                     __BicoTokenImplementation_init_unchained(accessControlAdmin,pauser,minter);
                                     _mint(beneficiary, 1000000000 * 10 ** decimals());
                                     __ERC2771Context_init(trustedForwarder);
                                     __Pausable_init();
                                     __AccessControl_init();
                                     __Governed_init(governor);
                                     __ReentrancyGuard_init();
                                     _initializedVersion = 0;
                                     mintingAllowedAfter = 0;
                                     minimumTimeBetweenMints = 1 days * 365;
                                     mintCap = 2;
                                  }
                                  
                                  function __BicoTokenImplementation_init_unchained(address accessControlAdmin, address pauser, address minter) internal initializer {
                                      _name = "Biconomy Token";
                                      _symbol = "BICO";
                                      _setupRole(DEFAULT_ADMIN_ROLE, accessControlAdmin);
                                      _setupRole(PAUSER_ROLE, pauser);
                                      _setupRole(MINTER_ROLE, minter);
                              
                                      // EIP-712 domain separator
                                      DOMAIN_SEPARATOR = keccak256(
                                          abi.encode(
                                              DOMAIN_TYPE_HASH,
                                              keccak256("Biconomy Token"),
                                              keccak256("1"),
                                              address(this),
                                              bytes32(getChainId())
                                          )
                                      );
                                  }
                              
                                  /**
                                   * @dev Returns the name of the token.
                                   */
                                  function name() public view virtual returns (string memory) {
                                      return _name;
                                  }
                              
                                  /**
                                   * @dev Returns the symbol of the token, usually a shorter version of the
                                   * name.
                                   */
                                  function symbol() public view virtual returns (string memory) {
                                      return _symbol;
                                  }
                              
                                  /**
                                   * @dev Returns the number of decimals used to get its user representation.
                                   * For example, if `decimals` equals `2`, a balance of `505` tokens should
                                   * be displayed to a user as `5.05` (`505 / 10 ** 2`).
                                   *
                                   * Tokens usually opt for a value of 18, imitating the relationship between
                                   * Ether and Wei. This is the value {ERC20} uses, unless this function is
                                   * overridden;
                                   *
                                   * NOTE: This information is only used for _display_ purposes: it in
                                   * no way affects any of the arithmetic of the contract, including
                                   * {IERC20-balanceOf} and {IERC20-transfer}.
                                   */
                                  function decimals() public view virtual returns (uint8) {
                                      return 18;
                                  }
                              
                                  /**
                                   * @dev See {IERC20-totalSupply}.
                                   */
                                  function totalSupply() public view virtual returns (uint256) {
                                      return _totalSupply;
                                  }
                              
                                  /**
                                   * @dev See {IERC20-balanceOf}.
                                   */
                                  function balanceOf(address account) public view virtual returns (uint256) {
                                      return _balances[account];
                                  }
                              
                              
                                  /**
                                   * @dev See {IERC20-transfer}.
                                   *
                                   * Requirements:
                                   *
                                   * - `recipient` cannot be the zero address.
                                   * - the caller must have a balance of at least `amount`.
                                   */
                                  function transfer(address recipient, uint256 amount) public virtual nonReentrant whenNotPaused returns (bool) {
                                      _transfer(_msgSender(), recipient, amount);
                                      return true;
                                  }
                              
                                  /**
                                   * @dev See {IERC20-allowance}.
                                   */
                                  function allowance(address owner, address spender) public view virtual returns (uint256) {
                                      return _allowances[owner][spender];
                                  }
                              
                                  /**
                                   * @dev See {IERC20-approve}.
                                   *
                                   * Requirements:
                                   *
                                   * - `spender` cannot be the zero address.
                                   */
                                  function approve(address spender, uint256 amount) public virtual nonReentrant whenNotPaused returns (bool) {
                                      _approve(_msgSender(), spender, amount);
                                      return true;
                                  }
                              
                                  /**
                                   * @dev See {IERC20-transferFrom}.
                                   *
                                   * Emits an {Approval} event indicating the updated allowance. This is not
                                   * required by the EIP. See the note at the beginning of {ERC20}.
                                   *
                                   * Requirements:
                                   *
                                   * - `sender` and `recipient` cannot be the zero address.
                                   * - `sender` must have a balance of at least `amount`.
                                   * - the caller must have allowance for ``sender``'s tokens of at least
                                   * `amount`.
                                   */
                                  function transferFrom(
                                      address sender,
                                      address recipient,
                                      uint256 amount
                                  ) public virtual nonReentrant whenNotPaused returns (bool) {
                                      _transfer(sender, recipient, amount);
                              
                                      uint256 currentAllowance = _allowances[sender][_msgSender()];
                                      require(currentAllowance >= amount, "BICO:: ERC20: transfer amount exceeds allowance");  
                                      unchecked {      
                                          _approve(sender, _msgSender(), currentAllowance - amount);
                                      }
                                      return true;
                                  }
                              
                                  /**
                                   * @dev Atomically increases the allowance granted to `spender` by the caller.
                                   *
                                   * This is an alternative to {approve} that can be used as a mitigation for
                                   * problems described in {IERC20-approve}.
                                   *
                                   * Emits an {Approval} event indicating the updated allowance.
                                   *
                                   * Requirements:
                                   *
                                   * - `spender` cannot be the zero address.
                                   */
                                  function increaseAllowance(address spender, uint256 addedValue) public virtual nonReentrant whenNotPaused returns (bool) {
                                      _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
                                      return true;
                                  }
                              
                                  /**
                                   * @dev Atomically decreases the allowance granted to `spender` by the caller.
                                   *
                                   * This is an alternative to {approve} that can be used as a mitigation for
                                   * problems described in {IERC20-approve}.
                                   *
                                   * Emits an {Approval} event indicating the updated allowance.
                                   *
                                   * Requirements:
                                   *
                                   * - `spender` cannot be the zero address.
                                   * - `spender` must have allowance for the caller of at least
                                   * `subtractedValue`.
                                   */
                                  function decreaseAllowance(address spender, uint256 subtractedValue) public virtual nonReentrant whenNotPaused returns (bool) {
                                      uint256 currentAllowance = _allowances[_msgSender()][spender];
                                      require(currentAllowance >= subtractedValue, "BICO:: ERC20: decreased allowance below zero");
                                      unchecked {
                                          _approve(_msgSender(), spender, currentAllowance - subtractedValue);
                                      }
                                      return true;
                                  }
                              
                                  /**
                                   * @dev Moves `amount` of tokens from `sender` to `recipient`.
                                   *
                                   * This internal function is equivalent to {transfer}, and can be used to
                                   * e.g. implement automatic token fees, slashing mechanisms, etc.
                                   *
                                   * Emits a {Transfer} event.
                                   *
                                   * Requirements:
                                   *
                                   * - `sender` cannot be the zero address.
                                   * - `recipient` cannot be the zero address.
                                   * - `sender` must have a balance of at least `amount`.
                                   */
                                  function _transfer(
                                      address sender,
                                      address recipient,
                                      uint256 amount
                                  ) internal virtual {
                                      require(sender != address(0), "BICO:: ERC20: transfer from the zero address");
                                      require(recipient != address(0), "BICO:: ERC20: transfer to the zero address");
                              
                                      uint256 senderBalance = _balances[sender];
                                      require(senderBalance >= amount, "BICO:: ERC20: transfer amount exceeds balance");
                                      unchecked {
                                          _balances[sender] = senderBalance - amount;
                                      }
                                      _balances[recipient] += amount;
                              
                                      emit Transfer(sender, recipient, amount);
                              
                                  }
                              
                                  /** @dev Creates `amount` tokens and assigns them to `account`, increasing
                                   * the total supply.
                                   *
                                   * Emits a {Transfer} event with `from` set to the zero address.
                                   *
                                   * Requirements:
                                   *
                                   * - `account` cannot be the zero address.
                                   */
                                  function _mint(address account, uint256 amount) internal virtual {
                                      require(account != address(0), "BICO:: ERC20: mint to the zero address");
                              
                                      _totalSupply += amount;
                                      _balances[account] += amount;
                              
                                      emit Transfer(address(0), account, amount);
                                  }
                              
                                  //there is no public burn() method in V0
                                  /**
                                   * @dev Destroys `amount` tokens from `account`, reducing the
                                   * total supply.
                                   *
                                   * Emits a {Transfer} event with `to` set to the zero address.
                                   *
                                   * Requirements:
                                   *
                                   * - `account` cannot be the zero address.
                                   * - `account` must have at least `amount` tokens.
                                   */
                                  function _burn(address account, uint256 amount) internal virtual {
                                      require(account != address(0), "BICO:: ERC20: burn from the zero address");
                              
                                      uint256 accountBalance = _balances[account];
                                      require(accountBalance >= amount, "BICO:: ERC20: burn amount exceeds balance");
                                      unchecked {
                                          _balances[account] = accountBalance - amount;
                                      }
                                      _totalSupply -= amount;
                              
                                      emit Transfer(account, address(0), amount);
                                  }
                              
                                  /**
                                   * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
                                   *
                                   * This internal function is equivalent to `approve`, and can be used to
                                   * e.g. set automatic allowances for certain subsystems, etc.
                                   *
                                   * Emits an {Approval} event.
                                   *
                                   * Requirements:
                                   *
                                   * - `owner` cannot be the zero address.
                                   * - `spender` cannot be the zero address.
                                   */
                                  function _approve(
                                      address owner,
                                      address spender,
                                      uint256 amount
                                  ) internal virtual {
                                      require(owner != address(0), "BICO:: ERC20: approve from the zero address");
                                      require(spender != address(0), "BICO:: ERC20: approve to the zero address");
                              
                                      _allowances[owner][spender] = amount;
                                      emit Approval(owner, spender, amount);
                                  }
                              
                                  /**
                                   * @dev Increments the nonce of given user/batch pair
                                   * @dev Updates the highestBatchId of the given user if the request's batchId > current highest
                                   * @dev only intended to be called post call execution
                                   * @param _user : owner or sender address
                                   * @param _batchId : batch Id
                                   */
                                  function _updateNonce(address _user, uint256 _batchId) internal {
                                      nonces[_user][_batchId]++;
                                  }
                              
                                  /**
                                   * @dev Approve token allowance by validating a message signed by the holder.
                                   * @param _owner Address of the token holder
                                   * @param _spender Address of the approved spender
                                   * @param _value Amount of tokens to approve the spender
                                   * @param _batchId Batch Id. pass this 0 if batching is not needed.
                                   * @param _deadline Expiration time of the signed approval
                                   * @param _v Signature version
                                   * @param _r Signature r value
                                   * @param _s Signature s value
                                   */
                                  function approveWithSig(
                                      uint8 _v,
                                      bytes32 _r,
                                      bytes32 _s,
                                      uint256 _deadline,
                                      address _owner,
                                      uint256 _batchId,
                                      address _spender,
                                      uint256 _value
                                  ) public virtual nonReentrant whenNotPaused {
                                      bytes32 digest = keccak256(
                                          abi.encodePacked(
                                              "\x19\x01",
                                              DOMAIN_SEPARATOR,
                                              keccak256(
                                                  abi.encode(
                                                      APPROVE_TYPEHASH,
                                                      _owner,
                                                      _spender,
                                                      _value,
                                                      _batchId,
                                                      nonces[_owner][_batchId],
                                                      _deadline
                                                  )
                                              )
                                          )
                                      );
                                      
                                      address recoveredAddress = ECDSA.recover(digest, abi.encodePacked(_r, _s, _v));
                                      require(recoveredAddress != address(0), "BICO:: invalid signature");
                                      require(_owner == recoveredAddress, "BICO:: invalid approval:Unauthorized");
                                      require(_deadline == 0 || block.timestamp <= _deadline, "BICO:: expired approval");
                                        _updateNonce(_owner,_batchId);
                                      _approve(_owner, _spender, _value);
                                  }
                              
                                  /**
                                   * @dev Transfer tokens by validating a message signed by the sender.
                                   * @param _sender Address of the token sender
                                   * @param _recipient Address of the token recipient
                                   * @param _amount Amount of tokens to transfer
                                   * @param _batchId Batch Id. pass this 0 if batching is not needed.
                                   * @param _deadline Expiration time of the signed approval
                                   * @param _v Signature version
                                   * @param _r Signature r value
                                   * @param _s Signature s value
                                   */
                                  function transferWithSig(
                                      uint8 _v,
                                      bytes32 _r,
                                      bytes32 _s,
                                      uint256 _deadline,
                                      address _sender,
                                      uint256 _batchId,
                                      address _recipient,
                                      uint256 _amount
                                  ) public virtual nonReentrant whenNotPaused {
                                      bytes32 digest = keccak256(
                                          abi.encodePacked(
                                              "\x19\x01",
                                              DOMAIN_SEPARATOR,
                                              keccak256(
                                                  abi.encode(
                                                      TRANSFER_TYPEHASH,
                                                      _sender,
                                                      _recipient,
                                                      _amount,
                                                      _batchId,
                                                      nonces[_sender][_batchId],
                                                      _deadline
                                                  )
                                              )
                                          )
                                      );
                                      
                              
                                      address recoveredAddress = ECDSA.recover(digest, abi.encodePacked(_r, _s, _v));
                                      require(recoveredAddress != address(0), "BICO:: invalid signature");
                                      require(_sender == recoveredAddress, "BICO:: invalid transfer:Unauthorized");
                                      require(_deadline == 0 || block.timestamp <= _deadline, "BICO:: expired transfer");
                                      _updateNonce(_sender,_batchId);
                                      _transfer(_sender, _recipient, _amount);
                                  }
                              
                                  function pause() public onlyRole(PAUSER_ROLE) {
                                      _pause();
                                  }
                              
                                  function unpause() public onlyRole(PAUSER_ROLE) {
                                      _unpause();
                                  }
                              
                                  function setTrustedForwarder(address payable _forwarder) external onlyGovernor {
                                      require(_forwarder != address(0), "BICO:: Invalid address for new trusted forwarder");
                                      _trustedForwarder = _forwarder;
                                      emit TrustedForwarderChanged(_forwarder, msg.sender);
                                  }
                              
                                  function setMintingAllowedAfter(uint _mintingAllowedAfter) external onlyGovernor {
                                      mintingAllowedAfter = _mintingAllowedAfter;
                                      emit MintingAllowedAfterChanged(_mintingAllowedAfter,msg.sender);
                                  }
                              
                                  function setMinimumTimeBetweenMints(uint32 _minimumTimeBetweenMints) external onlyGovernor {
                                      minimumTimeBetweenMints = _minimumTimeBetweenMints;
                                      emit MinimumTimeBetweenMintsChanged(_minimumTimeBetweenMints,msg.sender);
                                  }
                              
                                  function setMintCap(uint8 _mintCap) external onlyGovernor {
                                      mintCap = _mintCap;
                                      emit MintCapChanged(_mintCap, msg.sender);
                                  }
                              
                                  function getChainId() internal view returns (uint) {
                                      uint256 chainId;
                                      assembly { chainId := chainid() }
                                      return chainId;
                                  }
                              
                              }