FTM Price: $0.564544 (-2.77%)
Gas: 3 GWei
 

Overview

FTM Balance

Fantom LogoFantom LogoFantom Logo1 wei

FTM Value

Less Than $0.01 (@ $0.56/FTM)

Token Holdings

Multichain Info

1 address found via
Transaction Hash
Method
Block
From
To
Value
Swap800039552024-04-26 6:08:0358 days ago1714111683IN
0xF029ED11...CEDD9aa42
10 FTM0.02308857183.37655685
Swap800039552024-04-26 6:08:0358 days ago1714111683IN
0xF029ED11...CEDD9aa42
10 FTM0.0273518199.20475121
Swap779253112024-03-22 1:46:3793 days ago1711071997IN
0xF029ED11...CEDD9aa42
0 FTM0.0384113726.68852906
Swap777594772024-03-20 2:56:2995 days ago1710903389IN
0xF029ED11...CEDD9aa42
0 FTM0.393036700
Swap777593362024-03-20 2:54:1095 days ago1710903250IN
0xF029ED11...CEDD9aa42
0 FTM0.1857393502.41091101
Swap777591332024-03-20 2:51:1195 days ago1710903071IN
0xF029ED11...CEDD9aa42
0 FTM0.19265682502.52708573
Swap777590012024-03-20 2:48:5995 days ago1710902939IN
0xF029ED11...CEDD9aa42
0 FTM0.46851112560
Swap777588852024-03-20 2:46:5295 days ago1710902812IN
0xF029ED11...CEDD9aa42
0 FTM0.18563889502.1393145
Swap777588682024-03-20 2:46:3495 days ago1710902794IN
0xF029ED11...CEDD9aa42
0 FTM0.2770734536
Swap777587552024-03-20 2:44:4495 days ago1710902684IN
0xF029ED11...CEDD9aa42
978 FTM0.10108435517.29100409
Swap777586852024-03-20 2:43:4395 days ago1710902623IN
0xF029ED11...CEDD9aa42
9.75 FTM0.08490057509.58894281
Swap777586792024-03-20 2:43:3695 days ago1710902616IN
0xF029ED11...CEDD9aa42
0 FTM0.38787967509.85009726
Swap777586772024-03-20 2:43:3595 days ago1710902615IN
0xF029ED11...CEDD9aa42
0 FTM0.23128545535.06838995
Swap777586432024-03-20 2:43:0895 days ago1710902588IN
0xF029ED11...CEDD9aa42
10.79 FTM0.14190235510.18686215
Swap777585582024-03-20 2:41:5895 days ago1710902518IN
0xF029ED11...CEDD9aa42
0 FTM0.16318461509.70186102
Swap777584332024-03-20 2:39:5395 days ago1710902393IN
0xF029ED11...CEDD9aa42
19 FTM0.0902142509.63872937
Swap777584122024-03-20 2:39:3295 days ago1710902372IN
0xF029ED11...CEDD9aa42
19 FTM0.10012107509.69581878
Swap777583982024-03-20 2:39:1695 days ago1710902356IN
0xF029ED11...CEDD9aa42
10.3 FTM0.12883215627.176808
Swap777583592024-03-20 2:38:3295 days ago1710902312IN
0xF029ED11...CEDD9aa42
0 FTM0.19102888509.8631156
Swap777583242024-03-20 2:38:0195 days ago1710902281IN
0xF029ED11...CEDD9aa42
0 FTM0.29273509508.93280629
Swap777582822024-03-20 2:37:2195 days ago1710902241IN
0xF029ED11...CEDD9aa42
0 FTM0.15447712508.87323473
Swap777582592024-03-20 2:37:0195 days ago1710902221IN
0xF029ED11...CEDD9aa42
0 FTM0.12855745508.71735579
Swap777582242024-03-20 2:36:2595 days ago1710902185IN
0xF029ED11...CEDD9aa42
162 FTM0.10202963508.8176346
Swap777581512024-03-20 2:35:2295 days ago1710902122IN
0xF029ED11...CEDD9aa42
17 FTM0.08483302509.18350331
Swap777580422024-03-20 2:33:4095 days ago1710902020IN
0xF029ED11...CEDD9aa42
0 FTM0.34762361618.91738184
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To Value
800039552024-04-26 6:08:0358 days ago1714111683
0xF029ED11...CEDD9aa42
10 FTM
800039552024-04-26 6:08:0358 days ago1714111683
0xF029ED11...CEDD9aa42
10 FTM
777594772024-03-20 2:56:2995 days ago1710903389
0xF029ED11...CEDD9aa42
1,205.63536854 FTM
777588682024-03-20 2:46:3495 days ago1710902794
0xF029ED11...CEDD9aa42
0.36820059 FTM
777588682024-03-20 2:46:3495 days ago1710902794
0xF029ED11...CEDD9aa42
0.36820059 FTM
777587552024-03-20 2:44:4495 days ago1710902684
0xF029ED11...CEDD9aa42
978 FTM
777586852024-03-20 2:43:4395 days ago1710902623
0xF029ED11...CEDD9aa42
9.75 FTM
777586772024-03-20 2:43:3595 days ago1710902615
0xF029ED11...CEDD9aa42
36.15828766 FTM
777586772024-03-20 2:43:3595 days ago1710902615
0xF029ED11...CEDD9aa42
36.15828766 FTM
777586432024-03-20 2:43:0895 days ago1710902588
0xF029ED11...CEDD9aa42
10.79 FTM
777585582024-03-20 2:41:5895 days ago1710902518
0xF029ED11...CEDD9aa42
16.79236446 FTM
777585582024-03-20 2:41:5895 days ago1710902518
0xF029ED11...CEDD9aa42
16.79236446 FTM
777584332024-03-20 2:39:5395 days ago1710902393
0xF029ED11...CEDD9aa42
19 FTM
777584122024-03-20 2:39:3295 days ago1710902372
0xF029ED11...CEDD9aa42
19 FTM
777583982024-03-20 2:39:1695 days ago1710902356
0xF029ED11...CEDD9aa42
10.3 FTM
777583592024-03-20 2:38:3295 days ago1710902312
0xF029ED11...CEDD9aa42
54.35660971 FTM
777583592024-03-20 2:38:3295 days ago1710902312
0xF029ED11...CEDD9aa42
54.35660971 FTM
777582822024-03-20 2:37:2195 days ago1710902241
0xF029ED11...CEDD9aa42
7.06432024 FTM
777582822024-03-20 2:37:2195 days ago1710902241
0xF029ED11...CEDD9aa42
7.06432024 FTM
777582242024-03-20 2:36:2595 days ago1710902185
0xF029ED11...CEDD9aa42
162 FTM
777581512024-03-20 2:35:2295 days ago1710902122
0xF029ED11...CEDD9aa42
17 FTM
777578182024-03-20 2:30:2995 days ago1710901829
0xF029ED11...CEDD9aa42
4,283.14853404 FTM
777578182024-03-20 2:30:2995 days ago1710901829
0xF029ED11...CEDD9aa42
4,283.14853404 FTM
777575242024-03-20 2:26:1495 days ago1710901574
0xF029ED11...CEDD9aa42
103.72537919 FTM
777575242024-03-20 2:26:1495 days ago1710901574
0xF029ED11...CEDD9aa42
103.72537919 FTM
View All Internal Transactions
Loading...
Loading

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

