Contract 0x51af494f1b4d3f77835951fa827d66fc4a18dae8

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x1569190efc05b3078d5c7255dae21b8b8a12cb140bec0a03369f83481d61779bCross Swap280236852023-03-28 21:32:107 mins ago0x7710b04be9c9bd4f4e611ba7f66f34ad87d72b0d IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae81.280788321410699 AVAX0.016833775 25
0x20f5ac86e59625d283971675d695af7b00744510691da8cb94737ab56d6c5148Cross Swap280236832023-03-28 21:32:067 mins ago0x5428a10d8555382eb859b80f2610431b127d3678 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae80.059607070768799 AVAX0.016833175 25
0x03862b09b8894cd74a5e3260a13157b959fc3c8b2c0285d176cd91fab2e6ad52Cross Swap280235412023-03-28 21:27:0212 mins ago0x5119f837e1eb6291f5c0abae84017bd5359a8463 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae82.644730171468099 AVAX0.016833475 25
0x9ea2732770e3f632c03b0eddee3a8628c645c521b15b6e666a4bb88e6d22bc2bCross Swap280234532023-03-28 21:23:4915 mins ago0xdf3bc3e662d9f177e7444c81d400c64ab6036379 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae84.014730171468099 AVAX0.016833475 25
0x9de2a5eb2041002bee53fa52df4a816e604139b951cf53c2b65707082e66e373Cross Swap280234072023-03-28 21:22:1317 mins ago0x92e14928a9807ec65aeda4480e640d5cf3117230 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae80.817954081623588 AVAX0.016763775 25
0x2c60ef875a4d8f13587b0c5262b68d85d77aef3900df986d5ba0bf670f6a0803Cross Swap280233632023-03-28 21:20:3518 mins ago0x7709c756fb66e7f61bc1c852cd9b70ba1d535aea IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae87.737030171468099 AVAX0.016833775 25
0x77d1bcc1f08ec4695132110eb4b853c36cef9c267bc3042dee16952282325ffaCross Swap280233562023-03-28 21:20:2119 mins ago0xf819b28463532322fcbdfb3da089ef3d81b5e92e IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae85.099365083519693 AVAX0.016834075 25
0xc5169c78e1e8163c137f811beb04cd7a9d9ec86537190cd7dfd2957e3940a7b7Cross Swap280232562023-03-28 21:16:5522 mins ago0x351ae4860d1f75abfd771eaa4ab28d4d550dcbc9 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae86.439942536314733 AVAX0.016834075 25
0x6f97b85aa9abb6fd7b52a4fdc3052a15b6fdd2561e8a59bfda749360790108f9Cross Swap280231892023-03-28 21:14:3524 mins ago0x8e2087e955c90440594aabcb79528d3d16ca0a9f IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae836.244730171468101 AVAX0.016834675 25
0x421fef57eec48f59a9b7a9b8def3b6d7f96d5226b14bdd59ea94dadc22a145a7Cross Swap280231812023-03-28 21:14:1625 mins ago0x7489537d221fbeeb9993ade6097a28ef3b2bab3d IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae830.012682663824282 AVAX0.01705095 25
0x9c3a8f22e2021373a7c3e0f07c93a84d5b8eb0d7435c08345baafadd312e62d4Cross Swap280227142023-03-28 20:58:2241 mins ago0x8b542a8d8439b17928c42f47fa8a1124634214f7 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae84.544730171468099 AVAX0.016833475 25
0xd2592076256084d51823f0822507bd6ecdb767050653ea3d38dccb7c9e770587Cross Swap280225512023-03-28 20:52:4246 mins ago0xe2ad82582a06c9a13919d70437280fe1abb08936 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae82.127921135628761 AVAX0.016834075 25
0x72a2e4d25f46189273bb00a5a8b7ced9529c1e32e4440c02a627c96d475154c4Cross Swap280225232023-03-28 20:51:4347 mins ago0x6d6f58415810e96a17022c437f54fafd57b329ce IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae81.055306357449177 AVAX0.016882875 25
0x260b4bc24d8587813fd960b84a44947eedf059df837d91bb57d57b33efbef39eCross Swap280224572023-03-28 20:49:2849 mins ago0x5af6355bd9f2b1edfbb39bd82a97d83697d29846 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae80.344730171468099 AVAX0.016833775 25
0x8121707c0e925149dd5f7243d5608c614fa9ed9d8f98d7a222dd46f0cec9d2bbCross Swap280224452023-03-28 20:49:0450 mins ago0x70b9aa54c5fcd4e01d225bc763b46b382c98b8d6 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae82.344730171468098 AVAX0.016834075 25
0xa8d19eac5181d6d435e8e62735d335105810eb009ad71bb0cb6bc7ec91f43580Cross Swap280223502023-03-28 20:45:4253 mins ago0xe2ad82582a06c9a13919d70437280fe1abb08936 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae82.363059232561038 AVAX0.01705255 25
0xf79b0d109e69701806cf076e10d726be6a6f6231f0e34d684802f4c971c2dcddCross Swap280223202023-03-28 20:44:3954 mins ago0x530fbb3abbce46f7f100db810ec8c68acec629d7 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae81.444730171468098 AVAX0.016833775 25
0x7d810263dbef4611535829c5191eaee5eba2c25fda07bb5e9e4b6de8d649a3afCross Swap280223092023-03-28 20:44:1755 mins ago0x4e2c1349e55ab802e061d747b4525db6d30bf8b6 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae82.644730171468099 AVAX0.016833475 25
0xcbb222ca6638e5e82c39a309e40e5cc39bf79c7d0a181f1cb4dc8d74ceb7e95fCross Swap280222392023-03-28 20:41:5357 mins ago0x259da2fcc317ed3a5ba36049e10e7cd2953b8af6 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae85.044730171468099 AVAX0.016833475 25
0xe11051d3476f66bd6a4d8ffa8107c5a3ca7469f91c2c1031c5ff95e8abca4274Cross Swap280221972023-03-28 20:40:2858 mins ago0x99528d254c182e5c52fbe589c2000923ec6618ae IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae84.064274739072991 AVAX0.016833775 25
0x901d73df3ce602d3edb5951c78696d8e048eeed88f3f26a397261fbfaa94015bCross Swap280221892023-03-28 20:40:1259 mins ago0x10f48ca46128ee6c852f55b7ac02e6913f7a1769 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae84.117559701910138 AVAX0.016833775 25
0x3579533250301b38ac1d4d729617781256a55a40886ec136a1f9f05a8a754d0bCross Swap280221862023-03-28 20:40:0659 mins ago0x667650b25a26169bf507d00b074f4a511a8e60c9 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae84.007338997187771 AVAX0.016833775 25
0x5c61a34b5de214cc18896b72cc6e2fb4a8932ff7b6d489788585c7e079d59ac9Cross Swap280221852023-03-28 20:40:0359 mins ago0x7693c242fb8898254be1ef5f64b15ca844deacf2 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae811.451832921144098 AVAX0.016834375 25
0x95047a764592ea0580ffd9d6d2a76357e7b0beb33764dcc4adf0d4c5ffe48631Cross Swap280221822023-03-28 20:39:5859 mins ago0x6a4b752356cbdef61acd603b12afb0596e42fde9 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae82.020931691360358 AVAX0.016763775 25
0xd2ea9656dcfec42bb003f38715560be01bfc642c1efb3b09cad5a0e94c8a9dcdCross Swap280221792023-03-28 20:39:5259 mins ago0xaf28708e01fefe4eb7cf4654425d74a4ec2f7803 IN  0x51af494f1b4d3f77835951fa827d66fc4a18dae84.126451338943506 AVAX0.016834075 25
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x1569190efc05b3078d5c7255dae21b8b8a12cb140bec0a03369f83481d61779b280236852023-03-28 21:32:107 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.04473017146809904 AVAX
0x1569190efc05b3078d5c7255dae21b8b8a12cb140bec0a03369f83481d61779b280236852023-03-28 21:32:107 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Wrapped AVAX1.236058149942599993 AVAX
0x20f5ac86e59625d283971675d695af7b00744510691da8cb94737ab56d6c5148280236832023-03-28 21:32:067 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.04473017146809904 AVAX
0x20f5ac86e59625d283971675d695af7b00744510691da8cb94737ab56d6c5148280236832023-03-28 21:32:067 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Wrapped AVAX0.0148768993007 AVAX
0x03862b09b8894cd74a5e3260a13157b959fc3c8b2c0285d176cd91fab2e6ad52280235412023-03-28 21:27:0212 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.04473017146809904 AVAX
0x03862b09b8894cd74a5e3260a13157b959fc3c8b2c0285d176cd91fab2e6ad52280235412023-03-28 21:27:0212 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Wrapped AVAX2.600000000000000089 AVAX
0x9ea2732770e3f632c03b0eddee3a8628c645c521b15b6e666a4bb88e6d22bc2b280234532023-03-28 21:23:4915 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.04473017146809904 AVAX
0x9ea2732770e3f632c03b0eddee3a8628c645c521b15b6e666a4bb88e6d22bc2b280234532023-03-28 21:23:4915 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Wrapped AVAX3.970000000000000195 AVAX
0x9de2a5eb2041002bee53fa52df4a816e604139b951cf53c2b65707082e66e373280234072023-03-28 21:22:1317 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.04473017146809904 AVAX
0x9de2a5eb2041002bee53fa52df4a816e604139b951cf53c2b65707082e66e373280234072023-03-28 21:22:1317 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Wrapped AVAX0.77322391015548908 AVAX
0x2c60ef875a4d8f13587b0c5262b68d85d77aef3900df986d5ba0bf670f6a0803280233632023-03-28 21:20:3518 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.04473017146809904 AVAX
0x2c60ef875a4d8f13587b0c5262b68d85d77aef3900df986d5ba0bf670f6a0803280233632023-03-28 21:20:3518 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Wrapped AVAX7.69230000000000036 AVAX
0x77d1bcc1f08ec4695132110eb4b853c36cef9c267bc3042dee16952282325ffa280233562023-03-28 21:20:2119 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.04473017146809904 AVAX
0x77d1bcc1f08ec4695132110eb4b853c36cef9c267bc3042dee16952282325ffa280233562023-03-28 21:20:2119 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Wrapped AVAX5.05463491205159432 AVAX
0xc5169c78e1e8163c137f811beb04cd7a9d9ec86537190cd7dfd2957e3940a7b7280232562023-03-28 21:16:5522 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.04473017146809904 AVAX
0xc5169c78e1e8163c137f811beb04cd7a9d9ec86537190cd7dfd2957e3940a7b7280232562023-03-28 21:16:5522 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Wrapped AVAX6.395212364846634578 AVAX
0x6f97b85aa9abb6fd7b52a4fdc3052a15b6fdd2561e8a59bfda749360790108f9280231892023-03-28 21:14:3524 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.04473017146809904 AVAX
0x6f97b85aa9abb6fd7b52a4fdc3052a15b6fdd2561e8a59bfda749360790108f9280231892023-03-28 21:14:3524 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Wrapped AVAX36.200000000000002842 AVAX
0x421fef57eec48f59a9b7a9b8def3b6d7f96d5226b14bdd59ea94dadc22a145a7280231812023-03-28 21:14:1625 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.012682663824282815 AVAX
0x421fef57eec48f59a9b7a9b8def3b6d7f96d5226b14bdd59ea94dadc22a145a7280231812023-03-28 21:14:1625 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Wrapped AVAX30 AVAX
0x9c3a8f22e2021373a7c3e0f07c93a84d5b8eb0d7435c08345baafadd312e62d4280227142023-03-28 20:58:2241 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.04473017146809904 AVAX
0x9c3a8f22e2021373a7c3e0f07c93a84d5b8eb0d7435c08345baafadd312e62d4280227142023-03-28 20:58:2241 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Wrapped AVAX4.5 AVAX
0xd2592076256084d51823f0822507bd6ecdb767050653ea3d38dccb7c9e770587280225512023-03-28 20:52:4246 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.04473017146809904 AVAX
0xd2592076256084d51823f0822507bd6ecdb767050653ea3d38dccb7c9e770587280225512023-03-28 20:52:4246 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Wrapped AVAX2.083190964160662517 AVAX
0x72a2e4d25f46189273bb00a5a8b7ced9529c1e32e4440c02a627c96d475154c4280225232023-03-28 20:51:4347 mins ago 0x51af494f1b4d3f77835951fa827d66fc4a18dae8 Stargate Finance: Router0.055306357449177196 AVAX
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
WooCrossChainRouterV2

