Contract 0xd8aa70f7990dab4a383a0d8a57df7a372916575d 1

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x5753d65679362cc5b269fa3d68eb62afe522f99861552217dc161bb27916b24eSwap Exact ETH F...233382622022-12-07 18:10:555 hrs 11 mins ago0x8d1ff8b966b6f2807497a194666c3581471532e0 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0.05 AVAX0.004205497 26.5
0xd7318efb5f52bac60e4b374806bb22fd65d812215eb5c30c6df02f333245c8b2Swap Exact Token...227433482022-11-23 14:20:3714 days 9 hrs ago0x250cb2dce7434a92bdbced4eb1997b4d04ddf933 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0 AVAX0.004204278 26.5
0xcc26ae8bdb2788f9f3812d1d44123ee5d7161d0142be2c895220769b3ad5ba47Swap Exact Token...226533652022-11-21 11:01:2216 days 12 hrs ago0x4770f67db9d09ca7347c1fccbf3795a464065ecb IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0 AVAX0.004203218 26.5
0xcce007768f451c6a330460b829f5d776ad549e0db61472ab3c5b703dbf948672Swap Exact ETH F...221268052022-11-08 20:59:3429 days 2 hrs ago0x5964bdbf157a6d4d54c765dab7d4b33860090698 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0.000352314901206 AVAX0.0039671525
0xb0afea3e2baa8119b4819719c9db128b89a41e158cb4859685726f7a6ca08535Swap Exact Token...218971892022-11-03 10:29:0234 days 12 hrs ago0x9326c7e813b2eb8afd886d00d518261753ec6738 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0 AVAX0.004153716 26.5
0x347970cce224daf38b609c76d5ff166a33e1110d52d809a61395c46fc3dcde6bSwap Exact ETH F...214794222022-10-24 14:08:4544 days 9 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d9.49 AVAX0.00354065 25
0xd48ee9a36d1b8a4283a2e8751601a220ffd683d9acb865d0c47d8fd9778a7580Swap Exact ETH F...214619632022-10-24 4:14:0444 days 19 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d9.39 AVAX0.00354065 25
0xdd4c2dfd7546b0bdce4a804fe28661d936d294f20f1052665494179fb04c1563Swap Tokens For ...214548182022-10-24 0:11:5244 days 23 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0 AVAX0.00396625 25
0xec24dc186e1604def57cd78f6cc2f968afa53cd61615836bb45c0a7b114fbde0Swap Exact ETH F...214494362022-10-23 21:09:4745 days 2 hrs ago0x62ef5c4f5cf0597d06860116644b2181ec1b4f13 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0.107717422212233 AVAX0.0039376525
0x6000b72167455f20401f51cff4a6e685082928ee59eac7d5f06d782de88f5941Swap Tokens For ...214442272022-10-23 18:13:0845 days 5 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0 AVAX0.00396625 25
0x303b5352ee16aa80c25980afe42885dcdf30bf11fdbc0b02d3c76592a313a829Swap Exact ETH F...214421422022-10-23 17:03:0045 days 6 hrs ago0x67d710e2af6ff96151b6b726769dd816129f2603 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0.018017233265253 AVAX0.003720759 26.5
0xac82f16367dd2f8b12353ca37c4537de414ea270b48747632ee14f6ce962c9f3Swap Exact Token...214340992022-10-23 12:29:4645 days 10 hrs ago0x54aeb6d0206916f810ce26ddf7d9206beaf32241 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0 AVAX0.0042983751 27.425
0x30f26631b3ad9b29fb63551348aadf5b6c4a4e143f66e9fdba67e9b3d349ba4aSwap Exact ETH F...213747132022-10-22 2:37:3946 days 20 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d9.59 AVAX0.00354065 25
0x845bde9e6c87a1afa5d278bee94dfcfc3a2659767d1a69616f05453b38ccbf62Swap Tokens For ...213712952022-10-22 0:40:1946 days 22 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0 AVAX0.004215596306 26.571675428
0x663d4f5d4378d1c2cda0cc8224ebd3747ccf8752cdf772829a7418d6ecfe20bdSwap Exact ETH F...213279032022-10-21 0:18:3447 days 23 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d7 AVAX0.00354065 25
0x8eff397fe1cf93bf68ebf041686be04f09770f97a9490827b3c5e4372d81043fSwap Exact ETH F...213170402022-10-20 18:10:2748 days 5 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d9.89 AVAX0.00354065 25
0xac78f63ef2dddcd41bbf054f9955b096b87672145435b61ba6dd2e97508354bdSwap Tokens For ...213149302022-10-20 16:59:5048 days 6 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0 AVAX0.00396625 25
0x3911284e6fa20046d11d002225f82c6eb3eeea34f0edd620bff0c2fda84c998fSwap Tokens For ...212933372022-10-20 4:47:2248 days 18 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0 AVAX0.00396625 25
0x0282a505077222c7dd6736a26efdfd86948fb2f4da74e05bcb996336d435914aSwap Exact ETH F...212161972022-10-18 9:03:1050 days 14 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d9.39 AVAX0.00354065 25
0x5c826a660792ab48518236168ad8c6e1733a95775d1fd74f94003f87e9b460c5Swap Tokens For ...211501982022-10-16 19:34:4452 days 3 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0 AVAX0.004042103224 25.478116765
0xbad6bfae8907af6e273d1b195b0718d1a8fc2e107f2b287fc8fe601b3cb7c7bbSwap Exact ETH F...210700042022-10-14 21:59:0154 days 1 hr ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d9.59 AVAX0.003774998897 26.654702508
0x1c2d234390775fc530aa9477390bda10c17390756565083ba28e111e6292bc39Swap Exact ETH F...210597022022-10-14 16:09:4854 days 7 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d9.49 AVAX0.00354065 25
0xaf003be301f7b7f7721bcdde4625558d7dd1db075f821750fadab03b7dbda511Swap Exact ETH F...210562102022-10-14 14:12:0154 days 9 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d9.39 AVAX0.003541196049 25.003855575
0x346fa99423e2ec14856c006bc777a0172a95668f5b42050c10d90bcb04fc3173Swap Tokens For ...210341272022-10-14 1:45:3554 days 21 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0 AVAX0.004790984269 30.198451116
0x2d8cb8b15f7eb13904ae216bc03154b10fdc37c2de335e1f52ab40d0023e2a6eSwap Tokens For ...210340572022-10-14 1:43:1454 days 21 hrs ago0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a7 IN  0xd8aa70f7990dab4a383a0d8a57df7a372916575d0 AVAX0.001222714865 28.641716227
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x5753d65679362cc5b269fa3d68eb62afe522f99861552217dc161bb27916b24e233382622022-12-07 18:10:555 hrs 11 mins ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d Wrapped AVAX0.05 AVAX
0xd7318efb5f52bac60e4b374806bb22fd65d812215eb5c30c6df02f333245c8b2227433482022-11-23 14:20:3714 days 9 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d0x250cb2dce7434a92bdbced4eb1997b4d04ddf9330.102742947104968641 AVAX
0xd7318efb5f52bac60e4b374806bb22fd65d812215eb5c30c6df02f333245c8b2227433482022-11-23 14:20:3714 days 9 hrs ago Wrapped AVAX 0xd8aa70f7990dab4a383a0d8a57df7a372916575d0.102742947104968641 AVAX
0xcc26ae8bdb2788f9f3812d1d44123ee5d7161d0142be2c895220769b3ad5ba47226533652022-11-21 11:01:2216 days 12 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d0x4770f67db9d09ca7347c1fccbf3795a464065ecb0.575916832347684936 AVAX
0xcc26ae8bdb2788f9f3812d1d44123ee5d7161d0142be2c895220769b3ad5ba47226533652022-11-21 11:01:2216 days 12 hrs ago Wrapped AVAX 0xd8aa70f7990dab4a383a0d8a57df7a372916575d0.575916832347684936 AVAX
0xcce007768f451c6a330460b829f5d776ad549e0db61472ab3c5b703dbf948672221268052022-11-08 20:59:3429 days 2 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d Wrapped AVAX0.000352314901206163 AVAX
0xb0afea3e2baa8119b4819719c9db128b89a41e158cb4859685726f7a6ca08535218971892022-11-03 10:29:0234 days 12 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d0x9326c7e813b2eb8afd886d00d518261753ec67380.096632976393599018 AVAX
0xb0afea3e2baa8119b4819719c9db128b89a41e158cb4859685726f7a6ca08535218971892022-11-03 10:29:0234 days 12 hrs ago Wrapped AVAX 0xd8aa70f7990dab4a383a0d8a57df7a372916575d0.096632976393599018 AVAX
0x347970cce224daf38b609c76d5ff166a33e1110d52d809a61395c46fc3dcde6b214794222022-10-24 14:08:4544 days 9 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d Wrapped AVAX9.49 AVAX
0xd48ee9a36d1b8a4283a2e8751601a220ffd683d9acb865d0c47d8fd9778a7580214619632022-10-24 4:14:0444 days 19 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d Wrapped AVAX9.39 AVAX
0xdd4c2dfd7546b0bdce4a804fe28661d936d294f20f1052665494179fb04c1563214548182022-10-24 0:11:5244 days 23 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a79.21 AVAX
0xdd4c2dfd7546b0bdce4a804fe28661d936d294f20f1052665494179fb04c1563214548182022-10-24 0:11:5244 days 23 hrs ago Wrapped AVAX 0xd8aa70f7990dab4a383a0d8a57df7a372916575d9.21 AVAX
0xec24dc186e1604def57cd78f6cc2f968afa53cd61615836bb45c0a7b114fbde0214494362022-10-23 21:09:4745 days 2 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d Wrapped AVAX0.107717422212233031 AVAX
0x6000b72167455f20401f51cff4a6e685082928ee59eac7d5f06d782de88f5941214442272022-10-23 18:13:0845 days 5 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a79.41 AVAX
0x6000b72167455f20401f51cff4a6e685082928ee59eac7d5f06d782de88f5941214442272022-10-23 18:13:0845 days 5 hrs ago Wrapped AVAX 0xd8aa70f7990dab4a383a0d8a57df7a372916575d9.41 AVAX
0x303b5352ee16aa80c25980afe42885dcdf30bf11fdbc0b02d3c76592a313a829214421422022-10-23 17:03:0045 days 6 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d Wrapped AVAX0.0180172332652536 AVAX
0xac82f16367dd2f8b12353ca37c4537de414ea270b48747632ee14f6ce962c9f3214340992022-10-23 12:29:4645 days 10 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d0x54aeb6d0206916f810ce26ddf7d9206beaf322410.036896565798975238 AVAX
0xac82f16367dd2f8b12353ca37c4537de414ea270b48747632ee14f6ce962c9f3214340992022-10-23 12:29:4645 days 10 hrs ago Wrapped AVAX 0xd8aa70f7990dab4a383a0d8a57df7a372916575d0.036896565798975238 AVAX
0x30f26631b3ad9b29fb63551348aadf5b6c4a4e143f66e9fdba67e9b3d349ba4a213747132022-10-22 2:37:3946 days 20 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d Wrapped AVAX9.59 AVAX
0x845bde9e6c87a1afa5d278bee94dfcfc3a2659767d1a69616f05453b38ccbf62213712952022-10-22 0:40:1946 days 22 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a79.51 AVAX
0x845bde9e6c87a1afa5d278bee94dfcfc3a2659767d1a69616f05453b38ccbf62213712952022-10-22 0:40:1946 days 22 hrs ago Wrapped AVAX 0xd8aa70f7990dab4a383a0d8a57df7a372916575d9.51 AVAX
0x663d4f5d4378d1c2cda0cc8224ebd3747ccf8752cdf772829a7418d6ecfe20bd213279032022-10-21 0:18:3447 days 23 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d Wrapped AVAX7 AVAX
0x8eff397fe1cf93bf68ebf041686be04f09770f97a9490827b3c5e4372d81043f213170402022-10-20 18:10:2748 days 5 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d Wrapped AVAX9.89 AVAX
0xac78f63ef2dddcd41bbf054f9955b096b87672145435b61ba6dd2e97508354bd213149302022-10-20 16:59:5048 days 6 hrs ago 0xd8aa70f7990dab4a383a0d8a57df7a372916575d0x8c8aec0e0eb5956e2941e9b07e3b06be2be3e2a79.71 AVAX
0xac78f63ef2dddcd41bbf054f9955b096b87672145435b61ba6dd2e97508354bd213149302022-10-20 16:59:5048 days 6 hrs ago Wrapped AVAX 0xd8aa70f7990dab4a383a0d8a57df7a372916575d9.71 AVAX
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
HcSwapAvaxRouter

Compiler Version
v0.6.6+commit.6c089d02

Optimization Enabled:
Yes with 9999 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 31 : IHcTokenFactory.sol
pragma solidity >=0.5.0;

interface IHcTokenFactory {
    function transferOwnership(address newOwner) external;

    function createAToken(string calldata name_,string calldata symbol_,uint8 decimals,address originAddress_) external returns(address token);
}

File 2 of 31 : HcSwapAvaxRouter.sol
pragma solidity =0.6.6;
pragma experimental ABIEncoderV2;

