S Price: $0.067881 (+0.53%)
Gas: 55 Gwei

Contract

0x0Af78f0ccb7D1a042D13f3D4def51ceC7c189a00

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0 S

S Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Deposit607923212026-01-20 18:26:056 days ago1768933565IN
0x0Af78f0c...C7c189a00
100 S0.0364648955
Deposit605137092026-01-16 13:20:3510 days ago1768569635IN
0x0Af78f0c...C7c189a00
119,374 S0.0313175150.0001
Deposit599347112026-01-08 17:57:5318 days ago1767895073IN
0x0Af78f0c...C7c189a00
14,000 S0.0304625150.0001
Deposit594637612026-01-02 22:35:5124 days ago1767393351IN
0x0Af78f0c...C7c189a00
57 S0.0304625150.0001
Deposit591587012025-12-29 7:14:1228 days ago1766992452IN
0x0Af78f0c...C7c189a00
1,001 S0.0304625150.0001
Deposit590491642025-12-27 15:08:5830 days ago1766848138IN
0x0Af78f0c...C7c189a00
1,000 S0.0313175150.0001
Deposit584038392025-12-20 5:59:0737 days ago1766210347IN
0x0Af78f0c...C7c189a00
10 S0.0304625150.0001
Deposit580164592025-12-15 19:18:5842 days ago1765826338IN
0x0Af78f0c...C7c189a00
0.1 S0.0354773655
Deposit577071762025-12-11 18:46:2146 days ago1765478781IN
0x0Af78f0c...C7c189a00
1,020 S0.0163681560.185
Deposit577070052025-12-11 18:45:0046 days ago1765478700IN
0x0Af78f0c...C7c189a00
1,140 S0.0376645560.185
Deposit577068112025-12-11 18:43:2146 days ago1765478601IN
0x0Af78f0c...C7c189a00
1,265 S0.0135982250.0001
Deposit577066842025-12-11 18:42:0646 days ago1765478526IN
0x0Af78f0c...C7c189a00
1,406 S0.0135982250.0001
Deposit577066182025-12-11 18:40:5146 days ago1765478451IN
0x0Af78f0c...C7c189a00
1,561 S0.0135982250.0001
Deposit577065382025-12-11 18:39:3846 days ago1765478378IN
0x0Af78f0c...C7c189a00
1,735 S0.0135982250.0001
Deposit577064002025-12-11 18:38:1746 days ago1765478297IN
0x0Af78f0c...C7c189a00
1,927 S0.0135982250.0001
Deposit577063132025-12-11 18:37:0446 days ago1765478224IN
0x0Af78f0c...C7c189a00
2,140 S0.0135982250.0001
Deposit577061652025-12-11 18:35:4246 days ago1765478142IN
0x0Af78f0c...C7c189a00
2,377 S0.0312907150.0001
Deposit577060392025-12-11 18:33:2646 days ago1765478006IN
0x0Af78f0c...C7c189a00
2,640 S0.0135982250.0001
Deposit577058462025-12-11 18:29:3846 days ago1765477778IN
0x0Af78f0c...C7c189a00
1,540 S0.0312907150.0001
Deposit569977072025-12-03 0:52:2955 days ago1764723149IN
0x0Af78f0c...C7c189a00
252 S0.047891374.31
Deposit569412582025-12-02 12:11:3255 days ago1764677492IN
0x0Af78f0c...C7c189a00
45 S0.0304357150.0001
Deposit569080872025-12-02 1:45:2955 days ago1764639929IN
0x0Af78f0c...C7c189a00
163 S0.0304357150.0001
Deposit566281162025-11-28 12:10:0959 days ago1764331809IN
0x0Af78f0c...C7c189a00
1,000 S0.0312907150.0001
Deposit563636062025-11-25 6:31:5062 days ago1764052310IN
0x0Af78f0c...C7c189a00
50 S0.0362831857.333
Deposit563317402025-11-24 20:53:5963 days ago1764017639IN
0x0Af78f0c...C7c189a00
150 S0.0382874260.5
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
607923212026-01-20 18:26:056 days ago1768933565
0x0Af78f0c...C7c189a00
100 S
605137092026-01-16 13:20:3510 days ago1768569635
0x0Af78f0c...C7c189a00
119,374 S
599347112026-01-08 17:57:5318 days ago1767895073
0x0Af78f0c...C7c189a00
14,000 S
594637612026-01-02 22:35:5124 days ago1767393351
0x0Af78f0c...C7c189a00
57 S
591587012025-12-29 7:14:1228 days ago1766992452
0x0Af78f0c...C7c189a00
1,001 S
590491642025-12-27 15:08:5830 days ago1766848138
0x0Af78f0c...C7c189a00
1,000 S
584038392025-12-20 5:59:0737 days ago1766210347
0x0Af78f0c...C7c189a00
10 S
580164592025-12-15 19:18:5842 days ago1765826338
0x0Af78f0c...C7c189a00
0.1 S
577071762025-12-11 18:46:2146 days ago1765478781
0x0Af78f0c...C7c189a00
1,020 S
577070052025-12-11 18:45:0046 days ago1765478700
0x0Af78f0c...C7c189a00
1,140 S
577068112025-12-11 18:43:2146 days ago1765478601
0x0Af78f0c...C7c189a00
1,265 S
577066842025-12-11 18:42:0646 days ago1765478526
0x0Af78f0c...C7c189a00
1,406 S
577066182025-12-11 18:40:5146 days ago1765478451
0x0Af78f0c...C7c189a00
1,561 S
577065382025-12-11 18:39:3846 days ago1765478378
0x0Af78f0c...C7c189a00
1,735 S
577064002025-12-11 18:38:1746 days ago1765478297
0x0Af78f0c...C7c189a00
1,927 S
577063132025-12-11 18:37:0446 days ago1765478224
0x0Af78f0c...C7c189a00
2,140 S
577061652025-12-11 18:35:4246 days ago1765478142
0x0Af78f0c...C7c189a00
2,377 S
577060392025-12-11 18:33:2646 days ago1765478006
0x0Af78f0c...C7c189a00
2,640 S
577058462025-12-11 18:29:3846 days ago1765477778
0x0Af78f0c...C7c189a00
1,540 S
569977072025-12-03 0:52:2955 days ago1764723149
0x0Af78f0c...C7c189a00
252 S
569412582025-12-02 12:11:3255 days ago1764677492
0x0Af78f0c...C7c189a00
45 S
569080872025-12-02 1:45:2955 days ago1764639929
0x0Af78f0c...C7c189a00
163 S
566281162025-11-28 12:10:0959 days ago1764331809
0x0Af78f0c...C7c189a00
1,000 S
563636062025-11-25 6:31:5062 days ago1764052310
0x0Af78f0c...C7c189a00
50 S
563317402025-11-24 20:53:5963 days ago1764017639
0x0Af78f0c...C7c189a00
150 S
View All Internal Transactions
Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AnglesSmartRouter

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 100 runs