Compiler Version
v0.8.14+commit.80d49f37

Optimization Enabled:
Yes with 20000 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 17 : WooCrossChainRouterV2.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.14;

// OpenZeppelin Contracts
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {ICommonOFT, IOFTWithFee} from "@layerzerolabs/solidity-examples/contracts/token/oft/v2/fee/IOFTWithFee.sol";

// Local Contracts
import {IWETH} from "./interfaces/IWETH.sol";
import {IWooCrossChainRouterV2} from "./interfaces/IWooCrossChainRouterV2.sol";
import {IWooRouterV2} from "./interfaces/IWooRouterV2.sol";
import {IStargateEthVault} from "./interfaces/Stargate/IStargateEthVault.sol";
import {IStargateRouter} from "./interfaces/Stargate/IStargateRouter.sol";
import {ILzApp} from "./interfaces/LayerZero/ILzApp.sol";

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

/// @title WOOFi cross chain router implementation.
/// @notice Router for stateless execution of cross chain swap against WOOFi private pool.
/// @custom:stargate-contracts https://stargateprotocol.gitbook.io/stargate/developers/contract-addresses/mainnet
contract WooCrossChainRouterV2 is IWooCrossChainRouterV2, Ownable, ReentrancyGuard {
    using EnumerableSet for EnumerableSet.AddressSet;

    /* ----- Constants ----- */

    address public constant ETH_PLACEHOLDER_ADDR = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

    /* ----- Variables ----- */

    IWooRouterV2 public wooRouter;
    IStargateRouter public stargateRouter;

    address public immutable weth;
    uint256 public bridgeSlippage; // 1 in 10000th: default 1%
    uint256 public dstGasForSwapCall;
    uint256 public dstGasForNoSwapCall;

    uint16 public sgChainIdLocal; // Stargate chainId on local chain

    mapping(uint16 => address) public wooCrossChainRouters; // chainId => WooCrossChainRouter address
    mapping(uint16 => address) public sgETHs; // chainId => SGETH token address
    mapping(uint16 => mapping(address => uint256)) public sgPoolIds; // chainId => token address => Stargate poolId

    mapping(address => address) public tokenToOFTs; // token address(sgChainIdLocal) => OFT address

    EnumerableSet.AddressSet private directBridgeTokens;

    receive() external payable {}

    constructor(
        address _weth,
        address _wooRouter,
        address _stargateRouter,
        uint16 _sgChainIdLocal
    ) {
        wooRouter = IWooRouterV2(_wooRouter);
        stargateRouter = IStargateRouter(_stargateRouter);

        weth = _weth;
        bridgeSlippage = 100;
        dstGasForSwapCall = 360000;
        dstGasForNoSwapCall = 80000;

        sgChainIdLocal = _sgChainIdLocal;

        _initSgETHs();
        _initSgPoolIds();
        _initTokenToOFTs(_sgChainIdLocal);
    }

    /* ----- Functions ----- */

    function crossSwap(
        uint256 refId,
        address payable to,
        SrcInfos memory srcInfos,
        DstInfos memory dstInfos
    ) external payable nonReentrant {
        require(srcInfos.fromToken != address(0), "WooCrossChainRouterV2: !srcInfos.fromToken");
        require(
            dstInfos.toToken != address(0) && dstInfos.toToken != sgETHs[dstInfos.chainId],
            "WooCrossChainRouterV2: !dstInfos.toToken"
        );
        require(to != address(0), "WooCrossChainRouterV2: !to");

        uint256 msgValue = msg.value;
        uint256 bridgeAmount;

        {
            // Step 1: transfer
            if (srcInfos.fromToken == ETH_PLACEHOLDER_ADDR) {
                require(srcInfos.fromAmount <= msgValue, "WooCrossChainRouterV2: !srcInfos.fromAmount");
                srcInfos.fromToken = weth;
                IWETH(weth).deposit{value: srcInfos.fromAmount}();
                msgValue -= srcInfos.fromAmount;
            } else {
                TransferHelper.safeTransferFrom(srcInfos.fromToken, msg.sender, address(this), srcInfos.fromAmount);
            }

            // Step 2: local swap by WooRouter or not
            // 1.WOO is directBridgeToken, path(always) WOO(Arbitrum) => WOO(BSC)
            // 2.WOO not the directBridgeToken, path(maybe): WOO(Arbitrum) -> USDC(Arbitrum) => BUSD(BSC) -> WOO(BSC)
            // 3.Ethereum no WOOFi liquidity, tokens(WOO, ETH, USDC) always will be bridged directly without swap
            if (!directBridgeTokens.contains(srcInfos.fromToken) && srcInfos.fromToken != srcInfos.bridgeToken) {
                TransferHelper.safeApprove(srcInfos.fromToken, address(wooRouter), srcInfos.fromAmount);
                bridgeAmount = wooRouter.swap(
                    srcInfos.fromToken,
                    srcInfos.bridgeToken,
                    srcInfos.fromAmount,
                    srcInfos.minBridgeAmount,
                    payable(address(this)),
                    to
                );
            } else {
                require(
                    srcInfos.fromAmount == srcInfos.minBridgeAmount,
                    "WooCrossChainRouterV2: !srcInfos.minBridgeAmount"
                );
                bridgeAmount = srcInfos.fromAmount;
            }

            require(
                bridgeAmount <= IERC20(srcInfos.bridgeToken).balanceOf(address(this)),
                "WooCrossChainRouterV2: !bridgeAmount"
            );
        }

        // Step 3: cross chain swap by [OFT / StargateRouter]
        address oft = tokenToOFTs[srcInfos.bridgeToken];
        if (oft != address(0)) {
            _bridgeByOFT(refId, to, msgValue, bridgeAmount, IOFTWithFee(oft), srcInfos, dstInfos);
        } else {
            _bridgeByStargate(refId, to, msgValue, bridgeAmount, srcInfos, dstInfos);
        }

        emit WooCrossSwapOnSrcChain(
            refId,
            _msgSender(),
            to,
            srcInfos.fromToken,
            srcInfos.fromAmount,
            srcInfos.minBridgeAmount,
            bridgeAmount
        );
    }

    function onOFTReceived(
        uint16 srcChainId,
        bytes memory, // srcAddress
        uint64, // nonce
        bytes32 from,
        uint256 amountLD,
        bytes memory payload
    ) external {
        require(_isLegitOFT(_msgSender()), "WooCrossChainRouterV2: INVALID_CALLER");
        require(
            wooCrossChainRouters[srcChainId] == address(uint160(uint256(from))),
            "WooCrossChainRouterV2: INVALID_FROM"
        );

        // _msgSender() should be OFT address if requires above are passed
        address bridgedToken = IOFTWithFee(_msgSender()).token();

        // make sure the same order to abi.encode when decode payload
        (uint256 refId, address to, address toToken, uint256 minToAmount) = abi.decode(
            payload,
            (uint256, address, address, uint256)
        );

        _handleERC20Received(refId, to, toToken, bridgedToken, amountLD, minToAmount);
    }

    function sgReceive(
        uint16, // srcChainId
        bytes memory, // srcAddress
        uint256, // nonce
        address bridgedToken,
        uint256 amountLD,
        bytes memory payload
    ) external {
        require(msg.sender == address(stargateRouter), "WooCrossChainRouterV2: INVALID_CALLER");

        // make sure the same order to abi.encode when decode payload
        (uint256 refId, address to, address toToken, uint256 minToAmount) = abi.decode(
            payload,
            (uint256, address, address, uint256)
        );

        // toToken won't be SGETH, and bridgedToken won't be ETH_PLACEHOLDER_ADDR
        if (bridgedToken == sgETHs[sgChainIdLocal]) {
            // bridgedToken is SGETH, received native token
            _handleNativeReceived(refId, to, toToken, amountLD, minToAmount);
        } else {
            // bridgedToken is not SGETH, received ERC20 token
            _handleERC20Received(refId, to, toToken, bridgedToken, amountLD, minToAmount);
        }
    }

    function quoteLayerZeroFee(
        uint256 refId,
        address to,
        SrcInfos memory srcInfos,
        DstInfos memory dstInfos
    ) external view returns (uint256, uint256) {
        bytes memory payload = abi.encode(refId, to, dstInfos.toToken, dstInfos.minToAmount);

        address oft = tokenToOFTs[srcInfos.bridgeToken];
        if (oft != address(0)) {
            // bridge via OFT if it's OFT
            uint256 dstGasForCall = _getDstGasForCall(dstInfos);
            bytes memory adapterParams = _getAdapterParams(to, oft, dstGasForCall, dstInfos);

            bool useZro = false;
            bytes32 dstWooCrossChainRouter = bytes32(uint256(uint160(wooCrossChainRouters[dstInfos.chainId])));

            return
                IOFTWithFee(oft).estimateSendAndCallFee(
                    dstInfos.chainId,
                    dstWooCrossChainRouter,
                    srcInfos.minBridgeAmount,
                    payload,
                    uint64(dstGasForCall),
                    useZro,
                    adapterParams
                );
        } else {
            // otherwise bridge via Stargate
            IStargateRouter.lzTxObj memory obj = _getLzTxObj(to, dstInfos);

            return
                stargateRouter.quoteLayerZeroFee(
                    dstInfos.chainId,
                    1, // https://stargateprotocol.gitbook.io/stargate/developers/function-types
                    obj.dstNativeAddr,
                    payload,
                    obj
                );
        }
    }

    function allDirectBridgeTokens() external view returns (address[] memory) {
        uint256 length = directBridgeTokens.length();
        address[] memory tokens = new address[](length);
        unchecked {
            for (uint256 i = 0; i < length; ++i) {
                tokens[i] = directBridgeTokens.at(i);
            }
        }
        return tokens;
    }

    function allDirectBridgeTokensLength() external view returns (uint256) {
        return directBridgeTokens.length();
    }

    function _initSgETHs() internal {
        // Ethereum
        sgETHs[101] = 0x72E2F4830b9E45d52F80aC08CB2bEC0FeF72eD9c;
        // Arbitrum
        sgETHs[110] = 0x82CbeCF39bEe528B5476FE6d1550af59a9dB6Fc0;
        // Optimism
        sgETHs[111] = 0xb69c8CBCD90A39D8D3d3ccf0a3E968511C3856A0;
    }

    function _initSgPoolIds() internal {
        // poolId > 0 means able to be bridge token
        // Ethereum
        sgPoolIds[101][0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48] = 1; // USDC
        sgPoolIds[101][0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2] = 13; // WETH
        sgPoolIds[101][0x4691937a7508860F876c9c0a2a617E7d9E945D4B] = 20; // WOO
        // BNB Chain
        sgPoolIds[102][0x55d398326f99059fF775485246999027B3197955] = 2; // USDT
        sgPoolIds[102][0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56] = 5; // BUSD
        sgPoolIds[102][0x4691937a7508860F876c9c0a2a617E7d9E945D4B] = 20; // WOO
        // Avalanche
        sgPoolIds[106][0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E] = 1; // USDC
        sgPoolIds[106][0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7] = 2; // USDT
        sgPoolIds[106][0xaBC9547B534519fF73921b1FBA6E672b5f58D083] = 20; // WOO
        // Polygon
        sgPoolIds[109][0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174] = 1; // USDC
        sgPoolIds[109][0xc2132D05D31c914a87C6611C10748AEb04B58e8F] = 2; // USDT
        sgPoolIds[109][0x1B815d120B3eF02039Ee11dC2d33DE7aA4a8C603] = 20; // WOO
        // Arbitrum
        sgPoolIds[110][0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8] = 1; // USDC
        sgPoolIds[110][0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9] = 2; // USDT
        sgPoolIds[110][0x82aF49447D8a07e3bd95BD0d56f35241523fBab1] = 13; // WETH
        sgPoolIds[110][0xcAFcD85D8ca7Ad1e1C6F82F651fA15E33AEfD07b] = 20; // WOO
        // Optimism
        sgPoolIds[111][0x7F5c764cBc14f9669B88837ca1490cCa17c31607] = 1; // USDC
        sgPoolIds[111][0x4200000000000000000000000000000000000006] = 13; // WETH
        sgPoolIds[111][0x871f2F2ff935FD1eD867842FF2a7bfD051A5E527] = 20; // WOO
        // Fantom
        sgPoolIds[112][0x04068DA6C83AFCFA0e13ba15A6696662335D5B75] = 1; // USDC
        sgPoolIds[112][0x6626c47c00F1D87902fc13EECfaC3ed06D5E8D8a] = 20; // WOO
    }

    function _initTokenToOFTs(uint16 _sgChainIdLocal) internal {
        address btcbOFT = 0x2297aEbD383787A160DD0d9F71508148769342E3; // BTCbOFT && BTCbProxyOFT

        if (_sgChainIdLocal == 106) {
            // BTC.b(ERC20) on Avalanche address
            tokenToOFTs[0x152b9d0FdC40C096757F570A51E494bd4b943E50] = btcbOFT;
        }
        tokenToOFTs[btcbOFT] = btcbOFT;
    }

    function _getDstGasForCall(DstInfos memory dstInfos) internal view returns (uint256) {
        return (dstInfos.toToken == dstInfos.bridgeToken) ? dstGasForNoSwapCall : dstGasForSwapCall;
    }

    function _getAdapterParams(
        address to,
        address oft,
        uint256 dstGasForCall,
        DstInfos memory dstInfos
    ) internal view returns (bytes memory) {
        // OFT src logic: require(providedGasLimit >= minGasLimit)
        // uint256 minGasLimit = minDstGasLookup[_dstChainId][_type] + dstGasForCall;
        // _type: 0(send), 1(send_and_call)
        uint256 providedGasLimit = ILzApp(oft).minDstGasLookup(dstInfos.chainId, 1) + dstGasForCall;

        // https://layerzero.gitbook.io/docs/evm-guides/advanced/relayer-adapter-parameters#airdrop
        return
            abi.encodePacked(
                uint16(2), // version: 2 is able to airdrop native token on destination but 1 is not
                providedGasLimit, // gasAmount: destination transaction gas for LayerZero to delivers
                dstInfos.airdropNativeAmount, // nativeForDst: airdrop native token amount
                to // addressOnDst: address to receive airdrop native token on destination
            );
    }

    function _getLzTxObj(address to, DstInfos memory dstInfos) internal view returns (IStargateRouter.lzTxObj memory) {
        uint256 dstGasForCall = _getDstGasForCall(dstInfos);

        return IStargateRouter.lzTxObj(dstGasForCall, dstInfos.airdropNativeAmount, abi.encodePacked(to));
    }

    function _isLegitOFT(address caller) internal view returns (bool) {
        return tokenToOFTs[caller] != address(0);
    }

    function _bridgeByOFT(
        uint256 refId,
        address payable to,
        uint256 msgValue,
        uint256 bridgeAmount,
        IOFTWithFee oft,
        SrcInfos memory srcInfos,
        DstInfos memory dstInfos
    ) internal {
        {
            address token = oft.token();
            require(token == srcInfos.bridgeToken, "WooCrossChainRouterV2: !token");
            if (token != address(oft)) {
                // oft.token() != address(oft) means is a ProxyOFT
                // for example: BTC.b on Avalanche is ERC20, need BTCbProxyOFT to lock up BTC.b
                TransferHelper.safeApprove(srcInfos.bridgeToken, address(oft), bridgeAmount);
            }
        }

        // OFT src logic: require(_removeDust(bridgeAmount) >= minAmount)
        uint256 minAmount = (bridgeAmount * (10000 - bridgeSlippage)) / 10000;

        bytes memory payload = abi.encode(refId, to, dstInfos.toToken, dstInfos.minToAmount);

        uint256 dstGasForCall = _getDstGasForCall(dstInfos);
        ICommonOFT.LzCallParams memory callParams;
        {
            bytes memory adapterParams = _getAdapterParams(to, address(oft), dstGasForCall, dstInfos);
            callParams = ICommonOFT.LzCallParams(
                payable(msg.sender), // refundAddress
                address(0), // zroPaymentAddress
                adapterParams //adapterParams
            );
        }

        bytes32 dstWooCrossChainRouter = bytes32(uint256(uint160(wooCrossChainRouters[dstInfos.chainId])));

        oft.sendAndCall{value: msgValue}(
            address(this),
            dstInfos.chainId,
            dstWooCrossChainRouter,
            bridgeAmount,
            minAmount,
            payload,
            uint64(dstGasForCall),
            callParams
        );
    }

    function _bridgeByStargate(
        uint256 refId,
        address payable to,
        uint256 msgValue,
        uint256 bridgeAmount,
        SrcInfos memory srcInfos,
        DstInfos memory dstInfos
    ) internal {
        uint256 srcPoolId = sgPoolIds[sgChainIdLocal][srcInfos.bridgeToken];
        require(srcPoolId > 0, "WooCrossChainRouterV2: !srcInfos.bridgeToken");

        uint256 dstPoolId = sgPoolIds[dstInfos.chainId][dstInfos.bridgeToken];
        require(dstPoolId > 0, "WooCrossChainRouterV2: !dstInfos.bridgeToken");

        bytes memory payload = abi.encode(refId, to, dstInfos.toToken, dstInfos.minToAmount);

        uint256 dstMinBridgeAmount = (bridgeAmount * (10000 - bridgeSlippage)) / 10000;
        bytes memory dstWooCrossChainRouter = abi.encodePacked(wooCrossChainRouters[dstInfos.chainId]);

        IStargateRouter.lzTxObj memory obj = _getLzTxObj(to, dstInfos);

        if (srcInfos.bridgeToken == weth) {
            IWETH(weth).withdraw(bridgeAmount);
            address sgETH = sgETHs[sgChainIdLocal];
            IStargateEthVault(sgETH).deposit{value: bridgeAmount}(); // logic from Stargate RouterETH.sol
            TransferHelper.safeApprove(sgETH, address(stargateRouter), bridgeAmount);
        } else {
            TransferHelper.safeApprove(srcInfos.bridgeToken, address(stargateRouter), bridgeAmount);
        }

        stargateRouter.swap{value: msgValue}(
            dstInfos.chainId, // dst chain id
            srcPoolId, // bridge token's pool id on src chain
            dstPoolId, // bridge token's pool id on dst chain
            payable(_msgSender()), // rebate address
            bridgeAmount, // swap amount on src chain
            dstMinBridgeAmount, // min received amount on dst chain
            obj, // config: dstGasForCall, dstAirdropNativeAmount, dstReceiveAirdropNativeTokenAddr
            dstWooCrossChainRouter, // smart contract to call on dst chain
            payload // payload to piggyback
        );
    }

    function _handleNativeReceived(
        uint256 refId,
        address to,
        address toToken,
        uint256 bridgedAmount,
        uint256 minToAmount
    ) internal {
        address msgSender = _msgSender();

        if (toToken == ETH_PLACEHOLDER_ADDR) {
            TransferHelper.safeTransferETH(to, bridgedAmount);
            emit WooCrossSwapOnDstChain(
                refId,
                msgSender,
                to,
                weth,
                bridgedAmount,
                toToken,
                ETH_PLACEHOLDER_ADDR,
                minToAmount,
                bridgedAmount
            );
        } else {
            try
                wooRouter.swap{value: bridgedAmount}(
                    ETH_PLACEHOLDER_ADDR,
                    toToken,
                    bridgedAmount,
                    minToAmount,
                    payable(to),
                    to
                )
            returns (uint256 realToAmount) {
                emit WooCrossSwapOnDstChain(
                    refId,
                    msgSender,
                    to,
                    weth,
                    bridgedAmount,
                    toToken,
                    toToken,
                    minToAmount,
                    realToAmount
                );
            } catch {
                TransferHelper.safeTransferETH(to, bridgedAmount);
                emit WooCrossSwapOnDstChain(
                    refId,
                    msgSender,
                    to,
                    weth,
                    bridgedAmount,
                    toToken,
                    ETH_PLACEHOLDER_ADDR,
                    minToAmount,
                    bridgedAmount
                );
            }
        }
    }

    function _handleERC20Received(
        uint256 refId,
        address to,
        address toToken,
        address bridgedToken,
        uint256 bridgedAmount,
        uint256 minToAmount
    ) internal {
        address msgSender = _msgSender();

        if (toToken == bridgedToken) {
            TransferHelper.safeTransfer(bridgedToken, to, bridgedAmount);
            emit WooCrossSwapOnDstChain(
                refId,
                msgSender,
                to,
                bridgedToken,
                bridgedAmount,
                toToken,
                toToken,
                minToAmount,
                bridgedAmount
            );
        } else {
            TransferHelper.safeApprove(bridgedToken, address(wooRouter), bridgedAmount);
            try wooRouter.swap(bridgedToken, toToken, bridgedAmount, minToAmount, payable(to), to) returns (
                uint256 realToAmount
            ) {
                emit WooCrossSwapOnDstChain(
                    refId,
                    msgSender,
                    to,
                    bridgedToken,
                    bridgedAmount,
                    toToken,
                    toToken,
                    minToAmount,
                    realToAmount
                );
            } catch {
                TransferHelper.safeTransfer(bridgedToken, to, bridgedAmount);
                emit WooCrossSwapOnDstChain(
                    refId,
                    msgSender,
                    to,
                    bridgedToken,
                    bridgedAmount,
                    toToken,
                    bridgedToken,
                    minToAmount,
                    bridgedAmount
                );
            }
        }
    }

    /* ----- Owner & Admin Functions ----- */

    function setWooRouter(address _wooRouter) external onlyOwner {
        require(_wooRouter != address(0), "WooCrossChainRouterV2: !_wooRouter");
        wooRouter = IWooRouterV2(_wooRouter);
    }

    function setStargateRouter(address _stargateRouter) external onlyOwner {
        require(_stargateRouter != address(0), "WooCrossChainRouterV2: !_stargateRouter");
        stargateRouter = IStargateRouter(_stargateRouter);
    }

    function setBridgeSlippage(uint256 _bridgeSlippage) external onlyOwner {
        require(_bridgeSlippage <= 10000, "WooCrossChainRouterV2: !_bridgeSlippage");
        bridgeSlippage = _bridgeSlippage;
    }

    function setDstGasForSwapCall(uint256 _dstGasForSwapCall) external onlyOwner {
        dstGasForSwapCall = _dstGasForSwapCall;
    }

    function setDstGasForNoSwapCall(uint256 _dstGasForNoSwapCall) external onlyOwner {
        dstGasForNoSwapCall = _dstGasForNoSwapCall;
    }

    function setSgChainIdLocal(uint16 _sgChainIdLocal) external onlyOwner {
        sgChainIdLocal = _sgChainIdLocal;
    }

    function setWooCrossChainRouter(uint16 chainId, address wooCrossChainRouter) external onlyOwner {
        require(wooCrossChainRouter != address(0), "WooCrossChainRouterV2: !wooCrossChainRouter");
        wooCrossChainRouters[chainId] = wooCrossChainRouter;
    }

    function setSgETH(uint16 chainId, address token) external onlyOwner {
        require(token != address(0), "WooCrossChainRouterV2: !token");
        sgETHs[chainId] = token;
    }

    function setSgPoolId(
        uint16 chainId,
        address token,
        uint256 poolId
    ) external onlyOwner {
        sgPoolIds[chainId][token] = poolId;
    }

    function setTokenToOFT(address token, address oft) external onlyOwner {
        tokenToOFTs[token] = oft;
    }

    function addDirectBridgeToken(address token) external onlyOwner {
        bool success = directBridgeTokens.add(token);
        require(success, "WooCrossChainRouterV2: token exist");
    }

    function removeDirectBridgeToken(address token) external onlyOwner {
        bool success = directBridgeTokens.remove(token);
        require(success, "WooCrossChainRouterV2: token not exist");
    }

    function inCaseTokenGotStuck(address stuckToken) external onlyOwner {
        if (stuckToken == ETH_PLACEHOLDER_ADDR) {
            TransferHelper.safeTransferETH(msg.sender, address(this).balance);
        } else {
            uint256 amount = IERC20(stuckToken).balanceOf(address(this));
            TransferHelper.safeTransfer(stuckToken, msg.sender, amount);
        }
    }
}