import './interfaces/IUniswapV2Factory.sol';
import './interfaces/IHcSwapAvaxFactory.sol';
import './libraries/TransferHelper.sol';
import '../public/libraries/LPQueue.sol';
import './interfaces/IUniswapV2Router02.sol';
import './libraries/UniswapV2Library.sol';
import './libraries/SafeMath.sol';
import './interfaces/IERC20.sol';
import './interfaces/IHcToken.sol';
import './interfaces/IWETH.sol';
import './interfaces/IUniswapV2Pair.sol';
import './interfaces/IHcSwapAvaxPair.sol';
import './interfaces/IHcTokenFactory.sol';
import '../public/contract/Pausable.sol';

contract HcSwapAvaxRouter is IUniswapV2Router02, Pausable {
    using SafeMath for uint;

    address public immutable override factory;
    address public immutable override WETH;
    address public immutable tokenFactory;

    address public owner;
    mapping(address => bool) public operator;
    mapping(address => address) public BSCToAvax;
    mapping(address => bool) public crossToken;

    uint256 public tasksIndex;
    enum CrossActionStatus{FAIL, SUCCESS, CROSS_EXPIRED, INSUFFICIENT_A_AMOUNT, INSUFFICIENT_B_AMOUNT, NO_PAIR}

    struct TokenInfo {
        address originAddress;// address from BSC
        string name;
        string symbol;
        uint8 decimal;
        uint256 amount;//init amount
        address specialAddress;// use custom token address
    }

    struct CrossAction {
        uint8 actionType; // 0 sync amount 1 mint lp 2 burn lp
        bytes32 checksum;//important!
        address tokenA;
        address tokenB;
        uint256 amountA;
        uint256 amountB;
        uint256 liquidity;// when type is sync, this field will be zero.
    }

    //status 0 = fail 1 = success >1=fail with message
    event CrossActionDone(uint256 indexed id, CrossActionStatus status, CrossAction result);
    event CrossLiquidityCreated(address indexed pair, uint liquidity, TokenInfo tokenA, TokenInfo tokenB);

    modifier onlyOwner(){
        require(msg.sender == owner, "HcSwapV2Router: ONLY_OWNER");
        _;
    }

    modifier onlyOperator(){
        require(isOperator(), "HcSwapV2Router:ONLY_OPERATOR");
        _;
    }

    function isOperator() public view returns (bool){
        return operator[msg.sender] || msg.sender == owner;
    }

    modifier ensure(uint deadline) {
        require(deadline >= block.timestamp, 'HcSwapV2Router: EXPIRED');
        _;
    }

    function setOwner(address _owner) onlyOwner public {
        owner = _owner;
    }

    function setPause(bool _status) onlyOwner public {
        if (_status && !paused()) {
            _pause();
        }

        if (!_status && paused()) {
            _unpause();
        }
    }

    function setCrossToken(address[] memory _token, bool[] memory _status) onlyOwner public {
        require(_token.length == _status.length, "HcSwapV2Router:SET_CROSS_TOKEN_WRONG_DATA");
        for (uint i = 0; i < _token.length; i++) {
            crossToken[_token[i]] = _status[i];
        }
    }

    function setOperator(address[] memory _ops, bool[] memory _status) onlyOwner public {
        require(_ops.length == _status.length, "HcSwapV2Router:SET_OPERATOR_WRONG_DATA");
        for (uint i = 0; i < _ops.length; i++) {
            operator[_ops[i]] = _status[i];
        }
    }

    constructor(address _factory, address _WETH, address _tokenFactory) public {
        factory = _factory;
        WETH = _WETH;
        tokenFactory = _tokenFactory;
        owner = msg.sender;
        tasksIndex = 1;
    }

    receive() external payable {
        assert(msg.sender == WETH);
        // only accept ETH via fallback from the WETH contract
    }

    // **** CROSS ACTION ****
    function CreateBSCCrossLiquidity(TokenInfo memory tokenA, TokenInfo memory tokenB) onlyOperator public {
        address tokenAAddress = BSCToAvax[tokenA.originAddress] == address(0) ? tokenA.specialAddress : BSCToAvax[tokenA.originAddress];
        address tokenBAddress = BSCToAvax[tokenB.originAddress] == address(0) ? tokenB.specialAddress : BSCToAvax[tokenB.originAddress];

        if (tokenAAddress != address(0)) {
            if (crossToken[tokenAAddress]) {
                IHcToken(tokenAAddress).superMint(address(this), tokenA.amount);
            } else {
                TransferHelper.safeTransferFrom(tokenAAddress, msg.sender, address(this), tokenA.amount);
            }
        } else {
            tokenAAddress = IHcTokenFactory(tokenFactory).createAToken(tokenA.name, tokenA.symbol, tokenA.decimal, tokenA.originAddress);
            crossToken[tokenAAddress] = true;
            IHcToken(tokenAAddress).superMint(address(this), tokenA.amount);
            IHcToken(tokenAAddress).transferOwnership(owner);
        }
        BSCToAvax[tokenA.originAddress] = tokenAAddress;

        if (tokenBAddress != address(0)) {
            if (crossToken[tokenBAddress]) {
                IHcToken(tokenBAddress).superMint(address(this), tokenB.amount);
            } else {
                TransferHelper.safeTransferFrom(tokenBAddress, msg.sender, address(this), tokenB.amount);
            }
        } else {
            tokenBAddress = IHcTokenFactory(tokenFactory).createAToken(tokenB.name, tokenB.symbol, tokenB.decimal, tokenB.originAddress);
            crossToken[tokenBAddress] = true;
            IHcToken(tokenBAddress).superMint(address(this), tokenB.amount);
            IHcToken(tokenBAddress).transferOwnership(owner);
        }
        BSCToAvax[tokenB.originAddress] = tokenBAddress;

        require(IUniswapV2Factory(factory).getPair(tokenAAddress, tokenBAddress) == address(0));
        IUniswapV2Factory(factory).createPair(tokenAAddress, tokenBAddress);
        address pair = UniswapV2Library.pairFor(factory, tokenAAddress, tokenBAddress);
        IHcSwapAvaxPair(pair).setCrossPair(true);

        TransferHelper.safeTransfer(tokenAAddress, pair, tokenA.amount);
        TransferHelper.safeTransfer(tokenBAddress, pair, tokenB.amount);
        uint liquidity = IUniswapV2Pair(pair).mint(msg.sender);
        emit CrossLiquidityCreated(pair, liquidity, tokenA, tokenB);
    }

    function onCrossTask(LPQueue.LPAction[] memory actions, uint256[] memory ids) onlyOperator public {
        require(actions.length == ids.length, 'HcSwapV2RouterAvax:WRONG_DATA');

        for (uint i = 0; i < actions.length; i++) {
            uint current = ids[i];
            require(current == tasksIndex, 'HcSwapV2RouterAvax:WRONG_INDEX');
            LPQueue.LPAction memory action = actions[i];
            require(LPQueue.checkData(action), "HcSwapV2RouterAvax:WRONG_CHECKSUM");

            if (action.addLP) {
                (address tokenA, address tokenB, uint amountA, uint amountB, uint liquidity, CrossActionStatus success) = onAddLPCrossTask(action);
                onEmitCrossAction(current, action.checksum, true, tokenA, tokenB, amountA, amountB, liquidity, success);
            } else {
                (address tokenA, address tokenB, uint amountA, uint amountB, uint liquidity, CrossActionStatus success) = onRemoveLPCrossTask(action);
                onEmitCrossAction(current, action.checksum, false, tokenA, tokenB, amountA, amountB, liquidity, success);
            }

            tasksIndex++;
        }
    }

    function onAddLPCrossTask(LPQueue.LPAction memory action) internal returns (address tokenA, address tokenB, uint amountA, uint amountB, uint liquidity, CrossActionStatus success){
        (address bscTokenA, address bscTokenB,uint amountADesired,uint amountBDesired,uint amountAMin,uint amountBMin,,uint deadline) = LPQueue.decodeAddLP(action.payload);
        (tokenA, tokenB) = _mappingBSCTokenToAvax(bscTokenA, bscTokenB);
        // require(deadline >= block.timestamp, 'HcSwapV2Router: CROSS_EXPIRED');
        if (deadline >= block.timestamp) {
            address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
            require(pair != address(0), "HcSwapV2Router::onRemoveLPCrossTask: NO_PAIR");

            (amountA, amountB, success) = _addLiquidityNoRevert(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
            if (success == CrossActionStatus.SUCCESS) {
                IHcToken(tokenA).superMint(pair, amountA);
                IHcToken(tokenB).superMint(pair, amountB);
                liquidity = IUniswapV2Pair(pair).mint(msg.sender);
            }
        } else {
            success = CrossActionStatus.CROSS_EXPIRED;
        }
        return (bscTokenA, bscTokenB, amountA, amountB, liquidity, success);
    }

    function onRemoveLPCrossTask(LPQueue.LPAction memory action) internal returns (address tokenA, address tokenB, uint amountA, uint amountB, uint liquidity, CrossActionStatus success){
        uint amountAMin;
        uint amountBMin;
        uint deadline;
        address bscTokenA;
        address bscTokenB;
        (bscTokenA, bscTokenB,liquidity, amountAMin, amountBMin,, deadline) = LPQueue.decodeRemoveLP(action.payload);
        (tokenA, tokenB) = _mappingBSCTokenToAvax(bscTokenA, bscTokenB);
        require(deadline >= block.timestamp, 'HcSwapV2Router: CROSS_EXPIRED');

        address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
        require(pair != address(0), "HcSwapV2Router::onRemoveLPCrossTask: NO_PAIR");

        (uint amount0, uint amount1) = IHcSwapAvaxPair(pair).burnQuery(liquidity);
        (address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB);
        (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
        if (amountA >= amountAMin && amountB >= amountBMin) {
            IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity);
            // send liquidity to pair
            (amountAMin, amountBMin) = IUniswapV2Pair(pair).burn(address(this));
            // avoid stack too deep. should use amountReal
            require(amount0 == amountAMin, "HcSwapV2Router::onRemoveLPCrossTask: AMOUNT0_WRONG");
            require(amount1 == amountBMin, "HcSwapV2Router::onRemoveLPCrossTask: AMOUNT1_WRONG");
            IHcToken(tokenA).burn(amountA);
            IHcToken(tokenB).burn(amountB);
            success = CrossActionStatus.SUCCESS;
        } else {
            if (amountA < amountAMin) {
                success = CrossActionStatus.INSUFFICIENT_A_AMOUNT;
            }

            if (amountB < amountBMin) {
                success = CrossActionStatus.INSUFFICIENT_B_AMOUNT;
            }
        }
        return (bscTokenA, bscTokenB, amountA, amountB, liquidity, success);
    }

    function onEmitCrossAction(uint id, bytes32 checksum, bool addLP, address tokenA, address tokenB, uint amountA, uint amountB, uint liquidity, CrossActionStatus success) internal {
        emit CrossActionDone(id, success, CrossAction({
        actionType : addLP ? 1 : 2,
        checksum : checksum,
        tokenA : tokenA,
        tokenB : tokenB,
        amountA : amountA,
        amountB : amountB,
        liquidity : liquidity
        }));
    }

    function _mappingBSCTokenToAvax(address bscTokenA, address bscTokenB) internal view returns (address tokenA, address tokenB){
        tokenA = BSCToAvax[bscTokenA];
        tokenB = BSCToAvax[bscTokenB];
    }

    // **** ADD LIQUIDITY ****
    function _addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin
    ) internal virtual returns (uint amountA, uint amountB) {
        address pair = IUniswapV2Factory(factory).getPair(tokenA, tokenB);
        // create the pair if it doesn't exist yet
        if (pair == address(0)) {
            require(!(crossToken[tokenA] && crossToken[tokenB]), "HcSwapV2Router::_addLiquidity CROSS_TOKEN_NOT_ALLOW_CREATE");
            pair = IUniswapV2Factory(factory).createPair(tokenA, tokenB);
        }
        if (IHcSwapAvaxPair(pair).crossPair()) {
            require(isOperator(), "HcSwapV2Router::_addLiquidity ONLY_OP_CAN_ADD_CROSS_LP");
        }

        (uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB);
        if (reserveA == 0 && reserveB == 0) {
            (amountA, amountB) = (amountADesired, amountBDesired);
        } else {
            uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB);
            if (amountBOptimal <= amountBDesired) {
                require(amountBOptimal >= amountBMin, 'HcSwapV2Router: INSUFFICIENT_B_AMOUNT');
                (amountA, amountB) = (amountADesired, amountBOptimal);
            } else {
                uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA);
                assert(amountAOptimal <= amountADesired);
                require(amountAOptimal >= amountAMin, 'HcSwapV2Router: INSUFFICIENT_A_AMOUNT');
                (amountA, amountB) = (amountAOptimal, amountBDesired);
            }
        }
    }

    function _addLiquidityNoRevert(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin
    ) internal virtual view returns (uint amountA, uint amountB, CrossActionStatus success){
        if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
            return (amountA, amountB, CrossActionStatus.NO_PAIR);
        }
        (uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB);
        if (reserveA == 0 && reserveB == 0) {
            (amountA, amountB) = (amountADesired, amountBDesired);
        } else {
            uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB);
            if (amountBOptimal <= amountBDesired) {
                // require(amountBOptimal >= amountBMin, 'HcSwapV2Router: INSUFFICIENT_B_AMOUNT');
                if (amountBOptimal < amountBMin) {
                    return (amountA, amountB, CrossActionStatus.INSUFFICIENT_B_AMOUNT);
                }
                (amountA, amountB) = (amountADesired, amountBOptimal);
            } else {
                uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA);
                // assert(amountAOptimal <= amountADesired);
                // require(amountAOptimal >= amountAMin, 'HcSwapV2Router: INSUFFICIENT_A_AMOUNT');
                if (amountAOptimal > amountADesired || amountAOptimal < amountAMin) {
                    return (amountA, amountB, CrossActionStatus.INSUFFICIENT_A_AMOUNT);
                }
                (amountA, amountB) = (amountAOptimal, amountBDesired);
            }
        }
        success = CrossActionStatus.SUCCESS;
    }

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) public virtual override ensure(deadline) whenNotPaused returns (uint amountA, uint amountB, uint liquidity) {
        (amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
        address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
        TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA);
        TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB);
        liquidity = IUniswapV2Pair(pair).mint(to);
    }

    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external virtual override payable ensure(deadline) whenNotPaused returns (uint amountToken, uint amountETH, uint liquidity) {
        (amountToken, amountETH) = _addLiquidity(
            token,
            WETH,
            amountTokenDesired,
            msg.value,
            amountTokenMin,
            amountETHMin
        );
        address pair = UniswapV2Library.pairFor(factory, token, WETH);
        TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken);
        IWETH(WETH).deposit{value : amountETH}();
        assert(IWETH(WETH).transfer(pair, amountETH));
        liquidity = IUniswapV2Pair(pair).mint(to);
        // refund dust eth, if any
        if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);
    }

    // **** REMOVE LIQUIDITY ****
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) public virtual override ensure(deadline) whenNotPaused returns (uint amountA, uint amountB) {
        address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
        IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity);
        // send liquidity to pair
        (uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to);
        (address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB);
        (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
        require(amountA >= amountAMin, 'HcSwapV2Router: INSUFFICIENT_A_AMOUNT');
        require(amountB >= amountBMin, 'HcSwapV2Router: INSUFFICIENT_B_AMOUNT');
    }

    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) public virtual override ensure(deadline) whenNotPaused returns (uint amountToken, uint amountETH) {
        (amountToken, amountETH) = removeLiquidity(
            token,
            WETH,
            liquidity,
            amountTokenMin,
            amountETHMin,
            address(this),
            deadline
        );
        TransferHelper.safeTransfer(token, to, amountToken);
        IWETH(WETH).withdraw(amountETH);
        TransferHelper.safeTransferETH(to, amountETH);
    }

    // **** SWAP ****
    // requires the initial amount to have already been sent to the first pair
    function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
        for (uint i; i < path.length - 1; i++) {
            (address input, address output) = (path[i], path[i + 1]);
            (address token0,) = UniswapV2Library.sortTokens(input, output);
            uint amountOut = amounts[i + 1];
            (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
            address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
            IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap(
                amount0Out, amount1Out, to, new bytes(0)
            );
        }
    }

    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external virtual override ensure(deadline) whenNotPaused returns (uint[] memory amounts) {
        amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
        require(amounts[amounts.length - 1] >= amountOutMin, 'HcSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
        TransferHelper.safeTransferFrom(
            path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
        );
        _swap(amounts, path, to);
    }

    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external virtual override ensure(deadline) whenNotPaused returns (uint[] memory amounts) {
        amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
        require(amounts[0] <= amountInMax, 'HcSwapV2Router: EXCESSIVE_INPUT_AMOUNT');
        TransferHelper.safeTransferFrom(
            path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
        );
        _swap(amounts, path, to);
    }

    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
    external
    virtual
    override
    payable
    ensure(deadline)
    whenNotPaused
    returns (uint[] memory amounts)
    {
        require(path[0] == WETH, 'HcSwapV2Router: INVALID_PATH');
        amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path);
        require(amounts[amounts.length - 1] >= amountOutMin, 'HcSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
        IWETH(WETH).deposit{value : amounts[0]}();
        assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
        _swap(amounts, path, to);
    }

    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
    external
    virtual
    override
    ensure(deadline)
    whenNotPaused
    returns (uint[] memory amounts)
    {
        require(path[path.length - 1] == WETH, 'HcSwapV2Router: INVALID_PATH');
        amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
        require(amounts[0] <= amountInMax, 'HcSwapV2Router: EXCESSIVE_INPUT_AMOUNT');
        TransferHelper.safeTransferFrom(
            path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
        );
        _swap(amounts, path, address(this));
        IWETH(WETH).withdraw(amounts[amounts.length - 1]);
        TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
    }

    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
    external
    virtual
    override
    ensure(deadline)
    whenNotPaused
    returns (uint[] memory amounts)
    {
        require(path[path.length - 1] == WETH, 'HcSwapV2Router: INVALID_PATH');
        amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
        require(amounts[amounts.length - 1] >= amountOutMin, 'HcSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
        TransferHelper.safeTransferFrom(
            path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
        );
        _swap(amounts, path, address(this));
        IWETH(WETH).withdraw(amounts[amounts.length - 1]);
        TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
    }

    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
    external
    virtual
    override
    payable
    ensure(deadline)
    whenNotPaused
    returns (uint[] memory amounts)
    {
        require(path[0] == WETH, 'HcSwapV2Router: INVALID_PATH');
        amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
        require(amounts[0] <= msg.value, 'HcSwapV2Router: EXCESSIVE_INPUT_AMOUNT');
        IWETH(WETH).deposit{value : amounts[0]}();
        assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
        _swap(amounts, path, to);
        // refund dust eth, if any
        if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]);
    }

    // **** LIBRARY FUNCTIONS ****
    function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
        return UniswapV2Library.quote(amountA, reserveA, reserveB);
    }
}

