Contract

0x422236ec2d8f28B5a1FcD88e5cccacE56249d746

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0 S

S Value

-
Transaction Hash
Method
Block
From
To
Swap With User S...17324752024-12-27 9:17:403 days ago1735291060IN
0x422236ec...56249d746
0 S0.000554012.155
Swap With Magpie...16683272024-12-26 17:28:353 days ago1735234115IN
0x422236ec...56249d746
0 S0.000276141.45454545
Swap With Magpie...16682022024-12-26 17:26:243 days ago1735233984IN
0x422236ec...56249d746
0 S0.000157691
Swap With Magpie...16608082024-12-26 15:34:323 days ago1735227272IN
0x422236ec...56249d746
0 S0.000219671.15714285
Swap With Magpie...16607372024-12-26 15:33:103 days ago1735227190IN
0x422236ec...56249d746
0 S0.000141671
Swap With User S...16606712024-12-26 15:32:123 days ago1735227132IN
0x422236ec...56249d746
0 S0.00016331.09166666
Swap With User S...16455712024-12-26 11:16:264 days ago1735211786IN
0x422236ec...56249d746
0 S0.000353321
Swap With Magpie...16452402024-12-26 11:12:394 days ago1735211559IN
0x422236ec...56249d746
54.7 S0.002336781.11
Swap With User S...16452092024-12-26 11:11:584 days ago1735211518IN
0x422236ec...56249d746
0 S0.000183291
Swap With Magpie...16451622024-12-26 11:11:334 days ago1735211493IN
0x422236ec...56249d746
150 S0.000104461.11
Swap With Magpie...16451202024-12-26 11:11:114 days ago1735211471IN
0x422236ec...56249d746
50 S0.000267441.12
Swap With Magpie...16418362024-12-26 10:12:484 days ago1735207968IN
0x422236ec...56249d746
2 S0.000074651
Swap With User S...16404722024-12-26 9:56:484 days ago1735207008IN
0x422236ec...56249d746
0 S0.000184561
Swap With User S...16402142024-12-26 9:52:534 days ago1735206773IN
0x422236ec...56249d746
0 S0.000777851
Swap With Magpie...16400722024-12-26 9:50:384 days ago1735206638IN
0x422236ec...56249d746
2 S0.000136851
Swap With Magpie...16397932024-12-26 9:46:204 days ago1735206380IN
0x422236ec...56249d746
2 S0.000409081
Swap With User S...16356112024-12-26 8:46:284 days ago1735202788IN
0x422236ec...56249d746
0 S0.00016791
Swap With Magpie...15700272024-12-25 15:21:094 days ago1735140069IN
0x422236ec...56249d746
7 S0.00305344.62513333
Swap With Magpie...15697872024-12-25 15:19:034 days ago1735139943IN
0x422236ec...56249d746
0 S0.000347751.11
Swap With Magpie...15697032024-12-25 15:18:174 days ago1735139897IN
0x422236ec...56249d746
0 S0.000093131
Swap With User S...15695492024-12-25 15:17:044 days ago1735139824IN
0x422236ec...56249d746
0 S0.000770632.155
Swap With User S...15694232024-12-25 15:16:044 days ago1735139764IN
0x422236ec...56249d746
0 S0.000356331.4675
Swap With User S...15693152024-12-25 15:15:054 days ago1735139705IN
0x422236ec...56249d746
0 S0.000133471
Swap With User S...15691342024-12-25 15:13:204 days ago1735139600IN
0x422236ec...56249d746
0 S0.000206971.10727272
Swap With User S...15690402024-12-25 15:12:294 days ago1735139549IN
0x422236ec...56249d746
0 S0.000241471.11133333
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
17324752024-12-27 9:17:403 days ago1735291060
0x422236ec...56249d746
6.86798141 S
17324752024-12-27 9:17:403 days ago1735291060
0x422236ec...56249d746
6.86798141 S
16607372024-12-26 15:33:103 days ago1735227190
0x422236ec...56249d746
5 S
16607372024-12-26 15:33:103 days ago1735227190
0x422236ec...56249d746
5 S
16606712024-12-26 15:32:123 days ago1735227132
0x422236ec...56249d746
9.99976818 S
16606712024-12-26 15:32:123 days ago1735227132
0x422236ec...56249d746
9.99976818 S
16452402024-12-26 11:12:394 days ago1735211559
0x422236ec...56249d746
32.82 S
16452402024-12-26 11:12:394 days ago1735211559
0x422236ec...56249d746
0.547 S
16452402024-12-26 11:12:394 days ago1735211559
0x422236ec...56249d746
0.547 S
16452402024-12-26 11:12:394 days ago1735211559
0x422236ec...56249d746
3.282 S
16452402024-12-26 11:12:394 days ago1735211559
0x422236ec...56249d746
4.376 S
16452402024-12-26 11:12:394 days ago1735211559
0x422236ec...56249d746
2.188 S
16452402024-12-26 11:12:394 days ago1735211559
0x422236ec...56249d746
2.188 S
16452402024-12-26 11:12:394 days ago1735211559
0x422236ec...56249d746
1.641 S
16452402024-12-26 11:12:394 days ago1735211559
0x422236ec...56249d746
6.017 S
16452402024-12-26 11:12:394 days ago1735211559
0x422236ec...56249d746
1.094 S
16451622024-12-26 11:11:334 days ago1735211493
0x422236ec...56249d746
150 S
16451202024-12-26 11:11:114 days ago1735211471
0x422236ec...56249d746
50 S
16418362024-12-26 10:12:484 days ago1735207968
0x422236ec...56249d746
2 S
16400722024-12-26 9:50:384 days ago1735206638
0x422236ec...56249d746
2 S
16397932024-12-26 9:46:204 days ago1735206380
0x422236ec...56249d746
2 S
15700272024-12-25 15:21:094 days ago1735140069
0x422236ec...56249d746
6.3 S
15700272024-12-25 15:21:094 days ago1735140069
0x422236ec...56249d746
0.7 S
15697032024-12-25 15:18:174 days ago1735139897
0x422236ec...56249d746
0.41 S
15697032024-12-25 15:18:174 days ago1735139897
0x422236ec...56249d746
0.41 S
View All Internal Transactions
Loading...
Loading

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

Contract Name:
MagpieRouterV3

Compiler Version
v0.8.24+commit.e11b9ed9

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion, MIT license
File 1 of 10 : MagpieRouterV3.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import {Ownable2Step} from "openzeppelin-solidity/contracts/access/Ownable2Step.sol";
import {Pausable} from "openzeppelin-solidity/contracts/security/Pausable.sol";
import {Address} from "openzeppelin-solidity/contracts/utils/Address.sol";
import {IMagpieRouterV3} from "./interfaces/IMagpieRouterV3.sol";
import {LibAsset} from "./libraries/LibAsset.sol";
import {LibRouter, SwapData} from "./libraries/LibRouter.sol";

error ExpiredTransaction();
error InsufficientAmountOut();
error InvalidCall();
error InvalidCommand();
error InvalidTransferFromCall();
error ApprovalFailed();
error TransferFromFailed();
error TransferFailed();
error UniswapV3InvalidAmount();
error InvalidCaller();
error InvalidAmountIn();
error InvalidSignature();
error InvalidOutput();
error InvalidNativeAmount();

enum CommandAction {
    Call, // Represents a generic call to a function within a contract.
    Approval, // Represents an approval operation.
    TransferFrom, // Indicates a transfer-from operation.
    Transfer, // Represents a direct transfer operation.
    Wrap, // This action is used for wrapping native tokens.
    Unwrap, // This action is used for unwrapping native tokens.
    Balance, // Checks the balance of an account or contract for a specific asset.
    Math,
    Comparison,
    EstimateGasStart,
    EstimateGasEnd
}