File 2 of 17 : IWooCrossChainRouterV2.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.14;

/*

░██╗░░░░░░░██╗░█████╗░░█████╗░░░░░░░███████╗██╗
░██║░░██╗░░██║██╔══██╗██╔══██╗░░░░░░██╔════╝██║
░╚██╗████╗██╔╝██║░░██║██║░░██║█████╗█████╗░░██║
░░████╔═████║░██║░░██║██║░░██║╚════╝██╔══╝░░██║
░░╚██╔╝░╚██╔╝░╚█████╔╝╚█████╔╝░░░░░░██║░░░░░██║
░░░╚═╝░░░╚═╝░░░╚════╝░░╚════╝░░░░░░░╚═╝░░░░░╚═╝

*
* MIT License
* ===========
*
* Copyright (c) 2020 WooTrade
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/// @title WOOFi cross chain router interface (version 2).
/// @notice functions to interface with WOOFi cross chain swap.
interface IWooCrossChainRouterV2 {
    /* ----- Structs ----- */

    struct SrcInfos {
        address fromToken;
        address bridgeToken;
        uint256 fromAmount;
        uint256 minBridgeAmount;
    }

    struct DstInfos {
        uint16 chainId;
        address toToken;
        address bridgeToken;
        uint256 minToAmount;
        uint256 airdropNativeAmount;
    }

    /* ----- Events ----- */

    event WooCrossSwapOnSrcChain(
        uint256 indexed refId,
        address indexed sender,
        address indexed to,
        address fromToken,
        uint256 fromAmount,
        uint256 minBridgeAmount,
        uint256 realBridgeAmount
    );

    event WooCrossSwapOnDstChain(
        uint256 indexed refId,
        address indexed sender,
        address indexed to,
        address bridgedToken,
        uint256 bridgedAmount,
        address toToken,
        address realToToken,
        uint256 minToAmount,
        uint256 realToAmount
    );

    /* ----- State Variables ----- */

    function weth() external view returns (address);

    function bridgeSlippage() external view returns (uint256);

    function dstGasForSwapCall() external view returns (uint256);

    function dstGasForNoSwapCall() external view returns (uint256);

    function sgChainIdLocal() external view returns (uint16);

    function wooCrossChainRouters(uint16 chainId) external view returns (address wooCrossChainRouter);

    function sgETHs(uint16 chainId) external view returns (address sgETH);

    function sgPoolIds(uint16 chainId, address token) external view returns (uint256 poolId);

    /* ----- Functions ----- */

    function crossSwap(
        uint256 refId,
        address payable to,
        SrcInfos memory srcInfos,
        DstInfos memory dstInfos
    ) external payable;

    function sgReceive(
        uint16 srcChainId,
        bytes memory srcAddress,
        uint256 nonce,
        address bridgedToken,
        uint256 amountLD,
        bytes memory payload
    ) external;

    function quoteLayerZeroFee(
        uint256 refId,
        address to,
        SrcInfos memory srcInfos,
        DstInfos memory dstInfos
    ) external view returns (uint256 nativeAmount, uint256 zroAmount);

    function allDirectBridgeTokens() external view returns (address[] memory tokens);

    function allDirectBridgeTokensLength() external view returns (uint256 length);
}