File 3 of 31 : IUniswapV2Factory.sol
pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function owner() external view returns (address);
    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

File 4 of 31 : IHcSwapAvaxFactory.sol
pragma solidity >=0.5.0;

interface IHcSwapAvaxFactory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function owner() external view returns (address);
    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);
    function createAToken(string calldata name,string calldata symbol,uint8 decimals,address originAddress_) external returns(address token);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

File 5 of 31 : TransferHelper.sol
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity >=0.6.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 6 of 31 : LPQueue.sol
pragma solidity =0.6.6;

library LPQueue {
    struct LPAction {
        bool addLP;
        address to;
        bytes32 checksum;
        bytes payload;
    }

    struct Store {
        mapping(uint256 => LPAction) queue;
        uint256 first;
        uint256 last;
        bool init;
    }

    function initStorage(Store storage s) internal {
        s.first = 1;
        s.last = 0;
        s.init = true;
    }

    function currentIndex(Store storage s) internal view returns (uint256) {
        require(s.init == true);
        require(s.last >= s.first, "Queue is Empty");
        return s.first;
    }

    function enqueue(Store storage s, LPAction memory data)
        internal
        returns (LPAction memory)
    {
        require(s.init == true);
        s.last += 1;
        s.queue[s.last] = data;

        return data;
    }

    function encodeAddLP(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) internal pure returns(LPQueue.LPAction memory) {
        bytes memory payload = abi.encode(tokenA,tokenB,amountADesired,amountBDesired,amountAMin,amountBMin,to,deadline);
        bytes32 checksum = keccak256(abi.encode(true, to, payload));
        return LPAction(true,to,checksum,payload);
    }

    //tokenA,tokenB,amountADesired,amountBDesired,amountAMin,amountBMin,to,deadline
    function decodeAddLP(bytes memory payload) internal pure returns(address,address,uint,uint,uint,uint,address,uint){
        return abi.decode(payload,(address,address,uint,uint,uint,uint,address,uint));
    }

    function encodeRemoveLP(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) internal pure returns(LPQueue.LPAction memory) {
        bytes memory payload = abi.encode(tokenA,tokenB,liquidity,amountAMin,amountBMin,to,deadline);
        bytes32 checksum = keccak256(abi.encode(false, to, payload));
        return LPAction(false,to,checksum,payload);
    }

    //tokenA,tokenB,liquidity,amountAMin,amountBMin,to,deadline
    function decodeRemoveLP(bytes memory payload) internal pure returns(address,address,uint,uint,uint,address,uint){
        return abi.decode(payload,(address,address,uint,uint,uint,address,uint));
    }

    function checkData(LPQueue.LPAction memory action) internal pure returns(bool){
        return action.checksum == keccak256(abi.encode(action.addLP, action.to, action.payload));
    }

    function readFirst(Store storage s)
        internal
        view
        returns (LPAction storage data)
    {
        data = s.queue[currentIndex(s)];
    }

    function readFirstPayload(Store storage s) internal view returns(bytes memory payload){
        return s.queue[currentIndex(s)].payload;
    }

    function dequeue(Store storage s) internal {
        require(s.init == true);
        require(s.last >= s.first, "Queue is Empty");
        delete s.queue[s.first];
        s.first += 1;
    }
}

File 7 of 31 : IUniswapV2Router02.sol
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {

}

File 8 of 31 : UniswapV2Library.sol
pragma solidity >=0.5.0;

import '../interfaces/IUniswapV2Pair.sol';
import '../interfaces/IHcSwapAvaxPair.sol';
import '../interfaces/IUniswapV2Factory.sol';

import "./SafeMath.sol";

library UniswapV2Library {
    using SafeMath for uint;

    // returns sorted token addresses, used to handle return values from pairs sorted in this order
    function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
        require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
    }

    // calculates the CREATE2 address for a pair without making any external calls
    function pairFor(address factory, address tokenA, address tokenB) internal view returns (address pair) {
        pair = IUniswapV2Factory(factory).getPair(tokenA, tokenB);
    }

    // fetches and sorts the reserves for a pair
    function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
        (address token0,) = sortTokens(tokenA, tokenB);
        (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
    }

    function getReservesWithCross(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB, bool cross) {
        (address token0,) = sortTokens(tokenA, tokenB);
        address pair = pairFor(factory, tokenA, tokenB);
        (uint reserve0, uint reserve1,) = IUniswapV2Pair(pair).getReserves();
        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
        cross = IHcSwapAvaxPair(pair).crossPair();
    }

    // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
    function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
        require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
        require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        amountB = amountA.mul(reserveB) / reserveA;
    }

    // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
        require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        uint amountInWithFee = amountIn.mul(995);
        uint numerator = amountInWithFee.mul(reserveOut);
        uint denominator = reserveIn.mul(1000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    // given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
        require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        uint numerator = reserveIn.mul(amountOut).mul(1000);
        uint denominator = reserveOut.sub(amountOut).mul(995);
        amountIn = (numerator / denominator).add(1);
    }

        // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function getAmountOutNoCross(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
        require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        uint amountInWithFee = amountIn.mul(997);
        uint numerator = amountInWithFee.mul(reserveOut);
        uint denominator = reserveIn.mul(1000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    // given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function getAmountInNoCross(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
        require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        uint numerator = reserveIn.mul(amountOut).mul(1000);
        uint denominator = reserveOut.sub(amountOut).mul(997);
        amountIn = (numerator / denominator).add(1);
    }

    // performs chained getAmountOut calculations on any number of pairs
    function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[0] = amountIn;
        for (uint i; i < path.length - 1; i++) {
            (uint reserveIn, uint reserveOut, bool cross) = getReservesWithCross(factory, path[i], path[i + 1]);
            amounts[i + 1] = cross?getAmountOut(amounts[i], reserveIn, reserveOut):getAmountOutNoCross(amounts[i], reserveIn, reserveOut);
        }
    }

    // performs chained getAmountIn calculations on any number of pairs
    function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[amounts.length - 1] = amountOut;
        for (uint i = path.length - 1; i > 0; i--) {
            (uint reserveIn, uint reserveOut, bool cross) = getReservesWithCross(factory, path[i - 1], path[i]);
            amounts[i - 1] = cross?getAmountIn(amounts[i], reserveIn, reserveOut):getAmountInNoCross(amounts[i], reserveIn, reserveOut);
        }
    }
}

File 9 of 31 : SafeMath.sol
pragma solidity >=0.5.16;

// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)

library SafeMath {
    function add(uint x, uint y) internal pure returns (uint z) {
        require((z = x + y) >= x, 'ds-math-add-overflow');
    }

    function sub(uint x, uint y) internal pure returns (uint z) {
        require((z = x - y) <= x, 'ds-math-sub-underflow');
    }

    function mul(uint x, uint y) internal pure returns (uint z) {
        require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
    }
}

File 10 of 31 : IERC20.sol
pragma solidity >=0.5.0;

interface IERC20 {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);
}

File 11 of 31 : IHcToken.sol
pragma solidity >=0.5.0;
import './IERC20.sol';

interface IHcToken is IERC20 {
    function originAddress() external view returns(address);
    function superMint(address to_,uint256 amount_) external;
    function transferOwnership(address newOwner) external;
    function burn(uint256 amount_) external;
}

File 12 of 31 : IWETH.sol
pragma solidity >=0.5.0;

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

File 13 of 31 : IUniswapV2Pair.sol
pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

File 14 of 31 : IHcSwapAvaxPair.sol
pragma solidity >=0.6.2;

import './IUniswapV2Pair.sol';

interface IHcSwapAvaxPair is IUniswapV2Pair {
    function setCrossPair(bool status_) external;
    function crossPair() external view returns (bool);
    function burnQuery(uint liquidity) external view returns (uint amount0, uint amount1);
}