Other Settings:
paris EvmVersion
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import "@openzeppelin/contracts/access/Ownable2Step.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "./interfaces/IAnglesVault.sol";
import "./interfaces/IBatchRouter.sol";

contract AnglesSmartRouter is Ownable2Step, ReentrancyGuard {
    using SafeERC20 for IERC20;

    address public feeReceiver;
    IERC20 public constant anS =
        IERC20(0x0C4E186Eae8aCAA7F7de1315D5AD174BE39Ec987);
    IAnglesVault public constant anglesVault =
        IAnglesVault(0xe5203Be1643465b3c0De28fd2154843497Ef4269);
    IBatchRouter public constant batchRouter =
        IBatchRouter(0x7761659F9e9834ad367e4d25E0306ba7A4968DAf);

    uint256 public alwaysDepositToVault = 1e17;

    // --------------------------------------------------------------------------------
    event FeeCollected(uint256 amount);
    event FeeReceiverSet(address feeReceiver);
    event AlwaysDepositToVaultSet(uint256 alwaysDepositToVault);

    // --------------------------------------------------------------------------------
    constructor(address _feeReceiver) {
        feeReceiver = _feeReceiver;
    }

    // ================================================================================
    // User functions
    // ================================================================================

    function deposit() external payable nonReentrant {
        uint256 amount = msg.value;

        (uint128 queued, uint128 claimable, , ) = anglesVault
            .withdrawalQueueMetadata();

        uint128 queueShortfall = queued - claimable;
        uint256 vaultRequires = Math.max(queueShortfall, alwaysDepositToVault);

        uint256 amountToDeposit = amount;

        if (amount > vaultRequires) {
            uint256 amountAvailableToSwap = amount - vaultRequires;

            // Trying to swap the amountAvailableToSwap. Expect it to fail, if the exchange rate is not favorable.
            // If exchange rate is not favorable, we will not swap anything. All the amount will be deposited in the vault directly.
            bool success = trySwapForProfit(amountAvailableToSwap);
            if (success) {
                // Remove what was swapped from the amount to deposit
                amountToDeposit -= amountAvailableToSwap;
            }
        }
        if (amountToDeposit > 0) {
            anglesVault.deposit{value: amountToDeposit}();
        }
        anS.safeTransfer(msg.sender, amount);

        uint256 anSOnContract = anS.balanceOf(address(this));
        if (anSOnContract > 0) {
            anS.safeTransfer(feeReceiver, anSOnContract);
        }

        emit FeeCollected(anSOnContract);
    }

    // ================================================================================
    // Internal functions
    // ================================================================================

    function trySwapForProfit(
        uint256 amountIn
    ) internal returns (bool success) {
        IBatchRouter.SwapPathExactAmountIn[]
            memory swapPaths = new IBatchRouter.SwapPathExactAmountIn[](1);
        swapPaths[0] = IBatchRouter.SwapPathExactAmountIn({
            tokenIn: IERC20(0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38),
            steps: new IBatchRouter.SwapPathStep[](2),
            exactAmountIn: amountIn,
            minAmountOut: amountIn + 1
        });

        swapPaths[0].steps[0] = IBatchRouter.SwapPathStep({
            pool: 0x016C306e103FbF48EC24810D078C65aD13c5f11B,
            tokenOut: IERC20(0x016C306e103FbF48EC24810D078C65aD13c5f11B),
            isBuffer: true
        });

        swapPaths[0].steps[1] = IBatchRouter.SwapPathStep({
            pool: 0x944D4AE892dE4BFd38742Cc8295d6D5164c5593C,
            tokenOut: anS,
            isBuffer: false
        });
        try
            batchRouter.swapExactIn{value: amountIn}(
                swapPaths,
                block.timestamp,
                true,
                ""
            )
        {
            return true;
        } catch {
            return false;
        }
    }

    // ================================================================================
    // Admin functions
    // ================================================================================
    function setFeeReceiver(address _feeReceiver) external onlyOwner {
        feeReceiver = _feeReceiver;
        emit FeeReceiverSet(_feeReceiver);
    }

    function setAlwaysDepositToVault(
        uint256 _alwaysDepositToVault
    ) external onlyOwner {
        alwaysDepositToVault = _alwaysDepositToVault;
        emit AlwaysDepositToVaultSet(_alwaysDepositToVault);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.0;

import "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        return _pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
        _transferOwnership(sender);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/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.
 *
 * ==== 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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/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;

    /**
     * @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.encodeWithSelector(token.transfer.selector, 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.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));
    }

    /**
     * @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);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    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");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @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.encodeWithSelector(token.approve.selector, spender, value);

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

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    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");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation 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).
     *
     * 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.isContract(address(token));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [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://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.0/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);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

interface IAnglesVault {
    function deposit() external payable;

    function withdrawalQueueMetadata()
        external
        view
        returns (
            uint128 queued,
            uint128 claimable,
            uint128 claimed,
            uint128 nextWithdrawalIndex
        );
}

File 12 of 12 : IBatchRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

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

interface IBatchRouter {
    struct SwapPathStep {
        address pool;
        IERC20 tokenOut;
        // If true, the "pool" is an ERC4626 Buffer. Used to wrap/unwrap tokens if pool doesn't have enough liquidity.
        bool isBuffer;
    }

    struct SwapPathExactAmountIn {
        IERC20 tokenIn;
        // For each step:
        // If tokenIn == pool, use removeLiquidity SINGLE_TOKEN_EXACT_IN.
        // If tokenOut == pool, use addLiquidity UNBALANCED.
        SwapPathStep[] steps;
        uint256 exactAmountIn;
        uint256 minAmountOut;
    }
    function swapExactIn(
        SwapPathExactAmountIn[] memory paths,
        uint256 deadline,
        bool wethIsEth,
        bytes calldata userData
    )
        external
        payable
        returns (
            uint256[] memory pathAmountsOut,
            address[] memory tokensOut,
            uint256[] memory amountsOut
        );
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_feeReceiver","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"alwaysDepositToVault","type":"uint256"}],"name":"AlwaysDepositToVaultSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeeCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"feeReceiver","type":"address"}],"name":"FeeReceiverSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","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"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"alwaysDepositToVault","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"anS","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"anglesVault","outputs":[{"internalType":"contract IAnglesVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"batchRouter","outputs":[{"internalType":"contract IBatchRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"feeReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_alwaysDepositToVault","type":"uint256"}],"name":"setAlwaysDepositToVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeReceiver","type":"address"}],"name":"setFeeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405267016345785d8a000060045534801561001c57600080fd5b5060405161133e38038061133e83398101604081905261003b916100da565b6100443361006e565b6001600255600380546001600160a01b0319166001600160a01b039290921691909117905561010a565b600180546001600160a01b03191690556100878161008a565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100ec57600080fd5b81516001600160a01b038116811461010357600080fd5b9392505050565b611225806101196000396000f3fe6080604052600436106100b25760003560e01c8063b82064361161006f578063b820643614610183578063d0e30db0146101a3578063dcddaf04146101ab578063e30c3978146101d3578063efdcd974146101f1578063f2fde38b14610211578063f5cd47441461023157600080fd5b80634cae133f146100b7578063715018a6146100f557806379ba50971461010c5780638da5cb5b14610121578063b3f006741461013f578063b56a75ac1461015f575b600080fd5b3480156100c357600080fd5b506100df737761659f9e9834ad367e4d25e0306ba7a4968daf81565b6040516100ec9190610d15565b60405180910390f35b34801561010157600080fd5b5061010a610259565b005b34801561011857600080fd5b5061010a61026d565b34801561012d57600080fd5b506000546001600160a01b03166100df565b34801561014b57600080fd5b506003546100df906001600160a01b031681565b34801561016b57600080fd5b5061017560045481565b6040519081526020016100ec565b34801561018f57600080fd5b5061010a61019e366004610d29565b6102ec565b61010a610330565b3480156101b757600080fd5b506100df730c4e186eae8acaa7f7de1315d5ad174be39ec98781565b3480156101df57600080fd5b506001546001600160a01b03166100df565b3480156101fd57600080fd5b5061010a61020c366004610d57565b6105a0565b34801561021d57600080fd5b5061010a61022c366004610d57565b6105f3565b34801561023d57600080fd5b506100df73e5203be1643465b3c0de28fd2154843497ef426981565b610261610664565b61026b60006106be565b565b60015433906001600160a01b031681146102e05760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084015b60405180910390fd5b6102e9816106be565b50565b6102f4610664565b60048190556040518181527f4bc673bb0c016247e6a20fe9e1f00321ea8217ac642db81d969d3814c1db0527906020015b60405180910390a150565b6103386106d7565b600034905060008073e5203be1643465b3c0de28fd2154843497ef42696001600160a01b031663362bd1a36040518163ffffffff1660e01b8152600401608060405180830381865afa158015610392573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b69190610d97565b505091509150600081836103ca9190610e01565b905060006103e3826001600160801b031660045461072e565b9050848181111561041f5760006103fa8388610e20565b9050600061040782610748565b9050801561041c576104198284610e20565b92505b50505b801561048e5773e5203be1643465b3c0de28fd2154843497ef42696001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561047457600080fd5b505af1158015610488573d6000803e3d6000fd5b50505050505b6104ad730c4e186eae8acaa7f7de1315d5ad174be39ec9873388610a09565b6040516370a0823160e01b8152600090730c4e186eae8acaa7f7de1315d5ad174be39ec987906370a08231906104e7903090600401610d15565b602060405180830381865afa158015610504573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105289190610e33565b9050801561055c5760035461055c90730c4e186eae8acaa7f7de1315d5ad174be39ec987906001600160a01b031683610a09565b6040518181527fc472cb3a7a659a876494d66b3063145f279701771d6150b9329c31611ed6405c9060200160405180910390a15050505050505061026b6001600255565b6105a8610664565b600380546001600160a01b0319166001600160a01b0383161790556040517fbdf37c276f641820b141429d245add2552b4118c0866e5a78638e3de5ef18d9d90610325908390610d15565b6105fb610664565b600180546001600160a01b0383166001600160a01b0319909116811790915561062c6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b0316331461026b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d7565b600180546001600160a01b03191690556102e981610a60565b60028054036107285760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102d7565b60028055565b600081831161073d578161073f565b825b90505b92915050565b604080516001808252818301909252600091829190816020015b610796604051806080016040528060006001600160a01b031681526020016060815260200160008152602001600081525090565b815260200190600190039081610762579050506040805160808101825273039e2fb66102314ce7b64ce5ce3e5183bc94ad3881528151600280825260608201909352929350916020830191816020015b60408051606081018252600080825260208083018290529282015282526000199092019101816107e6575050815260208101859052604001610829856001610e62565b8152508160008151811061083f5761083f610e75565b6020026020010181905250604051806060016040528073016c306e103fbf48ec24810d078c65ad13c5f11b6001600160a01b0316815260200173016c306e103fbf48ec24810d078c65ad13c5f11b6001600160a01b0316815260200160011515815250816000815181106108b5576108b5610e75565b6020026020010151602001516000815181106108d3576108d3610e75565b6020026020010181905250604051806060016040528073944d4ae892de4bfd38742cc8295d6d5164c5593c6001600160a01b03168152602001730c4e186eae8acaa7f7de1315d5ad174be39ec9876001600160a01b03168152602001600015158152508160008151811061094957610949610e75565b60200260200101516020015160018151811061096757610967610e75565b602090810291909101015260405163286f580d60e01b8152737761659f9e9834ad367e4d25e0306ba7a4968daf9063286f580d9085906109b09085904290600190600401610e8b565b60006040518083038185885af1935050505080156109f057506040513d6000823e601f3d908101601f191682016040526109ed9190810190611062565b60015b6109fd5750600092915050565b50600195945050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610a5b908490610ab0565b505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610b05826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610b859092919063ffffffff16565b9050805160001480610b26575080806020019051810190610b26919061115a565b610a5b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102d7565b6060610b948484600085610b9c565b949350505050565b606082471015610bfd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016102d7565b600080866001600160a01b03168587604051610c1991906111a0565b60006040518083038185875af1925050503d8060008114610c56576040519150601f19603f3d011682016040523d82523d6000602084013e610c5b565b606091505b5091509150610c6c87838387610c77565b979650505050505050565b60608315610ce6578251600003610cdf576001600160a01b0385163b610cdf5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102d7565b5081610b94565b610b948383815115610cfb5781518083602001fd5b8060405162461bcd60e51b81526004016102d791906111bc565b6001600160a01b0391909116815260200190565b600060208284031215610d3b57600080fd5b5035919050565b6001600160a01b03811681146102e957600080fd5b600060208284031215610d6957600080fd5b8135610d7481610d42565b9392505050565b80516001600160801b0381168114610d9257600080fd5b919050565b60008060008060808587031215610dad57600080fd5b610db685610d7b565b9350610dc460208601610d7b565b9250610dd260408601610d7b565b9150610de060608601610d7b565b905092959194509250565b634e487b7160e01b600052601160045260246000fd5b6001600160801b03828116828216039081111561074257610742610deb565b8181038181111561074257610742610deb565b600060208284031215610e4557600080fd5b5051919050565b634e487b7160e01b600052604160045260246000fd5b8082018082111561074257610742610deb565b634e487b7160e01b600052603260045260246000fd5b6000608082016080835280865180835260a08501915060a08160051b86010192506020880160005b82811015610f6e57868503609f19018452815180516001600160a01b031686526020808201516080828901819052815190890181905291019060009060a08901905b80831015610f4057835180516001600160a01b039081168452602080830151909116818501526040918201511515918401919091529093019260019290920191606090910190610ef5565b50604084810151908a0152606093840151939098019290925250506020938401939190910190600101610eb3565b50505050846020840152610f86604084018515159052565b828103606084015260008152602081019695505050505050565b604051601f8201601f1916810167ffffffffffffffff81118282101715610fc957610fc9610e4c565b604052919050565b600067ffffffffffffffff821115610feb57610feb610e4c565b5060051b60200190565b600082601f83011261100657600080fd5b815161101961101482610fd1565b610fa0565b8082825260208201915060208360051b86010192508583111561103b57600080fd5b602085015b83811015611058578051835260209283019201611040565b5095945050505050565b60008060006060848603121561107757600080fd5b835167ffffffffffffffff81111561108e57600080fd5b61109a86828701610ff5565b935050602084015167ffffffffffffffff8111156110b757600080fd5b8401601f810186136110c857600080fd5b80516110d661101482610fd1565b8082825260208201915060208360051b8501019250888311156110f857600080fd5b6020840193505b8284101561112357835161111281610d42565b8252602093840193909101906110ff565b80955050505050604084015167ffffffffffffffff81111561114457600080fd5b61115086828701610ff5565b9150509250925092565b60006020828403121561116c57600080fd5b81518015158114610d7457600080fd5b60005b8381101561119757818101518382015260200161117f565b50506000910152565b600082516111b281846020870161117c565b9190910192915050565b60208152600082518060208401526111db81604085016020870161117c565b601f01601f1916919091016040019291505056fea2646970667358221220cb3eaf4446ea5f2fed7afb4a96ccbeff35095b8a0b8b692cb4074a906f79654864736f6c634300081c0033000000000000000000000000a568c066809bae9278f97d246e51058686f60639

Deployed Bytecode

0x6080604052600436106100b25760003560e01c8063b82064361161006f578063b820643614610183578063d0e30db0146101a3578063dcddaf04146101ab578063e30c3978146101d3578063efdcd974146101f1578063f2fde38b14610211578063f5cd47441461023157600080fd5b80634cae133f146100b7578063715018a6146100f557806379ba50971461010c5780638da5cb5b14610121578063b3f006741461013f578063b56a75ac1461015f575b600080fd5b3480156100c357600080fd5b506100df737761659f9e9834ad367e4d25e0306ba7a4968daf81565b6040516100ec9190610d15565b60405180910390f35b34801561010157600080fd5b5061010a610259565b005b34801561011857600080fd5b5061010a61026d565b34801561012d57600080fd5b506000546001600160a01b03166100df565b34801561014b57600080fd5b506003546100df906001600160a01b031681565b34801561016b57600080fd5b5061017560045481565b6040519081526020016100ec565b34801561018f57600080fd5b5061010a61019e366004610d29565b6102ec565b61010a610330565b3480156101b757600080fd5b506100df730c4e186eae8acaa7f7de1315d5ad174be39ec98781565b3480156101df57600080fd5b506001546001600160a01b03166100df565b3480156101fd57600080fd5b5061010a61020c366004610d57565b6105a0565b34801561021d57600080fd5b5061010a61022c366004610d57565b6105f3565b34801561023d57600080fd5b506100df73e5203be1643465b3c0de28fd2154843497ef426981565b610261610664565b61026b60006106be565b565b60015433906001600160a01b031681146102e05760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084015b60405180910390fd5b6102e9816106be565b50565b6102f4610664565b60048190556040518181527f4bc673bb0c016247e6a20fe9e1f00321ea8217ac642db81d969d3814c1db0527906020015b60405180910390a150565b6103386106d7565b600034905060008073e5203be1643465b3c0de28fd2154843497ef42696001600160a01b031663362bd1a36040518163ffffffff1660e01b8152600401608060405180830381865afa158015610392573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b69190610d97565b505091509150600081836103ca9190610e01565b905060006103e3826001600160801b031660045461072e565b9050848181111561041f5760006103fa8388610e20565b9050600061040782610748565b9050801561041c576104198284610e20565b92505b50505b801561048e5773e5203be1643465b3c0de28fd2154843497ef42696001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561047457600080fd5b505af1158015610488573d6000803e3d6000fd5b50505050505b6104ad730c4e186eae8acaa7f7de1315d5ad174be39ec9873388610a09565b6040516370a0823160e01b8152600090730c4e186eae8acaa7f7de1315d5ad174be39ec987906370a08231906104e7903090600401610d15565b602060405180830381865afa158015610504573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105289190610e33565b9050801561055c5760035461055c90730c4e186eae8acaa7f7de1315d5ad174be39ec987906001600160a01b031683610a09565b6040518181527fc472cb3a7a659a876494d66b3063145f279701771d6150b9329c31611ed6405c9060200160405180910390a15050505050505061026b6001600255565b6105a8610664565b600380546001600160a01b0319166001600160a01b0383161790556040517fbdf37c276f641820b141429d245add2552b4118c0866e5a78638e3de5ef18d9d90610325908390610d15565b6105fb610664565b600180546001600160a01b0383166001600160a01b0319909116811790915561062c6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b0316331461026b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102d7565b600180546001600160a01b03191690556102e981610a60565b60028054036107285760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102d7565b60028055565b600081831161073d578161073f565b825b90505b92915050565b604080516001808252818301909252600091829190816020015b610796604051806080016040528060006001600160a01b031681526020016060815260200160008152602001600081525090565b815260200190600190039081610762579050506040805160808101825273039e2fb66102314ce7b64ce5ce3e5183bc94ad3881528151600280825260608201909352929350916020830191816020015b60408051606081018252600080825260208083018290529282015282526000199092019101816107e6575050815260208101859052604001610829856001610e62565b8152508160008151811061083f5761083f610e75565b6020026020010181905250604051806060016040528073016c306e103fbf48ec24810d078c65ad13c5f11b6001600160a01b0316815260200173016c306e103fbf48ec24810d078c65ad13c5f11b6001600160a01b0316815260200160011515815250816000815181106108b5576108b5610e75565b6020026020010151602001516000815181106108d3576108d3610e75565b6020026020010181905250604051806060016040528073944d4ae892de4bfd38742cc8295d6d5164c5593c6001600160a01b03168152602001730c4e186eae8acaa7f7de1315d5ad174be39ec9876001600160a01b03168152602001600015158152508160008151811061094957610949610e75565b60200260200101516020015160018151811061096757610967610e75565b602090810291909101015260405163286f580d60e01b8152737761659f9e9834ad367e4d25e0306ba7a4968daf9063286f580d9085906109b09085904290600190600401610e8b565b60006040518083038185885af1935050505080156109f057506040513d6000823e601f3d908101601f191682016040526109ed9190810190611062565b60015b6109fd5750600092915050565b50600195945050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610a5b908490610ab0565b505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610b05826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610b859092919063ffffffff16565b9050805160001480610b26575080806020019051810190610b26919061115a565b610a5b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102d7565b6060610b948484600085610b9c565b949350505050565b606082471015610bfd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016102d7565b600080866001600160a01b03168587604051610c1991906111a0565b60006040518083038185875af1925050503d8060008114610c56576040519150601f19603f3d011682016040523d82523d6000602084013e610c5b565b606091505b5091509150610c6c87838387610c77565b979650505050505050565b60608315610ce6578251600003610cdf576001600160a01b0385163b610cdf5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102d7565b5081610b94565b610b948383815115610cfb5781518083602001fd5b8060405162461bcd60e51b81526004016102d791906111bc565b6001600160a01b0391909116815260200190565b600060208284031215610d3b57600080fd5b5035919050565b6001600160a01b03811681146102e957600080fd5b600060208284031215610d6957600080fd5b8135610d7481610d42565b9392505050565b80516001600160801b0381168114610d9257600080fd5b919050565b60008060008060808587031215610dad57600080fd5b610db685610d7b565b9350610dc460208601610d7b565b9250610dd260408601610d7b565b9150610de060608601610d7b565b905092959194509250565b634e487b7160e01b600052601160045260246000fd5b6001600160801b03828116828216039081111561074257610742610deb565b8181038181111561074257610742610deb565b600060208284031215610e4557600080fd5b5051919050565b634e487b7160e01b600052604160045260246000fd5b8082018082111561074257610742610deb565b634e487b7160e01b600052603260045260246000fd5b6000608082016080835280865180835260a08501915060a08160051b86010192506020880160005b82811015610f6e57868503609f19018452815180516001600160a01b031686526020808201516080828901819052815190890181905291019060009060a08901905b80831015610f4057835180516001600160a01b039081168452602080830151909116818501526040918201511515918401919091529093019260019290920191606090910190610ef5565b50604084810151908a0152606093840151939098019290925250506020938401939190910190600101610eb3565b50505050846020840152610f86604084018515159052565b828103606084015260008152602081019695505050505050565b604051601f8201601f1916810167ffffffffffffffff81118282101715610fc957610fc9610e4c565b604052919050565b600067ffffffffffffffff821115610feb57610feb610e4c565b5060051b60200190565b600082601f83011261100657600080fd5b815161101961101482610fd1565b610fa0565b8082825260208201915060208360051b86010192508583111561103b57600080fd5b602085015b83811015611058578051835260209283019201611040565b5095945050505050565b60008060006060848603121561107757600080fd5b835167ffffffffffffffff81111561108e57600080fd5b61109a86828701610ff5565b935050602084015167ffffffffffffffff8111156110b757600080fd5b8401601f810186136110c857600080fd5b80516110d661101482610fd1565b8082825260208201915060208360051b8501019250888311156110f857600080fd5b6020840193505b8284101561112357835161111281610d42565b8252602093840193909101906110ff565b80955050505050604084015167ffffffffffffffff81111561114457600080fd5b61115086828701610ff5565b9150509250925092565b60006020828403121561116c57600080fd5b81518015158114610d7457600080fd5b60005b8381101561119757818101518382015260200161117f565b50506000910152565b600082516111b281846020870161117c565b9190910192915050565b60208152600082518060208401526111db81604085016020870161117c565b601f01601f1916919091016040019291505056fea2646970667358221220cb3eaf4446ea5f2fed7afb4a96ccbeff35095b8a0b8b692cb4074a906f79654864736f6c634300081c0033

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

000000000000000000000000a568c066809bae9278f97d246e51058686f60639

-----Decoded View---------------
Arg [0] : _feeReceiver (address): 0xA568c066809baE9278F97d246e51058686F60639

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000a568c066809bae9278f97d246e51058686f60639


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
Loading...
Loading
[ 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.