File 3 of 17 : IWooRouterV2.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.14;

/*

░██╗░░░░░░░██╗░█████╗░░█████╗░░░░░░░███████╗██╗
░██║░░██╗░░██║██╔══██╗██╔══██╗░░░░░░██╔════╝██║
░╚██╗████╗██╔╝██║░░██║██║░░██║█████╗█████╗░░██║
░░████╔═████║░██║░░██║██║░░██║╚════╝██╔══╝░░██║
░░╚██╔╝░╚██╔╝░╚█████╔╝╚█████╔╝░░░░░░██║░░░░░██║
░░░╚═╝░░░╚═╝░░░╚════╝░░╚════╝░░░░░░░╚═╝░░░░░╚═╝

*
* MIT License
* ===========
*
* Copyright (c) 2020 WooTrade
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

import "../interfaces/IWooPPV2.sol";

/// @title Woo router interface (version 2)
/// @notice functions to interface with WooFi swap
interface IWooRouterV2 {
    /* ----- Type declarations ----- */

    enum SwapType {
        WooSwap,
        DodoSwap
    }

    /* ----- Events ----- */

    event WooRouterSwap(
        SwapType swapType,
        address indexed fromToken,
        address indexed toToken,
        uint256 fromAmount,
        uint256 toAmount,
        address from,
        address indexed to,
        address rebateTo
    );

    event WooPoolChanged(address newPool);

    /* ----- Router properties ----- */

    function WETH() external view returns (address);

    function wooPool() external view returns (IWooPPV2);

    /* ----- Main query & swap APIs ----- */

    /// @notice query the amount to swap fromToken -> toToken
    /// @param fromToken the from token
    /// @param toToken the to token
    /// @param fromAmount the amount of fromToken to swap
    /// @return toAmount the predicted amount to receive
    function querySwap(
        address fromToken,
        address toToken,
        uint256 fromAmount
    ) external view returns (uint256 toAmount);

    /// @notice query the amount to swap fromToken -> toToken,
    ///     WITHOUT checking the reserve balance; so it
    ///     always returns the quoted amount (for reference).
    /// @param fromToken the from token
    /// @param toToken the to token
    /// @param fromAmount the amount of fromToken to swap
    /// @return toAmount the predicted amount to receive
    function tryQuerySwap(
        address fromToken,
        address toToken,
        uint256 fromAmount
    ) external view returns (uint256 toAmount);

    /// @notice Swap `fromToken` to `toToken`.
    /// @param fromToken the from token
    /// @param toToken the to token
    /// @param fromAmount the amount of `fromToken` to swap
    /// @param minToAmount the minimum amount of `toToken` to receive
    /// @param to the destination address
    /// @param rebateTo the rebate address (optional, can be 0)
    /// @return realToAmount the amount of toToken to receive
    function swap(
        address fromToken,
        address toToken,
        uint256 fromAmount,
        uint256 minToAmount,
        address payable to,
        address rebateTo
    ) external payable returns (uint256 realToAmount);

    /* ----- 3rd party DEX swap ----- */

    /// @notice swap fromToken -> toToken via an external 3rd swap
    /// @param approveTarget the contract address for token transfer approval
    /// @param swapTarget the contract address for swap
    /// @param fromToken the from token
    /// @param toToken the to token
    /// @param fromAmount the amount of fromToken to swap
    /// @param minToAmount the min amount of swapped toToken
    /// @param to the destination address
    /// @param data call data for external call
    function externalSwap(
        address approveTarget,
        address swapTarget,
        address fromToken,
        address toToken,
        uint256 fromAmount,
        uint256 minToAmount,
        address payable to,
        bytes calldata data
    ) external payable returns (uint256 realToAmount);
}

