Contract 0x18BBF96BC8014aA93cbf1A5Bce005a485b5C2C4a 2

Contract Overview

Balance:
0 ETH
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x2d493ac8950bb21b341dcd85ca5e1b3cc58315d99a7c5e4f311e16912c8e31e6Accept Proposed ...98886822023-03-03 23:41:0218 days 5 hrs ago0xa2ee8dcd2a8a3a54cf37f6590e5108bbe502b006 IN  0x18bbf96bc8014aa93cbf1a5bce005a485b5c2c4a0 ETH0.00000307 0.1
0x33566a229f842db512308a2d9dcadf9a1adffe497e71e4ac215c48a91bdb9c16Propose New Owne...89783442023-02-24 21:17:0525 days 8 hrs ago0x54baa998771639628ffc0206c3b916c466b79c89 IN  0x18bbf96bc8014aa93cbf1a5bce005a485b5c2c4a0 ETH0.00002337 0.1
0x88d6f5d4c43eabaf8684c646eec9e005375e36bf1af81f8efd3dd296c6ed4cea0x60c0604050797122023-01-21 1:17:0260 days 4 hrs ago0x54baa998771639628ffc0206c3b916c466b79c89 IN  Create: Unwrapper0 ETH0.000081680.1
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Unwrapper

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Standard Json-Input format)

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 5 of 8 : IXReceiver.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;

interface IXReceiver {
  function xReceive(
    bytes32 _transferId,
    uint256 _amount,
    address _asset,
    address _originSender,
    uint32 _origin,
    bytes memory _callData
  ) external returns (bytes memory);
}

File 6 of 8 : Unwrapper.sol
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity 0.8.17;

import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";

import {ProposedOwnable} from "../../shared/ProposedOwnable.sol";
import {IXReceiver} from "../connext/interfaces/IXReceiver.sol";

interface IWrapper {
  function withdraw(uint256 wad) external;

  function transfer(address dst, uint256 wad) external returns (bool);
}

/**
 * @notice A utility contract for unwrapping native tokens at the destination.
 *
 * @dev The `xreceive` function of contract may fail in the following ways:
 * - unwrapping fails
 * - the wrong asset is delivered, and transferring that fails
 * - sending the native asset fails
 * - the caller is not connext
 * - the amount is zero
 * - balance of the contract != amount
 *
 * In the event of these failures, funds for the crosschain transfer will be sent
 * to this contract and will be held here. To rescue them, the owner of this contract
 * can call `sweep` or `unwrapAndSweep` to transfer assets from this contract to a
 * specified address.
 *
 * It is unlikely failures of these types will occur, so ownership of this contract
 * should be renounced after a suitable trial period on mainnet.
 *
 * @dev Ownership of this contract is governed using the same ProposedOwnable setup
 * that is prevalent throughout the system.
 */