Contract Name:
ForgedRouter

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
File 1 of 8 : ForgedRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {IForgedExecutor} from "./interfaces/IForgedExecutor.sol";
import {RevertReasonParser} from "./libraries/RevertReasonParser.sol";
import {ForgedCommon} from "./common/ForgedCommon.sol";

contract ForgedRouter is ForgedCommon {
    using SafeERC20 for IERC20;

    struct SwapDescription {
        address srcToken;
        address dstToken;
        address srcReceiver;
        address dstReceiver;
        uint256 amountIn;
        uint256 minReturnAmount;
        uint16 flags;
    }

    uint256 private constant _PARTIAL_FILL = 0x01;
    uint256 private constant _REQUIRES_EXTRA_ETH = 0x02;

    event Swapped(address sender, address srcToken, address dstToken, address dstReceiver, uint256 spentAmount, uint256 returnAmount, uint256 timestamp);

    error EthDepositRejected();
    error ZeroMinReturn();
    error ZeroDataLength();
    error InvalidMsgValue();
    error PermitBadLength();
    error PermitFailed(string reason);
    error ExecuteFailed(string reason);
    error ZeroReturnAmount();
    error ReturnAmountIsNotEnough();

    receive() external payable {
        if (msg.sender == tx.origin) revert EthDepositRejected(); // solhint-disable-line avoid-tx-origin
    }

    /// @notice Performs a swap, delegating all calls encoded in `data` to `executor`.
    /// @dev router keeps 1 wei of every token on the contract balance for gas optimisations reasons. This affects first swap of every token by leaving 1 wei on the contract.
    /// @param executor Aggregation executor that executes calls described in `data`
    /// @param desc Swap description
    /// @param permit Should contain valid permit that can be used in `IERC20Permit.permit` calls.
    /// @param data Encoded calls that `caller` should execute in between of swaps
    /// @return returnAmount Resulting token amount
    /// @return spentAmount Source token amount
    function swap(
        IForgedExecutor executor,
        SwapDescription calldata desc,
        bytes calldata permit,
        bytes calldata data
    ) external payable returns (uint256 returnAmount, uint256 spentAmount) {
        if (desc.minReturnAmount == 0) revert ZeroMinReturn();
        if (data.length == 0) revert ZeroDataLength();

        address srcToken = desc.srcToken;
        address dstToken = desc.dstToken;

        bool srcETH = _isETH(srcToken);
        if (desc.flags & _REQUIRES_EXTRA_ETH != 0) {
            if (msg.value <= (srcETH ? desc.amountIn : 0)) revert InvalidMsgValue();
        } else {
            if (msg.value != (srcETH ? desc.amountIn : 0)) revert InvalidMsgValue();
        }

        if (!srcETH) {
            if (permit.length > 0) _permit(srcToken, permit);
            IERC20(srcToken).safeTransferFrom(msg.sender, desc.srcReceiver, desc.amountIn);
        }

        {
            (bool success, bytes memory result) = address(executor).call{value: srcETH ? desc.amountIn : 0}(
                abi.encodeWithSelector(executor.execute.selector, msg.sender, data)
            );
            if (!success) revert ExecuteFailed(RevertReasonParser.parse(result));
        }

        spentAmount = desc.amountIn;
        returnAmount = _balance(dstToken);
        if (returnAmount == 0) revert ZeroReturnAmount();
        // we leave 1 wei on the router for gas optimisations reasons
        returnAmount--;

        if (desc.flags & _PARTIAL_FILL != 0) {
            uint256 unspentAmount = _balance(srcToken);
            if (unspentAmount > 1) {
                // we leave 1 wei on the router for gas optimisations reasons
                unspentAmount--;
                spentAmount -= unspentAmount;
                _transfer(srcToken, payable(msg.sender), unspentAmount);
            }
            if (returnAmount * desc.amountIn < desc.minReturnAmount * spentAmount) revert ReturnAmountIsNotEnough();
        } else {
            if (returnAmount < desc.minReturnAmount) revert ReturnAmountIsNotEnough();
        }

        address dstReceiver = (desc.dstReceiver == address(0)) ? msg.sender : desc.dstReceiver;
        _transfer(dstToken, payable(dstReceiver), returnAmount);

        emit Swapped(msg.sender, srcToken, dstToken, dstReceiver, spentAmount, returnAmount, block.timestamp);
    }

    function _permit(address token, bytes calldata permit) internal {
        if (permit.length != 32 * 7) revert PermitBadLength();
        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory result) = address(token).call(abi.encodePacked(IERC20Permit.permit.selector, permit));
        if (!success) revert PermitFailed(RevertReasonParser.parse(result));
    }
}

File 2 of 8 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @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.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
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].
     *
     * CAUTION: See Security Considerations above.
     */
    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 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}

File 4 of 8 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../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;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @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);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

File 5 of 8 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) 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 FailedInnerCall();
        }
    }
}

File 6 of 8 : ForgedCommon.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

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

abstract contract ForgedCommon {
    using SafeERC20 for IERC20;

    address private constant _ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

    error InsufficientBalance();
    error ETHTransferFailed();

    function _transfer(address token, address payable to, uint256 amount) internal {
        if (amount == 0) return;
        if (_isETH(token)) {
            if (address(this).balance < amount) revert InsufficientBalance();
            (bool success, ) = to.call{value: amount}("");
            if (!success) revert ETHTransferFailed();
        } else {
            IERC20(token).safeTransfer(to, amount);
        }
    }

    function _balance(address token) internal view returns (uint256) {
        return _isETH(token) ? address(this).balance : IERC20(token).balanceOf(address(this));
    }

    function _isETH(address token) internal pure returns (bool) {
        return (token == _ETH_ADDRESS);
    }
}

File 7 of 8 : IForgedExecutor.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/// @title Interface for making arbitrary calls during swap
interface IForgedExecutor {
    /// @notice propagates information about original msg.sender and executes arbitrary data
    function execute(address initiator, bytes calldata data) external payable;
}