File 4 of 17 : ILzApp.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @dev Interface of the LzApp that functions not exist in the @layerzerolabs package
 */
interface ILzApp {
    function minDstGasLookup(uint16 _dstChainId, uint16 _type) external view returns (uint256 _minGasLimit);
}

File 5 of 17 : IWETH.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Wrapped ETH.
interface IWETH {
    /// @dev Deposit ETH into WETH
    function deposit() external payable;

    /// @dev Transfer WETH to receiver
    /// @param to address of WETH receiver
    /// @param value amount of WETH to transfer
    /// @return get true when succeed, else false
    function transfer(address to, uint256 value) external returns (bool);

    /// @dev Withdraw WETH to ETH
    function withdraw(uint256) external;
}

File 6 of 17 : TransferHelper.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('approve(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            "TransferHelper::safeApprove: approve failed"
        );
    }

    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transfer(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            "TransferHelper::safeTransfer: transfer failed"
        );
    }

    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            "TransferHelper::transferFrom: transferFrom failed"
        );
    }

    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, "TransferHelper::safeTransferETH: ETH transfer failed");
    }
}

File 7 of 17 : IStargateEthVault.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IStargateEthVault {
    function deposit() external payable;

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

    function withdraw(uint256) external;

    function approve(address guy, uint256 wad) external returns (bool);

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

File 8 of 17 : IStargateRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.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);
}

File 9 of 17 : 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 10 of 17 : 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 11 of 17 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 12 of 17 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 *  Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
 *  See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 *  In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 13 of 17 : IOFTWithFee.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.0;

import "../ICommonOFT.sol";

/**
 * @dev Interface of the IOFT core standard
 */
interface IOFTWithFee is ICommonOFT {

    /**
     * @dev send `_amount` amount of token to (`_dstChainId`, `_toAddress`) from `_from`
     * `_from` the owner of token
     * `_dstChainId` the destination chain identifier
     * `_toAddress` can be any size depending on the `dstChainId`.
     * `_amount` the quantity of tokens in wei
     * `_minAmount` the minimum amount of tokens to receive on dstChain
     * `_refundAddress` the address LayerZero refunds if too much message fee is sent
     * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token)
     * `_adapterParams` is a flexible bytes array to indicate messaging adapter services
     */
    function sendFrom(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, uint _minAmount, LzCallParams calldata _callParams) external payable;

    function sendAndCall(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, uint _minAmount, bytes calldata _payload, uint64 _dstGasForCall, LzCallParams calldata _callParams) external payable;
}

File 14 of 17 : IWooPPV2.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.14;

/*

░██╗░░░░░░░██╗░█████╗░░█████╗░░░░░░░███████╗██╗
░██║░░██╗░░██║██╔══██╗██╔══██╗░░░░░░██╔════╝██║
░╚██╗████╗██╔╝██║░░██║██║░░██║█████╗█████╗░░██║
░░████╔═████║░██║░░██║██║░░██║╚════╝██╔══╝░░██║
░░╚██╔╝░╚██╔╝░╚█████╔╝╚█████╔╝░░░░░░██║░░░░░██║
░░░╚═╝░░░╚═╝░░░╚════╝░░╚════╝░░░░░░░╚═╝░░░░░╚═╝

*
* MIT License
* ===========
*
* Copyright (c) 2020 WooTrade
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/// @title Woo private pool for swap.
/// @notice Use this contract to directly interfact with woo's synthetic proactive
///         marketing making pool.
/// @author woo.network
interface IWooPPV2 {
    /* ----- Events ----- */

    event Deposit(address indexed token, address indexed sender, uint256 amount);
    event Withdraw(address indexed token, address indexed receiver, uint256 amount);
    event Migrate(address indexed token, address indexed receiver, uint256 amount);
    event AdminUpdated(address indexed addr, bool flag);
    event FeeAddrUpdated(address indexed newFeeAddr);
    event WooracleUpdated(address indexed newWooracle);
    event WooSwap(
        address indexed fromToken,
        address indexed toToken,
        uint256 fromAmount,
        uint256 toAmount,
        address from,
        address indexed to,
        address rebateTo,
        uint256 swapVol,
        uint256 swapFee
    );

    /* ----- External Functions ----- */

    /// @notice The quote token address (immutable).
    /// @return address of quote token
    function quoteToken() external view returns (address);

    /// @notice Gets the pool size of the specified token (swap liquidity).
    /// @param token the token address
    /// @return the pool size
    function poolSize(address token) external view returns (uint256);

    /// @notice Query the amount to swap `fromToken` to `toToken`, without checking the pool reserve balance.
    /// @param fromToken the from token
    /// @param toToken the to token
    /// @param fromAmount the amount of `fromToken` to swap
    /// @return toAmount the swapped amount of `toToken`
    function tryQuery(
        address fromToken,
        address toToken,
        uint256 fromAmount
    ) external view returns (uint256 toAmount);

    /// @notice Query the amount to swap `fromToken` to `toToken`, with checking the pool reserve balance.
    /// @dev tx reverts when 'toToken' balance is insufficient.
    /// @param fromToken the from token
    /// @param toToken the to token
    /// @param fromAmount the amount of `fromToken` to swap
    /// @return toAmount the swapped amount of `toToken`
    function query(
        address fromToken,
        address toToken,
        uint256 fromAmount
    ) external view returns (uint256 toAmount);

    /// @notice Swap `fromToken` to `toToken`.
    /// @param fromToken the from token
    /// @param toToken the to token
    /// @param fromAmount the amount of `fromToken` to swap
    /// @param minToAmount the minimum amount of `toToken` to receive
    /// @param to the destination address
    /// @param rebateTo the rebate address (optional, can be address ZERO)
    /// @return realToAmount the amount of toToken to receive
    function swap(
        address fromToken,
        address toToken,
        uint256 fromAmount,
        uint256 minToAmount,
        address to,
        address rebateTo
    ) external returns (uint256 realToAmount);

    /// @notice Deposit the specified token into the liquidity pool of WooPPV2.
    /// @param token the token to deposit
    /// @param amount the deposit amount
    function deposit(address token, uint256 amount) external;
}

File 15 of 17 : 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 16 of 17 : ICommonOFT.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.0;

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/**
 * @dev Interface of the IOFT core standard
 */
interface ICommonOFT is IERC165 {

    struct LzCallParams {
        address payable refundAddress;
        address zroPaymentAddress;
        bytes adapterParams;
    }

    /**
     * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`)
     * _dstChainId - L0 defined chain id to send tokens too
     * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain
     * _amount - amount of the tokens to transfer
     * _useZro - indicates to use zro to pay L0 fees
     * _adapterParam - flexible bytes array to indicate messaging adapter services in L0
     */
    function estimateSendFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee);

    function estimateSendAndCallFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee);

    /**
     * @dev returns the circulating amount of tokens on current chain
     */
    function circulatingSupply() external view returns (uint);

    /**
     * @dev returns the address of the ERC20 token
     */
    function token() external view returns (address);
}