File 15 of 31 : Pausable.sol
pragma solidity =0.6.6;

abstract contract Pausable {

    event Paused(address account);
    event Unpaused(address account);

    bool private _paused;

    constructor () internal {
        _paused = false;
    }

    function paused() public view virtual returns (bool) {
        return _paused;
    }

    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(msg.sender);
    }

    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(msg.sender);
    }
}

File 16 of 31 : IUniswapV2Router01.sol
pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
}

File 17 of 31 : HcSwapV2Router02.sol
pragma solidity =0.6.6;
pragma experimental ABIEncoderV2;

import './interfaces/IUniswapV2Factory.sol';
import './libraries/TransferHelper.sol';

import './interfaces/IHcSwapBSC.sol';
import './libraries/UniswapV2Library.sol';
import './libraries/SafeMath.sol';
import './interfaces/IERC20.sol';
import './interfaces/IWETH.sol';
import './interfaces/IHcSwapBSCPair.sol';
import '../public/libraries/LPQueue.sol';
import '../public/contract/Pausable.sol';

contract HcSwapV2Router02 is IHcSwapBSC, Pausable {
    using SafeMath for uint;
    using LPQueue for LPQueue.Store;

    address public immutable override factory;
    address public immutable override WETH;

    address public owner;
    mapping(address => bool) public operator;
    mapping(address => uint) public minAmount;

    uint private unlocked = 1;

    LPQueue.Store public tasks;

    struct CrossAction {
        uint8 actionType; // 0 sync amount 1 mint lp 2 burn lp
        bytes32 checksum;//important!
        address tokenA;
        address tokenB;
        uint256 amountA;
        uint256 amountB;
        uint256 liquidity;// when type is sync, this field will be zero.
        bool success;
    }

    event CrossLiquidity(uint256 indexed id, bytes32 indexed checksum, bool addLP, LPQueue.LPAction action);
    event CreateCrossLP(address indexed pair, address token0, address token1, uint amount0, uint amount1);

    function isOperator(address sender) public view returns (bool){
        return operator[sender] || sender == owner;
    }

    modifier lock() {
        require(unlocked == 1, 'HcSwap: LOCKED');
        unlocked = 0;
        _;
        unlocked = 1;
    }

    modifier onlyOwner(){
        require(msg.sender == owner, "HcSwapV2Router: ONLY_OWNER");
        _;
    }

    modifier onlyOperator(){
        require(isOperator(msg.sender), "HcSwapV2Router: ONLY_OPERATOR");
        _;
    }

    modifier ensure(uint deadline) {
        require(deadline >= block.timestamp, 'HcSwapV2Router: EXPIRED');
        _;
    }

    function setOwner(address _owner) onlyOwner public {
        owner = _owner;
    }

    function setPause(bool _status) onlyOwner public {
        if (_status && !paused()) {
            _pause();
        }

        if (!_status && paused()) {
            _unpause();
        }
    }

    function setOperator(address[] memory _ops, bool[] memory _status) onlyOwner public {
        require(_ops.length == _status.length, "HcSwapV2Router:SET_OPERATOR_WRONG_DATA");
        for (uint i = 0; i < _ops.length; i++) {
            operator[_ops[i]] = _status[i];
        }
    }

    constructor(address _factory, address _WETH) public {
        factory = _factory;
        WETH = _WETH;
        owner = msg.sender;
        tasks.initStorage();
    }

    receive() external payable {
        assert(msg.sender == WETH);
        // only accept ETH via fallback from the WETH contract
    }

    function requireMinAmount(address token, uint amount) public view {
        uint requireMin = minAmount[token] > 0 ? minAmount[token] : 1 finney;
        require(amount >= requireMin, "HcSwap::requireMinAmount NEED_MORE_AMOUNT");
    }

    function setMinAmount(address[] memory _tokens, uint[] memory _amount) onlyOwner public {
        require(_tokens.length == _amount.length, "HcSwapRouter: INVALID_MIN_AMOUNT_DATA");
        for (uint i = 0; i < _tokens.length; i++) {
            minAmount[_tokens[i]] = _amount[i];
        }
    }

    function onCrossSync(CrossAction[] calldata actions) external onlyOperator {
        for (uint256 i = 0; i < actions.length; i++) {
            CrossAction memory action = actions[i];
            IHcSwapBSCPair pair = IHcSwapBSCPair(UniswapV2Library.pairFor(factory, action.tokenA, action.tokenB));

            (address token0,address token1) = (pair.token0(), pair.token1());
            (uint256 amount0,uint256 amount1) = action.tokenA == pair.token0() ? (action.amountA, action.amountB) : (action.amountB, action.amountA);
            if (action.actionType == 0) {//sync
                if (IERC20(token0).balanceOf(address(pair)) < amount0) {
                    TransferHelper.safeTransferFrom(token0, msg.sender, address(pair), amount0.sub(IERC20(token0).balanceOf(address(pair))));
                }
                if (IERC20(token1).balanceOf(address(pair)) < amount1) {
                    TransferHelper.safeTransferFrom(token1, msg.sender, address(pair), amount1.sub(IERC20(token1).balanceOf(address(pair))));
                }
                pair.directlySync(amount0, amount1);
            } else {// mint lp
                LPQueue.LPAction storage task = tasks.readFirst();
                if (action.actionType == 1) {
                    require(action.checksum == task.checksum, "HcSwap:CHECKSUM_ERROR");
                    (,,uint amountADesired,uint amountBDesired,,,,) = LPQueue.decodeAddLP(task.payload);
                    if (action.success) {
                        require(action.liquidity > 0, "HcSwap:ZERO_LIQUIDITY");
                        TransferHelper.safeTransfer(action.tokenA, address(pair), action.amountA);
                        TransferHelper.safeTransfer(action.tokenB, address(pair), action.amountB);

                        if (amountADesired > action.amountA) {
                            TransferHelper.safeTransfer(action.tokenA, task.to, amountADesired.sub(action.amountA));
                        }
                        if (amountBDesired > action.amountB) {
                            TransferHelper.safeTransfer(action.tokenB, task.to, amountBDesired.sub(action.amountB));
                        }

                        pair.directlyMint(action.liquidity, task.to);
                    } else {
                        TransferHelper.safeTransfer(action.tokenA, task.to, amountADesired);
                        TransferHelper.safeTransfer(action.tokenB, task.to, amountBDesired);
                    }

                    tasks.dequeue();
                } else if (action.actionType == 2) {
                    require(action.checksum == task.checksum, "HcSwap: INVALID_CHECKSUM");
                    //tokenA,tokenB,liquidity,amountAMin,amountBMin,to,deadline
                    (,,uint liquidity,,,,) = LPQueue.decodeRemoveLP(task.payload);
                    require(action.liquidity == liquidity, "HcSwap: INVALID_LIQUIDITY");
                    if (action.success) {
                        pair.directlyBurn(action.liquidity, address(this), task.to, amount0, amount1);
                    } else {
                        TransferHelper.safeTransfer(address(pair), task.to, action.liquidity);
                    }

                    tasks.dequeue();
                } else {
                    revert('HcSwap:UNKNOWN_TYPE');
                }
            }
        }
    }

    // **** ADD LIQUIDITY ****
    function _addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin
    ) internal virtual returns (uint amountA, uint amountB) {
        // create the pair if it doesn't exist yet
        if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
            require(isOperator(msg.sender), "HcSwapBSC:NOT_OPERATOR");
            IHcSwapBSCPair pair = IHcSwapBSCPair(IUniswapV2Factory(factory).createPair(tokenA, tokenB));
            (uint amount0,uint amount1) = pair.token0() == tokenA ? (amountADesired, amountBDesired) : (amountBDesired, amountADesired);
            emit CreateCrossLP(address(pair), pair.token0(), pair.token1(), amount0, amount1);
        }
        (uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB);
        if (reserveA == 0 && reserveB == 0) {
            (amountA, amountB) = (amountADesired, amountBDesired);
        } else {
            uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB);
            if (amountBOptimal <= amountBDesired) {
                require(amountBOptimal >= amountBMin, 'HcSwapV2Router: INSUFFICIENT_B_AMOUNT');
                (amountA, amountB) = (amountADesired, amountBOptimal);
            } else {
                uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA);
                assert(amountAOptimal <= amountADesired);
                require(amountAOptimal >= amountAMin, 'HcSwapV2Router: INSUFFICIENT_A_AMOUNT');
                (amountA, amountB) = (amountAOptimal, amountBDesired);
            }
        }
    }

    function addLiquidityFromUser(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        uint deadline
    ) external ensure(deadline) lock whenNotPaused returns (uint256 index) {
        address to = msg.sender;
        address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
        require(pair != address(0), "HcSwapBSC: ONLY_CREATED_LP_ALLOW");
        TransferHelper.safeTransferFrom(tokenA, msg.sender, address(this), amountADesired);
        TransferHelper.safeTransferFrom(tokenB, msg.sender, address(this), amountBDesired);
        requireMinAmount(tokenA, amountADesired);
        requireMinAmount(tokenB, amountBDesired);

        LPQueue.LPAction memory lpAction = LPQueue.encodeAddLP(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin, to, deadline);
        tasks.enqueue(lpAction);
        index = tasks.currentIndex();
        emit CrossLiquidity(index, lpAction.checksum, true, lpAction);
    }

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external virtual override ensure(deadline) onlyOperator returns (uint amountA, uint amountB, uint liquidity) {
        (amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
        address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
        TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA);
        TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB);
        liquidity = IUniswapV2Pair(pair).mint(to);
    }

    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external virtual override payable ensure(deadline) onlyOperator returns (uint amountToken, uint amountETH, uint liquidity) {
        (amountToken, amountETH) = _addLiquidity(
            token,
            WETH,
            amountTokenDesired,
            msg.value,
            amountTokenMin,
            amountETHMin
        );
        address pair = UniswapV2Library.pairFor(factory, token, WETH);
        TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken);
        IWETH(WETH).deposit{value : amountETH}();
        assert(IWETH(WETH).transfer(pair, amountETH));
        liquidity = IUniswapV2Pair(pair).mint(to);
        // refund dust eth, if any
        if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);
    }

    // **** REMOVE LIQUIDITY ****
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) public virtual override ensure(deadline) onlyOperator returns (uint amountA, uint amountB) {
        address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
        IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity);
        // send liquidity to pair
        (uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to);
        (address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB);
        (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
        require(amountA >= amountAMin, 'HcSwapV2Router: INSUFFICIENT_A_AMOUNT');
        require(amountB >= amountBMin, 'HcSwapV2Router: INSUFFICIENT_B_AMOUNT');
    }

    function removeLiquidityFromUser(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        uint deadline
    ) external ensure(deadline) lock whenNotPaused returns (uint256 index) {
        address to = msg.sender;
        address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
        require(pair != address(0), "HcSwapBSC:ONLY_CREATED_LP");
        IUniswapV2Pair(pair).transferFrom(msg.sender, address(this), liquidity);
        // send liquidity to pair
        requireMinAmount(pair, liquidity);
        LPQueue.LPAction memory lpAction = LPQueue.encodeRemoveLP(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline);
        tasks.enqueue(lpAction);
        index = tasks.currentIndex();
        emit CrossLiquidity(index, lpAction.checksum, false, lpAction);
    }

    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) public virtual override ensure(deadline) onlyOperator returns (uint amountToken, uint amountETH) {
        (amountToken, amountETH) = removeLiquidity(
            token,
            WETH,
            liquidity,
            amountTokenMin,
            amountETHMin,
            address(this),
            deadline
        );
        TransferHelper.safeTransfer(token, to, amountToken);
        IWETH(WETH).withdraw(amountETH);
        TransferHelper.safeTransferETH(to, amountETH);
    }

    // **** SWAP ****
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external virtual override ensure(deadline) onlyOperator returns (uint[] memory amounts) {
        amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
        require(amounts[amounts.length - 1] >= amountOutMin, 'HcSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
        TransferHelper.safeTransferFrom(
            path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
        );
        _swap(amounts, path, to);
    }

    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external virtual override ensure(deadline) onlyOperator returns (uint[] memory amounts) {
        amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
        require(amounts[0] <= amountInMax, 'HcSwapV2Router: EXCESSIVE_INPUT_AMOUNT');
        TransferHelper.safeTransferFrom(
            path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
        );
        _swap(amounts, path, to);
    }

    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
    external
    virtual
    override
    payable
    ensure(deadline)
    onlyOperator
    returns (uint[] memory amounts)
    {
        require(path[0] == WETH, 'HcSwapV2Router: INVALID_PATH');
        amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path);
        require(amounts[amounts.length - 1] >= amountOutMin, 'HcSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
        IWETH(WETH).deposit{value : amounts[0]}();
        assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
        _swap(amounts, path, to);
    }

    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
    external
    virtual
    override
    ensure(deadline)
    onlyOperator
    returns (uint[] memory amounts)
    {
        require(path[path.length - 1] == WETH, 'HcSwapV2Router: INVALID_PATH');
        amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
        require(amounts[0] <= amountInMax, 'HcSwapV2Router: EXCESSIVE_INPUT_AMOUNT');
        TransferHelper.safeTransferFrom(
            path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
        );
        _swap(amounts, path, address(this));
        IWETH(WETH).withdraw(amounts[amounts.length - 1]);
        TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
    }

    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
    external
    virtual
    override
    ensure(deadline)
    onlyOperator
    returns (uint[] memory amounts)
    {
        require(path[path.length - 1] == WETH, 'HcSwapV2Router: INVALID_PATH');
        amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
        require(amounts[amounts.length - 1] >= amountOutMin, 'HcSwapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
        TransferHelper.safeTransferFrom(
            path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
        );
        _swap(amounts, path, address(this));
        IWETH(WETH).withdraw(amounts[amounts.length - 1]);
        TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
    }

    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
    external
    virtual
    override
    payable
    ensure(deadline)
    onlyOperator
    returns (uint[] memory amounts)
    {
        require(path[0] == WETH, 'HcSwapV2Router: INVALID_PATH');
        amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
        require(amounts[0] <= msg.value, 'HcSwapV2Router: EXCESSIVE_INPUT_AMOUNT');
        IWETH(WETH).deposit{value : amounts[0]}();
        assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
        _swap(amounts, path, to);
        // refund dust eth, if any
        if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]);
    }
    // requires the initial amount to have already been sent to the first pair
    function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
        for (uint i; i < path.length - 1; i++) {
            (address input, address output) = (path[i], path[i + 1]);
            (address token0,) = UniswapV2Library.sortTokens(input, output);
            uint amountOut = amounts[i + 1];
            (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
            address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
            IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap(
                amount0Out, amount1Out, to, new bytes(0)
            );
        }
    }

    // **** LIBRARY FUNCTIONS ****
    function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
        return UniswapV2Library.quote(amountA, reserveA, reserveB);
    }

    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut)
    public
    pure
    virtual
    override
    returns (uint amountOut)
    {
        return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut);
    }

    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut)
    public
    pure
    virtual
    override
    returns (uint amountIn)
    {
        return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut);
    }

    function getAmountsOut(uint amountIn, address[] memory path)
    public
    view
    virtual
    override
    returns (uint[] memory amounts)
    {
        return UniswapV2Library.getAmountsOut(factory, amountIn, path);
    }

    function getAmountsIn(uint amountOut, address[] memory path)
    public
    view
    virtual
    override
    returns (uint[] memory amounts)
    {
        return UniswapV2Library.getAmountsIn(factory, amountOut, path);
    }
}