contract Unwrapper is ProposedOwnable, IXReceiver {
  // ============ Libraries ============

  using SafeERC20 for IERC20;

  // ============ Events ============

  /**
   * @notice Emitted if the wrong wrapper asset is sent.
   * @param recipient - The target recipient address.
   * @param asset - The asset sent.
   */
  event WrongAsset(address recipient, address asset);

  /**
   * @notice Emitted when funds are sent from this contract
   * @param recipient - The target recipient address.
   * @param asset - The asset sent.
   * @param amount - The amount of the asset sent
   */
  event FundsDelivered(address recipient, address asset, uint256 amount);

  // ============ Properties ============

  /**
   * @notice Connext (diamond proxy) address, the only address permissioned to call `xReceive`.
   */
  address public immutable CONNEXT;

  /**
   * @notice The wrapper contract that this contract will always use for unwrapping native token.
   */
  IWrapper public immutable WRAPPER;

  // ============= Modifiers ==============

  /**
   * @notice Ensure caller is only the designated CONNEXT bridge address.
   */
  modifier onlyConnext() {
    require(msg.sender == CONNEXT, "unwrap: !connext");
    _;
  }

  // ============ Constructor ============

  /**
   * @dev The initial owner is set to the `msg.sender` of the contract.
   */
  constructor(address connext, address wrapper) ProposedOwnable() {
    _setOwner(msg.sender);
    WRAPPER = IWrapper(wrapper);
    CONNEXT = connext;
  }

  // ============ Admin Functions ============

  /**
   * @notice Sweeps the provided token from this address to a designated recipient.
   * @dev Only the owner of this contract can call this function.
   *
   * @dev Funds will end up on this contract IFF the external call on the Connext contract
   * fails and the transfer is reconciled. The `xreceive` function can fail in the following
   * cases:
   * - unwrapping fails
   * - transferring the asset fails
   * - `connext` is not the caller (should not sweep in this case)
   * - amount is zero (should not sweep in this case).
   *
   * It is left to the admin to determine the proper amounts to sweep.
   *
   * @param recipient The address to send the funds to
   * @param asset The asset to send from the contract to recipient
   * @param amount Amount of asset to sweep from contract
   */
  function sweep(
    address recipient,
    address asset,
    uint256 amount
  ) public onlyOwner {
    // Sanity check: amount is non-zero (otherwise, what are we unwrapping?).
    require(amount != 0, "sweep: !amount");

    // Send funds to recipient
    _sweep(recipient, asset, amount);
  }

  /**
   * @notice Unwraps and sweeps the provided token from this address to a designated recipient.
   * @dev Only the owner of this contract can call this function.
   *
   * @dev Funds will end up on this contract IFF the external call on the Connext contract
   * fails and the transfer is reconciled. The `xreceive` function can fail in the following
   * cases:
   * - unwrapping fails
   * - transferring the asset fails
   * - `connext` is not the caller (should not sweep in this case)
   * - amount is zero (should not sweep in this case).
   *
   * It is left to the admin to determine the proper amounts to sweep.
   *
   * @param recipient The address to send the funds to
   * @param amount Amount of asset to sweep from contract
   */
  function unwrapAndSweep(address recipient, uint256 amount) public onlyOwner {
    // Sanity check: amount is non-zero (otherwise, what are we unwrapping?).
    require(amount != 0, "unwrapAndSweep: !amount");

    // Withdraw from wrapper
    WRAPPER.withdraw(amount);

    // Send funds to recipient
    _sweep(recipient, address(0), amount);
  }

  // ============ Public Functions ============

  /**
   * @notice xReceive implementation for receiving cross-chain calls from Connext.
   * @dev We mostly ignore `originSender` argument: this could be a contract or EOA, but our
   * recipient should be specified in our `callData`! We only fallback to using `originSender` IFF
   * recipient argument is missing.
   * @dev If unwrapping (i.e. `withdraw`) fails, will emit UnwrappingFailed event! We will attempt
   * to transfer the wrapped tokens to the
   *
   * @param amount - The amount to transfer. Should NOT be 0, or this call will revert.
   * @param asset - This *should be* the wrapper contract address, an ERC20 token approved by the
   * Connext bridge. IFF this does NOT match the WRAPPER contract address stored in this contract,
   * we'll try to `IERC20.transfer` the assets to the intended recipient.
   * @param callData - Should be a tuple of just `(address)`. The address is the intended
   * recipient of the unwrapped native tokens. Whether it's ether or wether (i.e. whether it's
   * wrapped native tokens or native tokens) depends on whether we succeeded in the unwrapping
   * process.
   */
  function xReceive(
    bytes32, // transferId
    uint256 amount,
    address asset,
    address, // originSender
    uint32, // origin domain
    bytes memory callData
  ) external onlyConnext returns (bytes memory) {
    // Sanity check: amount is non-zero (otherwise, what are we unwrapping?).
    require(amount != 0, "unwrap: !amount");

    // Get the target recipient, which should be in the callData.
    // NOTE: If recipient is the zero address, funds will be burned!
    address recipient = abi.decode(callData, (address));

    // Sanity check: asset we've received matches our target wrapper.
    if (asset != address(WRAPPER)) {
      emit WrongAsset(recipient, asset);
      // If the delivered asset does not match our target wrapper, we try sending it anyway.
      _sweep(recipient, asset, amount);
      return bytes("");
    }

    // We've received wrapped native tokens; withdraw native tokens from the wrapper contract.
    WRAPPER.withdraw(amount);

    // Send to recipient
    _sweep(recipient, address(0), amount);
  }

  /**
   * @notice Fallback function so this contract can receive the funds from WETH
   */
  receive() external payable {}

  // ============ Internal Functions ============

  /**
   * @notice Sweeps the provided token from this address to a designated recipient.
   * @dev Emits the `FundsDelivered` event
   *
   * @param recipient The address to send the funds to
   * @param asset The asset (or address(0) for native) to send from the contract to recipient
   * @param amount Amount of asset to sweep from contract
   */
  function _sweep(
    address recipient,
    address asset,
    uint256 amount
  ) internal {
    if (asset == address(0)) {
      Address.sendValue(payable(recipient), amount);
    } else {
      IERC20(asset).transfer(recipient, amount);
    }
    emit FundsDelivered(recipient, asset, amount);
  }
}