contract MagpieRouterV3 is IMagpieRouterV3, Ownable2Step, Pausable {
    using LibAsset for address;

    mapping(address => bool) public internalCaller;
    mapping(address => bool) public bridge;
    address public swapFeeAddress;

    /// @dev Restricts swap functions with signatures to only be called by whitelisted internal caller.
    modifier onlyInternalCaller() {
        if (!internalCaller[msg.sender]) {
            revert InvalidCaller();
        }
        _;
    }

    /// @dev Restricts swap functions with signatures to be called only by bridge.
    modifier onlyBridge() {
        if (!bridge[msg.sender]) {
            revert InvalidCaller();
        }
        _;
    }

    /// @dev See {IMagpieRouterV3-updateInternalCaller}
    function updateInternalCaller(address caller, bool value) external onlyOwner {
        internalCaller[caller] = value;

        emit UpdateInternalCaller(msg.sender, caller, value);
    }

    /// @dev See {IMagpieRouterV3-updateBridge}
    function updateBridge(address caller, bool value) external onlyOwner {
        bridge[caller] = value;

        emit UpdateBridge(msg.sender, caller, value);
    }

    /// @dev See {IMagpieRouterV3-updateSwapFeeAddress}
    function updateSwapFeeAddress(address value) external onlyOwner {
        swapFeeAddress = value;
    }

    /// @dev See {IMagpieRouterV3-pause}
    function pause() public onlyOwner whenNotPaused {
        _pause();
    }

    /// @dev See {IMagpieRouterV3-unpause}
    function unpause() public onlyOwner whenPaused {
        _unpause();
    }

    /// @dev See {IMagpieRouterV3-multicall}
    function multicall(bytes[] calldata data) external onlyOwner returns (bytes[] memory results) {
        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            results[i] = Address.functionDelegateCall(address(this), data[i]);
        }
        return results;
    }

    /// @dev Handle uniswapV3SwapCallback requests from any protocol that is based on UniswapV3. We dont check for factory since this contract is not supposed to store tokens. We protect the user by handling amountOutMin check at the end of execution by comparing starting and final balance at the destination address.
    fallback() external {
        int256 amount0Delta;
        int256 amount1Delta;
        address assetIn;
        uint256 callDataSize;
        assembly {
            amount0Delta := calldataload(4)
            amount1Delta := calldataload(36)
            assetIn := shr(96, calldataload(132))
            callDataSize := calldatasize()
        }

        if (callDataSize != 164) {
            revert InvalidCall();
        }

        if (amount0Delta <= 0 && amount1Delta <= 0) {
            revert UniswapV3InvalidAmount();
        }

        uint256 amount = amount0Delta > 0 ? uint256(amount0Delta) : uint256(amount1Delta);

        assetIn.transfer(msg.sender, amount);
    }

    /// @dev Retrieves the address to be used for a swap operation.
    /// @param swapData The data structure containing information about the swap.
    /// @param useCaller Boolean indicating whether to use the caller's address.
    /// @param checkSignature Boolean indicating whether to validate the signature.
    /// @return fromAddress The address to be used for the swap operation.
    function getFromAddress(
        SwapData memory swapData,
        bool useCaller,
        bool checkSignature
    ) private view returns (address fromAddress) {
        if (checkSignature) {
            bool hasAffiliate = swapData.hasAffiliate;
            uint256 messagePtr;
            uint256 messageLength = hasAffiliate ? 384 : 320;
            assembly {
                messagePtr := mload(0x40)
                mstore(0x40, add(messagePtr, messageLength))
                switch hasAffiliate
                case 1 {
                    // keccak256("Swap(address router,address sender,address recipient,address fromAsset,address toAsset,uint256 deadline,uint256 amountOutMin,uint256 swapFee,uint256 amountIn,address affiliate,uint256 affiliateFee)")
                    mstore(messagePtr, 0x64d67eff2ff010acba1b1df82fb327ba0dc6d2965ba6b0b472bc14c494c8b4f6)
                }
                default {
                    // keccak256("Swap(address router,address sender,address recipient,address fromAsset,address toAsset,uint256 deadline,uint256 amountOutMin,uint256 swapFee,uint256 amountIn)")
                    mstore(messagePtr, 0x783528850c43ab6adcc3a843186a6558aa806707dd0abb3d2909a2a70b7f22a3)
                }
            }
            fromAddress = LibRouter.verifySignature(
                // keccak256(bytes("Magpie Router")),
                0x86af987965544521ef5b52deabbeb812d3353977e11a2dbe7e0f4905d1e60721,
                // keccak256(bytes("3")),
                0x2a80e1ef1d7842f27f2e6be0972bb708b9a135c38860dbe73c27c3486c34f4de,
                swapData,
                messagePtr,
                messageLength,
                useCaller,
                2
            );
        } else {
            if (useCaller) {
                fromAddress = msg.sender;
            } else {
                revert InvalidCall();
            }
        }
    }

    /// @dev Swaps tokens based on the provided swap data.
    /// @param swapData The data structure containing information about the swap operation.
    /// @param fromAddress The address initiating the swap. This address is responsible for the input assets.
    /// @param fullAmountIn The full amount that was used for the operation. If its 0 then event wont be emited.
    /// @return amountOut The amount of tokens or assets received after the swap.
    /// @return gasUsed The amount of gas consumed by the recorded operation.
    function swap(
        SwapData memory swapData,
        address fromAddress,
        uint256 fullAmountIn
    ) private returns (uint256 amountOut, uint256 gasUsed) {
        address fromAssetAddress = swapData.fromAssetAddress;
        address toAssetAddress = swapData.toAssetAddress;
        address toAddress = swapData.toAddress;
        uint256 amountOutMin = swapData.amountOutMin;
        uint256 amountIn = swapData.amountIn;
        uint256 transferFromAmount;

        amountOut = toAssetAddress.getBalanceOf(toAddress);

        (transferFromAmount, gasUsed) = execute(fromAddress, fromAssetAddress);

        amountOut = toAssetAddress.getBalanceOf(toAddress) - amountOut;

        if (amountOut < amountOutMin) {
            revert InsufficientAmountOut();
        }

        if (!fromAssetAddress.isNative() && amountIn != transferFromAmount) {
            revert InvalidAmountIn();
        }

        if (fullAmountIn > 0) {
            emit Swap(fromAddress, toAddress, fromAssetAddress, toAssetAddress, fullAmountIn, amountOut);
        }
    }

    /// @dev See {IMagpieRouterV3-estimateSwapGas}
    function estimateSwapGas(
        bytes calldata
    ) external payable whenNotPaused returns (uint256 amountOut, uint256 gasUsed) {
        SwapData memory swapData = LibRouter.getData();
        address fromAddress = getFromAddress(swapData, true, true);
        if (swapData.hasPermit) {
            LibRouter.permit(swapData, fromAddress);
        }
        LibRouter.transferFees(swapData, fromAddress, swapData.swapFee == 0 ? address(0) : swapFeeAddress);
        (amountOut, gasUsed) = swap(
            swapData,
            fromAddress,
            swapData.amountIn + swapData.swapFee + swapData.affiliateFee
        );
    }

    /// @dev See {IMagpieRouterV3-swapWithMagpieSignature}
    function swapWithMagpieSignature(bytes calldata) external payable whenNotPaused returns (uint256 amountOut) {
        SwapData memory swapData = LibRouter.getData();
        address fromAddress = getFromAddress(swapData, true, true);
        if (swapData.hasPermit) {
            LibRouter.permit(swapData, fromAddress);
        }
        LibRouter.transferFees(swapData, fromAddress, swapData.swapFee == 0 ? address(0) : swapFeeAddress);
        (amountOut, ) = swap(swapData, fromAddress, swapData.amountIn + swapData.swapFee + swapData.affiliateFee);
    }

    /// @dev See {IMagpieRouterV3-swapWithUserSignature}
    function swapWithUserSignature(bytes calldata) external payable onlyInternalCaller returns (uint256 amountOut) {
        SwapData memory swapData = LibRouter.getData();
        if (msg.value > 0) {
            revert InvalidNativeAmount();
        }
        address fromAddress = getFromAddress(swapData, false, true);
        if (swapData.hasPermit) {
            LibRouter.permit(swapData, fromAddress);
        }
        LibRouter.transferFees(swapData, fromAddress, swapData.swapFee == 0 ? address(0) : swapFeeAddress);
        (amountOut, ) = swap(swapData, fromAddress, swapData.amountIn + swapData.swapFee + swapData.affiliateFee);
    }

    /// @dev See {IMagpieRouterV3-swapWithoutSignature}
    function swapWithoutSignature(bytes calldata) external payable onlyBridge returns (uint256 amountOut) {
        SwapData memory swapData = LibRouter.getData();
        address fromAddress = getFromAddress(swapData, true, false);
        (amountOut, ) = swap(swapData, fromAddress, 0);
    }

    /// @dev Prepares CommandData for command iteration.
    function getCommandData()
        private
        pure
        returns (uint16 commandsOffset, uint16 commandsOffsetEnd, uint16 outputsLength)
    {
        assembly {
            commandsOffset := add(70, shr(240, calldataload(68))) // dataOffset + dataLength
            commandsOffsetEnd := add(68, calldataload(36)) // commandsOffsetEnd / swapArgsOffset + swapArgsLength (swapArgsOffset - 32)
            outputsLength := shr(240, calldataload(70)) // dataOffset + 32
        }
    }

    /// @dev Handles the execution of a sequence of commands for the swap operation.
    /// @param fromAddress The address from which the assets will be swapped.
    /// @param fromAssetAddress The address of the asset to be swapped.
    /// @return transferFromAmount The amount transferred from the specified address.
    /// @return gasUsed The amount of gas used during the execution of the swap.
    function execute(
        address fromAddress,
        address fromAssetAddress
    ) private returns (uint256 transferFromAmount, uint256 gasUsed) {
        (uint16 commandsOffset, uint16 commandsOffsetEnd, uint16 outputsLength) = getCommandData();

        uint256 outputPtr;
        assembly {
            outputPtr := mload(0x40)
            mstore(0x40, add(outputPtr, outputsLength))
        }

        uint256 outputOffsetPtr = outputPtr;

        unchecked {
            for (uint256 i = commandsOffset; i < commandsOffsetEnd; ) {
                (transferFromAmount, gasUsed, outputOffsetPtr) = executeCommand(
                    i,
                    fromAddress,
                    fromAssetAddress,
                    outputPtr,
                    outputOffsetPtr,
                    transferFromAmount,
                    gasUsed
                );
                i += 9;
            }
        }

        if (outputOffsetPtr > outputPtr + outputsLength) {
            revert InvalidOutput();
        }
    }

    /// @dev Builds the input for a specific command.
    /// @param i Command data position.
    /// @param outputPtr Memory pointer of the currently available output.
    /// @return input Calculated input data.
    /// @return nativeAmount Native token amount.
    function getInput(uint256 i, uint256 outputPtr) private view returns (bytes memory input, uint256 nativeAmount) {
        assembly {
            let sequencesPositionEnd := shr(240, calldataload(add(i, 5)))

            input := mload(0x40)
            nativeAmount := 0

            let j := shr(240, calldataload(add(i, 3))) // sequencesPosition
            let inputOffsetPtr := add(input, 32)

            for {

            } lt(j, sequencesPositionEnd) {

            } {
                let sequenceType := shr(248, calldataload(j))

                switch sequenceType
                // NativeAmount
                case 0 {
                    switch shr(240, calldataload(add(j, 3)))
                    case 1 {
                        nativeAmount := mload(add(outputPtr, shr(240, calldataload(add(j, 1)))))
                    }
                    default {
                        let p := shr(240, calldataload(add(j, 1)))
                        nativeAmount := shr(shr(248, calldataload(p)), calldataload(add(p, 1)))
                    }
                    j := add(j, 5)
                }
                // Selector
                case 1 {
                    mstore(inputOffsetPtr, calldataload(shr(240, calldataload(add(j, 1)))))
                    inputOffsetPtr := add(inputOffsetPtr, 4)
                    j := add(j, 3)
                }
                // Address
                case 2 {
                    mstore(inputOffsetPtr, shr(96, calldataload(shr(240, calldataload(add(j, 1))))))
                    inputOffsetPtr := add(inputOffsetPtr, 32)
                    j := add(j, 3)
                }
                // Amount
                case 3 {
                    let p := shr(240, calldataload(add(j, 1)))
                    mstore(inputOffsetPtr, shr(shr(248, calldataload(p)), calldataload(add(p, 1))))
                    inputOffsetPtr := add(inputOffsetPtr, 32)
                    j := add(j, 3)
                }
                // Data
                case 4 {
                    let l := shr(240, calldataload(add(j, 3)))
                    calldatacopy(inputOffsetPtr, shr(240, calldataload(add(j, 1))), l)
                    inputOffsetPtr := add(inputOffsetPtr, l)
                    j := add(j, 5)
                }
                // CommandOutput
                case 5 {
                    mstore(inputOffsetPtr, mload(add(outputPtr, shr(240, calldataload(add(j, 1))))))
                    inputOffsetPtr := add(inputOffsetPtr, 32)
                    j := add(j, 3)
                }
                // RouterAddress
                case 6 {
                    mstore(inputOffsetPtr, address())
                    inputOffsetPtr := add(inputOffsetPtr, 32)
                    j := add(j, 1)
                }
                // SenderAddress
                case 7 {
                    mstore(inputOffsetPtr, caller())
                    inputOffsetPtr := add(inputOffsetPtr, 32)
                    j := add(j, 1)
                }
                default {
                    // InvalidSequenceType
                    mstore(0, 0xa90b6fde00000000000000000000000000000000000000000000000000000000)
                    revert(0, 4)
                }
            }

            mstore(input, sub(inputOffsetPtr, add(input, 32)))
            mstore(0x40, inputOffsetPtr)
        }
    }

    /// @dev Executes a command call with the given parameters.
    /// @param i The command data position.
    /// @param outputPtr The pointer to the output location in memory.
    /// @param outputOffsetPtr The pointer to the offset of the output in memory.
    /// @return New outputOffsetPtr position.
    function executeCommandCall(uint256 i, uint256 outputPtr, uint256 outputOffsetPtr) private returns (uint256) {
        bytes memory input;
        uint256 nativeAmount;
        (input, nativeAmount) = getInput(i, outputPtr);
        uint256 outputLength;
        assembly {
            outputLength := shr(240, calldataload(add(i, 1)))

            switch shr(224, mload(add(input, 32))) // selector
            case 0 {
                // InvalidSelector
                mstore(0, 0x7352d91c00000000000000000000000000000000000000000000000000000000)
                revert(0, 4)
            }
            case 0x23b872dd {
                // Blacklist transferFrom in custom calls
                // InvalidTransferFromCall
                mstore(0, 0x1751a8e400000000000000000000000000000000000000000000000000000000)
                revert(0, 4)
            }
            default {
                let targetAddress := shr(96, calldataload(shr(240, calldataload(add(i, 7))))) // targetPosition
                if eq(targetAddress, address()) {
                    // InvalidCall
                    mstore(0, 0xae962d4e00000000000000000000000000000000000000000000000000000000)
                    revert(0, 4)
                }
                if iszero(
                    call(
                        gas(),
                        targetAddress,
                        nativeAmount,
                        add(input, 32),
                        mload(input),
                        outputOffsetPtr,
                        outputLength
                    )
                ) {
                    returndatacopy(0, 0, returndatasize())
                    revert(0, returndatasize())
                }
            }
        }
        outputOffsetPtr += outputLength;

        return outputOffsetPtr;
    }

    /// @dev Executes a command approval with the given parameters.
    /// @param i The command data position.
    /// @param outputPtr The pointer to the output location in memory.
    function executeCommandApproval(uint256 i, uint256 outputPtr) private {
        (bytes memory input, ) = getInput(i, outputPtr);

        address self;
        address spender;
        uint256 amount;
        assembly {
            self := mload(add(input, 32))
            spender := mload(add(input, 64))
            amount := mload(add(input, 96))
        }
        self.approve(spender, amount);
    }

    /// @dev Executes a transfer command from a specific address and asset.
    /// @param i The command position.
    /// @param outputPtr The pointer to the output location in memory.
    /// @param fromAssetAddress The address of the asset to transfer from.
    /// @param fromAddress The address to transfer the asset from.
    /// @param transferFromAmount The accumulated amount of the asset to transfer.
    /// @return Accumulated transfer amount.
    function executeCommandTransferFrom(
        uint256 i,
        uint256 outputPtr,
        address fromAssetAddress,
        address fromAddress,
        uint256 transferFromAmount
    ) private returns (uint256) {
        (bytes memory input, ) = getInput(i, outputPtr);

        uint256 amount;
        assembly {
            amount := mload(add(input, 64))
        }
        if (amount > 0) {
            address to;
            assembly {
                to := mload(add(input, 32))
            }
            fromAssetAddress.transferFrom(fromAddress, to, amount);
            transferFromAmount += amount;
        }

        return transferFromAmount;
    }

    /// @dev Executes a transfer command with the given parameters.
    /// @param i The command data position.
    /// @param outputPtr The pointer to the output location in memory.
    function executeCommandTransfer(uint256 i, uint256 outputPtr) private {
        (bytes memory input, ) = getInput(i, outputPtr);

        uint256 amount;
        assembly {
            amount := mload(add(input, 96))
        }
        if (amount > 0) {
            address self;
            address recipient;
            assembly {
                self := mload(add(input, 32))
                recipient := mload(add(input, 64))
            }
            self.transfer(recipient, amount);
        }
    }

    /// @dev Executes a wrap command with the given parameters.
    /// @param i The command data position.
    /// @param outputPtr The pointer to the output location in memory.
    function executeCommandWrap(uint256 i, uint256 outputPtr) private {
        (bytes memory input, ) = getInput(i, outputPtr);

        address self;
        uint256 amount;
        assembly {
            self := mload(add(input, 32))
            amount := mload(add(input, 64))
        }
        self.wrap(amount);
    }

    /// @dev Executes an unwrap command with the given parameters.
    /// @param i The command data position.
    /// @param outputPtr The pointer to the output location in memory.
    function executeCommandUnwrap(uint256 i, uint256 outputPtr) private {
        (bytes memory input, ) = getInput(i, outputPtr);

        address self;
        uint256 amount;
        assembly {
            self := mload(add(input, 32))
            amount := mload(add(input, 64))
        }
        self.unwrap(amount);
    }

    /// @dev Executes a balance command and returns the resulting balance.
    /// @param i The command data position.
    /// @param outputPtr The pointer to the output location in memory.
    /// @param outputOffsetPtr The pointer to the offset of the output in memory.
    /// @return New outputOffsetPtr position.
    function executeCommandBalance(
        uint256 i,
        uint256 outputPtr,
        uint256 outputOffsetPtr
    ) private view returns (uint256) {
        (bytes memory input, ) = getInput(i, outputPtr);

        address self;
        uint256 amount;
        assembly {
            self := mload(add(input, 32))
        }

        amount = self.getBalance();

        assembly {
            mstore(outputOffsetPtr, amount)
        }

        outputOffsetPtr += 32;

        return outputOffsetPtr;
    }

    /// @dev Executes a mathematical command.
    /// @param i The command data position.
    /// @param outputPtr The pointer to the output location in memory.
    /// @param outputOffsetPtr The pointer to the offset of the output in memory.
    /// @return New outputOffsetPtr position.
    function executeCommandMath(uint256 i, uint256 outputPtr, uint256 outputOffsetPtr) private view returns (uint256) {
        (bytes memory input, ) = getInput(i, outputPtr);

        assembly {
            function math(currentInputPtr) -> amount {
                let currentOutputPtr := mload(0x40)
                let j := 0
                let amount0 := 0
                let amount1 := 0
                let operator := 0

                for {

                } lt(j, 10) {

                } {
                    let pos := add(currentInputPtr, mul(j, 3))
                    let amount0Index := shr(248, mload(add(pos, 1)))
                    switch lt(amount0Index, 10)
                    case 1 {
                        amount0 := mload(add(currentOutputPtr, mul(amount0Index, 32)))
                    }
                    default {
                        amount0Index := sub(amount0Index, 10)
                        amount0 := mload(add(add(currentInputPtr, 32), mul(amount0Index, 32)))
                    }
                    let amount1Index := shr(248, mload(add(pos, 2)))
                    switch lt(amount1Index, 10)
                    case 1 {
                        amount1 := mload(add(currentOutputPtr, mul(amount1Index, 32)))
                    }
                    default {
                        amount1Index := sub(amount1Index, 10)
                        amount1 := mload(add(add(currentInputPtr, 32), mul(amount1Index, 32)))
                    }
                    operator := shr(248, mload(pos))

                    switch operator
                    // None
                    case 0 {
                        let finalPtr := add(currentOutputPtr, mul(sub(j, 1), 32))
                        amount := mload(finalPtr)
                        mstore(0x40, add(finalPtr, 32))
                        leave
                    }
                    // Add
                    case 1 {
                        mstore(add(currentOutputPtr, mul(j, 32)), add(amount0, amount1))
                    }
                    // Sub
                    case 2 {
                        mstore(add(currentOutputPtr, mul(j, 32)), sub(amount0, amount1))
                    }
                    // Mul
                    case 3 {
                        mstore(add(currentOutputPtr, mul(j, 32)), mul(amount0, amount1))
                    }
                    // Div
                    case 4 {
                        mstore(add(currentOutputPtr, mul(j, 32)), div(amount0, amount1))
                    }
                    // Pow
                    case 5 {
                        mstore(add(currentOutputPtr, mul(j, 32)), exp(amount0, amount1))
                    }
                    // Abs128
                    case 6 {
                        if gt(amount0, 170141183460469231731687303715884105727) {
                            let mask := sar(127, amount0)
                            amount0 := xor(amount0, mask)
                            amount0 := sub(amount0, mask)
                        }
                        mstore(add(currentOutputPtr, mul(j, 32)), amount0)
                    }
                    // Abs256
                    case 7 {
                        if gt(amount0, 57896044618658097711785492504343953926634992332820282019728792003956564819967) {
                            let mask := sar(255, amount0)
                            amount0 := xor(amount0, mask)
                            amount0 := sub(amount0, mask)
                        }
                        mstore(add(currentOutputPtr, mul(j, 32)), amount0)
                    }
                    // Shr
                    case 8 {
                        mstore(add(currentOutputPtr, mul(j, 32)), shr(amount0, amount1))
                    }
                    // Shl
                    case 9 {
                        mstore(add(currentOutputPtr, mul(j, 32)), shl(amount0, amount1))
                    }

                    j := add(j, 1)
                }

                let finalPtr := add(currentOutputPtr, mul(9, 32))
                amount := mload(finalPtr)
                mstore(0x40, add(finalPtr, 32))
            }

            mstore(outputOffsetPtr, math(add(input, 32)))
        }

        outputOffsetPtr += 32;

        return outputOffsetPtr;
    }

    /// @dev Executes a comparison command.
    /// @param i The command data position.
    /// @param outputPtr The pointer to the output location in memory.
    /// @param outputOffsetPtr The pointer to the offset of the output in memory.
    /// @return New outputOffsetPtr position.
    function executeCommandComparison(
        uint256 i,
        uint256 outputPtr,
        uint256 outputOffsetPtr
    ) private view returns (uint256) {
        (bytes memory input, ) = getInput(i, outputPtr);

        assembly {
            function comparison(currentInputPtr) -> amount {
                let currentOutputPtr := mload(0x40)
                let j := 0
                let amount0 := 0
                let amount1 := 0
                let amount2 := 0
                let amount3 := 0
                let operator := 0

                for {

                } lt(j, 6) {

                } {
                    let pos := add(currentInputPtr, mul(j, 5))
                    let amount0Index := shr(248, mload(add(pos, 1)))
                    switch lt(amount0Index, 6)
                    case 1 {
                        amount0 := mload(add(currentOutputPtr, mul(amount0Index, 32)))
                    }
                    default {
                        amount0Index := sub(amount0Index, 6)
                        amount0 := mload(add(add(currentInputPtr, 32), mul(amount0Index, 32)))
                    }
                    let amount1Index := shr(248, mload(add(pos, 2)))
                    switch lt(amount1Index, 6)
                    case 1 {
                        amount1 := mload(add(currentOutputPtr, mul(amount1Index, 32)))
                    }
                    default {
                        amount1Index := sub(amount1Index, 6)
                        amount1 := mload(add(add(currentInputPtr, 32), mul(amount1Index, 32)))
                    }
                    let amount2Index := shr(248, mload(add(pos, 3)))
                    switch lt(amount2Index, 6)
                    case 1 {
                        amount2 := mload(add(currentOutputPtr, mul(amount2Index, 32)))
                    }
                    default {
                        amount2Index := sub(amount2Index, 6)
                        amount2 := mload(add(add(currentInputPtr, 32), mul(amount2Index, 32)))
                    }
                    let amount3Index := shr(248, mload(add(pos, 4)))
                    switch lt(amount3Index, 6)
                    case 1 {
                        amount3 := mload(add(currentOutputPtr, mul(amount3Index, 32)))
                    }
                    default {
                        amount3Index := sub(amount3Index, 6)
                        amount3 := mload(add(add(currentInputPtr, 32), mul(amount3Index, 32)))
                    }
                    operator := shr(248, mload(pos))

                    switch operator
                    // None
                    case 0 {
                        let finalPtr := add(currentOutputPtr, mul(sub(j, 1), 32))
                        amount := mload(finalPtr)
                        mstore(0x40, add(finalPtr, 32))
                        leave
                    }
                    // Lt
                    case 1 {
                        switch lt(amount0, amount1)
                        case 1 {
                            mstore(add(currentOutputPtr, mul(j, 32)), amount2)
                        }
                        default {
                            mstore(add(currentOutputPtr, mul(j, 32)), amount3)
                        }
                    }
                    // Lte
                    case 2 {
                        switch or(lt(amount0, amount1), eq(amount0, amount1))
                        case 1 {
                            mstore(add(currentOutputPtr, mul(j, 32)), amount2)
                        }
                        default {
                            mstore(add(currentOutputPtr, mul(j, 32)), amount3)
                        }
                    }
                    // Gt
                    case 3 {
                        switch gt(amount0, amount1)
                        case 1 {
                            mstore(add(currentOutputPtr, mul(j, 32)), amount2)
                        }
                        default {
                            mstore(add(currentOutputPtr, mul(j, 32)), amount3)
                        }
                    }
                    // Gte
                    case 4 {
                        switch or(gt(amount0, amount1), eq(amount0, amount1))
                        case 1 {
                            mstore(add(currentOutputPtr, mul(j, 32)), amount2)
                        }
                        default {
                            mstore(add(currentOutputPtr, mul(j, 32)), amount3)
                        }
                    }
                    // Eq
                    case 5 {
                        switch eq(amount0, amount1)
                        case 1 {
                            mstore(add(currentOutputPtr, mul(j, 32)), amount2)
                        }
                        default {
                            mstore(add(currentOutputPtr, mul(j, 32)), amount3)
                        }
                    }
                    // Ne
                    case 6 {
                        switch eq(amount0, amount1)
                        case 1 {
                            mstore(add(currentOutputPtr, mul(j, 32)), amount3)
                        }
                        default {
                            mstore(add(currentOutputPtr, mul(j, 32)), amount2)
                        }
                    }

                    j := add(j, 1)
                }

                let finalPtr := add(currentOutputPtr, mul(5, 32))
                amount := mload(finalPtr)
                mstore(0x40, add(finalPtr, 32))
            }

            mstore(outputOffsetPtr, comparison(add(input, 32)))
        }

        outputOffsetPtr += 32;

        return outputOffsetPtr;
    }

    /// @dev Handles the execution of the specified command commands for the swap operation.
    /// @param i The command data position.
    /// @param fromAddress The wallet / contract of the fromAssetAddress.
    /// @param fromAssetAddress The asset will be transfered from the user.
    /// @param outputPtr Starting position of the output memory pointer.
    /// @param outputOffsetPtr Current position of the output memory pointer.
    /// @param transferFromAmount Accumulated transferred amount.
    /// @param gasUsed Recorded gas between commands.
    function executeCommand(
        uint256 i,
        address fromAddress,
        address fromAssetAddress,
        uint256 outputPtr,
        uint256 outputOffsetPtr,
        uint256 transferFromAmount,
        uint256 gasUsed
    ) private returns (uint256, uint256, uint256) {
        CommandAction commandAction;
        assembly {
            commandAction := shr(248, calldataload(i))
        }

        if (commandAction == CommandAction.Call) {
            outputOffsetPtr = executeCommandCall(i, outputPtr, outputOffsetPtr);
        } else if (commandAction == CommandAction.Approval) {
            executeCommandApproval(i, outputPtr);
        } else if (commandAction == CommandAction.TransferFrom) {
            transferFromAmount = executeCommandTransferFrom(
                i,
                outputPtr,
                fromAssetAddress,
                fromAddress,
                transferFromAmount
            );
        } else if (commandAction == CommandAction.Transfer) {
            executeCommandTransfer(i, outputPtr);
        } else if (commandAction == CommandAction.Wrap) {
            executeCommandWrap(i, outputPtr);
        } else if (commandAction == CommandAction.Unwrap) {
            executeCommandUnwrap(i, outputPtr);
        } else if (commandAction == CommandAction.Balance) {
            outputOffsetPtr = executeCommandBalance(i, outputPtr, outputOffsetPtr);
        } else if (commandAction == CommandAction.Math) {
            outputOffsetPtr = executeCommandMath(i, outputPtr, outputOffsetPtr);
        } else if (commandAction == CommandAction.Comparison) {
            outputOffsetPtr = executeCommandComparison(i, outputPtr, outputOffsetPtr);
        } else if (commandAction == CommandAction.EstimateGasStart) {
            gasUsed = gasleft();
        } else if (commandAction == CommandAction.EstimateGasEnd) {
            gasUsed -= gasleft();
        } else {
            revert InvalidCommand();
        }

        return (transferFromAmount, gasUsed, outputOffsetPtr);
    }

    /// @dev Used to receive ethers
    receive() external payable {}
}

File 2 of 10 : IMagpieRouterV3.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

interface IMagpieRouterV3 {
    event UpdateInternalCaller(address indexed sender, address caller, bool value);

    /// @dev Allows the owner to update the whitelisted internal callers.
    /// @param caller Caller address.
    /// @param value Disable or enable the related caller.
    function updateInternalCaller(address caller, bool value) external;

    event UpdateBridge(address indexed sender, address caller, bool value);

    /// @dev Allows the owner to update the whitelisted bridges.
    /// @param caller Caller address.
    /// @param value Disable or enable the related caller.
    function updateBridge(address caller, bool value) external;

    /// @dev Allows the owner to update the swap fee receiver.
    /// @param value Swap fee receiver address.
    function updateSwapFeeAddress(address value) external;

    /// @dev Called by the owner to pause, triggers stopped state.
    function pause() external;

    /// @dev Called by the owner to unpause, returns to normal state.
    function unpause() external;

    event Swap(
        address indexed fromAddress,
        address indexed toAddress,
        address fromAssetAddress,
        address toAssetAddress,
        uint256 amountIn,
        uint256 amountOut
    );

    /// @dev Makes it possible to execute multiple functions in the same transaction.
    function multicall(bytes[] calldata data) external returns (bytes[] memory results);

    /// @dev Provides an external interface to estimate the gas cost of the last hop in a route.
    /// @return amountOut The amount received after swapping.
    /// @return gasUsed The cost of gas while performing the swap.
    function estimateSwapGas(bytes calldata swapArgs) external payable returns (uint256 amountOut, uint256 gasUsed);

    /// @dev Performs token swap with magpie signature.
    /// @return amountOut The amount received after swapping.
    function swapWithMagpieSignature(bytes calldata swapArgs) external payable returns (uint256 amountOut);

    /// @dev Performs token swap with a user signature.
    /// @return amountOut The amount received after swapping.
    function swapWithUserSignature(bytes calldata swapArgs) external payable returns (uint256 amountOut);

    /// @dev Performs token swap without a signature (data will be validated in the bridge) without triggering event.
    /// @return amountOut The amount received after swapping.
    function swapWithoutSignature(bytes calldata swapArgs) external payable returns (uint256 amountOut);
}

File 3 of 10 : IWETH.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

interface IWETH {
    function deposit() external payable;

    function transfer(address to, uint256 value) external returns (bool);

    function withdraw(uint256) external;
}

File 4 of 10 : LibAsset.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import "../interfaces/IWETH.sol";

error AssetNotReceived();
error ApprovalFailed();
error TransferFromFailed();
error TransferFailed();
error FailedWrap();
error FailedUnwrap();

library LibAsset {
    using LibAsset for address;

    address constant NATIVE_ASSETID = address(0);

    /// @dev Checks if the given address (self) represents a native asset (Ether).
    /// @param self The asset that will be checked for a native token.
    /// @return Flag to identify if the asset is native or not.
    function isNative(address self) internal pure returns (bool) {
        return self == NATIVE_ASSETID;
    }

    /// @dev Wraps the specified asset.
    /// @param self The asset that will be wrapped.
    function wrap(address self, uint256 amount) internal {
        uint256 ptr;
        assembly {
            ptr := mload(0x40)
            mstore(0x40, add(ptr, 4))
            mstore(ptr, 0xd0e30db000000000000000000000000000000000000000000000000000000000)
        }

        if (!execute(self, amount, ptr, 4, 0, 0)) {
            revert FailedWrap();
        }
    }

    /// @dev Unwraps the specified asset.
    /// @param self The asset that will be unwrapped.
    function unwrap(address self, uint256 amount) internal {
        uint256 ptr;
        assembly {
            ptr := mload(0x40)
            mstore(0x40, add(ptr, 36))
            mstore(ptr, 0x2e1a7d4d00000000000000000000000000000000000000000000000000000000)
            mstore(add(ptr, 4), amount)
        }

        if (!execute(self, 0, ptr, 36, 0, 0)) {
            revert FailedUnwrap();
        }
    }

    /// @dev Retrieves the balance of the current contract for a given asset (self).
    /// @param self Asset whose balance needs to be found.
    /// @return Balance of the specific asset.
    function getBalance(address self) internal view returns (uint256) {
        return getBalanceOf(self, address(this));
    }

    /// @dev Retrieves the balance of the target address for a given asset (self).
    /// @param self Asset whose balance needs to be found.
    /// @param targetAddress The address where the balance is checked from.
    /// @return amount Balance of the specific asset.
    function getBalanceOf(address self, address targetAddress) internal view returns (uint256 amount) {
        assembly {
            switch self
            case 0 {
                amount := balance(targetAddress)
            }
            default {
                let currentInputPtr := mload(0x40)
                mstore(0x40, add(currentInputPtr, 68))
                mstore(currentInputPtr, 0x70a0823100000000000000000000000000000000000000000000000000000000)
                mstore(add(currentInputPtr, 4), targetAddress)
                let currentOutputPtr := add(currentInputPtr, 36)
                if iszero(staticcall(gas(), self, currentInputPtr, 36, currentOutputPtr, 32)) {
                    returndatacopy(0, 0, returndatasize())
                    revert(0, returndatasize())
                }

                amount := mload(currentOutputPtr)
            }
        }
    }

    /// @dev Performs a safe transferFrom operation for a given asset (self) from one address (from) to another address (to).
    /// @param self Asset that will be transferred.
    /// @param from Address that will send the asset.
    /// @param to Address that will receive the asset.
    /// @param amount Transferred amount.
    function transferFrom(address self, address from, address to, uint256 amount) internal {
        uint256 ptr;
        assembly {
            ptr := mload(0x40)
            mstore(0x40, add(ptr, 100))
            mstore(ptr, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
            mstore(add(ptr, 4), from)
            mstore(add(ptr, 36), to)
            mstore(add(ptr, 68), amount)
        }

        if (!execute(self, 0, ptr, 100, 0, 0)) {
            revert TransferFromFailed();
        }
    }

    /// @dev Transfers a given amount of an asset (self) to a recipient address (recipient).
    /// @param self Asset that will be transferred.
    /// @param recipient Address that will receive the transferred asset.
    /// @param amount Transferred amount.
    function transfer(address self, address recipient, uint256 amount) internal {
        if (self.isNative()) {
            (bool success, ) = payable(recipient).call{value: amount}("");
            if (!success) {
                revert TransferFailed();
            }
        } else {
            uint256 ptr;
            assembly {
                ptr := mload(0x40)
                mstore(0x40, add(ptr, 68))
                mstore(ptr, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
                mstore(add(ptr, 4), recipient)
                mstore(add(ptr, 36), amount)
            }
            if (!execute(self, 0, ptr, 68, 0, 0)) {
                revert TransferFailed();
            }
        }
    }

    /// @dev Approves a spender address (spender) to spend a specified amount of an asset (self).
    /// @param self The asset that will be approved.
    /// @param spender Address of a contract that will spend the owners asset.
    /// @param amount Asset amount that can be spent.
    function approve(address self, address spender, uint256 amount) internal {
        uint256 ptr;
        assembly {
            ptr := mload(0x40)
            mstore(0x40, add(ptr, 68))
            mstore(ptr, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
            mstore(add(ptr, 4), spender)
            mstore(add(ptr, 36), amount)
        }

        if (!execute(self, 0, ptr, 68, 0, 0)) {
            assembly {
                mstore(add(ptr, 36), 0)
            }
            if (!execute(self, 0, ptr, 68, 0, 0)) {
                revert ApprovalFailed();
            }
            assembly {
                mstore(add(ptr, 36), amount)
            }
            if (!execute(self, 0, ptr, 68, 0, 0)) {
                revert ApprovalFailed();
            }
        }
    }

    function permit(
        address self,
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        assembly {
            let ptr := mload(0x40)
            mstore(0x40, add(ptr, 228))
            mstore(ptr, 0xd505accf00000000000000000000000000000000000000000000000000000000)
            mstore(add(ptr, 4), owner)
            mstore(add(ptr, 36), spender)
            mstore(add(ptr, 68), amount)
            mstore(add(ptr, 100), deadline)
            mstore(add(ptr, 132), v)
            mstore(add(ptr, 164), r)
            mstore(add(ptr, 196), s)
            let success := call(gas(), self, 0, ptr, 228, 0, 0)
        }
    }

    /// @dev Determines if a call was successful.
    /// @param target Address of the target contract.
    /// @param success To check if the call to the contract was successful or not.
    /// @param data The data was sent while calling the target contract.
    /// @return result The success of the call.
    function isSuccessful(address target, bool success, bytes memory data) private view returns (bool result) {
        if (success) {
            if (data.length == 0) {
                // isContract
                if (target.code.length > 0) {
                    result = true;
                }
            } else {
                assembly {
                    result := mload(add(data, 32))
                }
            }
        }
    }

    /// @dev Executes a low level call.
    function execute(
        address self,
        uint256 currentNativeAmount,
        uint256 currentInputPtr,
        uint256 currentInputLength,
        uint256 currentOutputPtr,
        uint256 outputLength
    ) internal returns (bool result) {
        assembly {
            function isSuccessfulCall(targetAddress) -> isSuccessful {
                switch iszero(returndatasize())
                case 1 {
                    if gt(extcodesize(targetAddress), 0) {
                        isSuccessful := 1
                    }
                }
                case 0 {
                    returndatacopy(0, 0, 32)
                    isSuccessful := gt(mload(0), 0)
                }
            }

            if iszero(
                call(
                    gas(),
                    self,
                    currentNativeAmount,
                    currentInputPtr,
                    currentInputLength,
                    currentOutputPtr,
                    outputLength
                )
            ) {
                returndatacopy(0, 0, returndatasize())
                revert(0, returndatasize())
            }

            result := isSuccessfulCall(self)
        }
    }
}

File 5 of 10 : LibRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import {LibAsset} from "../libraries/LibAsset.sol";

struct SwapData {
    address toAddress;
    address fromAssetAddress;
    address toAssetAddress;
    uint256 deadline;
    uint256 amountOutMin;
    uint256 swapFee;
    uint256 amountIn;
    bool hasPermit;
    bool hasAffiliate;
    address affiliateAddress;
    uint256 affiliateFee;
}

error InvalidSignature();
error ExpiredTransaction();

library LibRouter {
    using LibAsset for address;

    /// @dev Prepares SwapData from calldata
    function getData() internal view returns (SwapData memory swapData) {
        // dataOffset: 68 + 2
        assembly {
            let deadline := shr(
                shr(248, calldataload(132)), // dataOffset + 62
                calldataload(shr(240, calldataload(133))) // dataOffset + 62 + 1
            )

            if lt(deadline, timestamp()) {
                // ExpiredTransaction
                mstore(0, 0x931997cf00000000000000000000000000000000000000000000000000000000)
                revert(0, 4)
            }

            mstore(swapData, shr(96, calldataload(72))) // toAddress / dataOffset + 2
            mstore(add(swapData, 32), shr(96, calldataload(92))) // fromAssetAddress / dataOffset + 22
            mstore(add(swapData, 64), shr(96, calldataload(112))) // toAssetAddress / dataOffset + 42
            mstore(add(swapData, 96), deadline)
            mstore(
                add(swapData, 128),
                shr(
                    shr(248, calldataload(135)), // dataOffset + 62 + 3
                    calldataload(shr(240, calldataload(136))) // dataOffset + 62 + 4
                )
            ) // amountOutMin
            mstore(
                add(swapData, 160),
                shr(
                    shr(248, calldataload(138)), // dataOffset + 62 + 6
                    calldataload(shr(240, calldataload(139))) // dataOffset + 62 + 7
                )
            ) // swapFee
            mstore(
                add(swapData, 192),
                shr(
                    shr(248, calldataload(141)), // dataOffset + 62 + 9
                    calldataload(shr(240, calldataload(142))) // dataOffset + 62 + 10
                )
            ) // amountIn
            // calldataload(144) // r
            // calldataload(176) // s
            // shr(248, calldataload(208)) // v
            let hasPermit := gt(shr(248, calldataload(209)), 0) // permit v
            mstore(add(swapData, 224), hasPermit) // hasPermit
            // calldataload(210) // permit r
            // calldataload(242) // permit s
            // calldataload(274) // permit deadline
            switch hasPermit
            case 1 {
                let hasAffiliate := shr(248, calldataload(277))
                mstore(add(swapData, 256), hasAffiliate) // hasAffiliate
                if eq(hasAffiliate, 1) {
                    mstore(add(swapData, 288), shr(96, calldataload(278))) // affiliateAddress
                    mstore(
                        add(swapData, 320),
                        shr(shr(248, calldataload(298)), calldataload(shr(240, calldataload(299))))
                    ) // affiliateFee
                }
            }
            default {
                let hasAffiliate := shr(248, calldataload(210))
                mstore(add(swapData, 256), hasAffiliate) // hasAffiliate
                if eq(hasAffiliate, 1) {
                    mstore(add(swapData, 288), shr(96, calldataload(211))) // affiliateAddress
                    mstore(
                        add(swapData, 320),
                        shr(shr(248, calldataload(231)), calldataload(shr(240, calldataload(232))))
                    ) // affiliateFee
                }
            }
        }
    }

    /// @dev Transfers the required fees for the swap operation from the user's account.
    /// @param swapData The data structure containing the details of the swap operation, including fee information.
    /// @param fromAddress The address of the user from whom the fees will be deducted.
    /// @param swapFeeAddress The address of the swap fee receiver.
    function transferFees(SwapData memory swapData, address fromAddress, address swapFeeAddress) internal {
        if (swapData.swapFee > 0) {
            if (swapData.fromAssetAddress.isNative()) {
                swapData.fromAssetAddress.transfer(swapFeeAddress, swapData.swapFee);
            } else {
                swapData.fromAssetAddress.transferFrom(fromAddress, swapFeeAddress, swapData.swapFee);
            }
        }
        if (swapData.affiliateFee > 0) {
            if (swapData.fromAssetAddress.isNative()) {
                swapData.fromAssetAddress.transfer(swapData.affiliateAddress, swapData.affiliateFee);
            } else {
                swapData.fromAssetAddress.transferFrom(fromAddress, swapData.affiliateAddress, swapData.affiliateFee);
            }
        }
    }

    /// @dev Grants permission for the user's asset to be used in a swap operation.
    /// @param swapData The data structure containing the details of the swap operation.
    /// @param fromAddress The address of the user who is granting permission for their asset to be used.
    function permit(SwapData memory swapData, address fromAddress) internal {
        uint8 v;
        bytes32 r;
        bytes32 s;
        uint256 deadline;
        assembly {
            v := shr(248, calldataload(209))
            r := calldataload(210)
            s := calldataload(242)
            deadline := shr(shr(248, calldataload(274)), calldataload(shr(240, calldataload(275))))
        }

        swapData.fromAssetAddress.permit(
            fromAddress,
            address(this),
            swapData.amountIn + swapData.swapFee + swapData.affiliateFee,
            deadline,
            v,
            r,
            s
        );
    }

    /// @dev Recovers the signer's address from a hashed message and signature components.
    /// @param hash The hash of the message that was signed.
    /// @param r The `r` component of the signature.
    /// @param s The `s` component of the signature.
    /// @param v The `v` component of the signature.
    /// @return signer The address of the signer recovered from the signature.
    function recoverSigner(bytes32 hash, bytes32 r, bytes32 s, uint8 v) private pure returns (address signer) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            revert InvalidSignature();
        }
        if (v != 27 && v != 28) {
            revert InvalidSignature();
        }

        signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            revert InvalidSignature();
        }
    }

    function getDomainSeparator(bytes32 name, bytes32 version) private view returns (bytes32) {
        uint256 chainId;
        assembly {
            chainId := chainid()
        }

        return
            keccak256(
                abi.encode(
                    // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
                    0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,
                    name,
                    version,
                    chainId,
                    address(this)
                )
            );
    }

    /// @dev Verifies the signature for a swap operation.
    /// @param swapData The SwapData struct containing swap details.
    /// @param messagePtr Pointer to the message data in memory.
    /// @param messageLength Length of the message data.
    /// @param useCaller Flag indicating whether to use the caller's address for verification.
    /// @param internalCallersSlot Slot in the internal callers storage for verification.
    /// @return fromAddress The address of the signer / or caller if the signature is valid.
    function verifySignature(
        bytes32 name,
        bytes32 version,
        SwapData memory swapData,
        uint256 messagePtr,
        uint256 messageLength,
        bool useCaller,
        uint8 internalCallersSlot
    ) internal view returns (address fromAddress) {
        bytes32 domainSeparator = getDomainSeparator(name, version);
        bytes32 digest;
        bytes32 r;
        bytes32 s;
        uint8 v;
        assembly {
            mstore(add(messagePtr, 32), address())
            mstore(add(messagePtr, 64), caller())
            mstore(add(messagePtr, 96), mload(swapData))
            mstore(add(messagePtr, 128), mload(add(swapData, 32)))
            mstore(add(messagePtr, 160), mload(add(swapData, 64)))
            mstore(add(messagePtr, 192), mload(add(swapData, 96)))
            mstore(add(messagePtr, 224), mload(add(swapData, 128)))
            mstore(add(messagePtr, 256), mload(add(swapData, 160)))
            mstore(add(messagePtr, 288), mload(add(swapData, 192)))
            // hasAffiliate
            if eq(mload(add(swapData, 256)), 1) {
                mstore(add(messagePtr, 320), mload(add(swapData, 288)))
                mstore(add(messagePtr, 352), mload(add(swapData, 320)))
            }
            let hash := keccak256(messagePtr, messageLength)

            messagePtr := mload(0x40)
            mstore(0x40, add(messagePtr, 66))
            mstore(messagePtr, "\x19\x01")
            mstore(add(messagePtr, 2), domainSeparator)
            mstore(add(messagePtr, 34), hash)
            digest := keccak256(messagePtr, 66)

            r := calldataload(144)
            s := calldataload(176)
            v := shr(248, calldataload(208))
        }
        if (useCaller) {
            address internalCaller = recoverSigner(digest, r, s, v);
            assembly {
                fromAddress := caller()
                mstore(0, internalCaller)
                mstore(0x20, internalCallersSlot)
                if iszero(eq(sload(keccak256(0, 0x40)), 1)) {
                    // InvalidSignature
                    mstore(0, 0x8baa579f00000000000000000000000000000000000000000000000000000000)
                    revert(0, 4)
                }
            }
        } else {
            fromAddress = recoverSigner(digest, r, s, v);
            if (fromAddress == address(this)) {
                revert InvalidSignature();
            }
        }
    }
}

File 6 of 10 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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);
    }
}

File 7 of 10 : Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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);
    }
}

File 8 of 10 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

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

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * 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);
        }
    }
}

File 10 of 10 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"ApprovalFailed","type":"error"},{"inputs":[],"name":"FailedUnwrap","type":"error"},{"inputs":[],"name":"FailedWrap","type":"error"},{"inputs":[],"name":"InsufficientAmountOut","type":"error"},{"inputs":[],"name":"InvalidAmountIn","type":"error"},{"inputs":[],"name":"InvalidCall","type":"error"},{"inputs":[],"name":"InvalidCaller","type":"error"},{"inputs":[],"name":"InvalidCommand","type":"error"},{"inputs":[],"name":"InvalidNativeAmount","type":"error"},{"inputs":[],"name":"InvalidOutput","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"TransferFailed","type":"error"},{"inputs":[],"name":"TransferFromFailed","type":"error"},{"inputs":[],"name":"UniswapV3InvalidAmount","type":"error"},{"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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"fromAddress","type":"address"},{"indexed":true,"internalType":"address","name":"toAddress","type":"address"},{"indexed":false,"internalType":"address","name":"fromAssetAddress","type":"address"},{"indexed":false,"internalType":"address","name":"toAssetAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"UpdateBridge","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"UpdateInternalCaller","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"bridge","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"estimateSwapGas","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"gasUsed","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"internalCaller","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":[],"name":"swapFeeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"swapWithMagpieSignature","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"swapWithUserSignature","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"swapWithoutSignature","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"updateBridge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"updateInternalCaller","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"updateSwapFeeAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

Deployed Bytecode

0x6080604052600436106101185760003560e01c806373fc4457116100a05780638da5cb5b116100645780638da5cb5b14610382578063ac9650d8146103a0578063b8f38c74146103cd578063e30c3978146103ed578063f2fde38b1461040b5761011f565b806373fc4457146102fd57806377a1c5311461031057806379ba50971461033057806383bf2321146103455780638456cb591461036d5761011f565b8063519a98e0116100e7578063519a98e01461023957806353ca57da1461025957806357f46a1a146102995780635c975abb146102c9578063715018a6146102e85761011f565b8063158f6894146101b35780631ec4aec8146101d957806325e651ed146102115780633f4ba83a146102245761011f565b3661011f57005b34801561012b57600080fd5b5060043560243560843560601c3660a4811461015a5760405163574b16a760e11b815260040160405180910390fd5b6000841315801561016c575060008313155b1561018a57604051637ed0826d60e11b815260040160405180910390fd5b6000808513610199578361019b565b845b90506101b16001600160a01b038416338361042b565b005b6101c66101c1366004612233565b61050a565b6040519081526020015b60405180910390f35b3480156101e557600080fd5b506004546101f9906001600160a01b031681565b6040516001600160a01b0390911681526020016101d0565b6101c661021f366004612233565b61056d565b34801561023057600080fd5b506101b1610644565b34801561024557600080fd5b506101b16102543660046122c1565b61065e565b34801561026557600080fd5b506102896102743660046122fd565b60036020526000908152604090205460ff1681565b60405190151581526020016101d0565b3480156102a557600080fd5b506102896102b43660046122fd565b60026020526000908152604090205460ff1681565b3480156102d557600080fd5b50600154600160a01b900460ff16610289565b3480156102f457600080fd5b506101b16106cc565b6101c661030b366004612233565b6106de565b34801561031c57600080fd5b506101b161032b3660046122c1565b610702565b34801561033c57600080fd5b506101b1610768565b610358610353366004612233565b6107e7565b604080519283526020830191909152016101d0565b34801561037957600080fd5b506101b1610870565b34801561038e57600080fd5b506000546001600160a01b03166101f9565b3480156103ac57600080fd5b506103c06103bb366004612318565b610888565b6040516101d091906123cb565b3480156103d957600080fd5b506101b16103e83660046122fd565b61097b565b3480156103f957600080fd5b506001546001600160a01b03166101f9565b34801561041757600080fd5b506101b16104263660046122fd565b6109a5565b6001600160a01b0383166104b3576000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610486576040519150601f19603f3d011682016040523d82523d6000602084013e61048b565b606091505b50509050806104ad576040516312171d8360e31b815260040160405180910390fd5b50505050565b600060405190506044810160405263a9059cbb60e01b81528260048201528160248201526104e8846000836044600080610a16565b6104ad576040516312171d8360e31b815260040160405180910390fd5b505050565b3360009081526003602052604081205460ff1661053a576040516348f5c3ed60e01b815260040160405180910390fd5b6000610544610a83565b905060006105558260016000610bf4565b905061056382826000610d04565b5095945050505050565b3360009081526002602052604081205460ff1661059d576040516348f5c3ed60e01b815260040160405180910390fd5b60006105a7610a83565b905034156105c85760405163113a2f4b60e21b815260040160405180910390fd5b60006105d78260006001610bf4565b90508160e00151156105ed576105ed8282610e2f565b61061682828460a0015160001461060f576004546001600160a01b0316610ea4565b6000610ea4565b61056382828461014001518560a001518660c001516106359190612445565b61063f9190612445565b610d04565b61064c610f8a565b610654610fe4565b61065c611034565b565b610666610f8a565b6001600160a01b038216600081815260026020908152604091829020805460ff191685151590811790915582519384529083015233917fa71618a9ed4e81ce27edc2700d38db549c32abb5e4f32ec57f791151030fbc4591015b60405180910390a25050565b6106d4610f8a565b61065c6000611089565b60006106e86110a2565b60006106f2610a83565b905060006105d782600180610bf4565b61070a610f8a565b6001600160a01b038216600081815260036020908152604091829020805460ff191685151590811790915582519384529083015233917f15e602ce63b40cbac22a674a1c5f4ca3d6c942e18d5282f3c773fe6722dfb63a91016106c0565b60015433906001600160a01b031681146107db5760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084015b60405180910390fd5b6107e481611089565b50565b6000806107f26110a2565b60006107fc610a83565b9050600061080c82600180610bf4565b90508160e0015115610822576108228282610e2f565b61084482828460a0015160001461060f576004546001600160a01b0316610ea4565b61086382828461014001518560a001518660c001516106359190612445565b9097909650945050505050565b610878610f8a565b6108806110a2565b61065c6110ef565b6060610892610f8a565b8167ffffffffffffffff8111156108ab576108ab612458565b6040519080825280602002602001820160405280156108de57816020015b60608152602001906001900390816108c95790505b50905060005b828110156109735761094e308585848181106109025761090261246e565b90506020028101906109149190612484565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061113292505050565b8282815181106109605761096061246e565b60209081029190910101526001016108e4565b505b92915050565b610983610f8a565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6109ad610f8a565b600180546001600160a01b0383166001600160a01b031990911681179091556109de6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000610a59565b60003d1560018114610a34578015610a4557610a53565b823b15610a4057600191505b610a53565b60206000803e600080511191505b50919050565b81838587898b5af1610a6f573d6000803e3d6000fd5b610a7887610a1d565b979650505050505050565b6040805161016081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081018290526101008101829052610120810182905261014081019190915260853560f01c3560843560f81c1c42811015610b035763931997cf60e01b60005260046000fd5b60483560601c8252605c3560601c602083015260703560601c60408301528060608301525060883560f01c3560873560f81c1c6080820152608b3560f01c35608a3560f81c1c60a0820152608e3560f01c35608d3560f81c1c60c0820152600060d13560f81c118060e08301528060018114610bb55760d23560f81c8061010085015260018103610baf5760d33560601c61012085015260e83560f01c3560e73560f81c1c6101408501525b50505090565b6101153560f81c8061010085015260018103610baf576101163560601c61012085015261012b3560f01c3561012a3560f81c1c61014085015250505090565b60008115610cd75761010084015160008082610c1257610140610c16565b6101805b61ffff16905060405191508082016040528260018114610c58577f783528850c43ab6adcc3a843186a6558aa806707dd0abb3d2909a2a70b7f22a38352610c7c565b7f64d67eff2ff010acba1b1df82fb327ba0dc6d2965ba6b0b472bc14c494c8b4f683525b50610ccd7f86af987965544521ef5b52deabbeb812d3353977e11a2dbe7e0f4905d1e607217f2a80e1ef1d7842f27f2e6be0972bb708b9a135c38860dbe73c27c3486c34f4de8985858b6002611157565b9350505050610cfd565b8215610ce4575033610cfd565b60405163574b16a760e11b815260040160405180910390fd5b9392505050565b602083015160408401518451608086015160c0870151600094859490939092909185610d396001600160a01b03861685611301565b9750610d458a87611351565b9750905087610d5d6001600160a01b03871686611301565b610d6791906124d2565b975082881015610d8a57604051637294b85560e11b815260040160405180910390fd5b6001600160a01b03861615158015610da25750808214155b15610dc0576040516365719fe160e11b815260040160405180910390fd5b8815610e2157604080516001600160a01b03888116825287811660208301529181018b9052606081018a9052818616918c16907f20efd6d5195b7b50273f01cd79a27989255356f9f13293edc53ee142accfdb759060800160405180910390a35b505050505050935093915050565b60008060008060d13560f81c935060d235925060f23591506101133560f01c356101123560f81c1c9050610e9c85308861014001518960a001518a60c00151610e789190612445565b610e829190612445565b60208a01516001600160a01b0316929190858989896113e7565b505050505050565b60a083015115610f135760208301516001600160a01b0316610eeb57610ee6818460a0015185602001516001600160a01b031661042b9092919063ffffffff16565b610f13565b610f1382828560a0015186602001516001600160a01b031661143c909392919063ffffffff16565b610140830151156105055760208301516001600160a01b0316610f5c5761050583610120015184610140015185602001516001600160a01b031661042b9092919063ffffffff16565b6105058284610120015185610140015186602001516001600160a01b031661143c909392919063ffffffff16565b6000546001600160a01b0316331461065c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107d2565b600154600160a01b900460ff1661065c5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016107d2565b61103c610fe4565b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600180546001600160a01b03191690556107e48161149b565b600154600160a01b900460ff161561065c5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016107d2565b6110f76110a2565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861106c3390565b6060610cfd838360405180606001604052806027815260200161252b602791396114eb565b604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091528183018a9052606082018990524660808301523060a0808401919091528351808403909101815260c090920190925280519101206000906000806000803060208b01523360408b01528a5160608b015260208b015160808b015260408b015160a08b015260608b015160c08b015260808b015160e08b015260a08b01516101008b015260c08b01516101208b015260016101008c015103611239576101208b01516101408b01526101408b01516101608b01525b888a206040519a5060428b0160405261190160f01b8b528560028c01528060228c01525060428a209350609035925060b035915060d03560f81c905087156112ba57600061128985858585611563565b905033965080600052876020526001604060002054146112b457638baa579f60e01b60005260046000fd5b506112f1565b6112c684848484611563565b9550306001600160a01b038716036112f157604051638baa579f60e01b815260040160405180910390fd5b5050505050979650505050505050565b600082801561134957604051604481016040526370a0823160e01b815283600482015260248101602081602484895afa61133f573d6000803e3d6000fd5b5192506109739050565b505031919050565b604080516046803560f090811c80840190945260009384936044803590931c90930192602435909201918061ffff85165b8461ffff168110156113ac5761139d818b8b86868d8d61166b565b91995097509150600901611382565b506113bb61ffff841683612445565b8111156113db576040516398f7360960e01b815260040160405180910390fd5b50505050509250929050565b60405160e4810160405263d505accf60e01b81528760048201528660248201528560448201528460648201528360848201528260a48201528160c482015260008060e48360008d5af150505050505050505050565b60006040519050606481016040526323b872dd60e01b8152836004820152826024820152816044820152611477856000836064600080610a16565b61149457604051631e4e7d0960e21b815260040160405180910390fd5b5050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060600080856001600160a01b03168560405161150891906124e5565b600060405180830381855af49150503d8060008114611543576040519150601f19603f3d011682016040523d82523d6000602084013e611548565b606091505b50915091506115598683838761183f565b9695505050505050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156115a657604051638baa579f60e01b815260040160405180910390fd5b8160ff16601b141580156115be57508160ff16601c14155b156115dc57604051638baa579f60e01b815260040160405180910390fd5b60408051600081526020810180835287905260ff841691810191909152606081018590526080810184905260019060a0016020604051602081039080840390855afa15801561162f573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661166357604051638baa579f60e01b815260040160405180910390fd5b949350505050565b60008080893560f81c8181600a81111561168757611687612501565b0361169e576116978b89896118b8565b965061182d565b600181600a8111156116b2576116b2612501565b036116c6576116c18b89611960565b61182d565b600281600a8111156116da576116da612501565b036116f3576116ec8b898b8d8a611995565b955061182d565b600381600a81111561170757611707612501565b03611716576116c18b896119e5565b600481600a81111561172a5761172a612501565b03611739576116c18b89611a1e565b600581600a81111561174d5761174d612501565b0361175c576116c18b89611a4c565b600681600a81111561177057611770612501565b03611780576116978b8989611a7a565b600781600a81111561179457611794612501565b036117a4576116978b8989611ab4565b600881600a8111156117b8576117b8612501565b036117c8576116978b8989611cd2565b600981600a8111156117dc576117dc612501565b036117e9575a945061182d565b600a81600a8111156117fd576117fd612501565b03611814575a61180d90866124d2565b945061182d565b6040516312f269e560e01b815260040160405180910390fd5b50939992985093965090945050505050565b606083156118ae5782516000036118a7576001600160a01b0385163b6118a75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107d2565b5081611663565b6116638383611f27565b6000606060006118c88686611f51565b60208201519193509150600187013560f01c9060e01c8015611933576323b872dd811461194457600788013560f01c3560601c3081036119135763574b16a760e11b60005260046000fd5b828786516020880187855af161192d573d6000803e3d6000fd5b50611955565b631cd4b64760e21b60005260046000fd5b6305d46a3960e21b60005260046000fd5b50610a788186612445565b600061196c8383611f51565b506020810151604082015160608301519293509091610e9c6001600160a01b03841683836120f4565b6000806119a28787611f51565b50604081015190915080156119d95760208201516119cb6001600160a01b03881687838561143c565b6119d58286612445565b9450505b50919695505050505050565b60006119f18383611f51565b50606081015190915080156104ad5760208201516040830151610e9c6001600160a01b038316828561042b565b6000611a2a8383611f51565b5060208101516040820151919250906114946001600160a01b03831682612196565b6000611a588383611f51565b5060208101516040820151919250906114946001600160a01b038316826121db565b600080611a878585611f51565b5060208101519091506000611aa46001600160a01b038316612227565b8086529050610a78602086612445565b600080611ac18585611f51565b509050611cb0565b60006040516000806000805b600a841015611c9757600384028701600181015160f81c600a811060018114611b0f57600a820391506020820260208b0101519550611b19565b6020820288015195505b5050600281015160f81c600a811060018114611b4657600a820391506020820260208b0101519450611b50565b6020820288015194505b50505160f81c9050808015611bac5760018114611bca5760028114611bd95760038114611be85760048114611bf75760058114611c065760068114611c155760078114611c485760088114611c715760098114611c8057611c8b565b50505050600019016020908102919091018051910160405292915050565b82840160208602870152611c8b565b82840360208602870152611c8b565b82840260208602870152611c8b565b82840460208602870152611c8b565b82840a60208602870152611c8b565b6f7fffffffffffffffffffffffffffffff841115611c3b57607f84901d93841893909303925b8360208602870152611c8b565b6001600160ff1b03841115611c3b5760ff84901d93841893909303928360208602870152611c8b565b82841c60208602870152611c8b565b82841b602086028701525b50600184019350611ad5565b5050505061012081015161014090910160405292915050565b611cbc60208201611ac9565b8352611cc9602084612445565b95945050505050565b600080611cdf8585611f51565b509050611f1b565b60006040516000806000806000805b6006861015611f0157600586028901600181015160f81c6006811060018114611d30576006820391506020820260208d0101519750611d3a565b602082028a015197505b5050600281015160f81c6006811060018114611d67576006820391506020820260208d0101519650611d71565b602082028a015196505b5050600381015160f81c6006811060018114611d9e576006820391506020820260208d0101519550611da8565b602082028a015195505b5050600481015160f81c6006811060018114611dd5576006820391506020820260208d0101519450611ddf565b602082028a015194505b50505160f81c9050808015611e235760018114611e435760028114611e6a5760038114611e865760048114611e9e5760058114611eba5760068114611ed257611ef5565b505050505050600019016020908102919091018051910160405292915050565b84861060018114611e5b5783602089028a0152611e64565b84602089028a01525b50611ef5565b8486148587101760018114611e5b5783602089028a0152611e64565b84861160018114611e5b5783602089028a0152611e64565b8486148587111760018114611e5b5783602089028a0152611e64565b84861460018114611e5b5783602089028a0152611e64565b84861460018114611eea5784602089028a0152611ef3565b83602089028a01525b505b50600186019550611cf6565b5050505060a083015160c090930160405250909392505050565b611cbc60208201611ce7565b815115611f375781518083602001fd5b8060405162461bcd60e51b81526004016107d29190612517565b6040516000600584013560f090811c906003860135901c602084015b828210156120de57813560f81c808015611fca576001811461200f576002811461202b576003811461204a5760048114612071576005811461209557600681146120b357600781146120c757635485b7ef60e11b60005260046000fd5b600384013560f01c60018114611ff557600185013560f01c6001810135813560f81c1c975050612003565b600185013560f01c89015196505b506005840193506120d7565b600184013560f01c3583526004830192506003840193506120d7565b600184013560f01c3560601c83526020830192506003840193506120d7565b600184013560f01c6001810135813560f81c1c8452506020830192506003840193506120d7565b600384013560f01c80600186013560f01c85378084019350506005840193506120d7565b600184013560f01c88015183526020830192506003840193506120d7565b3083526020830192506001840193506120d7565b3383526020830192506001840193505b5050611f6d565b6020850181038552806040525050509250929050565b600060405190506044810160405263095ea7b360e01b8152826004820152816024820152612129846000836044600080610a16565b6104ad5760006024820152612145846000836044600080610a16565b612162576040516340b27c2160e11b815260040160405180910390fd5b816024820152612179846000836044600080610a16565b6104ad576040516340b27c2160e11b815260040160405180910390fd5b6000604051905060048101604052630d0e30db60e41b81526121be8383836004600080610a16565b6105055760405163bdc844ed60e01b815260040160405180910390fd5b6000604051905060248101604052632e1a7d4d60e01b815281600482015261220a836000836024600080610a16565b6105055760405163c617296b60e01b815260040160405180910390fd5b60006109758230611301565b6000806020838503121561224657600080fd5b823567ffffffffffffffff8082111561225e57600080fd5b818501915085601f83011261227257600080fd5b81358181111561228157600080fd5b86602082850101111561229357600080fd5b60209290920196919550909350505050565b80356001600160a01b03811681146122bc57600080fd5b919050565b600080604083850312156122d457600080fd5b6122dd836122a5565b9150602083013580151581146122f257600080fd5b809150509250929050565b60006020828403121561230f57600080fd5b610cfd826122a5565b6000806020838503121561232b57600080fd5b823567ffffffffffffffff8082111561234357600080fd5b818501915085601f83011261235757600080fd5b81358181111561236657600080fd5b8660208260051b850101111561229357600080fd5b60005b8381101561239657818101518382015260200161237e565b50506000910152565b600081518084526123b781602086016020860161237b565b601f01601f19169290920160200192915050565b600060208083016020845280855180835260408601915060408160051b87010192506020870160005b8281101561242257603f1988860301845261241085835161239f565b945092850192908501906001016123f4565b5092979650505050505050565b634e487b7160e01b600052601160045260246000fd5b808201808211156109755761097561242f565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261249b57600080fd5b83018035915067ffffffffffffffff8211156124b657600080fd5b6020019150368190038213156124cb57600080fd5b9250929050565b818103818111156109755761097561242f565b600082516124f781846020870161237b565b9190910192915050565b634e487b7160e01b600052602160045260246000fd5b602081526000610cfd602083018461239f56fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212209d482eea83e3c547d6b7a7976eeee6bd73b33f50f424013561ec0af41dd695f664736f6c63430008180033

Block Transaction Gas Used Reward
view all blocks produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
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.