creation_sourcecode: // SPDX-License-Identifier: UNLICENSED
  pragma solidity ^0.8.7;
  
  library SafeMath {
      function add(uint256 a, uint256 b) internal pure returns (uint256) {
          uint256 c = a + b;
          require(c >= a, "SafeMath: addition overflow");
  
          return c;
      }
  
      function sub(uint256 a, uint256 b) internal pure returns (uint256) {
          return sub(a, b, "SafeMath: subtraction overflow");
      }
  
      function sub(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          require(b <= a, errorMessage);
          uint256 c = a - b;
  
          return c;
      }
  
      function mul(uint256 a, uint256 b) internal pure returns (uint256) {
          if (a == 0) {
              return 0;
          }
  
          uint256 c = a * b;
          require(c / a == b, "SafeMath: multiplication overflow");
  
          return c;
      }
  
      function div(uint256 a, uint256 b) internal pure returns (uint256) {
          return div(a, b, "SafeMath: division by zero");
      }
  
      function div(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          require(b > 0, errorMessage);
          uint256 c = a / b;
          // assert(a == b * c + a % b); // There is no case in which this doesn't hold
  
          return c;
      }
  
      function mod(uint256 a, uint256 b) internal pure returns (uint256) {
          return mod(a, b, "SafeMath: modulo by zero");
      }
  
      function mod(
          uint256 a,
          uint256 b,
          string memory errorMessage
      ) internal pure returns (uint256) {
          require(b != 0, errorMessage);
          return a % b;
      }
  
      function min(uint256 x, uint256 y) internal pure returns (uint256 z) {
          z = x < y ? x : y;
      }
  
      function sqrt(uint256 y) internal pure returns (uint256 z) {
          if (y > 3) {
              z = y;
              uint256 x = y / 2 + 1;
              while (x < z) {
                  z = x;
                  x = (y / x + x) / 2;
              }
          } else if (y != 0) {
              z = 1;
          }
      }
  }
  
  // File: @pancakeswap/pancake-swap-lib/contracts/token/BEP20/IBEP20.sol
  
  interface IBEP20 {
      /**
       * @dev Returns the amount of tokens in existence.
       */
      function totalSupply() external view returns (uint256);
  
      /**
       * @dev Returns the token decimals.
       */
      function decimals() external view returns (uint8);
  
      /**
       * @dev Returns the token symbol.
       */
      function symbol() external view returns (string memory);
  
      /**
       * @dev Returns the token name.
       */
      function name() external view returns (string memory);
  
      /**
       * @dev Returns the bep token owner.
       */
      function getOwner() external view returns (address);
  
      /**
       * @dev Returns the amount of tokens owned by `account`.
       */
      function balanceOf(address account) external view returns (uint256);
  
      function transfer(
          address recipient,
          uint256 amount
      ) external returns (bool);
  
      function allowance(
          address _owner,
          address spender
      ) external view returns (uint256);
  
      function approve(address spender, uint256 amount) external returns (bool);
  
      function transferFrom(
          address sender,
          address recipient,
          uint256 amount
      ) external returns (bool);
  
      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 Collection of functions related to the address type
   */
  library Address {
      function isContract(address account) internal view returns (bool) {
          // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
          // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
          // for accounts without code, i.e. `keccak256('')`
          bytes32 codehash;
          bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
          // solhint-disable-next-line no-inline-assembly
          assembly {
              codehash := extcodehash(account)
          }
          return (codehash != accountHash && codehash != 0x0);
      }
  
      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"
          );
      }
  
      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);
      }
  
      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"
              );
      }
  
      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"
          );
          return _functionCallWithValue(target, data, value, errorMessage);
      }
  
      function _functionCallWithValue(
          address target,
          bytes memory data,
          uint256 weiValue,
          string memory errorMessage
      ) private returns (bytes memory) {
          require(isContract(target), "Address: call to non-contract");
  
          // solhint-disable-next-line avoid-low-level-calls
          (bool success, bytes memory returndata) = target.call{value: weiValue}(
              data
          );
          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);
              }
          }
      }
  }
  
  library SafeBEP20 {
      using SafeMath for uint256;
      using Address for address;
  
      function safeTransfer(IBEP20 token, address to, uint256 value) internal {
          _callOptionalReturn(
              token,
              abi.encodeWithSelector(token.transfer.selector, to, value)
          );
      }
  
      function safeTransferFrom(
          IBEP20 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
       * {IBEP20-approve}, and its usage is discouraged.
       *
       * Whenever possible, use {safeIncreaseAllowance} and
       * {safeDecreaseAllowance} instead.
       */
      function safeApprove(
          IBEP20 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'
          // solhint-disable-next-line max-line-length
          require(
              (value == 0) || (token.allowance(address(this), spender) == 0),
              "SafeBEP20: approve from non-zero to non-zero allowance"
          );
          _callOptionalReturn(
              token,
              abi.encodeWithSelector(token.approve.selector, spender, value)
          );
      }
  
      function safeIncreaseAllowance(
          IBEP20 token,
          address spender,
          uint256 value
      ) internal {
          uint256 newAllowance = token.allowance(address(this), spender).add(
              value
          );
          _callOptionalReturn(
              token,
              abi.encodeWithSelector(
                  token.approve.selector,
                  spender,
                  newAllowance
              )
          );
      }
  
      function safeDecreaseAllowance(
          IBEP20 token,
          address spender,
          uint256 value
      ) internal {
          uint256 newAllowance = token.allowance(address(this), spender).sub(
              value,
              "SafeBEP20: decreased allowance below zero"
          );
          _callOptionalReturn(
              token,
              abi.encodeWithSelector(
                  token.approve.selector,
                  spender,
                  newAllowance
              )
          );
      }
  
      function _callOptionalReturn(IBEP20 token, bytes memory data) private {
          bytes memory returndata = address(token).functionCall(
              data,
              "SafeBEP20: low-level call failed"
          );
          if (returndata.length > 0) {
              // Return data is optional
              // solhint-disable-next-line max-line-length
              require(
                  abi.decode(returndata, (bool)),
                  "SafeBEP20: BEP20 operation did not succeed"
              );
          }
      }
  }
  
  interface AggregatorV3Interface {
      function decimals() external view returns (uint8);
  
      function description() external view returns (string memory);
  
      function version() external view returns (uint256);
  
      // getRoundData and latestRoundData should both raise "No data present"
      // if they do not have data to report, instead of returning unset values
      // which could be misinterpreted as actual reported values.
      function getRoundData(
          uint80 _roundId
      )
          external
          view
          returns (
              uint80 roundId,
              int256 answer,
              uint256 startedAt,
              uint256 updatedAt,
              uint80 answeredInRound
          );
  
      function latestRoundData()
          external
          view
          returns (
              uint80 roundId,
              int256 answer,
              uint256 startedAt,
              uint256 updatedAt,
              uint80 answeredInRound
          );
  }
  
  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;
          }
      }
  }
  
  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 pure virtual returns (bytes calldata) {
          return msg.data;
      }
  
      uint256[50] private __gap;
  }
  
  abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
      address public _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 {
          _transferOwnership(_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 {
          _transferOwnership(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"
          );
          _transferOwnership(newOwner);
      }
  
      /**
       * @dev Transfers ownership of the contract to a new account (`newOwner`).
       * Internal function without access restriction.
       */
      function _transferOwnership(address newOwner) internal virtual {
          address oldOwner = _owner;
          _owner = newOwner;
          emit OwnershipTransferred(oldOwner, newOwner);
      }
  
      uint256[49] private __gap;
  }
  
  library UtilsBridge {
      struct lzTxObj {
          uint256 dstGasForCall;
          uint256 dstNativeAmount;
          bytes dstNativeAddr;
      }
  }
  
  interface IStargateRouterInterface {
      function swap(
          uint16 _dstChainId,
          uint256 _srcPoolId,
          uint256 _dstPoolId,
          address payable _refundAddress,
          uint256 _amountLD,
          uint256 _minAmountLD,
          UtilsBridge.lzTxObj memory _lzTxParams,
          bytes calldata _to,
          bytes calldata _payload
      ) external payable;
  }
  
  interface IStargateRouterETHInterface {
      function swapETH(
          uint16 _dstChainId,
          address payable _refundAddress,
          bytes calldata _toAddress,
          uint256 _amountLD,
          uint256 _minAmountLD
      ) external payable;
  }
  
  contract HODLDEX is ContextUpgradeable, OwnableUpgradeable {
      using SafeMath for uint256;
      using SafeBEP20 for IBEP20;
  
      event swapEvent(address indexed _receiver, uint256 _amount, uint256 _fee);
      event swapBridgeEvent(
          address indexed _receiver,
          uint256 _amount,
          uint256 _fee
      );
      event feeEvent(address indexed _admin, uint256 _fee);
      event receiverEvent(address indexed _admin);
  
      address public receiver;
      IStargateRouterInterface public IStargateRouter;
      IStargateRouterETHInterface public IStargateRouterETH;
  
      uint256 public bridgefee;
      bool private locked;
  
      modifier nonReentrant() {
          require(!locked, "No re-entrancy");
          locked = true;
          _;
          locked = false;
      }
  
      constructor() {}
  
      function initialize(
          address _admin,
          IStargateRouterInterface _router,
          IStargateRouterETHInterface _routereth
      ) public initializer {
          require(_admin != address(0), "Invalid receiver");
          receiver = _admin;
          IStargateRouter = IStargateRouterInterface(_router);
          IStargateRouterETH = IStargateRouterETHInterface(_routereth);
          bridgefee = 100;
          __Ownable_init();
      }
  
      function swapBridge(
          uint16 _dstChainId,
          uint256 _srcPoolId,
          uint256 _dstPoolId,
          address payable _refundAddress,
          uint256 _amountLD,
          uint256 _minAmountLD,
          UtilsBridge.lzTxObj memory _lzTxParams,
          bytes calldata _to,
          bytes calldata _payload,
          address fromToken
      ) external payable nonReentrant {
          require(_amountLD > 0, "Invalid amount");
          uint256 feeCal = (_amountLD.mul(bridgefee)).div(10000);
          IBEP20(fromToken).safeTransferFrom(
              msg.sender,
              address(this),
              _amountLD
          );
          IBEP20(fromToken).approve(address(IStargateRouter), _amountLD);
          IBEP20(fromToken).safeTransfer(receiver, feeCal);
          _amountLD = _amountLD - feeCal;
          IStargateRouter.swap{value: msg.value}(
              _dstChainId,
              _srcPoolId,
              _dstPoolId,
              _refundAddress,
              _amountLD,
              _minAmountLD,
              _lzTxParams,
              _to,
              _payload
          );
          emit swapBridgeEvent(msg.sender, _amountLD, feeCal);
      }
  
      function swapBridgeETH(
          uint16 _dstChainId,
          address payable _refundAddress,
          bytes calldata _toAddress,
          uint256 _amountLD,
          uint256 _minAmountLD
      ) external payable {
          require(_amountLD > 0, "Invalid amount");
          uint256 feeCal = (_amountLD.mul(bridgefee)).div(10000);
          payable(address(this)).transfer(msg.value);
          payable(receiver).transfer(feeCal);
          uint256 remain = msg.value - _amountLD;
          _amountLD = _amountLD - feeCal;
          uint256 gas = _amountLD.add(remain);
          IStargateRouterETH.swapETH{value: gas}(
              _dstChainId,
              _refundAddress,
              _toAddress,
              _amountLD,
              _minAmountLD
          );
          emit swapBridgeEvent(msg.sender, _amountLD, feeCal);
      }
  
      function updateBridgeRouter(
          IStargateRouterInterface _router
      ) external onlyOwner {
          IStargateRouter = IStargateRouterInterface(_router);
      }
  
      function updateBridgeRouterETH(
          IStargateRouterETHInterface _routereth
      ) external onlyOwner {
          IStargateRouterETH = IStargateRouterETHInterface(_routereth);
      }
  
      function updateBridgeFee(uint256 _fee) external onlyOwner {
          bridgefee = _fee;
          emit feeEvent(msg.sender, _fee);
      }
  
      function updateReceiver(address _receiver) external onlyOwner {
          require(_receiver != address(0), "Invalid receiver");
          receiver = _receiver;
          emit receiverEvent(receiver);
      }
  
      receive() external payable {}
  
      fallback() external payable {}
  }