File 7 of 8 : ProposedOwnable.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;

import {IProposedOwnable} from "./interfaces/IProposedOwnable.sol";

/**
 * @title ProposedOwnable
 * @notice 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 via a two step process:
 * 1. Call `proposeOwner`
 * 2. Wait out the delay period
 * 3. Call `acceptOwner`
 *
 * @dev 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.
 *
 * @dev The majority of this code was taken from the openzeppelin Ownable
 * contract
 *
 */
abstract contract ProposedOwnable is IProposedOwnable {
  // ========== Custom Errors ===========

  error ProposedOwnable__onlyOwner_notOwner();
  error ProposedOwnable__onlyProposed_notProposedOwner();
  error ProposedOwnable__ownershipDelayElapsed_delayNotElapsed();
  error ProposedOwnable__proposeNewOwner_invalidProposal();
  error ProposedOwnable__proposeNewOwner_noOwnershipChange();
  error ProposedOwnable__renounceOwnership_noProposal();
  error ProposedOwnable__renounceOwnership_invalidProposal();

  // ============ Properties ============

  address private _owner;

  address private _proposed;
  uint256 private _proposedOwnershipTimestamp;

  uint256 private constant _delay = 7 days;

  // ======== Getters =========

  /**
   * @notice Returns the address of the current owner.
   */
  function owner() public view virtual returns (address) {
    return _owner;
  }

  /**
   * @notice Returns the address of the proposed owner.
   */
  function proposed() public view virtual returns (address) {
    return _proposed;
  }

  /**
   * @notice Returns the address of the proposed owner.
   */
  function proposedTimestamp() public view virtual returns (uint256) {
    return _proposedOwnershipTimestamp;
  }

  /**
   * @notice Returns the delay period before a new owner can be accepted.
   */
  function delay() public view virtual returns (uint256) {
    return _delay;
  }

  /**
   * @notice Throws if called by any account other than the owner.
   */
  modifier onlyOwner() {
    if (_owner != msg.sender) revert ProposedOwnable__onlyOwner_notOwner();
    _;
  }

  /**
   * @notice Throws if called by any account other than the proposed owner.
   */
  modifier onlyProposed() {
    if (_proposed != msg.sender) revert ProposedOwnable__onlyProposed_notProposedOwner();
    _;
  }

  /**
   * @notice Throws if the ownership delay has not elapsed
   */
  modifier ownershipDelayElapsed() {
    // Ensure delay has elapsed
    if ((block.timestamp - _proposedOwnershipTimestamp) <= _delay)
      revert ProposedOwnable__ownershipDelayElapsed_delayNotElapsed();
    _;
  }

  /**
   * @notice Indicates if the ownership has been renounced() by
   * checking if current owner is address(0)
   */
  function renounced() public view returns (bool) {
    return _owner == address(0);
  }

  // ======== External =========

  /**
   * @notice Sets the timestamp for an owner to be proposed, and sets the
   * newly proposed owner as step 1 in a 2-step process
   */
  function proposeNewOwner(address newlyProposed) public virtual onlyOwner {
    // Contract as source of truth
    if (_proposed == newlyProposed && _proposedOwnershipTimestamp != 0)
      revert ProposedOwnable__proposeNewOwner_invalidProposal();

    // Sanity check: reasonable proposal
    if (_owner == newlyProposed) revert ProposedOwnable__proposeNewOwner_noOwnershipChange();

    _setProposed(newlyProposed);
  }

  /**
   * @notice Renounces ownership of the contract after a delay
   */
  function renounceOwnership() public virtual onlyOwner ownershipDelayElapsed {
    // Ensure there has been a proposal cycle started
    if (_proposedOwnershipTimestamp == 0) revert ProposedOwnable__renounceOwnership_noProposal();

    // Require proposed is set to 0
    if (_proposed != address(0)) revert ProposedOwnable__renounceOwnership_invalidProposal();

    // Emit event, set new owner, reset timestamp
    _setOwner(address(0));
  }

  /**
   * @notice Transfers ownership of the contract to a new account (`newOwner`).
   * Can only be called by the current owner.
   */
  function acceptProposedOwner() public virtual onlyProposed ownershipDelayElapsed {
    // NOTE: no need to check if _owner == _proposed, because the _proposed
    // is 0-d out and this check is implicitly enforced by modifier

    // NOTE: no need to check if _proposedOwnershipTimestamp > 0 because
    // the only time this would happen is if the _proposed was never
    // set (will fail from modifier) or if the owner == _proposed (checked
    // above)

    // Emit event, set new owner, reset timestamp
    _setOwner(_proposed);
  }

  // ======== Internal =========

  function _setOwner(address newOwner) internal {
    emit OwnershipTransferred(_owner, newOwner);
    _owner = newOwner;
    delete _proposedOwnershipTimestamp;
    delete _proposed;
  }

  function _setProposed(address newlyProposed) private {
    _proposedOwnershipTimestamp = block.timestamp;
    _proposed = newlyProposed;
    emit OwnershipProposed(newlyProposed);
  }
}