File 17 of 17 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_wooRouter","type":"address"},{"internalType":"address","name":"_stargateRouter","type":"address"},{"internalType":"uint16","name":"_sgChainIdLocal","type":"uint16"}],"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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"refId","type":"uint256"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address","name":"bridgedToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"bridgedAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"toToken","type":"address"},{"indexed":false,"internalType":"address","name":"realToToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"minToAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"realToAmount","type":"uint256"}],"name":"WooCrossSwapOnDstChain","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"refId","type":"uint256"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address","name":"fromToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"fromAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minBridgeAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"realBridgeAmount","type":"uint256"}],"name":"WooCrossSwapOnSrcChain","type":"event"},{"inputs":[],"name":"ETH_PLACEHOLDER_ADDR","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"addDirectBridgeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"allDirectBridgeTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allDirectBridgeTokensLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgeSlippage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"refId","type":"uint256"},{"internalType":"address payable","name":"to","type":"address"},{"components":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"bridgeToken","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"minBridgeAmount","type":"uint256"}],"internalType":"struct IWooCrossChainRouterV2.SrcInfos","name":"srcInfos","type":"tuple"},{"components":[{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"address","name":"bridgeToken","type":"address"},{"internalType":"uint256","name":"minToAmount","type":"uint256"},{"internalType":"uint256","name":"airdropNativeAmount","type":"uint256"}],"internalType":"struct IWooCrossChainRouterV2.DstInfos","name":"dstInfos","type":"tuple"}],"name":"crossSwap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"dstGasForNoSwapCall","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dstGasForSwapCall","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"stuckToken","type":"address"}],"name":"inCaseTokenGotStuck","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint64","name":"","type":"uint64"},{"internalType":"bytes32","name":"from","type":"bytes32"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"onOFTReceived","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"refId","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"components":[{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"bridgeToken","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"minBridgeAmount","type":"uint256"}],"internalType":"struct IWooCrossChainRouterV2.SrcInfos","name":"srcInfos","type":"tuple"},{"components":[{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"address","name":"bridgeToken","type":"address"},{"internalType":"uint256","name":"minToAmount","type":"uint256"},{"internalType":"uint256","name":"airdropNativeAmount","type":"uint256"}],"internalType":"struct IWooCrossChainRouterV2.DstInfos","name":"dstInfos","type":"tuple"}],"name":"quoteLayerZeroFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"removeDirectBridgeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_bridgeSlippage","type":"uint256"}],"name":"setBridgeSlippage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_dstGasForNoSwapCall","type":"uint256"}],"name":"setDstGasForNoSwapCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_dstGasForSwapCall","type":"uint256"}],"name":"setDstGasForSwapCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_sgChainIdLocal","type":"uint16"}],"name":"setSgChainIdLocal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"address","name":"token","type":"address"}],"name":"setSgETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"poolId","type":"uint256"}],"name":"setSgPoolId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stargateRouter","type":"address"}],"name":"setStargateRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"oft","type":"address"}],"name":"setTokenToOFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"address","name":"wooCrossChainRouter","type":"address"}],"name":"setWooCrossChainRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wooRouter","type":"address"}],"name":"setWooRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sgChainIdLocal","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"sgETHs","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"address","name":"","type":"address"}],"name":"sgPoolIds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"bridgedToken","type":"address"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"sgReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stargateRouter","outputs":[{"internalType":"contract IStargateRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenToOFTs","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"wooCrossChainRouters","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wooRouter","outputs":[{"internalType":"contract IWooRouterV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a06040523480156200001157600080fd5b50604051620043d9380380620043d98339810160408190526200003491620005d1565b6200003f33620004bf565b60018055600280546001600160a01b03199081166001600160a01b0386811691909117909255600380549091168483161790558416608052606460045562057e40600555620138806006556007805461ffff191661ffff83161790556200016e60096020527fc8f777898976f233a76ced87b7df382590c7f23fef0a3657bf3a39a3984e7ce580546001600160a01b03199081167372e2f4830b9e45d52f80ac08cb2bec0fef72ed9c179091557fbe6724fa89b83a2d4e572bb9309f266202304968943a10fee0e02aa3e9854fe3805482167382cbecf39bee528b5476fe6d1550af59a9db6fc0179055606f6000527fbf75c57350890dbbd251d6b28295c1dd9382742e601d97cd114cedeae20f8f20805490911673b69c8cbcd90a39d8d3d3ccf0a3e968511c3856a0179055565b620004aa60017ff345b45b5b4e0b94e4f2bdaa68448f5a4fbba442a3acd63e7333768bd1b1a1cc819055600d7fbb7d383c765b8dc484f967a7fab35023470286a720dbb52901994d00ea40c80f81905560147f644640afdd4da8f4704f863fc06bd1a6edd03afd4d20bdb8f07de4ef9a9a6ded81905560027f41e5fb2af4f0cb3078091d425a9f3e1b24206d060bcc67ca52f36dafa91c2c2c81905560057f18859fbad71f96e27d1c4596de4dde8a1641c74df4f448f35bcbe7ad7d5b4201557f366967270ad08dd9475b2fabd768116fbe5b69121e1f23f7f08997fb0460bd308290557fa5fe25a13676c77f07e1b48f4a5a686db194c58ecba48234f0ae736e2337c7e88490557fdf30bc6d747ae1c7bbe5615a1687c851e92410c3e00ff765f1174894068681c18190557f1366c9c152b7aa6fba145c07fd17438482a619d51fbaddfe8f2d750c2b870e9b8290557f8ce055b123932867564314c5addf0a2e812b531ba558671622300c9ac97e861f8490557fe0bf35334bdb04b6492dcf0d9afe9b5afbf04a5ce4bd8804359c446c00ee9bae8190557f7c26d340f1e6b9eeb4c96c8d6a61635bb5be0f9917c890f5c4a8a8c593a28f7d8290557f0b2058b6799eae0cea836f8fd983e3c5b4f74fe2b747b62b40a46f3ba78487a18490557fdc3c050c057ac0a4ddbb5e8653ac0ea0d86ba81868f2e37e4dc7a859af95942b557f0d2f45b4175f3651b2eec261a5a31d7483365cfacba7fc776988fc9c0d4b616c8290557fabb43d7b6a118eaf0c8196e9f94ce5edaa276f86c39c8f27e9a8ca62cf9b16b98190557f677e00ae69ed885781c4beb263f5a282399e13c770b569a57f55c0ddfcbe36f08390557f67bcb1c362de4fd86e6e6ec9460b3e8acd9fc7b1880209eddc44ced00f620921919091557f3c38854b581b209d07d7e502a560d1dc0c6cc9241866eb048abb54bc5227315e8190557ff012de93bfdfec7dea0b6b95c0707fdd7acc736f110695459086bafe461b34b791909155736626c47c00f1d87902fc13eecfac3ed06d5e8d8a6000527fa73d3e217b33ef4b1df748825563898b479692d6a703bd1098306487b274921c6020527fbff0847cc09eac7c830a05730f0c1d294c2b75d0e014caf81182aedcfed8085055565b620004b5816200050f565b5050505062000636565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b732297aebd383787a160dd0d9f71508148769342e361ffff8216606a03620005895773152b9d0fdc40c096757f570a51e494bd4b943e50600052600b6020527fbfd507f77366ff0850751077e337e35f4d03380d142049f1b87a1c846e7a2d3580546001600160a01b0319166001600160a01b0383161790555b6001600160a01b03166000818152600b6020526040902080546001600160a01b031916909117905550565b80516001600160a01b0381168114620005cc57600080fd5b919050565b60008060008060808587031215620005e857600080fd5b620005f385620005b4565b93506200060360208601620005b4565b92506200061360408601620005b4565b9150606085015161ffff811681146200062b57600080fd5b939692955090935050565b608051613d64620006756000396000818161029d0152818161139b015281816120610152818161220301528181612b7f0152612c030152613d646000f3fe60806040526004361061021d5760003560e01c806390dce9481161011d578063bd0085d3116100b0578063e1a4e72a1161007f578063f2fde38b11610064578063f2fde38b146106b9578063fafab104146106d9578063fdeba4e51461071c57600080fd5b8063e1a4e72a14610664578063e9ce79ca1461068457600080fd5b8063bd0085d3146105d8578063c22b74191461061b578063c45dec2714610631578063c6d2e2811461064457600080fd5b8063ab8236f3116100ec578063ab8236f31461054a578063b5997a5b1461056a578063b65dfe8e1461058a578063b88dafcb146105aa57600080fd5b806390dce948146104a55780639a8c88e3146104ba578063a4cd49ba146104da578063a9e56f3c1461051d57600080fd5b8063518a5175116101b05780637c91bc721161017f57806383af55501161016457806383af55501461043c57806388c4cb36146104525780638da5cb5b1461047a57600080fd5b80637c91bc72146103fc5780637fcf35da1461041c57600080fd5b8063518a51751461038f57806351b78b47146103b1578063616d2964146103d1578063715018a6146103e757600080fd5b8063403a01e5116101ec578063403a01e5146102e9578063498f3097146103095780634d8650d71461034f5780634dba39a21461036f57600080fd5b806301d122d614610229578063091a76c61461024b5780630ba22a051461026b5780633fc8cef31461028b57600080fd5b3661022457005b600080fd5b34801561023557600080fd5b506102496102443660046133e1565b610749565b005b34801561025757600080fd5b506102496102663660046133fc565b610786565b34801561027757600080fd5b50610249610286366004613437565b610793565b34801561029757600080fd5b506102bf7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b3480156102f557600080fd5b506102496103043660046133fc565b610826565b34801561031557600080fd5b5061034161032436600461345b565b600a60209081526000928352604080842090915290825290205481565b6040519081526020016102e0565b34801561035b57600080fd5b5061024961036a3660046133fc565b6108ab565b34801561037b57600080fd5b5061024961038a366004613437565b6108b8565b34801561039b57600080fd5b506103a4610990565b6040516102e09190613492565b3480156103bd57600080fd5b506102496103cc366004613437565b610a43565b3480156103dd57600080fd5b5061034160065481565b3480156103f357600080fd5b50610249610b1b565b34801561040857600080fd5b5061024961041736600461345b565b610b2f565b34801561042857600080fd5b506102496104373660046135c6565b610bf3565b34801561044857600080fd5b5061034160045481565b34801561045e57600080fd5b506102bf73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b34801561048657600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166102bf565b3480156104b157600080fd5b50610341610ddc565b3480156104c657600080fd5b506102496104d5366004613666565b610ded565b3480156104e657600080fd5b506102bf6104f53660046133e1565b60096020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b34801561052957600080fd5b506003546102bf9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561055657600080fd5b506102496105653660046136a5565b610e2d565b34801561057657600080fd5b5061024961058536600461345b565b610f40565b34801561059657600080fd5b506102496105a5366004613437565b61102a565b3480156105b657600080fd5b506007546105c59061ffff1681565b60405161ffff90911681526020016102e0565b3480156105e457600080fd5b506102bf6105f33660046133e1565b60086020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b34801561062757600080fd5b5061034160055481565b61024961063f366004613827565b6110b4565b34801561065057600080fd5b5061024961065f366004613879565b611801565b34801561067057600080fd5b5061024961067f366004613437565b61185c565b34801561069057600080fd5b506106a461069f366004613827565b61194c565b604080519283526020830191909152016102e0565b3480156106c557600080fd5b506102496106d4366004613437565b611bb1565b3480156106e557600080fd5b506102bf6106f4366004613437565b600b6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b34801561072857600080fd5b506002546102bf9073ffffffffffffffffffffffffffffffffffffffff1681565b610751611c4b565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661ffff92909216919091179055565b61078e611c4b565b600655565b61079b611c4b565b60006107a8600c83611cb2565b9050806108225760405162461bcd60e51b815260206004820152602660248201527f576f6f43726f7373436861696e526f7574657256323a20746f6b656e206e6f7460448201527f206578697374000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b5050565b61082e611c4b565b6127108111156108a65760405162461bcd60e51b815260206004820152602760248201527f576f6f43726f7373436861696e526f7574657256323a20215f6272696467655360448201527f6c697070616765000000000000000000000000000000000000000000000000006064820152608401610819565b600455565b6108b3611c4b565b600555565b6108c0611c4b565b73ffffffffffffffffffffffffffffffffffffffff81166109495760405162461bcd60e51b815260206004820152602260248201527f576f6f43726f7373436861696e526f7574657256323a20215f776f6f526f757460448201527f65720000000000000000000000000000000000000000000000000000000000006064820152608401610819565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6060600061099e600c611cdd565b905060008167ffffffffffffffff8111156109bb576109bb6134ec565b6040519080825280602002602001820160405280156109e4578160200160208202803683370190505b50905060005b82811015610a3c576109fd600c82611ce7565b828281518110610a0f57610a0f613897565b73ffffffffffffffffffffffffffffffffffffffff909216602092830291909101909101526001016109ea565b5092915050565b610a4b611c4b565b73ffffffffffffffffffffffffffffffffffffffff8116610ad45760405162461bcd60e51b815260206004820152602760248201527f576f6f43726f7373436861696e526f7574657256323a20215f7374617267617460448201527f65526f75746572000000000000000000000000000000000000000000000000006064820152608401610819565b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b610b23611c4b565b610b2d6000611cf3565b565b610b37611c4b565b73ffffffffffffffffffffffffffffffffffffffff8116610b9a5760405162461bcd60e51b815260206004820152601d60248201527f576f6f43726f7373436861696e526f7574657256323a2021746f6b656e0000006044820152606401610819565b61ffff91909116600090815260096020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909216919091179055565b336000908152600b602052604090205473ffffffffffffffffffffffffffffffffffffffff16610c8b5760405162461bcd60e51b815260206004820152602560248201527f576f6f43726f7373436861696e526f7574657256323a20494e56414c49445f4360448201527f414c4c45520000000000000000000000000000000000000000000000000000006064820152608401610819565b61ffff861660009081526008602052604090205473ffffffffffffffffffffffffffffffffffffffff848116911614610d2c5760405162461bcd60e51b815260206004820152602360248201527f576f6f43726f7373436861696e526f7574657256323a20494e56414c49445f4660448201527f524f4d00000000000000000000000000000000000000000000000000000000006064820152608401610819565b60003373ffffffffffffffffffffffffffffffffffffffff1663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9d91906138c6565b905060008060008085806020019051810190610db991906138e3565b9350935093509350610dcf848484888b86611d68565b5050505050505050505050565b6000610de8600c611cdd565b905090565b610df5611c4b565b61ffff9092166000908152600a6020908152604080832073ffffffffffffffffffffffffffffffffffffffff90941683529290522055565b60035473ffffffffffffffffffffffffffffffffffffffff163314610eba5760405162461bcd60e51b815260206004820152602560248201527f576f6f43726f7373436861696e526f7574657256323a20494e56414c49445f4360448201527f414c4c45520000000000000000000000000000000000000000000000000000006064820152608401610819565b60008060008084806020019051810190610ed491906138e3565b60075461ffff166000908152600960205260409020549397509195509350915073ffffffffffffffffffffffffffffffffffffffff90811690881603610f2657610f218484848985612013565b610f34565b610f348484848a8a86611d68565b50505050505050505050565b610f48611c4b565b73ffffffffffffffffffffffffffffffffffffffff8116610fd15760405162461bcd60e51b815260206004820152602b60248201527f576f6f43726f7373436861696e526f7574657256323a2021776f6f43726f737360448201527f436861696e526f757465720000000000000000000000000000000000000000006064820152608401610819565b61ffff91909116600090815260086020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909216919091179055565b611032611c4b565b600061103f600c8361229e565b9050806108225760405162461bcd60e51b815260206004820152602260248201527f576f6f43726f7373436861696e526f7574657256323a20746f6b656e2065786960448201527f73740000000000000000000000000000000000000000000000000000000000006064820152608401610819565b6002600154036111065760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610819565b6002600155815173ffffffffffffffffffffffffffffffffffffffff166111955760405162461bcd60e51b815260206004820152602a60248201527f576f6f43726f7373436861696e526f7574657256323a2021737263496e666f7360448201527f2e66726f6d546f6b656e000000000000000000000000000000000000000000006064820152608401610819565b602081015173ffffffffffffffffffffffffffffffffffffffff16158015906111f25750805161ffff166000908152600960209081526040909120549082015173ffffffffffffffffffffffffffffffffffffffff908116911614155b6112645760405162461bcd60e51b815260206004820152602860248201527f576f6f43726f7373436861696e526f7574657256323a2021647374496e666f7360448201527f2e746f546f6b656e0000000000000000000000000000000000000000000000006064820152608401610819565b73ffffffffffffffffffffffffffffffffffffffff83166112c75760405162461bcd60e51b815260206004820152601a60248201527f576f6f43726f7373436861696e526f7574657256323a2021746f0000000000006044820152606401610819565b8151349060009073ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffff1111111111111111111111111111111111111112016114425781846040015111156113845760405162461bcd60e51b815260206004820152602b60248201527f576f6f43726f7373436861696e526f7574657256323a2021737263496e666f7360448201527f2e66726f6d416d6f756e740000000000000000000000000000000000000000006064820152608401610819565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001680855260408086015181517fd0e30db0000000000000000000000000000000000000000000000000000000008152915163d0e30db09260048082019260009290919082900301818588803b15801561141257600080fd5b505af1158015611426573d6000803e3d6000fd5b505050505083604001518261143b919061395b565b9150611456565b6114568460000151333087604001516122c0565b835161146490600c9061243d565b1580156114a55750836020015173ffffffffffffffffffffffffffffffffffffffff16846000015173ffffffffffffffffffffffffffffffffffffffff1614155b156115a257835160025460408601516114d5929173ffffffffffffffffffffffffffffffffffffffff169061246c565b60025484516020860151604080880151606089015191517f7dc2038200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff948516600482015292841660248401526044830152606482015230608482015287821660a4820152911690637dc203829060c4016020604051808303816000875af1158015611577573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159b9190613972565b9050611626565b836060015184604001511461161f5760405162461bcd60e51b815260206004820152603060248201527f576f6f43726f7373436861696e526f7574657256323a2021737263496e666f7360448201527f2e6d696e427269646765416d6f756e74000000000000000000000000000000006064820152608401610819565b5060408301515b60208401516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611696573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ba9190613972565b81111561172e5760405162461bcd60e51b8152602060048201526024808201527f576f6f43726f7373436861696e526f7574657256323a2021627269646765416d60448201527f6f756e74000000000000000000000000000000000000000000000000000000006064820152608401610819565b60208085015173ffffffffffffffffffffffffffffffffffffffff9081166000908152600b9092526040909120541680156117775761177287878585858a8a6125e8565b611785565b611785878785858989612912565b8451604080870151606080890151835173ffffffffffffffffffffffffffffffffffffffff9586168152602081019390935282840152810185905290519188169133918a917f84f8431fa975655da1378bee00f1e50b540c722eadd17490117d753a896a16119181900360800190a45050600180555050505050565b611809611c4b565b73ffffffffffffffffffffffffffffffffffffffff9182166000908152600b6020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001691909216179055565b611864611c4b565b7fffffffffffffffffffffffff111111111111111111111111111111111111111273ffffffffffffffffffffffffffffffffffffffff8216016118ae576118ab3347612db1565b50565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa15801561191b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193f9190613972565b9050610822823383612ea6565b600080600086868560200151866060015160405160200161199d949392919093845273ffffffffffffffffffffffffffffffffffffffff928316602085015291166040830152606082015260800190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815260208781015173ffffffffffffffffffffffffffffffffffffffff9081166000908152600b90925291902054919250168015611aed576000611a0c8661301b565b90506000611a1c8984848a613068565b875161ffff16600090815260086020526040808220548a5160608d015192517fa4c51df5000000000000000000000000000000000000000000000000000000008152949550929373ffffffffffffffffffffffffffffffffffffffff918216939188169263a4c51df592611a9e92909186918c908b908a908c90600401613a05565b6040805180830381865afa158015611aba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ade9190613a66565b97509750505050505050611ba8565b6000611af9888761319e565b600354875160408084015190517f0a51236900000000000000000000000000000000000000000000000000000000815293945073ffffffffffffffffffffffffffffffffffffffff90921692630a51236992611b6092916001919089908890600401613abb565b6040805180830381865afa158015611b7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ba09190613a66565b945094505050505b94509492505050565b611bb9611c4b565b73ffffffffffffffffffffffffffffffffffffffff8116611c425760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610819565b6118ab81611cf3565b60005473ffffffffffffffffffffffffffffffffffffffff163314610b2d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610819565b6000611cd48373ffffffffffffffffffffffffffffffffffffffff841661325e565b90505b92915050565b6000611cd7825490565b6000611cd48383613351565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b3373ffffffffffffffffffffffffffffffffffffffff80851690861603611e1457611d94848785612ea6565b6040805173ffffffffffffffffffffffffffffffffffffffff86811682526020820186905287811692820183905260608201929092526080810184905260a081018590528188169183169089907f12ec1cd5a97a783f66bac513e496864dd4a0f398d181f887a6bb6df6bb9330fc9060c0015b60405180910390a461200a565b600254611e3990859073ffffffffffffffffffffffffffffffffffffffff168561246c565b6002546040517f7dc2038200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152878116602483015260448201869052606482018590528881166084830181905260a483015290911690637dc203829060c4016020604051808303816000875af1925050508015611f0a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252611f0791810190613972565b60015b611f9257611f19848785612ea6565b6040805173ffffffffffffffffffffffffffffffffffffffff868116808352602083018790528882169383019390935260608201929092526080810184905260a081018590528188169183169089907f12ec1cd5a97a783f66bac513e496864dd4a0f398d181f887a6bb6df6bb9330fc9060c001611e07565b6040805173ffffffffffffffffffffffffffffffffffffffff87811682526020820187905288811682840181905260608301526080820186905260a082018490529151898316928516918b917f12ec1cd5a97a783f66bac513e496864dd4a0f398d181f887a6bb6df6bb9330fc9181900360c00190a4505b50505050505050565b3373ffffffffffffffffffffffffffffffffffffffff84167fffffffffffffffffffffffff11111111111111111111111111111111111111120161210a5761205b8584612db1565b604080517f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff9081168252602082018690528681168284015273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee60608301526080820185905260a0820186905291518783169284169189917f12ec1cd5a97a783f66bac513e496864dd4a0f398d181f887a6bb6df6bb9330fc9181900360c00190a4612296565b6002546040517f7dc2038200000000000000000000000000000000000000000000000000000000815273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee600482015273ffffffffffffffffffffffffffffffffffffffff868116602483015260448201869052606482018590528781166084830181905260a483015290911690637dc2038290859060c40160206040518083038185885af1935050505080156121ef575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526121ec91810190613972565b60015b6121fd5761205b8584612db1565b604080517f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff90811682526020820187905287811682840181905260608301526080820186905260a082018490529151888316928516918a917f12ec1cd5a97a783f66bac513e496864dd4a0f398d181f887a6bb6df6bb9330fc9181900360c00190a4505b505050505050565b6000611cd48373ffffffffffffffffffffffffffffffffffffffff841661337b565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052915160009283929088169161235f9190613b13565b6000604051808303816000865af19150503d806000811461239c576040519150601f19603f3d011682016040523d82523d6000602084013e6123a1565b606091505b50915091508180156123cb5750805115806123cb5750808060200190518101906123cb9190613b2f565b6122965760405162461bcd60e51b815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a20747260448201527f616e7366657246726f6d206661696c65640000000000000000000000000000006064820152608401610819565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001830160205260408120541515611cd4565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905291516000928392908716916125039190613b13565b6000604051808303816000865af19150503d8060008114612540576040519150601f19603f3d011682016040523d82523d6000602084013e612545565b606091505b509150915081801561256f57508051158061256f57508080602001905181019061256f9190613b2f565b6125e15760405162461bcd60e51b815260206004820152602b60248201527f5472616e7366657248656c7065723a3a73616665417070726f76653a2061707060448201527f726f7665206661696c65640000000000000000000000000000000000000000006064820152608401610819565b5050505050565b60008373ffffffffffffffffffffffffffffffffffffffff1663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612635573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061265991906138c6565b9050826020015173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146126da5760405162461bcd60e51b815260206004820152601d60248201527f576f6f43726f7373436861696e526f7574657256323a2021746f6b656e0000006044820152606401610819565b8373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461271c5761271c8360200151858761246c565b506000612710600454612710612732919061395b565b61273c9087613b51565b6127469190613b8e565b90506000888884602001518560600151604051602001612796949392919093845273ffffffffffffffffffffffffffffffffffffffff928316602085015291166040830152606082015260800190565b604051602081830303815290604052905060006127b28461301b565b6040805160608082018352600080835260208301819052928201529192506127dc8b898589613068565b905060405180606001604052803373ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200182815250915050600060086000876000015161ffff1661ffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660001b90508773ffffffffffffffffffffffffffffffffffffffff1663455ba27d8b308960000151858e8b8b8b8b6040518a63ffffffff1660e01b81526004016128d2989796959493929190613bc9565b6000604051808303818588803b1580156128eb57600080fd5b505af11580156128ff573d6000803e3d6000fd5b5050505050505050505050505050505050565b60075461ffff166000908152600a602090815260408083208583015173ffffffffffffffffffffffffffffffffffffffff168452909152902054806129bf5760405162461bcd60e51b815260206004820152602c60248201527f576f6f43726f7373436861696e526f7574657256323a2021737263496e666f7360448201527f2e627269646765546f6b656e00000000000000000000000000000000000000006064820152608401610819565b815161ffff166000908152600a602090815260408083208186015173ffffffffffffffffffffffffffffffffffffffff16845290915290205480612a6b5760405162461bcd60e51b815260206004820152602c60248201527f576f6f43726f7373436861696e526f7574657256323a2021647374496e666f7360448201527f2e627269646765546f6b656e00000000000000000000000000000000000000006064820152608401610819565b6000888885602001518660600151604051602001612ab9949392919093845273ffffffffffffffffffffffffffffffffffffffff928316602085015291166040830152606082015260800190565b60405160208183030381529060405290506000612710600454612710612adf919061395b565b612ae99089613b51565b612af39190613b8e565b855161ffff1660009081526008602090815260408083205490519394509192612b5e9273ffffffffffffffffffffffffffffffffffffffff16910160609190911b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016815260140190565b60405160208183030381529060405290506000612b7b8b8861319e565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16886020015173ffffffffffffffffffffffffffffffffffffffff1603612d36576040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018a90527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632e1a7d4d90602401600060405180830381600087803b158015612c5c57600080fd5b505af1158015612c70573d6000803e3d6000fd5b505060075461ffff166000908152600960205260408082205481517fd0e30db0000000000000000000000000000000000000000000000000000000008152915173ffffffffffffffffffffffffffffffffffffffff909116945084935063d0e30db0928e926004808201939182900301818588803b158015612cf157600080fd5b505af1158015612d05573d6000803e3d6000fd5b5050600354612d30935084925073ffffffffffffffffffffffffffffffffffffffff1690508c61246c565b50612d5f565b6020880151600354612d5f919073ffffffffffffffffffffffffffffffffffffffff168b61246c565b600354875173ffffffffffffffffffffffffffffffffffffffff90911690639fbf10fc908c908989338f8a898b8e6040518b63ffffffff1660e01b81526004016128d299989796959493929190613c6c565b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff8416908390604051612de89190613b13565b60006040518083038185875af1925050503d8060008114612e25576040519150601f19603f3d011682016040523d82523d6000602084013e612e2a565b606091505b5050905080612ea15760405162461bcd60e51b815260206004820152603460248201527f5472616e7366657248656c7065723a3a736166655472616e736665724554483a60448201527f20455448207472616e73666572206661696c65640000000000000000000000006064820152608401610819565b505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790529151600092839290871691612f3d9190613b13565b6000604051808303816000865af19150503d8060008114612f7a576040519150601f19603f3d011682016040523d82523d6000602084013e612f7f565b606091505b5091509150818015612fa9575080511580612fa9575080806020019051810190612fa99190613b2f565b6125e15760405162461bcd60e51b815260206004820152602d60248201527f5472616e7366657248656c7065723a3a736166655472616e736665723a20747260448201527f616e73666572206661696c6564000000000000000000000000000000000000006064820152608401610819565b6000816040015173ffffffffffffffffffffffffffffffffffffffff16826020015173ffffffffffffffffffffffffffffffffffffffff161461306057600554611cd7565b505060065490565b80516040517f8cfd8f5c00000000000000000000000000000000000000000000000000000000815261ffff909116600482015260016024820152606090600090849073ffffffffffffffffffffffffffffffffffffffff871690638cfd8f5c90604401602060405180830381865afa1580156130e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061310c9190613972565b6131169190613ce7565b60808401516040517e0200000000000000000000000000000000000000000000000000000000000060208201526022810183905260428101919091527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089901b166062820152909150607601604051602081830303815290604052915050949350505050565b6131c260405180606001604052806000815260200160008152602001606081525090565b60006131cd8361301b565b905060405180606001604052808281526020018460800151815260200185604051602001613226919060609190911b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016815260140190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190529052949350505050565b6000818152600183016020526040812054801561334757600061328260018361395b565b85549091506000906132969060019061395b565b90508181146132fb5760008660000182815481106132b6576132b6613897565b90600052602060002001549050808760000184815481106132d9576132d9613897565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061330c5761330c613cff565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611cd7565b6000915050611cd7565b600082600001828154811061336857613368613897565b9060005260206000200154905092915050565b60008181526001830160205260408120546133c257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611cd7565b506000611cd7565b803561ffff811681146133dc57600080fd5b919050565b6000602082840312156133f357600080fd5b611cd4826133ca565b60006020828403121561340e57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff811681146118ab57600080fd5b60006020828403121561344957600080fd5b813561345481613415565b9392505050565b6000806040838503121561346e57600080fd5b613477836133ca565b9150602083013561348781613415565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156134e057835173ffffffffffffffffffffffffffffffffffffffff16835292840192918401916001016134ae565b50909695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261352c57600080fd5b813567ffffffffffffffff80821115613547576135476134ec565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190828211818310171561358d5761358d6134ec565b816040528381528660208588010111156135a657600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060008060c087890312156135df57600080fd5b6135e8876133ca565b9550602087013567ffffffffffffffff8082111561360557600080fd5b6136118a838b0161351b565b965060408901359150808216821461362857600080fd5b909450606088013593506080880135925060a0880135908082111561364c57600080fd5b5061365989828a0161351b565b9150509295509295509295565b60008060006060848603121561367b57600080fd5b613684846133ca565b9250602084013561369481613415565b929592945050506040919091013590565b60008060008060008060c087890312156136be57600080fd5b6136c7876133ca565b9550602087013567ffffffffffffffff808211156136e457600080fd5b6136f08a838b0161351b565b9650604089013595506060890135915061370982613415565b9093506080880135925060a0880135908082111561364c57600080fd5b60006080828403121561373857600080fd5b6040516080810181811067ffffffffffffffff8211171561375b5761375b6134ec565b604052905080823561376c81613415565b8152602083013561377c81613415565b8060208301525060408301356040820152606083013560608201525092915050565b600060a082840312156137b057600080fd5b60405160a0810181811067ffffffffffffffff821117156137d3576137d36134ec565b6040529050806137e2836133ca565b815260208301356137f281613415565b6020820152604083013561380581613415565b8060408301525060608301356060820152608083013560808201525092915050565b600080600080610160858703121561383e57600080fd5b84359350602085013561385081613415565b925061385f8660408701613726565b915061386e8660c0870161379e565b905092959194509250565b6000806040838503121561388c57600080fd5b823561347781613415565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000602082840312156138d857600080fd5b815161345481613415565b600080600080608085870312156138f957600080fd5b84519350602085015161390b81613415565b604086015190935061391c81613415565b6060959095015193969295505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008282101561396d5761396d61392c565b500390565b60006020828403121561398457600080fd5b5051919050565b60005b838110156139a657818101518382015260200161398e565b838111156139b5576000848401525b50505050565b600081518084526139d381602086016020860161398b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b61ffff8816815286602082015285604082015260e060608201526000613a2e60e08301876139bb565b67ffffffffffffffff8616608084015284151560a084015282810360c0840152613a5881856139bb565b9a9950505050505050505050565b60008060408385031215613a7957600080fd5b505080516020909101519092909150565b80518252602081015160208301526000604082015160606040850152613ab360608501826139bb565b949350505050565b61ffff8616815260ff8516602082015260a060408201526000613ae160a08301866139bb565b8281036060840152613af381866139bb565b90508281036080840152613b078185613a8a565b98975050505050505050565b60008251613b2581846020870161398b565b9190910192915050565b600060208284031215613b4157600080fd5b8151801515811461345457600080fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613b8957613b8961392c565b500290565b600082613bc4577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600061010073ffffffffffffffffffffffffffffffffffffffff808c16845261ffff8b1660208501528960408501528860608501528760808501528160a0850152613c16828501886139bb565b915067ffffffffffffffff861660c085015283820360e085015280855116825280602086015116602083015250604084015160606040830152613c5c60608301826139bb565b9c9b505050505050505050505050565b600061012061ffff8c1683528a602084015289604084015273ffffffffffffffffffffffffffffffffffffffff891660608401528760808401528660a08401528060c0840152613cbe81840187613a8a565b905082810360e0840152613cd281866139bb565b9050828103610100840152613c5c81856139bb565b60008219821115613cfa57613cfa61392c565b500190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea2646970667358221220b0157953db3e4c1f9ecd0466942710326b6f913e3717459b52ede699460fd83d64736f6c634300080e0033000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7000000000000000000000000c22fbb3133df781e6c25ea6acebe2d2bb8cea2f900000000000000000000000045a01e4e04f14f7a4a6702c74187c5f6222033cd000000000000000000000000000000000000000000000000000000000000006a

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

000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7000000000000000000000000c22fbb3133df781e6c25ea6acebe2d2bb8cea2f900000000000000000000000045a01e4e04f14f7a4a6702c74187c5f6222033cd000000000000000000000000000000000000000000000000000000000000006a

-----Decoded View---------------
Arg [0] : _weth (address): 0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7
Arg [1] : _wooRouter (address): 0xc22fbb3133df781e6c25ea6acebe2d2bb8cea2f9
Arg [2] : _stargateRouter (address): 0x45a01e4e04f14f7a4a6702c74187c5f6222033cd
Arg [3] : _sgChainIdLocal (uint16): 106

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7
Arg [1] : 000000000000000000000000c22fbb3133df781e6c25ea6acebe2d2bb8cea2f9
Arg [2] : 00000000000000000000000045a01e4e04f14f7a4a6702c74187c5f6222033cd
Arg [3] : 000000000000000000000000000000000000000000000000000000000000006a


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.