File 18 of 31 : IUniswapV2Factory.sol
pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function owner() external view returns (address);
    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

File 19 of 31 : TransferHelper.sol
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity >=0.6.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 20 of 31 : IHcSwapBSC.sol
pragma solidity >=0.6.2;

interface IHcSwapBSC {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);

    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

File 21 of 31 : UniswapV2Library.sol
pragma solidity >=0.5.0;

import '../interfaces/IUniswapV2Pair.sol';
import '../interfaces/IUniswapV2Factory.sol';

import "./SafeMath.sol";

library UniswapV2Library {
    using SafeMath for uint;

    // returns sorted token addresses, used to handle return values from pairs sorted in this order
    function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
        require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
    }

    // calculates the CREATE2 address for a pair without making any external calls
    function pairFor(address factory, address tokenA, address tokenB) internal view returns (address pair) {
        pair = IUniswapV2Factory(factory).getPair(tokenA, tokenB);
    }

    // fetches and sorts the reserves for a pair
    function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
        (address token0,) = sortTokens(tokenA, tokenB);
        (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
    }

    // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
    function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
        require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
        require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        amountB = amountA.mul(reserveB) / reserveA;
    }

    // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
        require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        uint amountInWithFee = amountIn.mul(995);
        uint numerator = amountInWithFee.mul(reserveOut);
        uint denominator = reserveIn.mul(1000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    // given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
        require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        uint numerator = reserveIn.mul(amountOut).mul(1000);
        uint denominator = reserveOut.sub(amountOut).mul(995);
        amountIn = (numerator / denominator).add(1);
    }

    // performs chained getAmountOut calculations on any number of pairs
    function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[0] = amountIn;
        for (uint i; i < path.length - 1; i++) {
            (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
            amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
        }
    }

    // performs chained getAmountIn calculations on any number of pairs
    function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[amounts.length - 1] = amountOut;
        for (uint i = path.length - 1; i > 0; i--) {
            (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
            amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
        }
    }
}

File 22 of 31 : SafeMath.sol
pragma solidity >=0.5.16;

// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)

library SafeMath {
    function add(uint x, uint y) internal pure returns (uint z) {
        require((z = x + y) >= x, 'ds-math-add-overflow');
    }

    function sub(uint x, uint y) internal pure returns (uint z) {
        require((z = x - y) <= x, 'ds-math-sub-underflow');
    }

    function mul(uint x, uint y) internal pure returns (uint z) {
        require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
    }
}

File 23 of 31 : IERC20.sol
pragma solidity >=0.5.0;

interface IERC20 {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);
}

File 24 of 31 : IWETH.sol
pragma solidity >=0.5.0;

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

File 25 of 31 : IHcSwapBSCPair.sol
pragma solidity >=0.5.0;

interface IHcSwapBSCPair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
    
    function directlyMint(uint liquidity, address to) external;
    function directlyBurn(uint liquidity, address from, address to, uint amount0, uint amount1) external;
    function directlySync(uint256 amount0, uint256 amount1) external;
}

File 26 of 31 : IUniswapV2Pair.sol
pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

File 27 of 31 : IUniswapV2ERC20.sol
pragma solidity >=0.5.0;

interface IUniswapV2ERC20 {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}

File 28 of 31 : IUniswapV2Callee.sol
pragma solidity >=0.5.0;

interface IUniswapV2Callee {
    function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
}

File 29 of 31 : HcSwapHelper.sol
pragma solidity >=0.6.2;

import './interfaces/IHcSwapAvaxPair.sol';
import './interfaces/IHcSwapAvaxFactory.sol';
import './libraries/SafeMath.sol';

contract HcSwapHelper {
    using SafeMath for uint;

    function sqrt(uint y) internal pure returns (uint z) {
        if (y > 3) {
            z = y;
            uint x = y / 2 + 1;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
    }

    function calcMintFee(address _pair) public view returns (uint liquidity) {
        IHcSwapAvaxPair pair = IHcSwapAvaxPair(_pair);
        uint kLast = pair.kLast();
        (uint112 reserve0, uint112 reserve1,) = pair.getReserves();
        if (kLast != 0) {
            uint rootK = sqrt(uint(reserve0).mul(reserve1));
            uint rootKLast = sqrt(kLast);
            if (rootK > rootKLast) {
                uint numerator = pair.totalSupply().mul(rootK.sub(rootKLast));
                uint denominator = (rootK.mul(3) / 2).add(rootKLast);
                liquidity = numerator / denominator;
            }
        }
    }

    function calcReserve(address _pair, address _operator) public view returns (uint reserve0, uint reserve1) {
        IHcSwapAvaxPair pair = IHcSwapAvaxPair(_pair);
        (reserve0, reserve1,) = pair.getReserves();
        uint feeLp = pair.totalSupply().sub(pair.balanceOf(_operator)).sub(1000).add(calcMintFee(_pair));
        (uint amount0, uint amount1) = pair.burnQuery(feeLp);
        reserve0 = reserve0.sub(amount0);
        reserve1 = reserve1.sub(amount1);
    }
}

File 30 of 31 : IUniswapV2Callee.sol
pragma solidity >=0.5.0;

interface IUniswapV2Callee {
    function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
}

File 31 of 31 : IUniswapV2ERC20.sol
pragma solidity >=0.5.0;

interface IUniswapV2ERC20 {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_WETH","type":"address"},{"internalType":"address","name":"_tokenFactory","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"enum HcSwapAvaxRouter.CrossActionStatus","name":"status","type":"uint8"},{"components":[{"internalType":"uint8","name":"actionType","type":"uint8"},{"internalType":"bytes32","name":"checksum","type":"bytes32"},{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"indexed":false,"internalType":"struct HcSwapAvaxRouter.CrossAction","name":"result","type":"tuple"}],"name":"CrossActionDone","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"liquidity","type":"uint256"},{"components":[{"internalType":"address","name":"originAddress","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint8","name":"decimal","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"specialAddress","type":"address"}],"indexed":false,"internalType":"struct HcSwapAvaxRouter.TokenInfo","name":"tokenA","type":"tuple"},{"components":[{"internalType":"address","name":"originAddress","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint8","name":"decimal","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"specialAddress","type":"address"}],"indexed":false,"internalType":"struct HcSwapAvaxRouter.TokenInfo","name":"tokenB","type":"tuple"}],"name":"CrossLiquidityCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"BSCToAvax","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"originAddress","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint8","name":"decimal","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"specialAddress","type":"address"}],"internalType":"struct HcSwapAvaxRouter.TokenInfo","name":"tokenA","type":"tuple"},{"components":[{"internalType":"address","name":"originAddress","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint8","name":"decimal","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"specialAddress","type":"address"}],"internalType":"struct HcSwapAvaxRouter.TokenInfo","name":"tokenB","type":"tuple"}],"name":"CreateBSCCrossLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"amountADesired","type":"uint256"},{"internalType":"uint256","name":"amountBDesired","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"addLiquidity","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountTokenDesired","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"addLiquidityETH","outputs":[{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"uint256","name":"amountETH","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"crossToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isOperator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bool","name":"addLP","type":"bool"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes32","name":"checksum","type":"bytes32"},{"internalType":"bytes","name":"payload","type":"bytes"}],"internalType":"struct LPQueue.LPAction[]","name":"actions","type":"tuple[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"onCrossTask","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"operator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"reserveA","type":"uint256"},{"internalType":"uint256","name":"reserveB","type":"uint256"}],"name":"quote","outputs":[{"internalType":"uint256","name":"amountB","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidity","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidityETH","outputs":[{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_token","type":"address[]"},{"internalType":"bool[]","name":"_status","type":"bool[]"}],"name":"setCrossToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_ops","type":"address[]"},{"internalType":"bool[]","name":"_status","type":"bool[]"}],"name":"setOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_status","type":"bool"}],"name":"setPause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapETHForExactTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactETHForTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForETH","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMax","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapTokensForExactETH","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMax","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapTokensForExactTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tasksIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60e06040523480156200001157600080fd5b5060405162005c6538038062005c6583398101604081905262000034916200007b565b60008054606094851b6001600160601b031990811660805293851b841660a0529190931b90911660c0526001600160a81b03191661010033021790556001600455620000e7565b60008060006060848603121562000090578283fd5b83516200009d81620000ce565b6020850151909350620000b081620000ce565b6040850151909250620000c381620000ce565b809150509250925092565b6001600160a01b0381168114620000e457600080fd5b50565b60805160601c60a05160601c60c05160601c615a76620001ef6000398061170a5280612043528061232c5250806101c0528061058c52806105f552806108995280610aa75280610d1e5280610e8e5280610f97528061101f528061133352806118cb5280611921528061195552806119f45280611b8b5280611c915280611d1952508061092752806109e45280610bb35280610dac5280610f035280611051528061127952806113ba52806116b6528061179152806118ff5280611c005280611d4b528061253f5280612609528061269a5280612a655280612d5552806134555280613498528061389b52806139d45280613b025280613c565280613d115250615a766000f3fe6080604052600436106101b05760003560e01c80639a307391116100ec578063d23b3cde1161008a578063e8e3370011610064578063e8e33700146104bf578063f305d719146104ee578063fb3bdb4114610501578063fcc055c814610514576101e9565b8063d23b3cde1461046a578063d98928571461048a578063e77772fe146104aa576101e9565b8063baa2abde116100c6578063baa2abde146103f5578063bedb86fb14610415578063c3b873ff14610435578063c45a015514610455576101e9565b80639a307391146103a0578063ad5c4648146103c0578063ad615dec146103d5576101e9565b80634456eda2116101595780637ff36ab5116101335780637ff36ab51461032b57806384643eff1461033e5780638803dbee1461035e5780638da5cb5b1461037e576101e9565b80634456eda2146102d45780634a25d94a146102f65780635c975abb14610316576101e9565b806318cbafe51161018a57806318cbafe51461026557806338ed1739146102925780633f9f5452146102b2576101e9565b806302751cec146101ee578063114f90ab1461022557806313af403514610245576101e9565b366101e957336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146101e757fe5b005b600080fd5b3480156101fa57600080fd5b5061020e6102093660046147d0565b610534565b60405161021c92919061593c565b60405180910390f35b34801561023157600080fd5b506101e76102403660046148ef565b610672565b34801561025157600080fd5b506101e76102603660046145b3565b6107d9565b34801561027157600080fd5b50610285610280366004614b9a565b610847565b60405161021c9190614d86565b34801561029e57600080fd5b506102856102ad366004614b9a565b610b66565b3480156102be57600080fd5b506102c7610c94565b60405161021c9190615908565b3480156102e057600080fd5b506102e9610c9a565b60405161021c9190614dca565b34801561030257600080fd5b50610285610311366004614b9a565b610ccc565b34801561032257600080fd5b506102e9610e3b565b610285610339366004614b12565b610e44565b34801561034a57600080fd5b506101e761035936600461482d565b611172565b34801561036a57600080fd5b50610285610379366004614b9a565b61122c565b34801561038a57600080fd5b50610393611308565b60405161021c9190614d1b565b3480156103ac57600080fd5b506102e96103bb3660046145b3565b61131c565b3480156103cc57600080fd5b50610393611331565b3480156103e157600080fd5b506102c76103f0366004614c0b565b611355565b34801561040157600080fd5b5061020e6104103660046146e4565b61136a565b34801561042157600080fd5b506101e7610430366004614a17565b61158b565b34801561044157600080fd5b506101e761045036600461482d565b6115fa565b34801561046157600080fd5b506103936116b4565b34801561047657600080fd5b506103936104853660046145b3565b6116d8565b34801561049657600080fd5b506102e96104a53660046145b3565b6116f3565b3480156104b657600080fd5b50610393611708565b3480156104cb57600080fd5b506104df6104da366004614755565b61172c565b60405161021c93929190615978565b6104df6104fc3660046147d0565b61187a565b61028561050f366004614b12565b611b41565b34801561052057600080fd5b506101e761052f366004614a4f565b611e7c565b60008082428110156105615760405162461bcd60e51b815260040161055890615479565b60405180910390fd5b610569610e3b565b156105865760405162461bcd60e51b8152600401610558906154b0565b6105b5897f00000000000000000000000000000000000000000000000000000000000000008a8a8a308a61136a565b90935091506105c5898685612842565b6040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d9061062a908590600401615908565b600060405180830381600087803b15801561064457600080fd5b505af1158015610658573d6000803e3d6000fd5b505050506106668583612945565b50965096945050505050565b61067a610c9a565b6106965760405162461bcd60e51b815260040161055890615112565b80518251146106b75760405162461bcd60e51b815260040161055890615442565b60005b82518110156107d45760008282815181106106d157fe5b6020026020010151905060045481146106fc5760405162461bcd60e51b815260040161055890614f30565b610704614323565b84838151811061071057fe5b60200260200101519050610723816129d2565b61073f5760405162461bcd60e51b8152600401610558906153e5565b8051156107855760008060008060008061075887612a18565b95509550955095509550955061077a8888604001516001898989898989612c55565b5050505050506107c0565b60008060008060008061079787612cef565b9550955095509550955095506107b98888604001516000898989898989612c55565b5050505050505b5050600480546001908101909155016106ba565b505050565b60005461010090046001600160a01b031633146108085760405162461bcd60e51b8152600401610558906158d1565b600080546001600160a01b03909216610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff909216919091179055565b6060814281101561086a5760405162461bcd60e51b815260040161055890615479565b610872610e3b565b1561088f5760405162461bcd60e51b8152600401610558906154b0565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001686867fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81018181106108e757fe5b90506020020160208101906108fc91906145b3565b6001600160a01b0316146109225760405162461bcd60e51b8152600401610558906153ae565b6109807f0000000000000000000000000000000000000000000000000000000000000000898888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506130c292505050565b9150868260018451038151811061099357fe5b602002602001015110156109b95760405162461bcd60e51b815260040161055890615297565b610a66868660008181106109c957fe5b90506020020160208101906109de91906145b3565b33610a4c7f00000000000000000000000000000000000000000000000000000000000000008a8a6000818110610a1057fe5b9050602002016020810190610a2591906145b3565b8b8b6001818110610a3257fe5b9050602002016020810190610a4791906145b3565b613206565b85600081518110610a5957fe5b60200260200101516132a0565b610aa5828787808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503092506133a6915050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632e1a7d4d83600185510381518110610ae457fe5b60200260200101516040518263ffffffff1660e01b8152600401610b089190615908565b600060405180830381600087803b158015610b2257600080fd5b505af1158015610b36573d6000803e3d6000fd5b50505050610b5b8483600185510381518110610b4e57fe5b6020026020010151612945565b509695505050505050565b60608142811015610b895760405162461bcd60e51b815260040161055890615479565b610b91610e3b565b15610bae5760405162461bcd60e51b8152600401610558906154b0565b610c0c7f0000000000000000000000000000000000000000000000000000000000000000898888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506130c292505050565b91508682600184510381518110610c1f57fe5b60200260200101511015610c455760405162461bcd60e51b815260040161055890615297565b610c55868660008181106109c957fe5b610b5b828787808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508992506133a6915050565b60045481565b3360009081526001602052604081205460ff1680610cc7575060005461010090046001600160a01b031633145b905090565b60608142811015610cef5760405162461bcd60e51b815260040161055890615479565b610cf7610e3b565b15610d145760405162461bcd60e51b8152600401610558906154b0565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001686867fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101818110610d6c57fe5b9050602002016020810190610d8191906145b3565b6001600160a01b031614610da75760405162461bcd60e51b8152600401610558906153ae565b610e057f00000000000000000000000000000000000000000000000000000000000000008988888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061356692505050565b91508682600081518110610e1557fe5b602002602001015111156109b95760405162461bcd60e51b8152600401610558906157ba565b60005460ff1690565b60608142811015610e675760405162461bcd60e51b815260040161055890615479565b610e6f610e3b565b15610e8c5760405162461bcd60e51b8152600401610558906154b0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031686866000818110610ec357fe5b9050602002016020810190610ed891906145b3565b6001600160a01b031614610efe5760405162461bcd60e51b8152600401610558906153ae565b610f5c7f0000000000000000000000000000000000000000000000000000000000000000348888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506130c292505050565b91508682600184510381518110610f6f57fe5b60200260200101511015610f955760405162461bcd60e51b815260040161055890615297565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db083600081518110610fd157fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b15801561100457600080fd5b505af1158015611018573d6000803e3d6000fd5b50505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a9059cbb61109f7f00000000000000000000000000000000000000000000000000000000000000008989600081811061107d57fe5b905060200201602081019061109291906145b3565b8a8a6001818110610a3257fe5b846000815181106110ac57fe5b60200260200101516040518363ffffffff1660e01b81526004016110d1929190614d53565b602060405180830381600087803b1580156110eb57600080fd5b505af11580156110ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111239190614a33565b61112957fe5b611168828787808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508992506133a6915050565b5095945050505050565b60005461010090046001600160a01b031633146111a15760405162461bcd60e51b8152600401610558906158d1565b80518251146111c25760405162461bcd60e51b815260040161055890615817565b60005b82518110156107d4578181815181106111da57fe5b6020026020010151600160008584815181106111f257fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016111c5565b6060814281101561124f5760405162461bcd60e51b815260040161055890615479565b611257610e3b565b156112745760405162461bcd60e51b8152600401610558906154b0565b6112d27f00000000000000000000000000000000000000000000000000000000000000008988888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061356692505050565b915086826000815181106112e257fe5b60200260200101511115610c455760405162461bcd60e51b8152600401610558906157ba565b60005461010090046001600160a01b031681565b60016020526000908152604090205460ff1681565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006113628484846136d2565b949350505050565b600080824281101561138e5760405162461bcd60e51b815260040161055890615479565b611396610e3b565b156113b35760405162461bcd60e51b8152600401610558906154b0565b60006113e07f00000000000000000000000000000000000000000000000000000000000000008c8c613206565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081529091506001600160a01b038216906323b872dd9061142c90339085908e90600401614d2f565b602060405180830381600087803b15801561144657600080fd5b505af115801561145a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147e9190614a33565b50600080826001600160a01b03166389afcb44896040518263ffffffff1660e01b81526004016114ae9190614d1b565b6040805180830381600087803b1580156114c757600080fd5b505af11580156114db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ff9190614b77565b91509150600061150f8e8e613740565b509050806001600160a01b03168e6001600160a01b031614611532578183611535565b82825b90975095508a87101561155a5760405162461bcd60e51b815260040161055890614ffb565b8986101561157a5760405162461bcd60e51b815260040161055890615058565b505050505097509795505050505050565b60005461010090046001600160a01b031633146115ba5760405162461bcd60e51b8152600401610558906158d1565b8080156115cc57506115ca610e3b565b155b156115d9576115d96137ca565b801580156115ea57506115ea610e3b565b156115f7576115f7613836565b50565b60005461010090046001600160a01b031633146116295760405162461bcd60e51b8152600401610558906158d1565b805182511461164a5760405162461bcd60e51b8152600401610558906150b5565b60005b82518110156107d45781818151811061166257fe5b60200260200101516003600085848151811061167a57fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191691151591909117905560010161164d565b7f000000000000000000000000000000000000000000000000000000000000000081565b6002602052600090815260409020546001600160a01b031681565b60036020526000908152604090205460ff1681565b7f000000000000000000000000000000000000000000000000000000000000000081565b600080600083428110156117525760405162461bcd60e51b815260040161055890615479565b61175a610e3b565b156117775760405162461bcd60e51b8152600401610558906154b0565b6117858c8c8c8c8c8c613894565b909450925060006117b77f00000000000000000000000000000000000000000000000000000000000000008e8e613206565b90506117c58d3383886132a0565b6117d18c3383876132a0565b6040517f6a6278420000000000000000000000000000000000000000000000000000000081526001600160a01b03821690636a62784290611816908a90600401614d1b565b602060405180830381600087803b15801561183057600080fd5b505af1158015611844573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118689190614afa565b92505050985098509895505050505050565b600080600083428110156118a05760405162461bcd60e51b815260040161055890615479565b6118a8610e3b565b156118c55760405162461bcd60e51b8152600401610558906154b0565b6118f38a7f00000000000000000000000000000000000000000000000000000000000000008b348c8c613894565b909450925060006119457f00000000000000000000000000000000000000000000000000000000000000008c7f0000000000000000000000000000000000000000000000000000000000000000613206565b90506119538b3383886132a0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0856040518263ffffffff1660e01b81526004016000604051808303818588803b1580156119ae57600080fd5b505af11580156119c2573d6000803e3d6000fd5b50506040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016935063a9059cbb9250611a2e915084908890600401614d53565b602060405180830381600087803b158015611a4857600080fd5b505af1158015611a5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a809190614a33565b611a8657fe5b6040517f6a6278420000000000000000000000000000000000000000000000000000000081526001600160a01b03821690636a62784290611acb908a90600401614d1b565b602060405180830381600087803b158015611ae557600080fd5b505af1158015611af9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1d9190614afa565b925083341115611b3357611b3333853403612945565b505096509650969350505050565b60608142811015611b645760405162461bcd60e51b815260040161055890615479565b611b6c610e3b565b15611b895760405162461bcd60e51b8152600401610558906154b0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031686866000818110611bc057fe5b9050602002016020810190611bd591906145b3565b6001600160a01b031614611bfb5760405162461bcd60e51b8152600401610558906153ae565b611c597f00000000000000000000000000000000000000000000000000000000000000008888888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061356692505050565b91503482600081518110611c6957fe5b60200260200101511115611c8f5760405162461bcd60e51b8152600401610558906157ba565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db083600081518110611ccb57fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b158015611cfe57600080fd5b505af1158015611d12573d6000803e3d6000fd5b50505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663a9059cbb611d777f00000000000000000000000000000000000000000000000000000000000000008989600081811061107d57fe5b84600081518110611d8457fe5b60200260200101516040518363ffffffff1660e01b8152600401611da9929190614d53565b602060405180830381600087803b158015611dc357600080fd5b505af1158015611dd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dfb9190614a33565b611e0157fe5b611e40828787808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508992506133a6915050565b81600081518110611e4d57fe5b6020026020010151341115611168576111683383600081518110611e6d57fe5b60200260200101513403612945565b611e84610c9a565b611ea05760405162461bcd60e51b815260040161055890615112565b81516001600160a01b0390811660009081526002602052604081205490911615611ee65782516001600160a01b0390811660009081526002602052604090205416611eec565b8260a001515b82516001600160a01b03908116600090815260026020526040812054929350911615611f345782516001600160a01b0390811660009081526002602052604090205416611f3a565b8260a001515b90506001600160a01b03821615612002576001600160a01b03821660009081526003602052604090205460ff1615611fed5760808401516040517ffa6171e40000000000000000000000000000000000000000000000000000000081526001600160a01b0384169163fa6171e491611fb6913091600401614d53565b600060405180830381600087803b158015611fd057600080fd5b505af1158015611fe4573d6000803e3d6000fd5b50505050611ffd565b611ffd82333087608001516132a0565b6121e8565b60208401516040808601516060870151875192517f6ea08c0e0000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001694636ea08c0e9461207a9491939192600401614e79565b602060405180830381600087803b15801561209457600080fd5b505af11580156120a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120cc91906145d6565b6001600160a01b03811660008181526003602052604090819020805460ff19166001179055608087015190517ffa6171e4000000000000000000000000000000000000000000000000000000008152929450909163fa6171e49161213591309190600401614d53565b600060405180830381600087803b15801561214f57600080fd5b505af1158015612163573d6000803e3d6000fd5b50506000546040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b03808716945063f2fde38b93506121b59261010090041690600401614d1b565b600060405180830381600087803b1580156121cf57600080fd5b505af11580156121e3573d6000803e3d6000fd5b505050505b83516001600160a01b03908116600090815260026020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168483161790558116156122eb576001600160a01b03811660009081526003602052604090205460ff16156122d65760808301516040517ffa6171e40000000000000000000000000000000000000000000000000000000081526001600160a01b0383169163fa6171e49161229f913091600401614d53565b600060405180830381600087803b1580156122b957600080fd5b505af11580156122cd573d6000803e3d6000fd5b505050506122e6565b6122e681333086608001516132a0565b6124d1565b60208301516040808501516060860151865192517f6ea08c0e0000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001694636ea08c0e946123639491939192600401614e79565b602060405180830381600087803b15801561237d57600080fd5b505af1158015612391573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b591906145d6565b6001600160a01b03811660008181526003602052604090819020805460ff19166001179055608086015190517ffa6171e4000000000000000000000000000000000000000000000000000000008152929350909163fa6171e49161241e91309190600401614d53565b600060405180830381600087803b15801561243857600080fd5b505af115801561244c573d6000803e3d6000fd5b50506000546040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b03808616945063f2fde38b935061249e9261010090041690600401614d1b565b600060405180830381600087803b1580156124b857600080fd5b505af11580156124cc573d6000803e3d6000fd5b505050505b82516001600160a01b0390811660009081526002602052604080822080547fffffffffffffffffffffffff000000000000000000000000000000000000000016858516179055517fe6a4390500000000000000000000000000000000000000000000000000000000815290917f0000000000000000000000000000000000000000000000000000000000000000169063e6a43905906125769086908690600401614d6c565b60206040518083038186803b15801561258e57600080fd5b505afa1580156125a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125c691906145d6565b6001600160a01b0316146125d957600080fd5b6040517fc9c653960000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c9c65396906126409085908590600401614d6c565b602060405180830381600087803b15801561265a57600080fd5b505af115801561266e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061269291906145d6565b5060006126c07f00000000000000000000000000000000000000000000000000000000000000008484613206565b6040517f9eb4c1560000000000000000000000000000000000000000000000000000000081529091506001600160a01b03821690639eb4c1569061270990600190600401614dca565b600060405180830381600087803b15801561272357600080fd5b505af1158015612737573d6000803e3d6000fd5b5050505061274a83828760800151612842565b61275982828660800151612842565b6040517f6a6278420000000000000000000000000000000000000000000000000000000081526000906001600160a01b03831690636a627842906127a1903390600401614d1b565b602060405180830381600087803b1580156127bb57600080fd5b505af11580156127cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127f39190614afa565b9050816001600160a01b03167fa33a5608dbfba36866993653adf08bb56b0f5fde40fcdd3c2732092d1f5f1c4882888860405161283293929190615911565b60405180910390a2505050505050565b60006060846001600160a01b031663a9059cbb8585604051602401612868929190614d53565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516128b69190614cff565b6000604051808303816000865af19150503d80600081146128f3576040519150601f19603f3d011682016040523d82523d6000602084013e6128f8565b606091505b50915091508180156129225750805115806129225750808060200190518101906129229190614a33565b61293e5760405162461bcd60e51b815260040161055890615726565b5050505050565b604080516000808252602082019092526001600160a01b03841690839060405161296f9190614cff565b60006040518083038185875af1925050503d80600081146129ac576040519150601f19603f3d011682016040523d82523d6000602084013e6129b1565b606091505b50509050806107d45760405162461bcd60e51b81526004016105589061523a565b60008160000151826020015183606001516040516020016129f593929190614dd5565b604051602081830303815290604052805190602001208260400151149050919050565b6000806000806000806000806000806000806000612a398e60600151613bda565b975050965096509650965096509650612a528787613c19565b909d509b50428110612c3c576000612a8b7f00000000000000000000000000000000000000000000000000000000000000008f8f613206565b90506001600160a01b038116612ab35760405162461bcd60e51b8152600401610558906154e7565b612ac18e8e88888888613c45565b919d509b5098506001896005811115612ad657fe5b1415612c36578d6001600160a01b031663fa6171e4828e6040518363ffffffff1660e01b8152600401612b0a929190614d53565b600060405180830381600087803b158015612b2457600080fd5b505af1158015612b38573d6000803e3d6000fd5b505050508c6001600160a01b031663fa6171e4828d6040518363ffffffff1660e01b8152600401612b6a929190614d53565b600060405180830381600087803b158015612b8457600080fd5b505af1158015612b98573d6000803e3d6000fd5b50506040517f6a6278420000000000000000000000000000000000000000000000000000000081526001600160a01b0384169250636a6278429150612be1903390600401614d1b565b602060405180830381600087803b158015612bfb57600080fd5b505af1158015612c0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c339190614afa565b99505b50612c41565b600297505b50949a509298505050505091939550919395565b887f5bd1fbac372bf6d0e59065858f811ff6b527196d9d6a0f9229e7002bee868070826040518060e001604052808b612c8f576002612c92565b60015b60ff1681526020018c81526020018a6001600160a01b03168152602001896001600160a01b0316815260200188815260200187815260200186815250604051612cdc929190614e08565b60405180910390a2505050505050505050565b6000806000806000806000806000806000612d0d8c60600151613dd9565b939c5091995097509095509193509150612d2990508282613c19565b909b50995042831015612d4e5760405162461bcd60e51b81526004016105589061557b565b6000612d7b7f00000000000000000000000000000000000000000000000000000000000000008d8d613206565b90506001600160a01b038116612da35760405162461bcd60e51b8152600401610558906154e7565b600080826001600160a01b0316637b4fb8588b6040518263ffffffff1660e01b8152600401612dd29190615908565b604080518083038186803b158015612de957600080fd5b505afa158015612dfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e219190614b77565b915091506000612e318f8f613740565b509050806001600160a01b03168f6001600160a01b031614612e54578183612e57565b82825b909d509b50888d10801590612e6c5750878c10155b1561309257836001600160a01b03166323b872dd33868e6040518463ffffffff1660e01b8152600401612ea193929190614d2f565b602060405180830381600087803b158015612ebb57600080fd5b505af1158015612ecf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ef39190614a33565b506040517f89afcb440000000000000000000000000000000000000000000000000000000081526001600160a01b038516906389afcb4490612f39903090600401614d1b565b6040805180830381600087803b158015612f5257600080fd5b505af1158015612f66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f8a9190614b77565b9099509750828914612fae5760405162461bcd60e51b81526004016105589061566c565b878214612fcd5760405162461bcd60e51b8152600401610558906155b2565b8e6001600160a01b03166342966c688e6040518263ffffffff1660e01b8152600401612ff99190615908565b600060405180830381600087803b15801561301357600080fd5b505af1158015613027573d6000803e3d6000fd5b505050508d6001600160a01b03166342966c688d6040518263ffffffff1660e01b81526004016130579190615908565b600060405180830381600087803b15801561307157600080fd5b505af1158015613085573d6000803e3d6000fd5b50505050600199506130ac565b888d101561309f57600399505b878c10156130ac57600499505b50939c50919a5050505050505091939550919395565b60606002825110156130e65760405162461bcd60e51b815260040161055890615544565b815167ffffffffffffffff811180156130fe57600080fd5b50604051908082528060200260200182016040528015613128578160200160208202803683370190505b509050828160008151811061313957fe5b60200260200101818152505060005b60018351038110156131fe57600080600061318d8887868151811061316957fe5b602002602001015188876001018151811061318057fe5b6020026020010151613e0f565b925092509250806131bb576131b68585815181106131a757fe5b60200260200101518484613f75565b6131d9565b6131d98585815181106131ca57fe5b60200260200101518484614027565b8585600101815181106131e857fe5b6020908102919091010152505050600101613148565b509392505050565b6040517fe6a439050000000000000000000000000000000000000000000000000000000081526000906001600160a01b0385169063e6a43905906132509086908690600401614d6c565b60206040518083038186803b15801561326857600080fd5b505afa15801561327c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061136291906145d6565b60006060856001600160a01b03166323b872dd8686866040516024016132c893929190614d2f565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516133169190614cff565b6000604051808303816000865af19150503d8060008114613353576040519150601f19603f3d011682016040523d82523d6000602084013e613358565b606091505b50915091508180156133825750805115806133825750808060200190518101906133829190614a33565b61339e5760405162461bcd60e51b8152600401610558906151dd565b505050505050565b60005b6001835103811015613560576000808483815181106133c457fe5b60200260200101518584600101815181106133db57fe5b60200260200101519150915060006133f38383613740565b509050600087856001018151811061340757fe5b60200260200101519050600080836001600160a01b0316866001600160a01b03161461343557826000613439565b6000835b91509150600060028a510388106134505788613491565b6134917f0000000000000000000000000000000000000000000000000000000000000000878c8b6002018151811061348457fe5b6020026020010151613206565b90506134be7f00000000000000000000000000000000000000000000000000000000000000008888613206565b6001600160a01b031663022c0d9f84848460006040519080825280601f01601f1916602001820160405280156134fb576020820181803683370190505b506040518563ffffffff1660e01b815260040161351b949392919061594a565b600060405180830381600087803b15801561353557600080fd5b505af1158015613549573d6000803e3d6000fd5b5050600190990198506133a9975050505050505050565b50505050565b606060028251101561358a5760405162461bcd60e51b815260040161055890615544565b815167ffffffffffffffff811180156135a257600080fd5b506040519080825280602002602001820160405280156135cc578160200160208202803683370190505b50905082816001835103815181106135e057fe5b602090810291909101015281517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff015b80156131fe5760008060006136428887600187038151811061362e57fe5b602002602001015188878151811061318057fe5b925092509250806136705761366b85858151811061365c57fe5b60200260200101518484614088565b61368e565b61368e85858151811061367f57fe5b6020026020010151848461413a565b85600186038151811061369d57fe5b60209081029190910101525050507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01613610565b60008084116136f35760405162461bcd60e51b8152600401610558906156c9565b6000831180156137035750600082115b61371f5760405162461bcd60e51b81526004016105589061560f565b82613730858463ffffffff6141b916565b8161373757fe5b04949350505050565b600080826001600160a01b0316846001600160a01b031614156137755760405162461bcd60e51b815260040161055890615351565b826001600160a01b0316846001600160a01b031610613795578284613798565b83835b90925090506001600160a01b0382166137c35760405162461bcd60e51b815260040161055890615783565b9250929050565b6137d2610e3b565b156137ef5760405162461bcd60e51b8152600401610558906154b0565b6000805460ff191660011790556040517f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2589061382c903390614d1b565b60405180910390a1565b61383e610e3b565b61385a5760405162461bcd60e51b815260040161055890614ef9565b6000805460ff191690556040517f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa9061382c903390614d1b565b60008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e6a439058a8a6040518363ffffffff1660e01b81526004016138e7929190614d6c565b60206040518083038186803b1580156138ff57600080fd5b505afa158015613913573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061393791906145d6565b90506001600160a01b038116613a60576001600160a01b03891660009081526003602052604090205460ff16801561398757506001600160a01b03881660009081526003602052604090205460ff165b156139a45760405162461bcd60e51b8152600401610558906152f4565b6040517fc9c653960000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c9c6539690613a0b908c908c90600401614d6c565b602060405180830381600087803b158015613a2557600080fd5b505af1158015613a39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a5d91906145d6565b90505b806001600160a01b03166303f8bfb06040518163ffffffff1660e01b815260040160206040518083038186803b158015613a9957600080fd5b505afa158015613aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ad19190614a33565b15613afa57613ade610c9a565b613afa5760405162461bcd60e51b815260040161055890614f67565b600080613b287f00000000000000000000000000000000000000000000000000000000000000008c8c6141f6565b91509150816000148015613b3a575080155b15613b4a57889450879350613bcc565b6000613b578a84846136d2565b9050888111613b8b5786811015613b805760405162461bcd60e51b815260040161055890615058565b899550935083613bca565b6000613b988a84866136d2565b90508a811115613ba457fe5b88811015613bc45760405162461bcd60e51b815260040161055890614ffb565b95508894505b505b505050965096945050505050565b60008060008060008060008088806020019051810190613bfa9190614666565b969e50949c50929a509098509650945092509050919395975091939597565b6001600160a01b0391821660009081526002602052604080822054928416825290205490821692911690565b6000806000806001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e6a439058b8b6040518363ffffffff1660e01b8152600401613ca2929190614d6c565b60206040518083038186803b158015613cba57600080fd5b505afa158015613cce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cf291906145d6565b6001600160a01b03161415613d0957506005613dcd565b600080613d377f00000000000000000000000000000000000000000000000000000000000000008c8c6141f6565b91509150816000148015613d49575080155b15613d5957889450879350613dc6565b6000613d668a84846136d2565b9050888111613d8f5786811015613d84575060049250613dcd915050565b899550935083613dc4565b6000613d9c8a84866136d2565b90508a811180613dab57508881105b15613dbe575060039350613dcd92505050565b95508894505b505b6001925050505b96509650969350505050565b600080600080600080600087806020019051810190613df891906145f2565b959e949d50929b5090995097509550909350915050565b600080600080613e1f8686613740565b5090506000613e2f888888613206565b9050600080826001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015613e6d57600080fd5b505afa158015613e81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ea59190614aa6565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff169150836001600160a01b0316896001600160a01b031614613eea578082613eed565b81815b8097508198505050826001600160a01b03166303f8bfb06040518163ffffffff1660e01b815260040160206040518083038186803b158015613f2e57600080fd5b505afa158015613f42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f669190614a33565b94505050505093509350939050565b6000808411613f965760405162461bcd60e51b815260040161055890615874565b600083118015613fa65750600082115b613fc25760405162461bcd60e51b81526004016105589061560f565b6000613fd6856103e563ffffffff6141b916565b90506000613fea828563ffffffff6141b916565b9050600061401083614004886103e863ffffffff6141b916565b9063ffffffff6142dd16565b905080828161401b57fe5b04979650505050505050565b60008084116140485760405162461bcd60e51b815260040161055890615874565b6000831180156140585750600082115b6140745760405162461bcd60e51b81526004016105589061560f565b6000613fd6856103e363ffffffff6141b916565b60008084116140a95760405162461bcd60e51b815260040161055890615149565b6000831180156140b95750600082115b6140d55760405162461bcd60e51b81526004016105589061560f565b60006140f96103e86140ed868863ffffffff6141b916565b9063ffffffff6141b916565b905060006141136103e56140ed868963ffffffff61430016565b9050614130600182848161412357fe5b049063ffffffff6142dd16565b9695505050505050565b600080841161415b5760405162461bcd60e51b815260040161055890615149565b60008311801561416b5750600082115b6141875760405162461bcd60e51b81526004016105589061560f565b600061419f6103e86140ed868863ffffffff6141b916565b905060006141136103e36140ed868963ffffffff61430016565b60008115806141d4575050808202828282816141d157fe5b04145b6141f05760405162461bcd60e51b815260040161055890614fc4565b92915050565b60008060006142058585613740565b509050600080614216888888613206565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561424e57600080fd5b505afa158015614262573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142869190614aa6565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff169150826001600160a01b0316876001600160a01b0316146142cb5780826142ce565b81815b90999098509650505050505050565b808201828110156141f05760405162461bcd60e51b8152600401610558906151a6565b808203828111156141f05760405162461bcd60e51b815260040161055890614ec2565b604080516080810182526000808252602082018190529181019190915260608082015290565b80356141f081615a01565b60008083601f840112614365578182fd5b50813567ffffffffffffffff81111561437c578182fd5b60208301915083602080830285010111156137c357600080fd5b600082601f8301126143a6578081fd5b81356143b96143b4826159b5565b61598e565b8181529150602080830190848101818402860182018710156143da57600080fd5b60005b848110156144025781356143f081615a16565b845292820192908201906001016143dd565b505050505092915050565b600082601f83011261441d578081fd5b813561442b6143b4826159b5565b81815291506020808301908481018184028601820187101561444c57600080fd5b60005b848110156144025781358452928201929082019060010161444f565b600082601f83011261447b578081fd5b813567ffffffffffffffff811115614491578182fd5b6144c260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160161598e565b91508082528360208285010111156144d957600080fd5b8060208401602084013760009082016020015292915050565b600060c08284031215614503578081fd5b61450d60c061598e565b90506145198383614349565b8152602082013567ffffffffffffffff8082111561453657600080fd5b6145428583860161446b565b6020840152604084013591508082111561455b57600080fd5b506145688482850161446b565b60408301525061457b83606084016145a2565b6060820152608082013560808201526145978360a08401614349565b60a082015292915050565b803560ff811681146141f057600080fd5b6000602082840312156145c4578081fd5b81356145cf81615a01565b9392505050565b6000602082840312156145e7578081fd5b81516145cf81615a01565b600080600080600080600060e0888a03121561460c578283fd5b875161461781615a01565b602089015190975061462881615a01565b8096505060408801519450606088015193506080880151925060a088015161464f81615a01565b8092505060c0880151905092959891949750929550565b600080600080600080600080610100898b031215614682578182fd5b885161468d81615a01565b60208a015190985061469e81615a01565b8097505060408901519550606089015194506080890151935060a0890151925060c08901516146cc81615a01565b8092505060e089015190509295985092959890939650565b600080600080600080600060e0888a0312156146fe578081fd5b873561470981615a01565b9650602088013561471981615a01565b955060408801359450606088013593506080880135925060a088013561473e81615a01565b8092505060c0880135905092959891949750929550565b600080600080600080600080610100898b031215614771578182fd5b883561477c81615a01565b9750602089013561478c81615a01565b965060408901359550606089013594506080890135935060a0890135925060c08901356147b881615a01565b8092505060e089013590509295985092959890939650565b60008060008060008060c087890312156147e8578384fd5b86356147f381615a01565b9550602087013594506040870135935060608701359250608087013561481881615a01565b8092505060a087013590509295509295509295565b6000806040838503121561483f578182fd5b823567ffffffffffffffff80821115614856578384fd5b81850186601f820112614867578485fd5b803592506148776143b4846159b5565b80848252602080830192508084018a828389028701011115614897578889fd5b8894505b868510156148c1576148ad8b82614349565b84526001949094019392810192810161489b565b5090965087013593505050808211156148d8578283fd5b506148e585828601614396565b9150509250929050565b60008060408385031215614901578182fd5b823567ffffffffffffffff80821115614918578384fd5b81850186601f820112614929578485fd5b803592506149396143b4846159b5565b83815260208082019190838101885b878110156149f2578135860160807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0828f03011215614985578a8bfd5b61498f608061598e565b8482013561499c81615a16565b815260408201356149ac81615a01565b81860152606082013560408201526080820135898111156149cb578c8dfd5b6149d98f878386010161446b565b6060830152508652509382019390820190600101614948565b50919750880135945050505080821115614a0a578283fd5b506148e58582860161440d565b600060208284031215614a28578081fd5b81356145cf81615a16565b600060208284031215614a44578081fd5b81516145cf81615a16565b60008060408385031215614a61578182fd5b823567ffffffffffffffff80821115614a78578384fd5b614a84868387016144f2565b93506020850135915080821115614a99578283fd5b506148e5858286016144f2565b600080600060608486031215614aba578081fd5b8351614ac581615a24565b6020850151909350614ad681615a24565b604085015190925063ffffffff81168114614aef578182fd5b809150509250925092565b600060208284031215614b0b578081fd5b5051919050565b600080600080600060808688031215614b29578283fd5b85359450602086013567ffffffffffffffff811115614b46578384fd5b614b5288828901614354565b9095509350506040860135614b6681615a01565b949793965091946060013592915050565b60008060408385031215614b89578182fd5b505080516020909101519092909150565b60008060008060008060a08789031215614bb2578384fd5b8635955060208701359450604087013567ffffffffffffffff811115614bd6578485fd5b614be289828a01614354565b9095509350506060870135614bf681615a01565b80925050608087013590509295509295509295565b600080600060608486031215614c1f578081fd5b505081359360208301359350604090920135919050565b6001600160a01b03169052565b60008151808452614c5b8160208601602086016159d5565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60006001600160a01b03808351168452602083015160c06020860152614cb660c0860182614c43565b604085015191508581036040870152614ccf8183614c43565b60ff6060870151166060880152608086015160808801528360a08701511660a08801528094505050505092915050565b60008251614d118184602087016159d5565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0392831681529116602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015614dbe57835183529284019291840191600101614da2565b50909695505050505050565b901515815260200190565b600084151582526001600160a01b038416602083015260606040830152614dff6060830184614c43565b95945050505050565b610100810160068410614e1757fe5b83825260ff8351166020830152602083015160408301526001600160a01b0360408401511660608301526060830151614e536080840182614c36565b50608083015160a083015260a083015160c083015260c083015160e08301529392505050565b600060808252614e8c6080830187614c43565b8281036020840152614e9e8187614c43565b91505060ff841660408301526001600160a01b038316606083015295945050505050565b60208082526015908201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604082015260600190565b60208082526014908201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604082015260600190565b6020808252601e908201527f4863537761705632526f75746572417661783a57524f4e475f494e4445580000604082015260600190565b60208082526036908201527f4863537761705632526f757465723a3a5f6164644c6971756964697479204f4e60408201527f4c595f4f505f43414e5f4144445f43524f53535f4c5000000000000000000000606082015260800190565b60208082526014908201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604082015260600190565b60208082526025908201527f4863537761705632526f757465723a20494e53554646494349454e545f415f4160408201527f4d4f554e54000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526025908201527f4863537761705632526f757465723a20494e53554646494349454e545f425f4160408201527f4d4f554e54000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526029908201527f4863537761705632526f757465723a5345545f43524f53535f544f4b454e5f5760408201527f524f4e475f444154410000000000000000000000000000000000000000000000606082015260800190565b6020808252601c908201527f4863537761705632526f757465723a4f4e4c595f4f50455241544f5200000000604082015260600190565b6020808252602c908201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4f60408201527f55545055545f414d4f554e540000000000000000000000000000000000000000606082015260800190565b60208082526014908201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604082015260600190565b60208082526031908201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a20747260408201527f616e7366657246726f6d206661696c6564000000000000000000000000000000606082015260800190565b60208082526034908201527f5472616e7366657248656c7065723a3a736166655472616e736665724554483a60408201527f20455448207472616e73666572206661696c6564000000000000000000000000606082015260800190565b6020808252602a908201527f4863537761705632526f757465723a20494e53554646494349454e545f4f555460408201527f5055545f414d4f554e5400000000000000000000000000000000000000000000606082015260800190565b6020808252603a908201527f4863537761705632526f757465723a3a5f6164644c697175696469747920435260408201527f4f53535f544f4b454e5f4e4f545f414c4c4f575f435245415445000000000000606082015260800190565b60208082526025908201527f556e697377617056324c6962726172793a204944454e544943414c5f4144445260408201527f4553534553000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601c908201527f4863537761705632526f757465723a20494e56414c49445f5041544800000000604082015260600190565b60208082526021908201527f4863537761705632526f75746572417661783a57524f4e475f434845434b535560408201527f4d00000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601d908201527f4863537761705632526f75746572417661783a57524f4e475f44415441000000604082015260600190565b60208082526017908201527f4863537761705632526f757465723a2045585049524544000000000000000000604082015260600190565b60208082526010908201527f5061757361626c653a2070617573656400000000000000000000000000000000604082015260600190565b6020808252602c908201527f4863537761705632526f757465723a3a6f6e52656d6f76654c5043726f73735460408201527f61736b3a204e4f5f504149520000000000000000000000000000000000000000606082015260800190565b6020808252601e908201527f556e697377617056324c6962726172793a20494e56414c49445f504154480000604082015260600190565b6020808252601d908201527f4863537761705632526f757465723a2043524f53535f45585049524544000000604082015260600190565b60208082526032908201527f4863537761705632526f757465723a3a6f6e52656d6f76654c5043726f73735460408201527f61736b3a20414d4f554e54315f57524f4e470000000000000000000000000000606082015260800190565b60208082526028908201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4c60408201527f4951554944495459000000000000000000000000000000000000000000000000606082015260800190565b60208082526032908201527f4863537761705632526f757465723a3a6f6e52656d6f76654c5043726f73735460408201527f61736b3a20414d4f554e54305f57524f4e470000000000000000000000000000606082015260800190565b60208082526025908201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4160408201527f4d4f554e54000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602d908201527f5472616e7366657248656c7065723a3a736166655472616e736665723a20747260408201527f616e73666572206661696c656400000000000000000000000000000000000000606082015260800190565b6020808252601e908201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604082015260600190565b60208082526026908201527f4863537761705632526f757465723a204558434553534956455f494e5055545f60408201527f414d4f554e540000000000000000000000000000000000000000000000000000606082015260800190565b60208082526026908201527f4863537761705632526f757465723a5345545f4f50455241544f525f57524f4e60408201527f475f444154410000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602b908201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4960408201527f4e5055545f414d4f554e54000000000000000000000000000000000000000000606082015260800190565b6020808252601a908201527f4863537761705632526f757465723a204f4e4c595f4f574e4552000000000000604082015260600190565b90815260200190565b60008482526060602083015261592a6060830185614c8d565b82810360408401526141308185614c8d565b918252602082015260400190565b60008582528460208301526001600160a01b0384166040830152608060608301526141306080830184614c43565b9283526020830191909152604082015260600190565b60405181810167ffffffffffffffff811182821017156159ad57600080fd5b604052919050565b600067ffffffffffffffff8211156159cb578081fd5b5060209081020190565b60005b838110156159f05781810151838201526020016159d8565b838111156135605750506000910152565b6001600160a01b03811681146115f757600080fd5b80151581146115f757600080fd5b6dffffffffffffffffffffffffffff811681146115f757600080fdfea26469706673582212203f5b3a0dba09383a4e1578f2e19934540e857cb4aa6bb71ce92612330eba2fa764736f6c634300060600330000000000000000000000008e6f4af0b6c26d16febdd6f28fa7c694bd49c6bf000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c70000000000000000000000007bff46929dfac8fb52bc663f5a4eb62fd8bd1ec8

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

0000000000000000000000008e6f4af0b6c26d16febdd6f28fa7c694bd49c6bf000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c70000000000000000000000007bff46929dfac8fb52bc663f5a4eb62fd8bd1ec8

-----Decoded View---------------
Arg [0] : _factory (address): 0x8e6f4af0b6c26d16febdd6f28fa7c694bd49c6bf
Arg [1] : _WETH (address): 0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7
Arg [2] : _tokenFactory (address): 0x7bff46929dfac8fb52bc663f5a4eb62fd8bd1ec8

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000008e6f4af0b6c26d16febdd6f28fa7c694bd49c6bf
Arg [1] : 000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7
Arg [2] : 0000000000000000000000007bff46929dfac8fb52bc663f5a4eb62fd8bd1ec8


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.