File 8 of 8 : RevertReasonParser.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

library RevertReasonParser {
    error InvalidRevertReason();

    function parse(bytes memory data) internal pure returns (string memory) {
        // https://solidity.readthedocs.io/en/latest/control-structures.html#revert
        // We assume that revert reason is abi-encoded as Error(string)

        // 68 = 4-byte selector 0x08c379a0 + 32 bytes offset + 32 bytes length
        if (data.length >= 68 && data[0] == "\x08" && data[1] == "\xc3" && data[2] == "\x79" && data[3] == "\xa0") {
            string memory reason;
            // solhint-disable no-inline-assembly
            assembly {
                // 68 = 32 bytes data length + 4-byte selector + 32 bytes offset
                reason := add(data, 68)
            }
            /*
                revert reason is padded up to 32 bytes with ABI encoder: Error(string)
                also sometimes there is extra 32 bytes of zeros padded in the end:
                https://github.com/ethereum/solidity/issues/10170
                because of that we can't check for equality and instead check
                that string length + extra 68 bytes is less than overall data length
            */
            if (data.length < 68 + bytes(reason).length) revert InvalidRevertReason();
            return reason;
        }
        // 36 = 4-byte selector 0x4e487b71 + 32 bytes integer
        else if (data.length == 36 && data[0] == "\x4e" && data[1] == "\x48" && data[2] == "\x7b" && data[3] == "\x71") {
            uint256 code;
            // solhint-disable no-inline-assembly
            assembly {
                // 36 = 32 bytes data length + 4-byte selector
                code := mload(add(data, 36))
            }
            return string(abi.encodePacked("panic(", _toHex(code), ")"));
        }

        return "unknown";
    }

    function _toHex(uint256 value) private pure returns (string memory) {
        return _toHex(abi.encodePacked(value));
    }

    function _toHex(bytes memory data) private pure returns (string memory) {
        bytes memory alphabet = "0123456789abcdef";
        bytes memory str = new bytes(2 + data.length * 2);
        str[0] = "0";
        str[1] = "x";
        for (uint256 i = 0; i < data.length; i++) {
            str[2 * i + 2] = alphabet[uint8(data[i] >> 4)];
            str[2 * i + 3] = alphabet[uint8(data[i] & 0x0f)];
        }
        return string(str);
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 1000
  },
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"ETHTransferFailed","type":"error"},{"inputs":[],"name":"EthDepositRejected","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"ExecuteFailed","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidMsgValue","type":"error"},{"inputs":[],"name":"InvalidRevertReason","type":"error"},{"inputs":[],"name":"PermitBadLength","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"PermitFailed","type":"error"},{"inputs":[],"name":"ReturnAmountIsNotEnough","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"ZeroDataLength","type":"error"},{"inputs":[],"name":"ZeroMinReturn","type":"error"},{"inputs":[],"name":"ZeroReturnAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"srcToken","type":"address"},{"indexed":false,"internalType":"address","name":"dstToken","type":"address"},{"indexed":false,"internalType":"address","name":"dstReceiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"spentAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"returnAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"Swapped","type":"event"},{"inputs":[{"internalType":"contract IForgedExecutor","name":"executor","type":"address"},{"components":[{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"address","name":"srcReceiver","type":"address"},{"internalType":"address","name":"dstReceiver","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"minReturnAmount","type":"uint256"},{"internalType":"uint16","name":"flags","type":"uint16"}],"internalType":"struct ForgedRouter.SwapDescription","name":"desc","type":"tuple"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"swap","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"},{"internalType":"uint256","name":"spentAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]

Deployed Bytecode

0x6080604052600436106100225760003560e01c8063339398711461006757600080fd5b3661006257323303610060576040517f1b10b0f900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b005b600080fd5b61007a6100753660046110e7565b610093565b6040805192835260208301919091520160405180910390f35b6000808660a001356000036100d4576040517f0262dde400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600083900361010f576040517fbda012f900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061011e6020890189611189565b9050600061013260408a0160208b01611189565b90506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14600261016660e08c0160c08d016111a6565b1661ffff16156101a6578061017c576000610182565b89608001355b34116101a157604051631841b4e160e01b815260040160405180910390fd5b6101d7565b806101b25760006101b8565b89608001355b34146101d757604051631841b4e160e01b815260040160405180910390fd5b806102175787156101ed576101ed838a8a61053b565b6102173361020160608d0160408e01611189565b6001600160a01b038616919060808e0135610647565b6000808c6001600160a01b031683610230576000610236565b8c608001355b6040517f1cff79cd000000000000000000000000000000000000000000000000000000009061026d9033908e908e906024016111ca565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516102d8919061122d565b60006040518083038185875af1925050503d8060008114610315576040519150601f19603f3d011682016040523d82523d6000602084013e61031a565b606091505b5091509150816103695761032d816106c9565b6040517f1f71d9550000000000000000000000000000000000000000000000000000000081526004016103609190611249565b60405180910390fd5b50508960800135935061037b82610a09565b9450846000036103b7576040517f28ebf24700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b846103c181611292565b9550600190506103d760e08c0160c08d016111a6565b1661ffff161561045d5760006103ec84610a09565b9050600181111561041c578061040181611292565b915061040f905081866112a9565b945061041c843383610abc565b61042a8560a08d01356112bc565b61043860808d0135886112bc565b10156104575760405163f32bec2f60e01b815260040160405180910390fd5b50610482565b8960a001358510156104825760405163f32bec2f60e01b815260040160405180910390fd5b60008061049560808d0160608e01611189565b6001600160a01b0316146104b8576104b360808c0160608d01611189565b6104ba565b335b90506104c7838288610abc565b604080513381526001600160a01b03868116602083015285811682840152831660608201526080810187905260a081018890524260c082015290517fc007afccfb096c18134ad3ecc7e9ef71a52270d5ebfd6b168122e684a5baf12b9181900360e00190a150505050965096945050505050565b60e08114610575576040517fa609333c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080846001600160a01b031663d505accf60e01b858560405160200161059e939291906112d3565b60408051601f19818403018152908290526105b89161122d565b6000604051808303816000865af19150503d80600081146105f5576040519150601f19603f3d011682016040523d82523d6000602084013e6105fa565b606091505b5091509150816106405761060d816106c9565b6040517fe19fbc5f0000000000000000000000000000000000000000000000000000000081526004016103609190611249565b5050505050565b6040516001600160a01b0384811660248301528381166044830152606482018390526106c39186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610bcd565b50505050565b6060604482511015801561071e5750816000815181106106eb576106eb61130f565b6020910101516001600160f81b0319167f0800000000000000000000000000000000000000000000000000000000000000145b801561076b5750816001815181106107385761073861130f565b6020910101516001600160f81b0319167fc300000000000000000000000000000000000000000000000000000000000000145b80156107b85750816002815181106107855761078561130f565b6020910101516001600160f81b0319167f7900000000000000000000000000000000000000000000000000000000000000145b80156108055750816003815181106107d2576107d261130f565b6020910101516001600160f81b0319167fa000000000000000000000000000000000000000000000000000000000000000145b1561085d5760448281018051909161081d9190611325565b83511015610857576040517f4eda0c2f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b92915050565b815160241480156108af57508160008151811061087c5761087c61130f565b6020910101516001600160f81b0319167f4e00000000000000000000000000000000000000000000000000000000000000145b80156108fc5750816001815181106108c9576108c961130f565b6020910101516001600160f81b0319167f4800000000000000000000000000000000000000000000000000000000000000145b80156109495750816002815181106109165761091661130f565b6020910101516001600160f81b0319167f7b00000000000000000000000000000000000000000000000000000000000000145b80156109965750816003815181106109635761096361130f565b6020910101516001600160f81b0319167f7100000000000000000000000000000000000000000000000000000000000000145b156109d05760248201516109a981610c49565b6040516020016109b99190611338565b604051602081830303815290604052915050919050565b505060408051808201909152600781527f756e6b6e6f776e00000000000000000000000000000000000000000000000000602082015290565b600073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b03831614610ab5576040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015610a8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab091906113a4565b610857565b4792915050565b80600003610ac957505050565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b03841603610bb45780471015610b27576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610b74576040519150601f19603f3d011682016040523d82523d6000602084013e610b79565b606091505b50509050806106c3576040517fb12d13eb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bc86001600160a01b0384168383610c75565b505050565b6000610be26001600160a01b03841683610ca6565b90508051600014158015610c07575080806020019051810190610c0591906113bd565b155b15610bc8576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610360565b606061085782604051602001610c6191815260200190565b604051602081830303815290604052610cbb565b6040516001600160a01b03838116602483015260448201839052610bc891859182169063a9059cbb9060640161067c565b6060610cb483836000610f19565b9392505050565b60408051808201909152601081527f30313233343536373839616263646566000000000000000000000000000000006020820152815160609190600090610d039060026112bc565b610d0e906002611325565b67ffffffffffffffff811115610d2657610d266113df565b6040519080825280601f01601f191660200182016040528015610d50576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110610d8757610d8761130f565b60200101906001600160f81b031916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110610dd257610dd261130f565b60200101906001600160f81b031916908160001a90535060005b8451811015610f1157826004868381518110610e0a57610e0a61130f565b016020015182516001600160f81b031990911690911c60f81c908110610e3257610e3261130f565b01602001516001600160f81b03191682610e4d8360026112bc565b610e58906002611325565b81518110610e6857610e6861130f565b60200101906001600160f81b031916908160001a90535082858281518110610e9257610e9261130f565b602091010151815160f89190911c600f16908110610eb257610eb261130f565b01602001516001600160f81b03191682610ecd8360026112bc565b610ed8906003611325565b81518110610ee857610ee861130f565b60200101906001600160f81b031916908160001a90535080610f09816113f5565b915050610dec565b509392505050565b606081471015610f57576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401610360565b600080856001600160a01b03168486604051610f73919061122d565b60006040518083038185875af1925050503d8060008114610fb0576040519150601f19603f3d011682016040523d82523d6000602084013e610fb5565b606091505b5091509150610fc5868383610fcf565b9695505050505050565b606082610fe457610fdf82611044565b610cb4565b8151158015610ffb57506001600160a01b0384163b155b1561103d576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610360565b5080610cb4565b8051156110545780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b6001600160a01b038116811461108657600080fd5b60008083601f8401126110b057600080fd5b50813567ffffffffffffffff8111156110c857600080fd5b6020830191508360208285010111156110e057600080fd5b9250929050565b60008060008060008086880361014081121561110257600080fd5b873561110d81611089565b965060e0601f198201121561112157600080fd5b5060208701945061010087013567ffffffffffffffff8082111561114457600080fd5b6111508a838b0161109e565b909650945061012089013591508082111561116a57600080fd5b5061117789828a0161109e565b979a9699509497509295939492505050565b60006020828403121561119b57600080fd5b8135610cb481611089565b6000602082840312156111b857600080fd5b813561ffff81168114610cb457600080fd5b6001600160a01b038416815260406020820152816040820152818360608301376000818301606090810191909152601f909201601f1916010192915050565b60005b8381101561122457818101518382015260200161120c565b50506000910152565b6000825161123f818460208701611209565b9190910192915050565b6020815260008251806020840152611268816040850160208701611209565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b6000816112a1576112a161127c565b506000190190565b818103818111156108575761085761127c565b80820281158282048414176108575761085761127c565b7fffffffff0000000000000000000000000000000000000000000000000000000084168152818360048301376000910160040190815292915050565b634e487b7160e01b600052603260045260246000fd5b808201808211156108575761085761127c565b7f70616e6963280000000000000000000000000000000000000000000000000000815260008251611370816006850160208701611209565b7f29000000000000000000000000000000000000000000000000000000000000006006939091019283015250600701919050565b6000602082840312156113b657600080fd5b5051919050565b6000602082840312156113cf57600080fd5b81518015158114610cb457600080fd5b634e487b7160e01b600052604160045260246000fd5b6000600182016114075761140761127c565b506001019056fea2646970667358221220cb701de7aef149546bccf8c49af00050678d1daada8a17c1aedf35ad2f153a8c64736f6c63430008140033

Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

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

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