File 8 of 8 : IProposedOwnable.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

/**
 * @title IProposedOwnable
 * @notice Defines a minimal interface for ownership with a two step proposal and acceptance
 * process
 */
interface IProposedOwnable {
  /**
   * @dev This emits when change in ownership of a contract is proposed.
   */
  event OwnershipProposed(address indexed proposedOwner);

  /**
   * @dev This emits when ownership of a contract changes.
   */
  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

  /**
   * @notice Get the address of the owner
   * @return owner_ The address of the owner.
   */
  function owner() external view returns (address owner_);

  /**
   * @notice Get the address of the proposed owner
   * @return proposed_ The address of the proposed.
   */
  function proposed() external view returns (address proposed_);

  /**
   * @notice Set the address of the proposed owner of the contract
   * @param newlyProposed The proposed new owner of the contract
   */
  function proposeNewOwner(address newlyProposed) external;

  /**
   * @notice Set the address of the proposed owner of the contract
   */
  function acceptProposedOwner() external;
}

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"connext","type":"address"},{"internalType":"address","name":"wrapper","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ProposedOwnable__onlyOwner_notOwner","type":"error"},{"inputs":[],"name":"ProposedOwnable__onlyProposed_notProposedOwner","type":"error"},{"inputs":[],"name":"ProposedOwnable__ownershipDelayElapsed_delayNotElapsed","type":"error"},{"inputs":[],"name":"ProposedOwnable__proposeNewOwner_invalidProposal","type":"error"},{"inputs":[],"name":"ProposedOwnable__proposeNewOwner_noOwnershipChange","type":"error"},{"inputs":[],"name":"ProposedOwnable__renounceOwnership_invalidProposal","type":"error"},{"inputs":[],"name":"ProposedOwnable__renounceOwnership_noProposal","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FundsDelivered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"proposedOwner","type":"address"}],"name":"OwnershipProposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"WrongAsset","type":"event"},{"inputs":[],"name":"CONNEXT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WRAPPER","outputs":[{"internalType":"contract IWrapper","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptProposedOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newlyProposed","type":"address"}],"name":"proposeNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proposed","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proposedTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounced","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unwrapAndSweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint32","name":"","type":"uint32"},{"internalType":"bytes","name":"callData","type":"bytes"}],"name":"xReceive","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60c060405234801561001057600080fd5b50604051610e83380380610e8383398101604081905261002f916100d0565b6100383361004f565b6001600160a01b0390811660a05216608052610103565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b039092166001600160a01b0319928316178155600255600180549091169055565b80516001600160a01b03811681146100cb57600080fd5b919050565b600080604083850312156100e357600080fd5b6100ec836100b4565b91506100fa602084016100b4565b90509250929050565b60805160a051610d3f610144600039600081816102570152818161057d015281816106ba015261076b01526000818161018701526105fe0152610d3f6000f3fe6080604052600436106100c65760003560e01c8063b1f8100d1161007f578063d232c22011610059578063d232c220146101fc578063e03720c014610225578063e1eb13c114610245578063fd614f411461027957600080fd5b8063b1f8100d146101a9578063c5b350df146101c9578063d1851c92146101de57600080fd5b80633cf52ffb146100d257806362c06767146100f65780636a42b8f814610118578063715018a61461012e5780638da5cb5b1461014357806392f75cb21461017557600080fd5b366100cd57005b600080fd5b3480156100de57600080fd5b506002545b6040519081526020015b60405180910390f35b34801561010257600080fd5b50610116610111366004610aaa565b6102a6565b005b34801561012457600080fd5b5062093a806100e3565b34801561013a57600080fd5b50610116610327565b34801561014f57600080fd5b506000546001600160a01b03165b6040516001600160a01b0390911681526020016100ed565b34801561018157600080fd5b5061015d7f000000000000000000000000000000000000000000000000000000000000000081565b3480156101b557600080fd5b506101166101c4366004610aeb565b6103db565b3480156101d557600080fd5b5061011661047c565b3480156101ea57600080fd5b506001546001600160a01b031661015d565b34801561020857600080fd5b506000546040516001600160a01b039091161581526020016100ed565b34801561023157600080fd5b50610116610240366004610b0f565b6104ec565b34801561025157600080fd5b5061015d7f000000000000000000000000000000000000000000000000000000000000000081565b34801561028557600080fd5b50610299610294366004610b51565b6105f1565b6040516100ed9190610c55565b6000546001600160a01b031633146102d1576040516311a8a1bb60e31b815260040160405180910390fd5b806000036103175760405162461bcd60e51b815260206004820152600e60248201526d1cddd9595c0e8808585b5bdd5b9d60921b60448201526064015b60405180910390fd5b6103228383836107e7565b505050565b6000546001600160a01b03163314610352576040516311a8a1bb60e31b815260040160405180910390fd5b62093a80600254426103649190610ca3565b11610382576040516324e0285f60e21b815260040160405180910390fd5b6002546000036103a557604051630e4b303f60e21b815260040160405180910390fd5b6001546001600160a01b0316156103cf576040516323295ef960e01b815260040160405180910390fd5b6103d960006108c9565b565b6000546001600160a01b03163314610406576040516311a8a1bb60e31b815260040160405180910390fd5b6001546001600160a01b038281169116148015610424575060025415155b15610442576040516311bc066560e11b815260040160405180910390fd5b6000546001600160a01b0380831691160361047057604051634a2fb73f60e11b815260040160405180910390fd5b6104798161092e565b50565b6001546001600160a01b031633146104a7576040516311a7f27160e11b815260040160405180910390fd5b62093a80600254426104b99190610ca3565b116104d7576040516324e0285f60e21b815260040160405180910390fd5b6001546103d9906001600160a01b03166108c9565b6000546001600160a01b03163314610517576040516311a8a1bb60e31b815260040160405180910390fd5b806000036105675760405162461bcd60e51b815260206004820152601760248201527f756e77726170416e6453776565703a2021616d6f756e74000000000000000000604482015260640161030e565b604051632e1a7d4d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b1580156105c957600080fd5b505af11580156105dd573d6000803e3d6000fd5b505050506105ed826000836107e7565b5050565b6060336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461065e5760405162461bcd60e51b815260206004820152601060248201526f1d5b9ddc985c0e880858dbdb9b995e1d60821b604482015260640161030e565b856000036106a05760405162461bcd60e51b815260206004820152600f60248201526e1d5b9ddc985c0e8808585b5bdd5b9d608a1b604482015260640161030e565b6000828060200190518101906106b69190610cca565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316866001600160a01b03161461075557604080516001600160a01b038084168252881660208201527f9f79eedfea1da16b88bd43866c5385861173a9895ac74e1628662f7f2192962e910160405180910390a161073f8187896107e7565b50506040805160208101909152600081526107dd565b604051632e1a7d4d60e01b8152600481018890527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b1580156107b757600080fd5b505af11580156107cb573d6000803e3d6000fd5b505050506107db816000896107e7565b505b9695505050505050565b6001600160a01b038216610804576107ff838261097c565b610879565b60405163a9059cbb60e01b81526001600160a01b0384811660048301526024820183905283169063a9059cbb906044016020604051808303816000875af1158015610853573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108779190610ce7565b505b604080516001600160a01b038086168252841660208201529081018290527f91ebf95f2932ae1bb84918555319ba9cf24fd2359b03932337af5599f2553fa99060600160405180910390a1505050565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b039092166001600160a01b0319928316178155600255600180549091169055565b42600255600180546001600160a01b0319166001600160a01b0383169081179091556040517f6ab4d119f23076e8ad491bc65ce85f017fb0591dce08755ba8591059cc51737a90600090a250565b804710156109cc5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161030e565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610a19576040519150601f19603f3d011682016040523d82523d6000602084013e610a1e565b606091505b50509050806103225760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161030e565b6001600160a01b038116811461047957600080fd5b600080600060608486031215610abf57600080fd5b8335610aca81610a95565b92506020840135610ada81610a95565b929592945050506040919091013590565b600060208284031215610afd57600080fd5b8135610b0881610a95565b9392505050565b60008060408385031215610b2257600080fd5b8235610b2d81610a95565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b60008060008060008060c08789031215610b6a57600080fd5b86359550602087013594506040870135610b8381610a95565b93506060870135610b9381610a95565b9250608087013563ffffffff81168114610bac57600080fd5b915060a087013567ffffffffffffffff80821115610bc957600080fd5b818901915089601f830112610bdd57600080fd5b813581811115610bef57610bef610b3b565b604051601f8201601f19908116603f01168101908382118183101715610c1757610c17610b3b565b816040528281528c6020848701011115610c3057600080fd5b8260208601602083013760006020848301015280955050505050509295509295509295565b600060208083528351808285015260005b81811015610c8257858101830151858201604001528201610c66565b506000604082860101526040601f19601f8301168501019250505092915050565b81810381811115610cc457634e487b7160e01b600052601160045260246000fd5b92915050565b600060208284031215610cdc57600080fd5b8151610b0881610a95565b600060208284031215610cf957600080fd5b81518015158114610b0857600080fdfea2646970667358221220f6b28a7547d9416268a270b6b949192890b994c51b055287f898d24006f507bb64736f6c634300081100330000000000000000000000002075c9e31f973bb53cae5bac36a8eeb4b082adc20000000000000000000000001346786e6a5e07b90184a1ba58e55444b99dc4a2

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000002075c9e31f973bb53cae5bac36a8eeb4b082adc20000000000000000000000001346786e6a5e07b90184a1ba58e55444b99dc4a2

-----Decoded View---------------
Arg [0] : connext (address): 0x2075c9e31f973bb53cae5bac36a8eeb4b082adc2
Arg [1] : wrapper (address): 0x1346786e6a5e07b90184a1ba58e55444b99dc4a2

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000002075c9e31f973bb53cae5bac36a8eeb4b082adc2
Arg [1] : 0000000000000000000000001346786e6a5e07b90184a1ba58e55444b99dc4a2


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading