Contract 0xc63e43e2f09537a2b07fba1e02c6f4163a956525

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x30dddab1be6b7b94550b0a67e82eb9fff57f5c84c0a046665c9b17c4e16313dcUpdate Magpie Co...196827842022-09-08 14:52:3625 days 10 hrs ago0x0dd6f5db21e9cd83409f4df9e2f791748cf5359d IN  0xc63e43e2f09537a2b07fba1e02c6f4163a9565250 AVAX0.001153225
0x2ca6c83ba9ad4a615153488a6409cc2df16df0b4f6734594d61c5128aa64d9990x60806040196824992022-09-08 14:41:5725 days 10 hrs ago0x0dd6f5db21e9cd83409f4df9e2f791748cf5359d IN  Create: MagpieBridge0 AVAX0.06193887525
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xdd3cfb81ec2ce17e38ff5ad558c32d3621f9ee14429157f1dcbb7dfce13194fe205884862022-10-03 9:47:1115 hrs 37 mins ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.000660423680178424 AVAX
0xdd3cfb81ec2ce17e38ff5ad558c32d3621f9ee14429157f1dcbb7dfce13194fe205884862022-10-03 9:47:1115 hrs 37 mins ago 0x6141143cf15d3327c17aac4b7bfb79a77a108fcc 0xc63e43e2f09537a2b07fba1e02c6f4163a9565250.000660423680178424 AVAX
0x6b3f48dc42e7eafa08a50fd93dddfcf6056a6456e83c7cfec1bb83e8c4f051c8204317522022-09-29 15:47:294 days 9 hrs ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.000568422816768738 AVAX
0x6b3f48dc42e7eafa08a50fd93dddfcf6056a6456e83c7cfec1bb83e8c4f051c8204317522022-09-29 15:47:294 days 9 hrs ago 0x6141143cf15d3327c17aac4b7bfb79a77a108fcc 0xc63e43e2f09537a2b07fba1e02c6f4163a9565250.000568422816768738 AVAX
0x232c14fd2ac217ac5ce6689040c0c55c9eff73c336b786db1a80c24f3a0c3706203996012022-09-28 21:26:575 days 3 hrs ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.033059541253529976 AVAX
0x232c14fd2ac217ac5ce6689040c0c55c9eff73c336b786db1a80c24f3a0c3706203996012022-09-28 21:26:575 days 3 hrs ago 0x6141143cf15d3327c17aac4b7bfb79a77a108fcc 0xc63e43e2f09537a2b07fba1e02c6f4163a9565250.033059541253529976 AVAX
0x1af32240b86d809952eb6e6e031dc3a4a2b2de0d849c6654b0612e9af1566d1c203994392022-09-28 21:21:265 days 4 hrs ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.033059541253529976 AVAX
0x1af32240b86d809952eb6e6e031dc3a4a2b2de0d849c6654b0612e9af1566d1c203994392022-09-28 21:21:265 days 4 hrs ago 0x6141143cf15d3327c17aac4b7bfb79a77a108fcc 0xc63e43e2f09537a2b07fba1e02c6f4163a9565250.033059541253529976 AVAX
0x3e7c6dee79f856b8822764d5ea0549d717942cc5f972bbc3ed5a49d5fe9839b5203988372022-09-28 21:00:585 days 4 hrs ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.033059541253529976 AVAX
0x3e7c6dee79f856b8822764d5ea0549d717942cc5f972bbc3ed5a49d5fe9839b5203988372022-09-28 21:00:585 days 4 hrs ago 0x6141143cf15d3327c17aac4b7bfb79a77a108fcc 0xc63e43e2f09537a2b07fba1e02c6f4163a9565250.033059541253529976 AVAX
0xd443d13d43853b66aa276ae3d03593bb294dba8375e673baf958038722e42e90202557462022-09-25 10:56:208 days 14 hrs ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.000575251583591261 AVAX
0xd443d13d43853b66aa276ae3d03593bb294dba8375e673baf958038722e42e90202557462022-09-25 10:56:208 days 14 hrs ago 0x6141143cf15d3327c17aac4b7bfb79a77a108fcc 0xc63e43e2f09537a2b07fba1e02c6f4163a9565250.000575251583591261 AVAX
0x18165655450d9fb4e2abde2d1c8e05db7fbb4145128b6b29dd74c171840c9818201922042022-09-23 21:57:5110 days 3 hrs ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.033059541253529976 AVAX
0x18165655450d9fb4e2abde2d1c8e05db7fbb4145128b6b29dd74c171840c9818201922042022-09-23 21:57:5110 days 3 hrs ago 0x6141143cf15d3327c17aac4b7bfb79a77a108fcc 0xc63e43e2f09537a2b07fba1e02c6f4163a9565250.033059541253529976 AVAX
0x38e77240c43f3a93615bebe63d326283514f0d3a8d690984ad7796f732b2312d201859632022-09-23 18:20:0610 days 7 hrs ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.033059541253529976 AVAX
0x38e77240c43f3a93615bebe63d326283514f0d3a8d690984ad7796f732b2312d201859632022-09-23 18:20:0610 days 7 hrs ago 0x6141143cf15d3327c17aac4b7bfb79a77a108fcc 0xc63e43e2f09537a2b07fba1e02c6f4163a9565250.033059541253529976 AVAX
0x1e0514e125ebcbf21d33801caed80941851d89918c6b7305188e01e23bf9257c201858702022-09-23 18:16:4910 days 7 hrs ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.033059541253529976 AVAX
0x1e0514e125ebcbf21d33801caed80941851d89918c6b7305188e01e23bf9257c201858702022-09-23 18:16:4910 days 7 hrs ago 0x6141143cf15d3327c17aac4b7bfb79a77a108fcc 0xc63e43e2f09537a2b07fba1e02c6f4163a9565250.033059541253529976 AVAX
0xf0c9c7ba920e460b40e0dc4f0b57a936661d2b79edfc13a30b22d3adb315439f201856972022-09-23 18:10:4710 days 7 hrs ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.033059541253529976 AVAX
0xf0c9c7ba920e460b40e0dc4f0b57a936661d2b79edfc13a30b22d3adb315439f201856972022-09-23 18:10:4710 days 7 hrs ago 0x6141143cf15d3327c17aac4b7bfb79a77a108fcc 0xc63e43e2f09537a2b07fba1e02c6f4163a9565250.033059541253529976 AVAX
0x537a7444e844e93c0d6a56475054fe4fb6aff357ae0933a5f3cf174f12761269201853842022-09-23 17:59:4010 days 7 hrs ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.033059541253529976 AVAX
0x537a7444e844e93c0d6a56475054fe4fb6aff357ae0933a5f3cf174f12761269201853842022-09-23 17:59:4010 days 7 hrs ago 0x6141143cf15d3327c17aac4b7bfb79a77a108fcc 0xc63e43e2f09537a2b07fba1e02c6f4163a9565250.033059541253529976 AVAX
0xd5a1f74493e1a580969c38781845d4477064eac8810060c430d366f1e4f1db39201853082022-09-23 17:57:0410 days 7 hrs ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.000539257147444673 AVAX
0xd5a1f74493e1a580969c38781845d4477064eac8810060c430d366f1e4f1db39201853082022-09-23 17:57:0410 days 7 hrs ago 0x6141143cf15d3327c17aac4b7bfb79a77a108fcc 0xc63e43e2f09537a2b07fba1e02c6f4163a9565250.000539257147444673 AVAX
0xae41df87177a22eab76e034d8b7562b2a84fc3c36daa4cc1c4302a94b906e4af201404882022-09-22 15:29:3411 days 9 hrs ago 0xc63e43e2f09537a2b07fba1e02c6f4163a956525 Stargate Finance: Router0.033059541253529976 AVAX
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MagpieBridge

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 25 : MagpieBridge.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "./interfaces/IStargateRouter.sol";
import "./interfaces/IStargateFactory.sol";
import "./interfaces/IStargatePool.sol";
import "./interfaces/IStargateFeeLibrary.sol";
import "./interfaces/IWormhole.sol";
import "./interfaces/IWormholeCore.sol";
import "./interfaces/IMagpieBridge.sol";
import "./lib/LibAsset.sol";
import "./lib/LibBytes.sol";
import "./lib/LibSwap.sol";

contract MagpieBridge is Ownable, IMagpieBridge {
    using LibAsset for address;
    using LibBytes for bytes;

    BridgeConfig public bridgeConfig;
    address public magpieCoreAddress;

    mapping(uint8 => mapping(uint64 => uint256)) public sequences;

    modifier onlyMagpieCore() {
        require(
            msg.sender == magpieCoreAddress,
            "MagpieBridge: only MagpieCore allowed"
        );
        _;
    }

    constructor(BridgeConfig memory _bridgeConfig) {
        bridgeConfig = _bridgeConfig;
    }

    function updateMagpieCore(address _magpieCoreAddress)
        external
        override
        onlyOwner
    {
        magpieCoreAddress = _magpieCoreAddress;
    }

    function updateConfig(BridgeConfig calldata _bridgeConfig)
        external
        override
        onlyOwner
    {
        bridgeConfig = _bridgeConfig;
    }

    function depositWormhole(
        ValidationInPayload memory payload,
        uint256 amount,
        address toAssetAddress
    ) private returns (uint256 depositAmount, uint64 tokenSequence) {
        depositAmount = amount;
        // Dust management
        uint8 toAssetDecimals = getDecimals(toAssetAddress);
        if (toAssetDecimals > 8) {
            depositAmount = normalize(toAssetDecimals, 8, depositAmount);
            depositAmount = denormalize(8, toAssetDecimals, depositAmount);
        }
        toAssetAddress.increaseAllowance(
            bridgeConfig.tokenBridgeAddress,
            depositAmount
        );
        tokenSequence = IWormhole(bridgeConfig.tokenBridgeAddress)
            .transferTokens(
                toAssetAddress,
                depositAmount,
                payload.recipientBridgeChainId,
                payload.recipientCoreAddress,
                0,
                uint32(block.timestamp % 2**32)
            );
    }

    function depositStargate(
        ValidationInPayload memory payload,
        uint64 coreSequence,
        uint256 amount,
        address refundAddress,
        address toAssetAddress
    ) private {
        toAssetAddress.increaseAllowance(
            bridgeConfig.stargateRouterAddress,
            amount
        );
        IStargateRouter(bridgeConfig.stargateRouterAddress).swap{
            value: msg.value
        }(
            uint16(payload.layerZeroRecipientChainId),
            payload.sourcePoolId,
            payload.destPoolId,
            payable(refundAddress),
            amount,
            getMinAmountLD(amount, payload),
            IStargateRouter.lzTxObj(0, 0, abi.encodePacked(refundAddress)),
            abi.encodePacked(
                address(uint160(uint256(payload.recipientCoreAddress)))
            ),
            bytes.concat(
                abi.encodePacked(
                    bridgeConfig.networkId,
                    bytes32(uint256(uint160(address(this))))
                ),
                abi.encodePacked(coreSequence)
            )
        );
    }

    function bridgeIn(
        BridgeType bridgeType,
        ValidationInPayload memory payload,
        uint256 amount,
        address toAssetAddress,
        address refundAddress
    )
        external
        payable
        override
        onlyMagpieCore
        returns (
            uint256 depositAmount,
            uint64 coreSequence,
            uint64 tokenSequence
        )
    {
        depositAmount = amount;
        tokenSequence = 0;

        if (bridgeType == BridgeType.Wormhole) {
            (depositAmount, tokenSequence) = depositWormhole(
                payload,
                amount,
                toAssetAddress
            );
        }
        uint8 senderIntermediaryDecimals = getDecimals(toAssetAddress);

        bytes memory payloadOut = bytes.concat(
            abi.encodePacked(
                payload.fromAssetAddress,
                payload.toAssetAddress,
                payload.to,
                payload.recipientCoreAddress,
                bytes32(uint256(uint160(address(this)))),
                payload.amountOutMin
            ),
            abi.encodePacked(
                payload.swapOutGasFee,
                depositAmount,
                tokenSequence,
                senderIntermediaryDecimals
            ),
            abi.encodePacked(
                bridgeConfig.networkId,
                payload.recipientNetworkId,
                bridgeType
            )
        );

        require(payloadOut.length == 268, "MagpieBridge: invalid payloadOut"); // Validating payloadOut

        coreSequence = IWormholeCore(bridgeConfig.coreBridgeAddress)
            .publishMessage(
                uint32(block.timestamp % 2**32),
                payloadOut,
                bridgeConfig.consistencyLevel
            );

        if (bridgeType == BridgeType.Stargate) {
            depositStargate(
                payload,
                coreSequence,
                amount,
                refundAddress,
                toAssetAddress
            );
        }
    }

    function getPayload(bytes memory encodedVm)
        public
        view
        returns (ValidationOutPayload memory payload, uint64 sequence)
    {
        IWormholeCore.VM memory vm = getVM(encodedVm);

        sequence = vm.sequence;
        payload = vm.payload.parse();
    }

    function getVM(bytes memory encodedVm)
        private
        view
        returns (IWormholeCore.VM memory)
    {
        (
            IWormholeCore.VM memory vm,
            bool valid,
            string memory reason
        ) = IWormholeCore(bridgeConfig.coreBridgeAddress).parseAndVerifyVM(
                encodedVm
            );
        require(valid, reason);

        return vm;
    }

    function bridgeOut(
        ValidationOutPayload memory payload,
        BridgeArgs memory bridgeArgs,
        uint64 tokenSequence,
        address assetAddress
    ) external override onlyMagpieCore returns (uint256 amount) {
        if (payload.bridgeType == BridgeType.Wormhole) {
            amount = adjustAssetDecimals(
                assetAddress,
                payload.senderIntermediaryDecimals,
                payload.amountIn
            );
            IWormholeCore.VM memory vm = getVM(bridgeArgs.encodedVmBridge);
            require(
                tokenSequence == vm.sequence,
                "MagpieBridge: invalid tokenSequence"
            );
            IWormhole(bridgeConfig.tokenBridgeAddress).completeTransfer(
                bridgeArgs.encodedVmBridge
            );
        } else {
            IStargateRouter(bridgeConfig.stargateRouterAddress).clearCachedSwap(
                    bridgeArgs.senderStargateChainId,
                    bridgeArgs.senderStargateBridgeAddress,
                    bridgeArgs.nonce
                );
        }
    }

    function getDecimals(address tokenAddress)
        private
        view
        returns (uint8 tokenDecimals)
    {
        tokenDecimals = 18;

        if (!tokenAddress.isNative()) {
            (, bytes memory queriedDecimals) = tokenAddress.staticcall(
                abi.encodeWithSignature("decimals()")
            );
            tokenDecimals = abi.decode(queriedDecimals, (uint8));
        }
    }

    function normalize(
        uint8 fromDecimals,
        uint8 toDecimals,
        uint256 amount
    ) private pure returns (uint256 amountOut) {
        uint256 exponent;

        exponent = fromDecimals - toDecimals;
        amountOut = amount / 10**exponent;
    }

    function denormalize(
        uint8 fromDecimals,
        uint8 toDecimals,
        uint256 amount
    ) private pure returns (uint256 amountOut) {
        uint256 exponent;

        exponent = toDecimals - fromDecimals;
        amountOut = amount * 10**exponent;
    }

    function adjustAssetDecimals(
        address assetAddress,
        uint8 fromDecimals,
        uint256 amountIn
    ) public view returns (uint256 amount) {
        uint8 receiverIntermediaryDecimals = getDecimals(assetAddress);
        if (fromDecimals > receiverIntermediaryDecimals) {
            amount = normalize(
                fromDecimals,
                receiverIntermediaryDecimals,
                amountIn
            );
        } else {
            amount = denormalize(
                fromDecimals,
                receiverIntermediaryDecimals,
                amountIn
            );
        }
    }

    function getSgPayload(bytes memory encodedBytes)
        public
        pure
        returns (
            uint8 networkId,
            bytes32 senderAddress,
            uint64 coreSequence
        )
    {
        (networkId, senderAddress, coreSequence) = encodedBytes.parseSgPayload();
    }

    function getMinAmountLD(uint256 amount, ValidationInPayload memory payload)
        private
        view
        returns (uint256)
    {
        address stargateFactoryAddress = IStargateRouter(
            bridgeConfig.stargateRouterAddress
        ).factory();
        address poolAddress = IStargateFactory(stargateFactoryAddress).getPool(
            payload.sourcePoolId
        );
        address feeLibraryAddress = IStargatePool(poolAddress).feeLibrary();
        uint256 convertRate = IStargatePool(poolAddress).convertRate();
        IStargatePool.SwapObj memory s = IStargateFeeLibrary(feeLibraryAddress)
            .getFees(
                payload.sourcePoolId,
                payload.destPoolId,
                uint16(payload.layerZeroRecipientChainId),
                address(this),
                amount / convertRate
            );
        s.amount =
            (amount /
                convertRate -
                (s.eqFee + s.protocolFee + s.lpFee) +
                s.eqReward) *
            convertRate;
        return s.amount;
    }
}

File 2 of 25 : 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 anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

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

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

File 3 of 25 : IStargateRouter.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

interface IStargateRouter {
    struct lzTxObj {
        uint256 dstGasForCall;
        uint256 dstNativeAmount;
        bytes dstNativeAddr;
    }

    function addLiquidity(
        uint256 _poolId,
        uint256 _amountLD,
        address _to
    ) external;

    function swap(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLD,
        uint256 _minAmountLD,
        lzTxObj memory _lzTxParams,
        bytes calldata _to,
        bytes calldata _payload
    ) external payable;

    function redeemRemote(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLP,
        uint256 _minAmountLD,
        bytes calldata _to,
        lzTxObj memory _lzTxParams
    ) external payable;

    function instantRedeemLocal(
        uint16 _srcPoolId,
        uint256 _amountLP,
        address _to
    ) external returns (uint256);

    function redeemLocal(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLP,
        bytes calldata _to,
        lzTxObj memory _lzTxParams
    ) external payable;

    function sendCredits(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress
    ) external payable;

    function quoteLayerZeroFee(
        uint16 _dstChainId,
        uint8 _functionType,
        bytes calldata _toAddress,
        bytes calldata _transferAndCallPayload,
        lzTxObj memory _lzTxParams
    ) external view returns (uint256, uint256);

    function clearCachedSwap(
        uint16 _srcChainId,
        bytes calldata _srcAddress,
        uint256 _nonce
    ) external;

    function factory() external view returns(address);
}

File 4 of 25 : IStargateFactory.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

interface IStargateFactory {
    function getPool(uint256) external view returns (address);
}

File 5 of 25 : IStargatePool.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

interface IStargatePool {
    struct SwapObj {
        uint256 amount;
        uint256 eqFee;
        uint256 eqReward;
        uint256 lpFee;
        uint256 protocolFee;
        uint256 lkbRemove;
    }

    function convertRate() external view returns (uint256);

    function feeLibrary() external view returns (address);
}

File 6 of 25 : IStargateFeeLibrary.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

import "./IStargatePool.sol";

interface IStargateFeeLibrary {
    function getFees(
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        uint16 _dstChainId,
        address _from,
        uint256 _amountSD
    ) external view returns (IStargatePool.SwapObj memory s);
}

File 7 of 25 : IWormhole.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

interface IWormhole {
    function transferTokens(
        address token,
        uint256 amount,
        uint16 recipientChain,
        bytes32 recipient,
        uint256 arbiterFee,
        uint32 nonce
    ) external payable returns (uint64 sequence);

    function wrapAndTransferETH(
        uint16 recipientChain,
        bytes32 recipient,
        uint256 arbiterFee,
        uint32 nonce
    ) external payable returns (uint64 sequence);

    function completeTransfer(bytes memory encodedVm) external;
}

File 8 of 25 : IWormholeCore.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

interface IWormholeCore {
    function publishMessage(
        uint32 nonce,
        bytes memory payload,
        uint8 consistencyLevel
    ) external payable returns (uint64 sequence);

    function parseAndVerifyVM(bytes calldata encodedVM)
        external
        view
        returns (
            IWormholeCore.VM memory vm,
            bool valid,
            string memory reason
        );

    struct Signature {
        bytes32 r;
        bytes32 s;
        uint8 v;
        uint8 guardianIndex;
    }

    struct VM {
        uint8 version;
        uint32 timestamp;
        uint32 nonce;
        uint16 emitterChainId;
        bytes32 emitterAddress;
        uint64 sequence;
        uint8 consistencyLevel;
        bytes payload;
        uint32 guardianSetIndex;
        Signature[] signatures;
        bytes32 hash;
    }
}

File 9 of 25 : IMagpieBridge.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

interface IMagpieBridge {
    enum BridgeType {
        Wormhole,
        Stargate
    }

    struct BridgeConfig {
        address stargateRouterAddress;
        address tokenBridgeAddress;
        address coreBridgeAddress;
        uint8 consistencyLevel;
        uint8 networkId;
    }

    struct BridgeArgs {
        bytes encodedVmBridge;
        bytes encodedVmCore;
        bytes senderStargateBridgeAddress;
        uint256 nonce;
        uint16 senderStargateChainId;
    }

    struct ValidationInPayload {
        bytes32 fromAssetAddress;
        bytes32 toAssetAddress;
        bytes32 to;
        bytes32 recipientCoreAddress;
        uint256 amountOutMin;
        uint256 layerZeroRecipientChainId;
        uint256 sourcePoolId;
        uint256 destPoolId;
        uint256 swapOutGasFee;
        uint16 recipientBridgeChainId;
        uint8 recipientNetworkId;
    }

    struct ValidationOutPayload {
        address fromAssetAddress;
        address toAssetAddress;
        address to;
        address recipientCoreAddress;
        bytes32 senderAddress;
        uint256 amountOutMin;
        uint256 swapOutGasFee;
        uint256 amountIn;
        uint64 tokenSequence;
        uint8 senderIntermediaryDecimals;
        uint8 senderNetworkId;
        uint8 recipientNetworkId;
        BridgeType bridgeType;
    }

    function updateConfig(BridgeConfig calldata _bridgeConfig) external;

    function bridgeIn(
        BridgeType bridgeType,
        ValidationInPayload memory payload,
        uint256 amount,
        address toAssetAddress,
        address refundAddress
    )
        external
        payable
        returns (
            uint256 depositAmount,
            uint64 coreSequence,
            uint64 tokenSequence
        );

    function getPayload(bytes memory encodedVm)
        external
        view
        returns (ValidationOutPayload memory payload, uint64 sequence);

    function bridgeOut(
        ValidationOutPayload memory payload,
        BridgeArgs memory bridgeArgs,
        uint64 tokenSequence,
        address assetAddress
    ) external returns (uint256 amount);

    function updateMagpieCore(address _magpieCoreAddress) external;

    function adjustAssetDecimals(
        address assetAddress,
        uint8 fromDecimals,
        uint256 amountIn
    ) external view returns (uint256 amount);
}

File 10 of 25 : LibAsset.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

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

library LibAsset {
    using LibAsset for address;

    address constant NATIVE_ASSETID = address(0);

    function isNative(address self) internal pure returns (bool) {
        return self == NATIVE_ASSETID;
    }

    function getBalance(address self) internal view returns (uint256) {
        return
            self.isNative()
                ? address(this).balance
                : IERC20(self).balanceOf(address(this));
    }

    function transferFrom(
        address self,
        address from,
        address to,
        uint256 amount
    ) internal {
        SafeERC20.safeTransferFrom(IERC20(self), from, to, amount);
    }

    function increaseAllowance(
        address self,
        address spender,
        uint256 amount
    ) internal {
        require(
            !self.isNative(),
            "LibAsset: Allowance can't be increased for native asset"
        );
        SafeERC20.safeIncreaseAllowance(IERC20(self), spender, amount);
    }

    function decreaseAllowance(
        address self,
        address spender,
        uint256 amount
    ) internal {
        require(
            !self.isNative(),
            "LibAsset: Allowance can't be decreased for native asset"
        );
        SafeERC20.safeDecreaseAllowance(IERC20(self), spender, amount);
    }

    function transfer(
        address self,
        address payable recipient,
        uint256 amount
    ) internal {
        self.isNative()
            ? Address.sendValue(recipient, amount)
            : SafeERC20.safeTransfer(IERC20(self), recipient, amount);
    }

    function approve(
        address self,
        address spender,
        uint256 amount
    ) internal {
        require(
            !self.isNative(),
            "LibAsset: Allowance can't be increased for native asset"
        );
        SafeERC20.safeApprove(IERC20(self), spender, amount);
    }

    function getAllowance(
        address self,
        address owner,
        address spender
    ) internal view returns (uint256) {
        return IERC20(self).allowance(owner, spender);
    }
}

File 11 of 25 : LibBytes.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;
import "../interfaces/IMagpieBridge.sol";

library LibBytes {
    using LibBytes for bytes;

    function toAddress(bytes memory self, uint256 start)
        internal
        pure
        returns (address)
    {
        return address(uint160(uint256(self.toBytes32(start))));
    }

    function toBool(bytes memory self, uint256 start)
        internal
        pure
        returns (bool)
    {
        return self.toUint8(start) == 1 ? true : false;
    }

    function toUint8(bytes memory self, uint256 start)
        internal
        pure
        returns (uint8)
    {
        require(self.length >= start + 1, "LibBytes: toUint8 outOfBounds");
        uint8 tempUint;

        assembly {
            tempUint := mload(add(add(self, 0x1), start))
        }

        return tempUint;
    }

    function toUint16(bytes memory self, uint256 start)
        internal
        pure
        returns (uint16)
    {
        require(self.length >= start + 2, "LibBytes: toUint16 outOfBounds");
        uint16 tempUint;

        assembly {
            tempUint := mload(add(add(self, 0x2), start))
        }

        return tempUint;
    }

    function toUint24(bytes memory self, uint256 start)
        internal
        pure
        returns (uint24)
    {
        require(self.length >= start + 3, "LibBytes: toUint24 outOfBounds");
        uint24 tempUint;

        assembly {
            tempUint := mload(add(add(self, 0x3), start))
        }

        return tempUint;
    }

    function toUint64(bytes memory self, uint256 start)
        internal
        pure
        returns (uint64)
    {
        require(self.length >= start + 8, "LibBytes: toUint64 outOfBounds");
        uint64 tempUint;

        assembly {
            tempUint := mload(add(add(self, 0x8), start))
        }

        return tempUint;
    }

    function toUint256(bytes memory self, uint256 start)
        internal
        pure
        returns (uint256)
    {
        require(self.length >= start + 32, "LibBytes: toUint256 outOfBounds");
        uint256 tempUint;

        assembly {
            tempUint := mload(add(add(self, 0x20), start))
        }

        return tempUint;
    }

    function toBytes32(bytes memory self, uint256 start)
        internal
        pure
        returns (bytes32)
    {
        require(self.length >= start + 32, "LibBytes: toBytes32 outOfBounds");
        bytes32 tempBytes32;

        assembly {
            tempBytes32 := mload(add(add(self, 0x20), start))
        }

        return tempBytes32;
    }

    function toBridgeType(bytes memory self, uint256 start)
        internal
        pure
        returns (IMagpieBridge.BridgeType)
    {
        return
            self.toUint8(start) == 0
                ? IMagpieBridge.BridgeType.Wormhole
                : IMagpieBridge.BridgeType.Stargate;
    }

    function parse(bytes memory self)
        internal
        pure
        returns (IMagpieBridge.ValidationOutPayload memory payload)
    {
        uint256 i = 0;

        payload.fromAssetAddress = self.toAddress(i);
        i += 32;

        payload.toAssetAddress = self.toAddress(i);
        i += 32;

        payload.to = self.toAddress(i);
        i += 32;

        payload.recipientCoreAddress = self.toAddress(i);
        i += 32;

        payload.senderAddress = self.toBytes32(i);
        i += 32;

        payload.amountOutMin = self.toUint256(i);
        i += 32;

        payload.swapOutGasFee = self.toUint256(i);
        i += 32;

        payload.amountIn = self.toUint256(i);
        i += 32;

        payload.tokenSequence = self.toUint64(i);
        i += 8;

        payload.senderIntermediaryDecimals = self.toUint8(i);
        i += 1;

        payload.senderNetworkId = self.toUint8(i);
        i += 1;

        payload.recipientNetworkId = self.toUint8(i);
        i += 1;

        payload.bridgeType = self.toBridgeType(i);
        i += 1;

        require(self.length == i, "LibBytes: payload is invalid");
    }

    function parseSgPayload(bytes memory self)
        internal
        pure
        returns (uint8 networkId, bytes32 senderAddress, uint64 coreSequence)
    {
        uint256 i = 0;
        networkId = self.toUint8(i);
        i += 1;
        senderAddress = self.toBytes32(i);
        i += 32;
        coreSequence = self.toUint64(i);
        i += 8;
        require(self.length == i, "LibBytes: payload is invalid");
    }
}

File 12 of 25 : LibSwap.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

import "../interfaces/IMagpieCore.sol";
import "../interfaces/IMagpieRouter.sol";
import "../interfaces/IWETH.sol";
import "./LibAssetUpgradeable.sol";

library LibSwap {
    using LibAssetUpgradeable for address;
    using LibSwap for IMagpieRouter.SwapArgs;

    function getFromAssetAddress(IMagpieRouter.SwapArgs memory self)
        internal
        pure
        returns (address)
    {
        return self.assets[self.routes[0].hops[0].path[0]];
    }

    function getToAssetAddress(IMagpieRouter.SwapArgs memory self)
        internal
        pure
        returns (address)
    {
        IMagpieRouter.Hop memory hop = self.routes[0].hops[
            self.routes[0].hops.length - 1
        ];
        return self.assets[hop.path[hop.path.length - 1]];
    }

    function getAmountIn(IMagpieRouter.SwapArgs memory self)
        internal
        pure
        returns (uint256)
    {
        uint256 amountIn = 0;

        for (uint256 i = 0; i < self.routes.length; i++) {
            amountIn += self.routes[i].amountIn;
        }

        return amountIn;
    }
}

File 13 of 25 : 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;
    }
}

File 14 of 25 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

File 15 of 25 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

    /**
     * @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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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 16 of 25 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

File 18 of 25 : IMagpieCore.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

import "./IMagpieRouter.sol";
import "./IMagpieBridge.sol";

interface IMagpieCore {
    struct Config {
        address weth;
        address pauserAddress;
        address magpieRouterAddress;
        address magpieBridgeAddress;
        address stargateAddress;
        address tokenBridgeAddress;
        address coreBridgeAddress;
        uint8 consistencyLevel;
        uint8 networkId;
    }

    struct SwapInArgs {
        IMagpieRouter.SwapArgs swapArgs;
        IMagpieBridge.ValidationInPayload payload;
        IMagpieBridge.BridgeType bridgeType;
    }

    struct SwapOutArgs {
        IMagpieRouter.SwapArgs swapArgs;
        IMagpieBridge.BridgeArgs bridgeArgs;
    }

    struct WrapSwapConfig {
        bool transferFromSender;
        bool prepareFromAsset;
        bool prepareToAsset;
        bool unwrapToAsset;
        bool swap;
    }

    function updateConfig(Config calldata config) external;

    function swap(IMagpieRouter.SwapArgs calldata args)
        external
        payable
        returns (uint256[] memory amountOuts);

    function swapIn(SwapInArgs calldata swapArgs)
        external
        payable
        returns (
            uint256[] memory amountOuts,
            uint256 depositAmount,
            uint64,
            uint64
        );

    function swapOut(SwapOutArgs calldata args)
        external
        returns (uint256[] memory amountOuts);

    function sgReceive(
        uint16 senderChainId,
        bytes memory magpieBridgeAddress,
        uint256 nonce,
        address assetAddress,
        uint256 amount,
        bytes memory payload
    ) external;

    event ConfigUpdated(Config config, address caller);

    event Swapped(
        IMagpieRouter.SwapArgs swapArgs,
        uint256[] amountOuts,
        address caller
    );

    event SwappedIn(
        SwapInArgs args,
        uint256[] amountOuts,
        uint256 depositAmount,
        uint8 receipientNetworkId,
        uint64 coreSequence,
        uint64 tokenSequence,
        bytes32 senderAddress,
        address caller
    );

    event SwappedOut(
        SwapOutArgs args,
        uint256[] amountOuts,
        uint8 senderNetworkId,
        uint64 coreSequence,
        bytes32 senderAddress,
        address caller
    );

    event GasFeeWithdraw(
        address indexed tokenAddress,
        address indexed owner,
        uint256 indexed amount
    );
}

File 19 of 25 : IMagpieRouter.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

interface IMagpieRouter {
    struct Amm {
        address id;
        uint16 index;
        uint8 protocolIndex;
    }

    struct Hop {
        uint16 ammIndex;
        uint8[] path;
        bytes poolData;
    }

    struct Route {
        uint256 amountIn;
        Hop[] hops;
    }

    struct SwapArgs {
        Route[] routes;
        address[] assets;
        address payable to;
        uint256 amountOutMin;
        uint256 deadline;
    }

    function updateAmms(Amm[] calldata amms) external;

    function swap(SwapArgs memory swapArgs)
        external
        returns (uint256[] memory amountOuts);

    function updateMagpieCore(address _magpieCoreAddress) external;

    function withdraw(address weth, uint256 amount) external;

    event AmmsUpdated(Amm[] amms, address caller);
}

File 20 of 25 : IWETH.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.5.0;

interface IWETH {
    function deposit() external payable;
    function transfer(address to, uint value) external returns (bool);
    function withdraw(uint) external;
}

File 21 of 25 : LibAssetUpgradeable.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0 <0.9.0;

import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

library LibAssetUpgradeable {
    using LibAssetUpgradeable for address;

    address constant NATIVE_ASSETID = address(0);

    function isNative(address self) internal pure returns (bool) {
        return self == NATIVE_ASSETID;
    }

    function getBalance(address self) internal view returns (uint256) {
        return
            self.isNative()
                ? address(this).balance
                : IERC20Upgradeable(self).balanceOf(address(this));
    }

    function transferFrom(
        address self,
        address from,
        address to,
        uint256 amount
    ) internal {
        SafeERC20Upgradeable.safeTransferFrom(IERC20Upgradeable(self), from, to, amount);
    }

    function increaseAllowance(
        address self,
        address spender,
        uint256 amount
    ) internal {
        require(
            !self.isNative(),
            "LibAsset: Allowance can't be increased for native asset"
        );
        SafeERC20Upgradeable.safeIncreaseAllowance(IERC20Upgradeable(self), spender, amount);
    }

    function decreaseAllowance(
        address self,
        address spender,
        uint256 amount
    ) internal {
        require(
            !self.isNative(),
            "LibAsset: Allowance can't be decreased for native asset"
        );
        SafeERC20Upgradeable.safeDecreaseAllowance(IERC20Upgradeable(self), spender, amount);
    }

    function transfer(
        address self,
        address payable recipient,
        uint256 amount
    ) internal {
        self.isNative()
            ? AddressUpgradeable.sendValue(recipient, amount)
            : SafeERC20Upgradeable.safeTransfer(IERC20Upgradeable(self), recipient, amount);
    }

    function approve(
        address self,
        address spender,
        uint256 amount
    ) internal {
        require(
            !self.isNative(),
            "LibAsset: Allowance can't be increased for native asset"
        );
        SafeERC20Upgradeable.safeApprove(IERC20Upgradeable(self), spender, amount);
    }

    function getAllowance(
        address self,
        address owner,
        address spender
    ) internal view returns (uint256) {
        return IERC20Upgradeable(self).allowance(owner, spender);
    }
}

File 22 of 25 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../extensions/draft-IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";

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

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

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

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

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

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

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

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

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

File 23 of 25 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

    /**
     * @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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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 24 of 25 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

Contract ABI

[{"inputs":[{"components":[{"internalType":"address","name":"stargateRouterAddress","type":"address"},{"internalType":"address","name":"tokenBridgeAddress","type":"address"},{"internalType":"address","name":"coreBridgeAddress","type":"address"},{"internalType":"uint8","name":"consistencyLevel","type":"uint8"},{"internalType":"uint8","name":"networkId","type":"uint8"}],"internalType":"struct IMagpieBridge.BridgeConfig","name":"_bridgeConfig","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"assetAddress","type":"address"},{"internalType":"uint8","name":"fromDecimals","type":"uint8"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"adjustAssetDecimals","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgeConfig","outputs":[{"internalType":"address","name":"stargateRouterAddress","type":"address"},{"internalType":"address","name":"tokenBridgeAddress","type":"address"},{"internalType":"address","name":"coreBridgeAddress","type":"address"},{"internalType":"uint8","name":"consistencyLevel","type":"uint8"},{"internalType":"uint8","name":"networkId","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum IMagpieBridge.BridgeType","name":"bridgeType","type":"uint8"},{"components":[{"internalType":"bytes32","name":"fromAssetAddress","type":"bytes32"},{"internalType":"bytes32","name":"toAssetAddress","type":"bytes32"},{"internalType":"bytes32","name":"to","type":"bytes32"},{"internalType":"bytes32","name":"recipientCoreAddress","type":"bytes32"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"uint256","name":"layerZeroRecipientChainId","type":"uint256"},{"internalType":"uint256","name":"sourcePoolId","type":"uint256"},{"internalType":"uint256","name":"destPoolId","type":"uint256"},{"internalType":"uint256","name":"swapOutGasFee","type":"uint256"},{"internalType":"uint16","name":"recipientBridgeChainId","type":"uint16"},{"internalType":"uint8","name":"recipientNetworkId","type":"uint8"}],"internalType":"struct IMagpieBridge.ValidationInPayload","name":"payload","type":"tuple"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"toAssetAddress","type":"address"},{"internalType":"address","name":"refundAddress","type":"address"}],"name":"bridgeIn","outputs":[{"internalType":"uint256","name":"depositAmount","type":"uint256"},{"internalType":"uint64","name":"coreSequence","type":"uint64"},{"internalType":"uint64","name":"tokenSequence","type":"uint64"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fromAssetAddress","type":"address"},{"internalType":"address","name":"toAssetAddress","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"recipientCoreAddress","type":"address"},{"internalType":"bytes32","name":"senderAddress","type":"bytes32"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"uint256","name":"swapOutGasFee","type":"uint256"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint64","name":"tokenSequence","type":"uint64"},{"internalType":"uint8","name":"senderIntermediaryDecimals","type":"uint8"},{"internalType":"uint8","name":"senderNetworkId","type":"uint8"},{"internalType":"uint8","name":"recipientNetworkId","type":"uint8"},{"internalType":"enum IMagpieBridge.BridgeType","name":"bridgeType","type":"uint8"}],"internalType":"struct IMagpieBridge.ValidationOutPayload","name":"payload","type":"tuple"},{"components":[{"internalType":"bytes","name":"encodedVmBridge","type":"bytes"},{"internalType":"bytes","name":"encodedVmCore","type":"bytes"},{"internalType":"bytes","name":"senderStargateBridgeAddress","type":"bytes"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint16","name":"senderStargateChainId","type":"uint16"}],"internalType":"struct IMagpieBridge.BridgeArgs","name":"bridgeArgs","type":"tuple"},{"internalType":"uint64","name":"tokenSequence","type":"uint64"},{"internalType":"address","name":"assetAddress","type":"address"}],"name":"bridgeOut","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedVm","type":"bytes"}],"name":"getPayload","outputs":[{"components":[{"internalType":"address","name":"fromAssetAddress","type":"address"},{"internalType":"address","name":"toAssetAddress","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"recipientCoreAddress","type":"address"},{"internalType":"bytes32","name":"senderAddress","type":"bytes32"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"uint256","name":"swapOutGasFee","type":"uint256"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint64","name":"tokenSequence","type":"uint64"},{"internalType":"uint8","name":"senderIntermediaryDecimals","type":"uint8"},{"internalType":"uint8","name":"senderNetworkId","type":"uint8"},{"internalType":"uint8","name":"recipientNetworkId","type":"uint8"},{"internalType":"enum IMagpieBridge.BridgeType","name":"bridgeType","type":"uint8"}],"internalType":"struct IMagpieBridge.ValidationOutPayload","name":"payload","type":"tuple"},{"internalType":"uint64","name":"sequence","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedBytes","type":"bytes"}],"name":"getSgPayload","outputs":[{"internalType":"uint8","name":"networkId","type":"uint8"},{"internalType":"bytes32","name":"senderAddress","type":"bytes32"},{"internalType":"uint64","name":"coreSequence","type":"uint64"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"magpieCoreAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"},{"internalType":"uint64","name":"","type":"uint64"}],"name":"sequences","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"stargateRouterAddress","type":"address"},{"internalType":"address","name":"tokenBridgeAddress","type":"address"},{"internalType":"address","name":"coreBridgeAddress","type":"address"},{"internalType":"uint8","name":"consistencyLevel","type":"uint8"},{"internalType":"uint8","name":"networkId","type":"uint8"}],"internalType":"struct IMagpieBridge.BridgeConfig","name":"_bridgeConfig","type":"tuple"}],"name":"updateConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_magpieCoreAddress","type":"address"}],"name":"updateMagpieCore","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b5060405162002c0a38038062002c0a833981016040819052620000349162000145565b6200003f33620000c6565b8051600180546001600160a01b03199081166001600160a01b03938416179091556020830151600280549092169083161790556040820151600380546060850151608090950151929093166001600160a81b031990931692909217600160a01b60ff948516021760ff60a81b1916600160a81b9390911692909202919091179055620001ec565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146200012e57600080fd5b919050565b805160ff811681146200012e57600080fd5b600060a082840312156200015857600080fd5b60405160a081016001600160401b03811182821017156200018957634e487b7160e01b600052604160045260246000fd5b604052620001978362000116565b8152620001a76020840162000116565b6020820152620001ba6040840162000116565b6040820152620001cd6060840162000133565b6060820152620001e06080840162000133565b60808201529392505050565b612a0e80620001fc6000396000f3fe6080604052600436106100c25760003560e01c80638da5cb5b1161007f578063b379c07511610059578063b379c075146102b3578063c66a4a3d146102d3578063d37e411b1461030b578063f2fde38b1461032b57600080fd5b80638da5cb5b1461024157806394d9cb7e14610273578063af6e524d1461029357600080fd5b8063186216ab146100c7578063235e5199146101145780632c6c8c09146101965780634c060c04146101ce578063715018a6146101fc578063874e968c14610213575b600080fd5b3480156100d357600080fd5b506100e76100e2366004611ba7565b61034b565b6040805160ff909416845260208401929092526001600160401b0316908201526060015b60405180910390f35b34801561012057600080fd5b50600154600254600354610158926001600160a01b03908116928116919081169060ff600160a01b8204811691600160a81b90041685565b604080516001600160a01b0396871681529486166020860152929094169183019190915260ff9081166060830152909116608082015260a00161010b565b6101a96101a4366004611c3f565b610366565b604080519384526001600160401b03928316602085015291169082015260600161010b565b3480156101da57600080fd5b506101ee6101e9366004611d32565b61060c565b60405190815260200161010b565b34801561020857600080fd5b50610211610650565b005b34801561021f57600080fd5b5061023361022e366004611ba7565b610664565b60405161010b929190611dab565b34801561024d57600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200161010b565b34801561027f57600080fd5b5061021161028e366004611eab565b610696565b34801561029f57600080fd5b506102116102ae366004611ebd565b6106b0565b3480156102bf57600080fd5b5060045461025b906001600160a01b031681565b3480156102df57600080fd5b506101ee6102ee366004611efa565b600560209081526000928352604080842090915290825290205481565b34801561031757600080fd5b506101ee610326366004611fe1565b6106da565b34801561033757600080fd5b50610211610346366004611ebd565b6108a1565b60008060006103598461091a565b9196909550909350915050565b600454600090819081906001600160a01b031633146103a05760405162461bcd60e51b815260040161039790612123565b60405180910390fd5b508491506000808860018111156103b9576103b9611d73565b14156103d0576103ca8787876109c2565b90935090505b60006103db86610af6565b88516020808b01516040808d015160608e015160808f0151925196975060009661043096959293919230929101958652602086019490945260408501929092526060840152608083015260a082015260c00190565b60408051601f198184030181528282526101008c015160208401528282018890526001600160c01b031960c087901b1660608401526001600160f81b031960f886901b16606884015281518084036049018152606984019092526003546101408d015191936104b092600160a81b90920460ff1691908f90608901612168565b60408051601f19818403018152908290526104cf9392916020016121e4565b6040516020818303038152906040529050805161010c146105325760405162461bcd60e51b815260206004820181905260248201527f4d61677069654272696467653a20696e76616c6964207061796c6f61644f75746044820152606401610397565b6003546001600160a01b031663b19a437e6105526401000000004261223d565b60035460405160e084901b6001600160e01b031916815261058492918691600160a01b90910460ff169060040161227d565b602060405180830381600087803b15801561059e57600080fd5b505af11580156105b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d691906122ba565b935060018a60018111156105ec576105ec611d73565b14156105ff576105ff89858a898b610baa565b5050955095509592505050565b60008061061885610af6565b90508060ff168460ff16111561063a57610633848285610d70565b9150610648565b610645848285610d97565b91505b509392505050565b610658610dbe565b6106626000610e18565b565b61066c6119ea565b60008061067884610e68565b90508060a00151915061068e8160e00151610f79565b925050915091565b61069e610dbe565b8060016106ab82826122f7565b505050565b6106b8610dbe565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6004546000906001600160a01b031633146107075760405162461bcd60e51b815260040161039790612123565b6000856101800151600181111561072057610720611d73565b14156108265761073a828661012001518760e0015161060c565b9050600061074b8560000151610e68565b90508060a001516001600160401b0316846001600160401b0316146107be5760405162461bcd60e51b815260206004820152602360248201527f4d61677069654272696467653a20696e76616c696420746f6b656e53657175656044820152626e636560e81b6064820152608401610397565b600254855160405163c687851960e01b81526001600160a01b039092169163c6878519916107ee9160040161239e565b600060405180830381600087803b15801561080857600080fd5b505af115801561081c573d6000803e3d6000fd5b5050505050610899565b60015460808501516040808701516060880151915163201d4fbd60e11b81526001600160a01b039094169363403a9f7a93610866939092916004016123b1565b600060405180830381600087803b15801561088057600080fd5b505af1158015610894573d6000803e3d6000fd5b505050505b949350505050565b6108a9610dbe565b6001600160a01b03811661090e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610397565b61091781610e18565b50565b600080808061092985826111a7565b93506109366001826123f4565b90506109428582611213565b925061094f6020826123f4565b905061095b8582611279565b91506109686008826123f4565b9050808551146109ba5760405162461bcd60e51b815260206004820152601c60248201527f4c696242797465733a207061796c6f616420697320696e76616c6964000000006044820152606401610397565b509193909250565b816000806109cf84610af6565b905060088160ff1611156109fa576109e981600885610d70565b92506109f760088285610d97565b92505b600254610a14906001600160a01b038681169116856112df565b60025461012087015160608801516001600160a01b0390921691630f5287b09187918791906000610a4a6401000000004261223d565b6040516001600160e01b031960e089901b1681526001600160a01b039096166004870152602486019490945261ffff90921660448501526064840152608483015263ffffffff1660a482015260c401602060405180830381600087803b158015610ab357600080fd5b505af1158015610ac7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aeb91906122ba565b915050935093915050565b60126001600160a01b03821615610ba55760408051600481526024810182526020810180516001600160e01b031663313ce56760e01b17905290516000916001600160a01b03851691610b49919061240c565b600060405180830381855afa9150503d8060008114610b84576040519150601f19603f3d011682016040523d82523d6000602084013e610b89565b606091505b5091505080806020019051810190610ba19190612433565b9150505b919050565b600154610bc4906001600160a01b038381169116856112df565b60015460a086015160c087015160e08801516001600160a01b0390931692639fbf10fc92349290918789610bf8818e611366565b604051806060016040528060008152602001600081526020018c604051602001610c3a919060609190911b6bffffffffffffffffffffffff1916815260140190565b6040516020818303038152906040528152508e6060015160001c604051602001610c7c919060609190911b6bffffffffffffffffffffffff1916815260140190565b60408051601f1981840301815290829052600354600160a81b900460f81b6001600160f81b0319166020830152306021830152906041016040516020818303038152906040528f604051602001610ce6919060c09190911b6001600160c01b031916815260080190565b60408051601f1981840301815290829052610d049291602001612450565b6040516020818303038152906040526040518b63ffffffff1660e01b8152600401610d379998979695949392919061247f565b6000604051808303818588803b158015610d5057600080fd5b505af1158015610d64573d6000803e3d6000fd5b50505050505050505050565b600080610d7d848661251d565b60ff169050610d8d81600a612624565b6106459084612630565b600080610da4858561251d565b60ff169050610db481600a612624565b6106459084612644565b6000546001600160a01b031633146106625760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610397565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b604080516101608101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c0820183905260e08201819052610100820183905261012082015261014081019190915260035460405163607ec5ef60e11b8152600091829182916001600160a01b03169063c0fd8bde90610ef590889060040161239e565b60006040518083038186803b158015610f0d57600080fd5b505afa158015610f21573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f4991908101906127a0565b925092509250818190610f6f5760405162461bcd60e51b8152600401610397919061239e565b5091949350505050565b610f816119ea565b6000610f8d8382611687565b6001600160a01b03168252610fa36020826123f4565b9050610faf8382611687565b6001600160a01b0316602080840191909152610fcb90826123f4565b9050610fd78382611687565b6001600160a01b03166040830152610ff06020826123f4565b9050610ffc8382611687565b6001600160a01b031660608301526110156020826123f4565b90506110218382611213565b60808301526110316020826123f4565b905061103d838261169a565b60a083015261104d6020826123f4565b9050611059838261169a565b60c08301526110696020826123f4565b9050611075838261169a565b60e08301526110856020826123f4565b90506110918382611279565b6001600160401b03166101008301526110ab6008826123f4565b90506110b783826111a7565b60ff166101208301526110cb6001826123f4565b90506110d783826111a7565b60ff166101408301526110eb6001826123f4565b90506110f783826111a7565b60ff1661016083015261110b6001826123f4565b905061111783826116f7565b826101800190600181111561112e5761112e611d73565b9081600181111561114157611141611d73565b90525061114f6001826123f4565b9050808351146111a15760405162461bcd60e51b815260206004820152601c60248201527f4c696242797465733a207061796c6f616420697320696e76616c6964000000006044820152606401610397565b50919050565b60006111b48260016123f4565b835110156112045760405162461bcd60e51b815260206004820152601d60248201527f4c696242797465733a20746f55696e7438206f75744f66426f756e64730000006044820152606401610397565b50818101600101515b92915050565b60006112208260206123f4565b835110156112705760405162461bcd60e51b815260206004820152601f60248201527f4c696242797465733a20746f42797465733332206f75744f66426f756e6473006044820152606401610397565b50016020015190565b60006112868260086123f4565b835110156112d65760405162461bcd60e51b815260206004820152601e60248201527f4c696242797465733a20746f55696e743634206f75744f66426f756e647300006044820152606401610397565b50016008015190565b6001600160a01b03831661135b5760405162461bcd60e51b815260206004820152603760248201527f4c696241737365743a20416c6c6f77616e63652063616e277420626520696e6360448201527f72656173656420666f72206e61746976652061737365740000000000000000006064820152608401610397565b6106ab83838361171b565b600080600160000160009054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156113ba57600080fd5b505afa1580156113ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f291906128f7565b90506000816001600160a01b031663068bcd8d8560c001516040518263ffffffff1660e01b815260040161142891815260200190565b60206040518083038186803b15801561144057600080fd5b505afa158015611454573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147891906128f7565b90506000816001600160a01b0316621edfab6040518163ffffffff1660e01b815260040160206040518083038186803b1580156114b457600080fd5b505afa1580156114c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ec91906128f7565b90506000826001600160a01b031663feb56b156040518163ffffffff1660e01b815260040160206040518083038186803b15801561152957600080fd5b505afa15801561153d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115619190612914565b90506000826001600160a01b0316631ab624308860c001518960e001518a60a0015130878e6115909190612630565b6040516001600160e01b031960e088901b1681526004810195909552602485019390935261ffff90911660448401526001600160a01b03166064830152608482015260a40160c06040518083038186803b1580156115ed57600080fd5b505afa158015611601573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611625919061292d565b905081816040015182606001518360800151846020015161164691906123f4565b61165091906123f4565b61165a858c612630565b61166491906129a6565b61166e91906123f4565b6116789190612644565b90819052979650505050505050565b60006116938383611213565b9392505050565b60006116a78260206123f4565b835110156112705760405162461bcd60e51b815260206004820152601f60248201527f4c696242797465733a20746f55696e74323536206f75744f66426f756e6473006044820152606401610397565b600061170383836111a7565b60ff1615611712576001611693565b60009392505050565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e9060440160206040518083038186803b15801561176757600080fd5b505afa15801561177b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179f9190612914565b6117a991906123f4565b604080516001600160a01b038616602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790529091506117fe908590611804565b50505050565b6000611859826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118d69092919063ffffffff16565b8051909150156106ab578080602001905181019061187791906129bd565b6106ab5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610397565b60606108998484600085856001600160a01b0385163b6119385760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610397565b600080866001600160a01b03168587604051611954919061240c565b60006040518083038185875af1925050503d8060008114611991576040519150601f19603f3d011682016040523d82523d6000602084013e611996565b606091505b50915091506119a68282866119b1565b979650505050505050565b606083156119c0575081611693565b8251156119d05782518084602001fd5b8160405162461bcd60e51b8152600401610397919061239e565b604080516101a081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081018290529061018082015290565b634e487b7160e01b600052604160045260246000fd5b60405161016081016001600160401b0381118282101715611a8d57611a8d611a54565b60405290565b60405160a081016001600160401b0381118282101715611a8d57611a8d611a54565b6040516101a081016001600160401b0381118282101715611a8d57611a8d611a54565b604051608081016001600160401b0381118282101715611a8d57611a8d611a54565b604051601f8201601f191681016001600160401b0381118282101715611b2257611b22611a54565b604052919050565b60006001600160401b03821115611b4357611b43611a54565b50601f01601f191660200190565b600082601f830112611b6257600080fd5b8135611b75611b7082611b2a565b611afa565b818152846020838601011115611b8a57600080fd5b816020850160208301376000918101602001919091529392505050565b600060208284031215611bb957600080fd5b81356001600160401b03811115611bcf57600080fd5b61089984828501611b51565b803560028110610ba557600080fd5b61ffff8116811461091757600080fd5b8035610ba581611bea565b60ff8116811461091757600080fd5b8035610ba581611c05565b6001600160a01b038116811461091757600080fd5b8035610ba581611c1f565b60008060008060008587036101e0811215611c5957600080fd5b611c6287611bdb565b955061016080601f1983011215611c7857600080fd5b611c80611a6a565b91506020880135825260408801356020830152606088013560408301526080880135606083015260a0880135608083015260c088013560a083015260e088013560c08301526101008089013560e0840152610120808a0135828501526101409150611cec828b01611bfa565b90840152611cfb898301611c14565b908301525093506101808601359250611d176101a08701611c34565b9150611d266101c08701611c34565b90509295509295909350565b600080600060608486031215611d4757600080fd5b8335611d5281611c1f565b92506020840135611d6281611c05565b929592945050506040919091013590565b634e487b7160e01b600052602160045260246000fd5b60028110611da757634e487b7160e01b600052602160045260246000fd5b9052565b82516001600160a01b031681526101c081016020840151611dd760208401826001600160a01b03169052565b506040840151611df260408401826001600160a01b03169052565b506060840151611e0d60608401826001600160a01b03169052565b506080840151608083015260a084015160a083015260c084015160c083015260e084015160e083015261010080850151611e51828501826001600160401b03169052565b50506101208481015160ff9081169184019190915261014080860151821690840152610160808601519091169083015261018080850151611e9482850182611d89565b50506001600160401b0383166101a0830152611693565b600060a082840312156111a157600080fd5b600060208284031215611ecf57600080fd5b813561169381611c1f565b6001600160401b038116811461091757600080fd5b8035610ba581611eda565b60008060408385031215611f0d57600080fd5b8235611f1881611c05565b91506020830135611f2881611eda565b809150509250929050565b600060a08284031215611f4557600080fd5b611f4d611a93565b905081356001600160401b0380821115611f6657600080fd5b611f7285838601611b51565b83526020840135915080821115611f8857600080fd5b611f9485838601611b51565b60208401526040840135915080821115611fad57600080fd5b50611fba84828501611b51565b60408301525060608201356060820152611fd660808301611bfa565b608082015292915050565b600080600080848603610200811215611ff957600080fd5b6101a08082121561200957600080fd5b612011611ab5565b915061201c87611c34565b825261202a60208801611c34565b602083015261203b60408801611c34565b604083015261204c60608801611c34565b60608301526080870135608083015260a087013560a083015260c087013560c083015260e087013560e0830152610100612087818901611eef565b90830152610120612099888201611c14565b908301526101406120ab888201611c14565b908301526101606120bd888201611c14565b908301526101806120cf888201611bdb565b908301529094508501356001600160401b038111156120ed57600080fd5b6120f987828801611f33565b9350506121096101c08601611eef565b91506121186101e08601611c34565b905092959194509250565b60208082526025908201527f4d61677069654272696467653a206f6e6c79204d6167706965436f726520616c6040820152641b1bddd95960da1b606082015260800190565b6001600160f81b031960f885811b8216835284901b1660018201526000600283106121a357634e487b7160e01b600052602160045260246000fd5b5060f89190911b600282015260030192915050565b60005b838110156121d35781810151838201526020016121bb565b838111156117fe5750506000910152565b600084516121f68184602089016121b8565b84519083019061220a8183602089016121b8565b845191019061221d8183602088016121b8565b0195945050505050565b634e487b7160e01b600052601260045260246000fd5b60008261224c5761224c612227565b500690565b600081518084526122698160208601602086016121b8565b601f01601f19169290920160200192915050565b63ffffffff8416815260606020820152600061229c6060830185612251565b905060ff83166040830152949350505050565b8051610ba581611eda565b6000602082840312156122cc57600080fd5b815161169381611eda565b80546001600160a01b0319166001600160a01b0392909216919091179055565b813561230281611c1f565b61230c81836122d7565b50602082013561231b81611c1f565b61232881600184016122d7565b5060028101604083013561233b81611c1f565b61234581836122d7565b50606083013561235481611c05565b815460ff60a01b19811660a09290921b60ff60a01b169182178355608085013561237d81611c05565b61ffff60a01b199190911690911760a89190911b60ff60a81b161790555050565b6020815260006116936020830184612251565b61ffff841681526060602082015260006123ce6060830185612251565b9050826040830152949350505050565b634e487b7160e01b600052601160045260246000fd5b60008219821115612407576124076123de565b500190565b6000825161241e8184602087016121b8565b9190910192915050565b8051610ba581611c05565b60006020828403121561244557600080fd5b815161169381611c05565b600083516124628184602088016121b8565b8351908301906124768183602088016121b8565b01949350505050565b600061012061ffff8c1683528a602084015289604084015260018060a01b03891660608401528760808401528660a08401528060c0840152855181840152506020850151610140830152604085015160606101608401526124e4610180840182612251565b905082810360e08401526124f88186612251565b905082810361010084015261250d8185612251565b9c9b505050505050505050505050565b600060ff821660ff841680821015612537576125376123de565b90039392505050565b600181815b8085111561257b578160001904821115612561576125616123de565b8085161561256e57918102915b93841c9390800290612545565b509250929050565b6000826125925750600161120d565b8161259f5750600061120d565b81600181146125b557600281146125bf576125db565b600191505061120d565b60ff8411156125d0576125d06123de565b50506001821b61120d565b5060208310610133831016604e8410600b84101617156125fe575081810a61120d565b6126088383612540565b806000190482111561261c5761261c6123de565b029392505050565b60006116938383612583565b60008261263f5761263f612227565b500490565b600081600019048311821515161561265e5761265e6123de565b500290565b805163ffffffff81168114610ba557600080fd5b8051610ba581611bea565b600082601f83011261269357600080fd5b81516126a1611b7082611b2a565b8181528460208386010111156126b657600080fd5b6108998260208301602087016121b8565b600082601f8301126126d857600080fd5b815160206001600160401b038211156126f3576126f3611a54565b612701818360051b01611afa565b82815260079290921b8401810191818101908684111561272057600080fd5b8286015b84811015612785576080818903121561273d5760008081fd5b612745611ad8565b81518152848201518582015260408083015161276081611c05565b9082015260608281015161277381611c05565b90820152835291830191608001612724565b509695505050505050565b80518015158114610ba557600080fd5b6000806000606084860312156127b557600080fd5b83516001600160401b03808211156127cc57600080fd5b9085019061016082880312156127e157600080fd5b6127e9611a6a565b6127f283612428565b815261280060208401612663565b602082015261281160408401612663565b604082015261282260608401612677565b60608201526080830151608082015261283d60a084016122af565b60a082015261284e60c08401612428565b60c082015260e08301518281111561286557600080fd5b61287189828601612682565b60e083015250610100612885818501612663565b90820152610120838101518381111561289d57600080fd5b6128a98a8287016126c7565b9183019190915250610140838101519082015294506128ca60208701612790565b935060408601519150808211156128e057600080fd5b506128ed86828701612682565b9150509250925092565b60006020828403121561290957600080fd5b815161169381611c1f565b60006020828403121561292657600080fd5b5051919050565b600060c0828403121561293f57600080fd5b60405160c081018181106001600160401b038211171561296157612961611a54565b8060405250825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a08201528091505092915050565b6000828210156129b8576129b86123de565b500390565b6000602082840312156129cf57600080fd5b6116938261279056fea2646970667358221220d5e7c032d769a6afd258a6cf7c9198138453ef724204c0181f894d6f655d875164736f6c6343000809003300000000000000000000000045a01e4e04f14f7a4a6702c74187c5f6222033cd0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d805200000000000000000000000054a8e5f9c4cba08f9943965859f6c34eaf03e26c00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000004

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

00000000000000000000000045a01e4e04f14f7a4a6702c74187c5f6222033cd0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d805200000000000000000000000054a8e5f9c4cba08f9943965859f6c34eaf03e26c00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000004

-----Decoded View---------------
Arg [0] : _bridgeConfig (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 00000000000000000000000045a01e4e04f14f7a4a6702c74187c5f6222033cd
Arg [1] : 0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052
Arg [2] : 00000000000000000000000054a8e5f9c4cba08f9943965859f6c34eaf03e26c
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000004


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.