Contract 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d89 13

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xafcb3a59c892d1cb86c4a502d1bb5166aa2703bf83b6a6b11be4306ff1d9d74dSwap Tokens To E...1853942012024-02-28 16:34:1112 hrs 42 mins ago0x5f05ed08e67cbd71e5f4819146c5409f405baee7 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.000516370.1
0xb809c8ee4f43568c3b8d7fcd50567503ae89d4edbe0c0abe7580f81db983573eDecrease Positio...1853933442024-02-28 16:30:3712 hrs 46 mins ago0x5f05ed08e67cbd71e5f4819146c5409f405baee7 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00056429 0.1
0xc4433ecfcb24af8b1d6c5a494ff0d37fc91d2477e765b7529f94428b7c40a872Swap Tokens To E...1850926012024-02-27 19:07:391 day 10 hrs ago0x04d98f2a8385f0ae437939e599539af531f96cba IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00050554 0.1
0x452429b25cb9d448f89a090e01a7ef757330c7cdf8dc4950757e97d7b9659970Swap Tokens To E...1850193912024-02-27 13:54:551 day 15 hrs ago0x02b8d062278db3ca6e27e88171d60bc71a076cea IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00046503 0.1
0xcc53d5a5ac77d5761f242a773dc9a902c98d9370bc40052c2d8e477d71da99f3Swap Tokens To E...1847792332024-02-26 20:47:582 days 8 hrs ago0x18afd65b6b18d14627a556ef56b989f93b9fc296 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00054206 0.1
0x439cec84fb30d41387f09b1d113a9561028251d54d6dbc7a300b350c61fb9f56Swap Tokens To E...1844240272024-02-25 19:32:113 days 9 hrs ago0x126e393d2e512d4284e8e8a82bb6f102f5051c1f IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00028457 0.1
0x563a299b3e66badf94ba561befeadd3173c7413cd72e58c1c30cea7e7179d4b2Swap Tokens To E...1840509212024-02-24 16:39:484 days 12 hrs ago0x15ee4a46c6a92b7924970494f645898c6925e41f IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00034071 0.1
0x10fd0260605995b835063dba3677007e1e4ed6de2d4e2a56b119b71d1a589ed5Swap Tokens To E...1813007782024-02-16 10:09:4112 days 19 hrs ago0x2dcf3613f8b28c8ac645f58bd1d8ee1c539306a0 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00023126 0.1
0xe23e06146e1be59b39e2a58d17be172a7ec0de3e972f12daebe34165a245ca9aDecrease Positio...1812996922024-02-16 10:05:0312 days 19 hrs ago0x2dcf3613f8b28c8ac645f58bd1d8ee1c539306a0 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00018739 0.1
0x7a2301b6ba25b09a4698f6d957bad6d584c4170f7cfeae6b265c287b03d151e7Swap ETH To Toke...1811371802024-02-15 22:24:2913 days 6 hrs ago0xb178bddc38ef87b65331c4181214ab1f4aab8069 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.003 ETH0.00027907 0.1
0x5be3d28bff91996cec35fa9aac4d7a4065226fe1f55a7d3d98a16b53ed140319Decrease Positio...1806107332024-02-14 8:44:1014 days 20 hrs ago0xac23f132bb2e26c9c3609cf502eae78046786202 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00023994 0.1
0xfb6f4a2d7ef172f56f6dd6ca0c92364773f032c916d3d7f6fa6e0819761579baDecrease Positio...1803122432024-02-13 11:28:2315 days 17 hrs ago0x6cccf6db7e41d3451c799cc99769d70da86c251a IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00022716 0.1
0x527f056cb143b00f5f8ec9b78bdc5b1654b4694f180b0162075ae6fc0e66297bDecrease Positio...1802163252024-02-13 4:45:0016 days 32 mins ago0x90c0bf8d71369d21f8addf0da33d21dcb0b1c384 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.000184210.1
0x105dc9a96dd7458f5bf01c54c756613c529c3a9a55e7a287debb28a6f107e174Swap Tokens To E...1800615712024-02-12 17:25:1716 days 11 hrs ago0x03dac5270f05a7fd9befde1ce034aa0eb76c3020 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00035565 0.1
0xe047cf93281d2243b0e3e35b2dd1d98ab75f9221b6066d908dd73978a46798d7Swap Tokens To E...1799364782024-02-12 8:38:3316 days 20 hrs ago0x3172f3987ce48f265b20d55b3a56fd97e0342137 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00021287 0.1
0xd6670fc81bb95f2e6674e265b5b00375e804aac1b60256b3d97d395cd5c6181cDecrease Positio...1799362072024-02-12 8:37:2416 days 20 hrs ago0x3172f3987ce48f265b20d55b3a56fd97e0342137 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00023236 0.1
0x59c1b5f24fdbc825dd93a9ad4e9cd43cd6de9a01d90c3ecb4cdb6179e6fb94e2Swap Tokens To E...1798815792024-02-12 4:42:4417 days 34 mins ago0x372c9bc8b61f47226bd8e2008d76ce3633c275d0 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00023362 0.1
0xdda28cde8c2509701301088cded52b0db64f2729a3d4ea9ee3d25c5acdb71ba6Swap ETH To Toke...1798566052024-02-12 2:56:1917 days 2 hrs ago0x71a9e62ed4feea0f66cbbd1bc43261daebdb0b62 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.008 ETH0.00021858 0.1
0x181e5e89a8a186334c4d8684e8055e6418f4051b46cb214b2487da04ba169eaeDecrease Positio...1791222892024-02-09 21:46:2619 days 7 hrs ago0x205a7f99b821640d0273e21c67710042830c6b21 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00039541 0.1
0x25cc06af7475f8ea7afa4c98a914618efd44a55543fa89df5e7ea111086154e2Decrease Positio...1789514142024-02-09 9:13:1219 days 20 hrs ago0x5b35cbc7239eab9bf8bd9ddc23872757c167bf75 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00036702 0.1
0x2f58c3fb3eac376e6d281204c4d7a1dc6bfa0bc31e008dff055f30245b3ed883Swap Tokens To E...1786654942024-02-08 11:49:0320 days 17 hrs ago0x67d645828c55beb21513efcc753df032b31fb507 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00046629 0.1
0x5e31671164766836a850de70057828501b69e92e11e3e2455e18a40d298b62feSwap Tokens To E...1783173312024-02-07 10:45:3321 days 18 hrs ago0xaaca474a0f567c9628ebf52536d73cb7bbe1ed0c IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00028561 0.1
0x08c5d9ffb8440e364280f20d5a986c2eb95aadc69af95a8d50a6368dccd0482aDecrease Positio...1783088502024-02-07 10:08:4521 days 19 hrs ago0x269eb9ac8e342f58fe4f56f5d3bdcc03efd5b3c5 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00033374 0.1
0xd7aef1cf058102c042a36be142772530c3708b2981fdc9c5f82bbb0f68832230Swap Tokens To E...1779514742024-02-06 8:30:3122 days 20 hrs ago0x7371703453b2b71688847ebb30a9900bad083c00 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.0004454 0.1
0xc421b56299954753402f539dc11030f667969ed7ea618d24f1e2f8c4c59e66e1Swap Tokens To E...1778492732024-02-06 0:48:5823 days 4 hrs ago0xf75e7fe5c681911ffe5e3859d8d26562c6e33085 IN  0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890 ETH0.00022849 0.1
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xafcb3a59c892d1cb86c4a502d1bb5166aa2703bf83b6a6b11be4306ff1d9d74d1853942012024-02-28 16:34:1112 hrs 42 mins ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890x5f05ed08e67cbd71e5f4819146c5409f405baee70.002953234777854427 ETH
0xafcb3a59c892d1cb86c4a502d1bb5166aa2703bf83b6a6b11be4306ff1d9d74d1853942012024-02-28 16:34:1112 hrs 42 mins ago Wrapped Ether 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.002953234777854427 ETH
0xc4433ecfcb24af8b1d6c5a494ff0d37fc91d2477e765b7529f94428b7c40a8721850926012024-02-27 19:07:391 day 10 hrs ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890x04d98f2a8385f0ae437939e599539af531f96cba0.001557981643820319 ETH
0xc4433ecfcb24af8b1d6c5a494ff0d37fc91d2477e765b7529f94428b7c40a8721850926012024-02-27 19:07:391 day 10 hrs ago Wrapped Ether 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.001557981643820319 ETH
0x452429b25cb9d448f89a090e01a7ef757330c7cdf8dc4950757e97d7b96599701850193912024-02-27 13:54:551 day 15 hrs ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890x02b8d062278db3ca6e27e88171d60bc71a076cea0.002573113717355736 ETH
0x452429b25cb9d448f89a090e01a7ef757330c7cdf8dc4950757e97d7b96599701850193912024-02-27 13:54:551 day 15 hrs ago Wrapped Ether 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.002573113717355736 ETH
0xcc53d5a5ac77d5761f242a773dc9a902c98d9370bc40052c2d8e477d71da99f31847792332024-02-26 20:47:582 days 8 hrs ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890x18afd65b6b18d14627a556ef56b989f93b9fc2960.002955493300682778 ETH
0xcc53d5a5ac77d5761f242a773dc9a902c98d9370bc40052c2d8e477d71da99f31847792332024-02-26 20:47:582 days 8 hrs ago Wrapped Ether 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.002955493300682778 ETH
0x439cec84fb30d41387f09b1d113a9561028251d54d6dbc7a300b350c61fb9f561844240272024-02-25 19:32:113 days 9 hrs ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890x126e393d2e512d4284e8e8a82bb6f102f5051c1f0.009717846714235854 ETH
0x439cec84fb30d41387f09b1d113a9561028251d54d6dbc7a300b350c61fb9f561844240272024-02-25 19:32:113 days 9 hrs ago Wrapped Ether 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.009717846714235854 ETH
0x563a299b3e66badf94ba561befeadd3173c7413cd72e58c1c30cea7e7179d4b21840509212024-02-24 16:39:484 days 12 hrs ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890x15ee4a46c6a92b7924970494f645898c6925e41f0.002328815845863532 ETH
0x563a299b3e66badf94ba561befeadd3173c7413cd72e58c1c30cea7e7179d4b21840509212024-02-24 16:39:484 days 12 hrs ago Wrapped Ether 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.002328815845863532 ETH
0x10fd0260605995b835063dba3677007e1e4ed6de2d4e2a56b119b71d1a589ed51813007782024-02-16 10:09:4112 days 19 hrs ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890x2dcf3613f8b28c8ac645f58bd1d8ee1c539306a00.003356494273673081 ETH
0x10fd0260605995b835063dba3677007e1e4ed6de2d4e2a56b119b71d1a589ed51813007782024-02-16 10:09:4112 days 19 hrs ago Wrapped Ether 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.003356494273673081 ETH
0x7a2301b6ba25b09a4698f6d957bad6d584c4170f7cfeae6b265c287b03d151e71811371802024-02-15 22:24:2913 days 6 hrs ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d89 Wrapped Ether0.003 ETH
0x105dc9a96dd7458f5bf01c54c756613c529c3a9a55e7a287debb28a6f107e1741800615712024-02-12 17:25:1716 days 11 hrs ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890x03dac5270f05a7fd9befde1ce034aa0eb76c30200.002947540664558415 ETH
0x105dc9a96dd7458f5bf01c54c756613c529c3a9a55e7a287debb28a6f107e1741800615712024-02-12 17:25:1716 days 11 hrs ago Wrapped Ether 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.002947540664558415 ETH
0xe047cf93281d2243b0e3e35b2dd1d98ab75f9221b6066d908dd73978a46798d71799364782024-02-12 8:38:3316 days 20 hrs ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890x3172f3987ce48f265b20d55b3a56fd97e03421370.003431720089624225 ETH
0xe047cf93281d2243b0e3e35b2dd1d98ab75f9221b6066d908dd73978a46798d71799364782024-02-12 8:38:3316 days 20 hrs ago Wrapped Ether 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.003431720089624225 ETH
0x59c1b5f24fdbc825dd93a9ad4e9cd43cd6de9a01d90c3ecb4cdb6179e6fb94e21798815792024-02-12 4:42:4417 days 34 mins ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890x372c9bc8b61f47226bd8e2008d76ce3633c275d00.002370885137016839 ETH
0x59c1b5f24fdbc825dd93a9ad4e9cd43cd6de9a01d90c3ecb4cdb6179e6fb94e21798815792024-02-12 4:42:4417 days 34 mins ago Wrapped Ether 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.002370885137016839 ETH
0xdda28cde8c2509701301088cded52b0db64f2729a3d4ea9ee3d25c5acdb71ba61798566052024-02-12 2:56:1917 days 2 hrs ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d89 Wrapped Ether0.008 ETH
0x2f58c3fb3eac376e6d281204c4d7a1dc6bfa0bc31e008dff055f30245b3ed8831786654942024-02-08 11:49:0320 days 17 hrs ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890x67d645828c55beb21513efcc753df032b31fb5070.004205636910995423 ETH
0x2f58c3fb3eac376e6d281204c4d7a1dc6bfa0bc31e008dff055f30245b3ed8831786654942024-02-08 11:49:0320 days 17 hrs ago Wrapped Ether 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890.004205636910995423 ETH
0x5e31671164766836a850de70057828501b69e92e11e3e2455e18a40d298b62fe1783173312024-02-07 10:45:3321 days 18 hrs ago 0x434b5245f6fe54d0c9f881d55c2ba27fe7132d890xaaca474a0f567c9628ebf52536d73cb7bbe1ed0c0.0032522573163059 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Router

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 11 : Router.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "../libraries/math/SafeMath.sol";
import "../libraries/token/IERC20.sol";
import "../libraries/token/SafeERC20.sol";
import "../libraries/utils/Address.sol";
import "../tokens/interfaces/IWETH.sol";
import "./interfaces/IVault.sol";
import "./interfaces/IVaultPriceFeed.sol";
import "./interfaces/IRouter.sol";
import "../rebates/IReferral.sol";

contract Router is IRouter {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;
    using Address for address payable;

    address public gov;

    // wrapped BNB / ETH
    address public immutable weth;
    address public immutable usdg;
    address public immutable vault;

    // Referral contract
    address public immutable referral;

    mapping(address => bool) public plugins;
    mapping(address => mapping(address => bool)) public approvedPlugins;

    event Swap(
        address account,
        address tokenIn,
        address tokenOut,
        uint256 amountIn,
        uint256 amountOut
    );

    modifier onlyGov() {
        require(msg.sender == gov, "Router: forbidden");
        _;
    }

    constructor(
        address _vault,
        address _usdg,
        address _weth,
        address _referral
    ) public {
        require(
            _vault != address(0) &&
                _usdg != address(0) &&
                _weth != address(0) &&
                _referral != address(0),
            "Addresses cannot be zero"
        );
        vault = _vault;
        usdg = _usdg;
        weth = _weth;
        referral = _referral;
        gov = msg.sender;
    }

    receive() external payable {
        require(msg.sender == weth, "Router: invalid sender");
    }

    function setGov(address _gov) external onlyGov {
        gov = _gov;
    }

    function addPlugin(address _plugin) external override onlyGov {
        plugins[_plugin] = true;
    }

    function removePlugin(address _plugin) external onlyGov {
        plugins[_plugin] = false;
    }

    function approvePlugin(address _plugin) external {
        approvedPlugins[msg.sender][_plugin] = true;
    }

    function denyPlugin(address _plugin) external {
        approvedPlugins[msg.sender][_plugin] = false;
    }

    function pluginTransfer(
        address _token,
        address _account,
        address _receiver,
        uint256 _amount
    ) external override {
        _validatePlugin(_account);
        IERC20(_token).safeTransferFrom(_account, _receiver, _amount);
    }

    function pluginIncreasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _sizeDelta,
        bool _isLong
    ) external override {
        _validatePlugin(_account);
        IVault(vault).increasePosition(
            _account,
            _collateralToken,
            _indexToken,
            _sizeDelta,
            _isLong
        );
    }

    function pluginDecreasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver
    ) external override returns (uint256) {
        _validatePlugin(_account);
        return
            IVault(vault).decreasePosition(
                _account,
                _collateralToken,
                _indexToken,
                _collateralDelta,
                _sizeDelta,
                _isLong,
                _receiver
            );
    }

    function directPoolDeposit(address _token, uint256 _amount) external {
        IERC20(_token).safeTransferFrom(_sender(), vault, _amount);
        IVault(vault).directPoolDeposit(_token);
    }

    function swap(
        address[] memory _path,
        uint256 _amountIn,
        uint256 _minOut,
        address _receiver,
        bytes calldata signedQuoteData
    ) public override {
        swapWithReferrer(
            _path,
            _amountIn,
            _minOut,
            _receiver,
            signedQuoteData,
            address(0)
        );
    }

    function swapWithReferrer(
        address[] memory _path,
        uint256 _amountIn,
        uint256 _minOut,
        address _receiver,
        bytes calldata signedQuoteData,
        address referrer
    ) public override {
        _setReferral(referrer);
        IVaultPriceFeed(IVault(vault).priceFeed()).h2sofaApplySignedQuote(
            signedQuoteData
        );

        IERC20(_path[0]).safeTransferFrom(_sender(), vault, _amountIn);
        uint256 amountOut = _swap(_path, _minOut, _receiver, _sender());
        emit Swap(
            msg.sender,
            _path[0],
            _path[_path.length - 1],
            _amountIn,
            amountOut
        );
    }

    function swapETHToTokens(
        address[] memory _path,
        uint256 _minOut,
        address _receiver,
        bytes calldata signedQuoteData
    ) external payable {
        swapETHToTokensWithReferrer(
            _path,
            _minOut,
            _receiver,
            signedQuoteData,
            address(0)
        );
    }

    function swapETHToTokensWithReferrer(
        address[] memory _path,
        uint256 _minOut,
        address _receiver,
        bytes calldata signedQuoteData,
        address referrer
    ) public payable {
        require(_path[0] == weth, "Router: invalid _path");

        _setReferral(referrer);
        IVaultPriceFeed(IVault(vault).priceFeed()).h2sofaApplySignedQuote(
            signedQuoteData
        );

        _transferETHToVault();
        uint256 amountOut = _swap(_path, _minOut, _receiver, _sender());
        emit Swap(
            msg.sender,
            _path[0],
            _path[_path.length - 1],
            msg.value,
            amountOut
        );
    }

    function swapTokensToETH(
        address[] memory _path,
        uint256 _amountIn,
        uint256 _minOut,
        address payable _receiver,
        bytes calldata signedQuoteData
    ) external {
        swapTokensToETHWithReferrer(
            _path,
            _amountIn,
            _minOut,
            _receiver,
            signedQuoteData,
            address(0)
        );
    }

    function swapTokensToETHWithReferrer(
        address[] memory _path,
        uint256 _amountIn,
        uint256 _minOut,
        address payable _receiver,
        bytes calldata signedQuoteData,
        address referrer
    ) public {
        require(_path[_path.length - 1] == weth, "Router: invalid _path");

        _setReferral(referrer);
        IVaultPriceFeed(IVault(vault).priceFeed()).h2sofaApplySignedQuote(
            signedQuoteData
        );

        IERC20(_path[0]).safeTransferFrom(_sender(), vault, _amountIn);
        uint256 amountOut = _swap(_path, _minOut, address(this), _sender());
        _transferOutETH(amountOut, _receiver);

        emit Swap(
            msg.sender,
            _path[0],
            _path[_path.length - 1],
            _amountIn,
            amountOut
        );
    }

    function increasePosition(
        address[] memory _path,
        address _indexToken,
        uint256 _amountIn,
        uint256 _minOut,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _price,
        bytes calldata signedQuoteData
    ) external {
        increasePositionWithReferrer(
            _path,
            _indexToken,
            _amountIn,
            _minOut,
            _sizeDelta,
            _isLong,
            _price,
            signedQuoteData,
            address(0)
        );
    }

    function increasePositionWithReferrer(
        address[] memory _path,
        address _indexToken,
        uint256 _amountIn,
        uint256 _minOut,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _price,
        bytes calldata signedQuoteData,
        address referrer
    ) public {
        _setReferral(referrer);
        IVaultPriceFeed(IVault(vault).priceFeed()).h2sofaApplySignedQuote(
            signedQuoteData
        );

        if (_amountIn > 0) {
            IERC20(_path[0]).safeTransferFrom(_sender(), vault, _amountIn);
        }
        if (_path.length > 1 && _amountIn > 0) {
            uint256 amountOut = _swap(_path, _minOut, address(this), _sender());
            IERC20(_path[_path.length - 1]).safeTransfer(vault, amountOut);
        }
        _increasePosition(
            _path[_path.length - 1],
            _indexToken,
            _sizeDelta,
            _isLong,
            _price
        );
    }

    function increasePositionETH(
        address[] memory _path,
        address _indexToken,
        uint256 _minOut,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _price,
        bytes calldata signedQuoteData
    ) external payable {
        increasePositionETHWithReferrer(
            _path,
            _indexToken,
            _minOut,
            _sizeDelta,
            _isLong,
            _price,
            signedQuoteData,
            address(0)
        );
    }

    function increasePositionETHWithReferrer(
        address[] memory _path,
        address _indexToken,
        uint256 _minOut,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _price,
        bytes calldata signedQuoteData,
        address referrer
    ) public payable {
        require(_path[0] == weth, "Router: invalid _path");

        _setReferral(referrer);
        IVaultPriceFeed(IVault(vault).priceFeed()).h2sofaApplySignedQuote(
            signedQuoteData
        );

        if (msg.value > 0) {
            _transferETHToVault();
        }
        if (_path.length > 1 && msg.value > 0) {
            uint256 amountOut = _swap(_path, _minOut, address(this), _sender());
            IERC20(_path[_path.length - 1]).safeTransfer(vault, amountOut);
        }
        _increasePosition(
            _path[_path.length - 1],
            _indexToken,
            _sizeDelta,
            _isLong,
            _price
        );
    }

    function decreasePosition(
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver,
        uint256 _price,
        bytes calldata signedQuoteData
    ) external {
        IVaultPriceFeed(IVault(vault).priceFeed()).h2sofaApplySignedQuote(
            signedQuoteData
        );

        _decreasePosition(
            _collateralToken,
            _indexToken,
            _collateralDelta,
            _sizeDelta,
            _isLong,
            _receiver,
            _price
        );
    }

    function decreasePositionETH(
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address payable _receiver,
        uint256 _price,
        bytes calldata signedQuoteData
    ) external {
        IVaultPriceFeed(IVault(vault).priceFeed()).h2sofaApplySignedQuote(
            signedQuoteData
        );

        uint256 amountOut = _decreasePosition(
            _collateralToken,
            _indexToken,
            _collateralDelta,
            _sizeDelta,
            _isLong,
            address(this),
            _price
        );
        _transferOutETH(amountOut, _receiver);
    }

    function decreasePositionAndSwap(
        address[] memory _path,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver,
        uint256 _price,
        uint256 _minOut,
        bytes calldata signedQuoteData
    ) public {
        IVaultPriceFeed(IVault(vault).priceFeed()).h2sofaApplySignedQuote(
            signedQuoteData
        );

        uint256 amount = _decreasePosition(
            _path[0],
            _indexToken,
            _collateralDelta,
            _sizeDelta,
            _isLong,
            address(this),
            _price
        );
        IERC20(_path[0]).safeTransfer(vault, amount);
        _swap(_path, _minOut, _receiver, _sender());
    }

    function decreasePositionAndSwapETH(
        address[] memory _path,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address payable _receiver,
        uint256 _price,
        uint256 _minOut,
        bytes calldata signedQuoteData
    ) public {
        require(_path[_path.length - 1] == weth, "Router: invalid _path");

        IVaultPriceFeed(IVault(vault).priceFeed()).h2sofaApplySignedQuote(
            signedQuoteData
        );

        uint256 amount = _decreasePosition(
            _path[0],
            _indexToken,
            _collateralDelta,
            _sizeDelta,
            _isLong,
            address(this),
            _price
        );
        IERC20(_path[0]).safeTransfer(vault, amount);
        uint256 amountOut = _swap(_path, _minOut, address(this), _sender());
        _transferOutETH(amountOut, _receiver);
    }

    function _increasePosition(
        address _collateralToken,
        address _indexToken,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _price
    ) private {
        if (_isLong) {
            require(
                IVault(vault).getMaxPrice(_indexToken) <= _price,
                "Router: mark price higher than limit"
            );
        } else {
            require(
                IVault(vault).getMinPrice(_indexToken) >= _price,
                "Router: mark price lower than limit"
            );
        }

        IVault(vault).increasePosition(
            _sender(),
            _collateralToken,
            _indexToken,
            _sizeDelta,
            _isLong
        );
    }

    function _decreasePosition(
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver,
        uint256 _price
    ) private returns (uint256) {
        if (_isLong) {
            require(
                IVault(vault).getMinPrice(_indexToken) >= _price,
                "Router: mark price lower than limit"
            );
        } else {
            require(
                IVault(vault).getMaxPrice(_indexToken) <= _price,
                "Router: mark price higher than limit"
            );
        }

        return
            IVault(vault).decreasePosition(
                _sender(),
                _collateralToken,
                _indexToken,
                _collateralDelta,
                _sizeDelta,
                _isLong,
                _receiver
            );
    }

    function _transferETHToVault() private {
        IWETH(weth).deposit{value: msg.value}();
        IERC20(weth).safeTransfer(vault, msg.value);
    }

    function _transferOutETH(uint256 _amountOut, address payable _receiver)
        private
    {
        IWETH(weth).withdraw(_amountOut);
        _receiver.sendValue(_amountOut);
    }

    function _swap(
        address[] memory _path,
        uint256 _minOut,
        address _receiver,
        address _rebateReceiver
    ) private returns (uint256) {
        if (_path.length == 2) {
            return
                _vaultSwap(
                    _path[0],
                    _path[1],
                    _minOut,
                    _receiver,
                    _rebateReceiver
                );
        }
        if (_path.length == 3) {
            uint256 midOut = _vaultSwap(
                _path[0],
                _path[1],
                0,
                address(this),
                _rebateReceiver
            );
            IERC20(_path[1]).safeTransfer(vault, midOut);
            return
                _vaultSwap(
                    _path[1],
                    _path[2],
                    _minOut,
                    _receiver,
                    _rebateReceiver
                );
        }

        revert("Router: invalid _path.length");
    }

    function _vaultSwap(
        address _tokenIn,
        address _tokenOut,
        uint256 _minOut,
        address _receiver,
        address _rebateReceiver
    ) private returns (uint256) {
        uint256 amountOut;

        if (_tokenOut == usdg) {
            // buyUSDG
            amountOut = IVault(vault).buyUSDG(_tokenIn, _receiver);
        } else if (_tokenIn == usdg) {
            // sellUSDG
            amountOut = IVault(vault).sellUSDG(_tokenOut, _receiver);
        } else {
            // swap
            amountOut = IVault(vault).swapWithRebateReceiver(
                _tokenIn,
                _tokenOut,
                _receiver,
                _rebateReceiver
            );
        }

        require(amountOut >= _minOut, "Router: insufficient amountOut");
        return amountOut;
    }

    function _sender() private view returns (address) {
        return msg.sender;
    }

    function _validatePlugin(address _account) private view {
        require(plugins[msg.sender], "Router: invalid plugin");
        require(
            approvedPlugins[_account][msg.sender],
            "Router: plugin not approved"
        );
    }

    function _setReferral(address referrer) private {
        IReferral(referral).setReferral(_sender(), referrer);
    }
}

File 2 of 11 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 3 of 11 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 4 of 11 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "./IERC20.sol";
import "../math/SafeMath.sol";
import "../utils/Address.sol";

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

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

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

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

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

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

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

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

File 5 of 11 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{value: amount}("");
        require(
            success,
            "Address: unable to send value, recipient may have reverted"
        );
    }

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return
            functionCallWithValue(
                target,
                data,
                value,
                "Address: low-level call with value failed"
            );
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(
            address(this).balance >= value,
            "Address: insufficient balance for call"
        );
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{value: value}(
            data
        );
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data)
        internal
        view
        returns (bytes memory)
    {
        return
            functionStaticCall(
                target,
                data,
                "Address: low-level static call failed"
            );
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.3._
     */
    function functionDelegateCall(address target, bytes memory data)
        internal
        returns (bytes memory)
    {
        return
            functionDelegateCall(
                target,
                data,
                "Address: low-level delegate call failed"
            );
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.3._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 6 of 11 : IWETH.sol
//SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IWETH {
    function deposit() external payable;

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

    function withdraw(uint256) external;
}

File 7 of 11 : IVault.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "./IVaultUtils.sol";

interface IVault {
    function isInitialized() external view returns (bool);

    function isSwapEnabled() external view returns (bool);

    function isLeverageEnabled() external view returns (bool);

    function setVaultUtils(IVaultUtils _vaultUtils) external;

    function setError(uint256 _errorCode, string calldata _error) external;

    function router() external view returns (address);

    function usdg() external view returns (address);

    function gov() external view returns (address);

    function whitelistedTokenCount() external view returns (uint256);

    function maxLeverage() external view returns (uint256);

    function minProfitTime() external view returns (uint256);

    function hasDynamicFees() external view returns (bool);

    function fundingInterval() external view returns (uint256);

    function totalTokenWeights() external view returns (uint256);

    function inManagerMode() external view returns (bool);

    function inPrivateLiquidationMode() external view returns (bool);

    function maxGasPrice() external view returns (uint256);

    function approvedRouters(address _account, address _router)
        external
        view
        returns (bool);

    function isLiquidator(address _account) external view returns (bool);

    function isManager(address _account) external view returns (bool);

    function minProfitBasisPoints(address _token)
        external
        view
        returns (uint256);

    function tokenBalances(address _token) external view returns (uint256);

    function lastFundingTimes(address _token) external view returns (uint256);

    function setMaxLeverage(uint256 _maxLeverage) external;

    function setInManagerMode(bool _inManagerMode) external;

    function setManager(address _manager, bool _isManager) external;

    function setIsSwapEnabled(bool _isSwapEnabled) external;

    function setIsLeverageEnabled(bool _isLeverageEnabled) external;

    function setMaxGasPrice(uint256 _maxGasPrice) external;

    function setUsdgAmount(address _token, uint256 _amount) external;

    function setBufferAmount(address _token, uint256 _amount) external;

    function setMaxGlobalShortSize(address _token, uint256 _amount) external;

    function setInPrivateLiquidationMode(bool _inPrivateLiquidationMode)
        external;

    function setLiquidator(address _liquidator, bool _isActive) external;

    function setFundingRate(
        uint256 _fundingInterval,
        uint256 _fundingRateFactor,
        uint256 _stableFundingRateFactor
    ) external;

    function setFees(
        uint256 _taxBasisPoints,
        uint256 _stableTaxBasisPoints,
        uint256 _mintBurnFeeBasisPoints,
        uint256 _swapFeeBasisPoints,
        uint256 _stableSwapFeeBasisPoints,
        uint256 _marginFeeBasisPoints,
        uint256 _liquidationFeeUsd,
        uint256 _minProfitTime,
        bool _hasDynamicFees
    ) external;

    function setTokenConfig(
        address _token,
        uint256 _tokenDecimals,
        uint256 _redemptionBps,
        uint256 _minProfitBps,
        uint256 _maxUsdgAmount,
        bool _isStable,
        bool _isShortable
    ) external;

    function setPriceFeed(address _priceFeed) external;

    function withdrawFees(address _token, address _receiver)
        external
        returns (uint256);

    function directPoolDeposit(address _token) external;

    function buyUSDG(address _token, address _receiver)
        external
        returns (uint256);

    function sellUSDG(address _token, address _receiver)
        external
        returns (uint256);

    function swap(
        address _tokenIn,
        address _tokenOut,
        address _receiver
    ) external returns (uint256);

    function swapWithRebateReceiver(
        address _tokenIn,
        address _tokenOut,
        address _receiver,
        address rebateReceiver
    ) external returns (uint256);

    function increasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _sizeDelta,
        bool _isLong
    ) external;

    function decreasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver
    ) external returns (uint256);

    function tokenToUsdMin(address _token, uint256 _tokenAmount)
        external
        view
        returns (uint256);

    function priceFeed() external view returns (address);

    function fundingRateFactor() external view returns (uint256);

    function stableFundingRateFactor() external view returns (uint256);

    function cumulativeFundingRates(address _token)
        external
        view
        returns (uint256);

    function getNextFundingRate(address _token) external view returns (uint256);

    function liquidationFeeUsd() external view returns (uint256);

    function taxBasisPoints() external view returns (uint256);

    function stableTaxBasisPoints() external view returns (uint256);

    function mintBurnFeeBasisPoints() external view returns (uint256);

    function swapFeeBasisPoints() external view returns (uint256);

    function stableSwapFeeBasisPoints() external view returns (uint256);

    function marginFeeBasisPoints() external view returns (uint256);

    function allWhitelistedTokensLength() external view returns (uint256);

    function allWhitelistedTokens(uint256) external view returns (address);

    function whitelistedTokens(address _token) external view returns (bool);

    function stableTokens(address _token) external view returns (bool);

    function shortableTokens(address _token) external view returns (bool);

    function feeReserves(address _token) external view returns (uint256);

    function globalShortSizes(address _token) external view returns (uint256);

    function globalShortAveragePrices(address _token)
        external
        view
        returns (uint256);

    function maxGlobalShortSizes(address _token)
        external
        view
        returns (uint256);

    function tokenDecimals(address _token) external view returns (uint256);

    function tokenWeights(address _token) external view returns (uint256);

    function guaranteedUsd(address _token) external view returns (uint256);

    function poolAmounts(address _token) external view returns (uint256);

    function bufferAmounts(address _token) external view returns (uint256);

    function reservedAmounts(address _token) external view returns (uint256);

    function usdgAmounts(address _token) external view returns (uint256);

    function maxUsdgAmounts(address _token) external view returns (uint256);

    function getRedemptionAmount(address _token, uint256 _usdgAmount)
        external
        view
        returns (uint256);

    function getMaxPrice(address _token) external view returns (uint256);

    function getMinPrice(address _token) external view returns (uint256);

    function getPosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong
    )
        external
        view
        returns (
            uint256,
            uint256,
            uint256,
            uint256,
            uint256,
            uint256,
            bool,
            uint256
        );

    function vaultUtils() external view returns (IVaultUtils);

    function usdToTokenMax(address _token, uint256 _usdAmount)
        external
        view
        returns (uint256);

    function usdToTokenMin(address _token, uint256 _usdAmount)
        external
        view
        returns (uint256);

    function getPositionKey(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong
    ) external pure returns (bytes32);
}

File 8 of 11 : IVaultPriceFeed.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IVaultPriceFeed {
    function adjustmentBasisPoints(address _token)
        external
        view
        returns (uint256);

    function isAdjustmentAdditive(address _token) external view returns (bool);

    function setH2soQuoteLifetimeSeconds(uint256 value) external;

    function setAdjustment(
        address _token,
        bool _isAdditive,
        uint256 _adjustmentBps
    ) external;

    function setUseV2Pricing(bool _useV2Pricing) external;

    function setIsAmmEnabled(bool _isEnabled) external;

    function setIsSecondaryPriceEnabled(bool _isEnabled) external;

    function setSpreadBasisPoints(address _token, uint256 _spreadBasisPoints)
        external;

    function setSpreadThresholdBasisPoints(uint256 _spreadThresholdBasisPoints)
        external;

    function setFavorPrimaryPrice(bool _favorPrimaryPrice) external;

    function setPriceSampleSpace(uint256 _priceSampleSpace) external;

    function setMaxStrictPriceDeviation(uint256 _maxStrictPriceDeviation)
        external;

    function getPrice(
        address _token,
        bool _maximise,
        bool _includeAmmPrice,
        bool _useSwapPricing
    ) external view returns (uint256);

    function getAmmPrice(address _token) external view returns (uint256);

    function getPrimaryPrice(address _token, bool _maximise)
        external
        view
        returns (uint256);

    function setTokenConfig(
        address _token,
        address _priceFeed,
        uint256 _priceDecimals,
        bool _isStrictStable
    ) external;

    function h2sofaApplySignedQuote(bytes calldata signedQuoteData) external;
}

File 9 of 11 : IRouter.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IRouter {
    function addPlugin(address _plugin) external;

    function pluginTransfer(
        address _token,
        address _account,
        address _receiver,
        uint256 _amount
    ) external;

    function pluginIncreasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _sizeDelta,
        bool _isLong
    ) external;

    function pluginDecreasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver
    ) external returns (uint256);

    function swapWithReferrer(
        address[] memory _path,
        uint256 _amountIn,
        uint256 _minOut,
        address _receiver,
        bytes calldata signedQuoteData,
        address referrer
    ) external;

    function swap(
        address[] memory _path,
        uint256 _amountIn,
        uint256 _minOut,
        address _receiver,
        bytes calldata signedQuoteData
    ) external;
}

File 10 of 11 : IReferral.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.6.12;

interface IReferral {
    function setReferral(address userAccount, address referralAccount) external;

    function getReferral(address userAccount) external view returns (address);
}

File 11 of 11 : IVaultUtils.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IVaultUtils {
    function updateCumulativeFundingRate(
        address _collateralToken,
        address _indexToken
    ) external returns (bool);

    function validateIncreasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _sizeDelta,
        bool _isLong
    ) external view;

    function validateDecreasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver
    ) external view;

    function validateLiquidation(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        bool _raise
    ) external view returns (uint256, uint256);

    function getEntryFundingRate(
        address _collateralToken,
        address _indexToken,
        bool _isLong
    ) external view returns (uint256);

    function getPositionFee(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        uint256 _sizeDelta
    ) external view returns (uint256);

    function getFundingFee(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        uint256 _size,
        uint256 _entryFundingRate
    ) external view returns (uint256);

    function getBuyUsdgFeeBasisPoints(address _token, uint256 _usdgAmount)
        external
        view
        returns (uint256);

    function getSellUsdgFeeBasisPoints(address _token, uint256 _usdgAmount)
        external
        view
        returns (uint256);

    function getSwapFeeBasisPoints(
        address _tokenIn,
        address _tokenOut,
        uint256 _usdgAmount
    ) external view returns (uint256);

    function getFeeBasisPoints(
        address _token,
        uint256 _usdgDelta,
        uint256 _feeBasisPoints,
        uint256 _taxBasisPoints,
        bool _increment
    ) external view returns (uint256);

    function getDelta(
        address _indexToken,
        uint256 _size,
        uint256 _averagePrice,
        bool _isLong,
        uint256 _lastIncreasedTime
    ) external view returns (bool, uint256);

    function getTargetUsdgAmount(address _token)
        external
        view
        returns (uint256);
}

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"_vault","type":"address"},{"internalType":"address","name":"_usdg","type":"address"},{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_referral","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":false,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"Swap","type":"event"},{"inputs":[{"internalType":"address","name":"_plugin","type":"address"}],"name":"addPlugin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_plugin","type":"address"}],"name":"approvePlugin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"approvedPlugins","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"}],"name":"decreasePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"}],"name":"decreasePositionAndSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"address payable","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"}],"name":"decreasePositionAndSwapETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"address payable","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"}],"name":"decreasePositionETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_plugin","type":"address"}],"name":"denyPlugin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"directPoolDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"gov","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"}],"name":"increasePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"}],"name":"increasePositionETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"},{"internalType":"address","name":"referrer","type":"address"}],"name":"increasePositionETHWithReferrer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"},{"internalType":"address","name":"referrer","type":"address"}],"name":"increasePositionWithReferrer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"pluginDecreasePosition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"}],"name":"pluginIncreasePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"pluginTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"plugins","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referral","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_plugin","type":"address"}],"name":"removePlugin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gov","type":"address"}],"name":"setGov","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"}],"name":"swap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"}],"name":"swapETHToTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"},{"internalType":"address","name":"referrer","type":"address"}],"name":"swapETHToTokensWithReferrer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"address payable","name":"_receiver","type":"address"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"}],"name":"swapTokensToETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"address payable","name":"_receiver","type":"address"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"},{"internalType":"address","name":"referrer","type":"address"}],"name":"swapTokensToETHWithReferrer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"bytes","name":"signedQuoteData","type":"bytes"},{"internalType":"address","name":"referrer","type":"address"}],"name":"swapWithReferrer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usdg","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

6101006040523480156200001257600080fd5b5060405162003e2838038062003e28833981810160405260808110156200003857600080fd5b50805160208201516040830151606090930151919290916001600160a01b038416158015906200007057506001600160a01b03831615155b80156200008557506001600160a01b03821615155b80156200009a57506001600160a01b03811615155b620000ec576040805162461bcd60e51b815260206004820152601860248201527f4164647265737365732063616e6e6f74206265207a65726f0000000000000000604482015290519081900360640190fd5b6001600160601b0319606094851b811660c05292841b831660a05290831b821660805290911b1660e052600080546001600160a01b0319163317905560805160601c60a05160601c60c05160601c60e05160601c613bf162000237600039806114e45280612ae35250806115a352806117e552806118ba52806119bf5280611af45280611c105280611d225280611e475280611ea15280611f2f5280611f56528061209452806121e1528061246f52806125aa52806126a1528061280852806129365280612a5e5280612abf5280612c205280612cde5280612eda5280612fb6528061308c52806131965280613272528061334852806134b752806135a4528061365c525080612a9b528061347d528061356a5250806101e1528061150852806119705280611ff952806123da52806126035280612b7e5280612bfc52806133e45250613bf16000f3fe6080604052600436106101d15760003560e01c8063877c7b8a116100f7578063cfad57a211610095578063e8d91a3a11610064578063e8d91a3a14611282578063f060febd1461133b578063f5b91b7b14611473578063fbfa77cf146114885761024e565b8063cfad57a214610fc3578063d8867fc814610ff6578063daffc8ec14611029578063e49b7329146111615761024e565b8063980a0578116100d1578063980a057814610d25578063a4d95b6414610e45578063cccc6e0514610e78578063cedd437514610f905761024e565b8063877c7b8a14610b7c57806390b64ad314610cb1578063956f285e14610cea5761024e565b806325ecda9a1161016f578063481e17e31161013e578063481e17e3146108565780634b12e6431461095b5780634f6970d9146109a25780636bb2529214610a5b5761024e565b806325ecda9a146106855780632662166b1461079b57806338c74dd91461080e5780633fc8cef3146108415761024e565b80631441a5a9116101ab5780631441a5a9146104c85780631b417cc8146104dd5780631b827878146105eb5780631f1dd176146106345761024e565b80630dde87fd1461025357806310a523161461036b57806312d43a51146104975761024e565b3661024e57336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461024c576040805162461bcd60e51b81526020600482015260166024820152752937baba32b91d1034b73b30b634b21039b2b73232b960511b604482015290519081900360640190fd5b005b600080fd5b34801561025f57600080fd5b5061024c600480360360a081101561027657600080fd5b810190602081018135600160201b81111561029057600080fd5b8201836020820111156102a257600080fd5b803590602001918460208302840111600160201b831117156102c357600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435956020860135956001600160a01b0360408201351695509193509150608081019060600135600160201b81111561032d57600080fd5b82018360208201111561033f57600080fd5b803590602001918460018302840111600160201b8311171561036057600080fd5b50909250905061149d565b34801561037757600080fd5b5061024c600480360361010081101561038f57600080fd5b810190602081018135600160201b8111156103a957600080fd5b8201836020820111156103bb57600080fd5b803590602001918460208302840111600160201b831117156103dc57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092956001600160a01b0385351695602086013595604081013595506060810135945060808101351515935060a081013592919060e081019060c00135600160201b81111561045957600080fd5b82018360208201111561046b57600080fd5b803590602001918460018302840111600160201b8311171561048c57600080fd5b5090925090506114b5565b3480156104a357600080fd5b506104ac6114d3565b604080516001600160a01b039092168252519081900360200190f35b3480156104d457600080fd5b506104ac6114e2565b61024c600480360360a08110156104f357600080fd5b810190602081018135600160201b81111561050d57600080fd5b82018360208201111561051f57600080fd5b803590602001918460208302840111600160201b8311171561054057600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435956001600160a01b0360208701351695919450925060608101915060400135600160201b8111156105a457600080fd5b8201836020820111156105b657600080fd5b803590602001918460018302840111600160201b831117156105d757600080fd5b9193509150356001600160a01b0316611506565b3480156105f757600080fd5b5061024c6004803603608081101561060e57600080fd5b506001600160a01b03813581169160208101358216916040820135169060600135611777565b34801561064057600080fd5b5061024c600480360360a081101561065757600080fd5b506001600160a01b03813581169160208101358216916040820135169060608101359060800135151561179b565b61024c600480360360e081101561069b57600080fd5b810190602081018135600160201b8111156106b557600080fd5b8201836020820111156106c757600080fd5b803590602001918460208302840111600160201b831117156106e857600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092956001600160a01b0385351695602086013595604081013595506060810135151594506080810135935060c081019060a00135600160201b81111561075d57600080fd5b82018360208201111561076f57600080fd5b803590602001918460018302840111600160201b8311171561079057600080fd5b509092509050611843565b3480156107a757600080fd5b506107fc600480360360e08110156107be57600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359160808201359160a081013515159160c0909101351661185f565b60408051918252519081900360200190f35b34801561081a57600080fd5b5061024c6004803603602081101561083157600080fd5b50356001600160a01b031661193d565b34801561084d57600080fd5b506104ac61196e565b61024c6004803603608081101561086c57600080fd5b810190602081018135600160201b81111561088657600080fd5b82018360208201111561089857600080fd5b803590602001918460208302840111600160201b831117156108b957600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435956001600160a01b0360208701351695919450925060608101915060400135600160201b81111561091d57600080fd5b82018360208201111561092f57600080fd5b803590602001918460018302840111600160201b8311171561095057600080fd5b509092509050611992565b34801561096757600080fd5b5061098e6004803603602081101561097e57600080fd5b50356001600160a01b03166119a8565b604080519115158252519081900360200190f35b3480156109ae57600080fd5b5061024c60048036036101008110156109c657600080fd5b6001600160a01b0382358116926020810135821692604082013592606083013592608081013515159260a08201359092169160c08201359190810190610100810160e0820135600160201b811115610a1d57600080fd5b820183602082011115610a2f57600080fd5b803590602001918460018302840111600160201b83111715610a5057600080fd5b5090925090506119bd565b348015610a6757600080fd5b5061024c600480360360c0811015610a7e57600080fd5b810190602081018135600160201b811115610a9857600080fd5b820183602082011115610aaa57600080fd5b803590602001918460208302840111600160201b83111715610acb57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435956020860135956001600160a01b0360408201351695509193509150608081019060600135600160201b811115610b3557600080fd5b820183602082011115610b4757600080fd5b803590602001918460018302840111600160201b83111715610b6857600080fd5b9193509150356001600160a01b0316611ae9565b348015610b8857600080fd5b5061024c6004803603610120811015610ba057600080fd5b810190602081018135600160201b811115610bba57600080fd5b820183602082011115610bcc57600080fd5b803590602001918460208302840111600160201b83111715610bed57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092956001600160a01b0385351695602086013595604081013595506060810135945060808101351515935060a081013592919060e081019060c00135600160201b811115610c6a57600080fd5b820183602082011115610c7c57600080fd5b803590602001918460018302840111600160201b83111715610c9d57600080fd5b9193509150356001600160a01b0316611d17565b348015610cbd57600080fd5b5061024c60048036036040811015610cd457600080fd5b506001600160a01b038135169060200135611f17565b348015610cf657600080fd5b5061098e60048036036040811015610d0d57600080fd5b506001600160a01b0381358116916020013516611fd7565b61024c6004803603610100811015610d3c57600080fd5b810190602081018135600160201b811115610d5657600080fd5b820183602082011115610d6857600080fd5b803590602001918460208302840111600160201b83111715610d8957600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092956001600160a01b0385351695602086013595604081013595506060810135151594506080810135935060c081019060a00135600160201b811115610dfe57600080fd5b820183602082011115610e1057600080fd5b803590602001918460018302840111600160201b83111715610e3157600080fd5b9193509150356001600160a01b0316611ff7565b348015610e5157600080fd5b5061024c60048036036020811015610e6857600080fd5b50356001600160a01b0316612237565b348015610e8457600080fd5b5061024c600480360360a0811015610e9b57600080fd5b810190602081018135600160201b811115610eb557600080fd5b820183602082011115610ec757600080fd5b803590602001918460208302840111600160201b83111715610ee857600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435956020860135956001600160a01b0360408201351695509193509150608081019060600135600160201b811115610f5257600080fd5b820183602082011115610f6457600080fd5b803590602001918460018302840111600160201b83111715610f8557600080fd5b5090925090506122ab565b348015610f9c57600080fd5b5061024c60048036036020811015610fb357600080fd5b50356001600160a01b03166122bb565b348015610fcf57600080fd5b5061024c60048036036020811015610fe657600080fd5b50356001600160a01b03166122e9565b34801561100257600080fd5b5061024c6004803603602081101561101957600080fd5b50356001600160a01b031661235e565b34801561103557600080fd5b5061024c600480360361012081101561104d57600080fd5b810190602081018135600160201b81111561106757600080fd5b82018360208201111561107957600080fd5b803590602001918460208302840111600160201b8311171561109a57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092956001600160a01b038535811696602087013596604081013596506060810135151595506080810135909216935060a08201359260c08301359290919061010081019060e00135600160201b81111561112357600080fd5b82018360208201111561113557600080fd5b803590602001918460018302840111600160201b8311171561115657600080fd5b5090925090506123d8565b34801561116d57600080fd5b5061024c600480360360c081101561118457600080fd5b810190602081018135600160201b81111561119e57600080fd5b8201836020820111156111b057600080fd5b803590602001918460208302840111600160201b831117156111d157600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435956020860135956001600160a01b0360408201351695509193509150608081019060600135600160201b81111561123b57600080fd5b82018360208201111561124d57600080fd5b803590602001918460018302840111600160201b8311171561126e57600080fd5b9193509150356001600160a01b0316612601565b34801561128e57600080fd5b5061024c60048036036101008110156112a657600080fd5b6001600160a01b0382358116926020810135821692604082013592606083013592608081013515159260a08201359092169160c08201359190810190610100810160e0820135600160201b8111156112fd57600080fd5b82018360208201111561130f57600080fd5b803590602001918460018302840111600160201b8311171561133057600080fd5b509092509050612806565b34801561134757600080fd5b5061024c600480360361012081101561135f57600080fd5b810190602081018135600160201b81111561137957600080fd5b82018360208201111561138b57600080fd5b803590602001918460208302840111600160201b831117156113ac57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092956001600160a01b038535811696602087013596604081013596506060810135151595506080810135909216935060a08201359260c08301359290919061010081019060e00135600160201b81111561143557600080fd5b82018360208201111561144757600080fd5b803590602001918460018302840111600160201b8311171561146857600080fd5b509092509050612934565b34801561147f57600080fd5b506104ac612a99565b34801561149457600080fd5b506104ac612abd565b6114ad8686868686866000611ae9565b505050505050565b6114c88989898989898989896000611d17565b505050505050505050565b6000546001600160a01b031681565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168660008151811061153d57fe5b60200260200101516001600160a01b031614611598576040805162461bcd60e51b81526020600482015260156024820152740a4deeae8cae47440d2dcecc2d8d2c840bee0c2e8d605b1b604482015290519081900360640190fd5b6115a181612ae1565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156115fa57600080fd5b505afa15801561160e573d6000803e3d6000fd5b505050506040513d602081101561162457600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018590526001600160a01b03909216916329adf8ba91869186918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b15801561169a57600080fd5b505af11580156116ae573d6000803e3d6000fd5b505050506116ba612b7c565b60006116cf8787876116ca612c49565b612c4d565b90507fcd3829a3813dc3cdd188fd3d01dcf3268c16be2fdd2dd21d0665418816e46062338860008151811061170057fe5b60200260200101518960018b51038151811061171857fe5b6020026020010151348560405180866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b031681526020018381526020018281526020019550505050505060405180910390a150505050505050565b61178083612d9d565b6117956001600160a01b038516848484612e75565b50505050565b6117a485612d9d565b604080516348d91abf60e01b81526001600160a01b0387811660048301528681166024830152858116604483015260648201859052831515608483015291517f0000000000000000000000000000000000000000000000000000000000000000909216916348d91abf9160a48082019260009290919082900301818387803b15801561182f57600080fd5b505af11580156114c8573d6000803e3d6000fd5b61185588888888888888886000611ff7565b5050505050505050565b600061186a88612d9d565b6040805163082a084960e41b81526001600160a01b038a8116600483015289811660248301528881166044830152606482018890526084820187905285151560a483015284811660c483015291517f0000000000000000000000000000000000000000000000000000000000000000909216916382a084909160e4808201926020929091908290030181600087803b15801561190557600080fd5b505af1158015611919573d6000803e3d6000fd5b505050506040513d602081101561192f57600080fd5b505198975050505050505050565b3360009081526002602090815260408083206001600160a01b0394909416835292905220805460ff19166001179055565b7f000000000000000000000000000000000000000000000000000000000000000081565b6119a185858585856000611506565b5050505050565b60016020526000908152604090205460ff1681565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b158015611a1657600080fd5b505afa158015611a2a573d6000803e3d6000fd5b505050506040513d6020811015611a4057600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018490526001600160a01b03909216916329adf8ba91859185918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b158015611ab657600080fd5b505af1158015611aca573d6000803e3d6000fd5b50505050611add89898989898989612ecf565b50505050505050505050565b611af281612ae1565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b4b57600080fd5b505afa158015611b5f573d6000803e3d6000fd5b505050506040513d6020811015611b7557600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018590526001600160a01b03909216916329adf8ba91869186918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b158015611beb57600080fd5b505af1158015611bff573d6000803e3d6000fd5b50505050611c5e611c0e612c49565b7f0000000000000000000000000000000000000000000000000000000000000000888a600081518110611c3d57fe5b60200260200101516001600160a01b0316612e75909392919063ffffffff16565b6000611c6e8887876116ca612c49565b90507fcd3829a3813dc3cdd188fd3d01dcf3268c16be2fdd2dd21d0665418816e460623389600081518110611c9f57fe5b60200260200101518a60018c510381518110611cb757fe5b60200260200101518a8560405180866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b031681526020018381526020018281526020019550505050505060405180910390a15050505050505050565b611d2081612ae1565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b158015611d7957600080fd5b505afa158015611d8d573d6000803e3d6000fd5b505050506040513d6020811015611da357600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018590526001600160a01b03909216916329adf8ba91869186918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b158015611e1957600080fd5b505af1158015611e2d573d6000803e3d6000fd5b505050506000881115611e7457611e74611e45612c49565b7f00000000000000000000000000000000000000000000000000000000000000008a8d600081518110611c3d57fe5b60018a51118015611e855750600088115b15611ef3576000611e9a8b89306116ca612c49565b9050611ef17f0000000000000000000000000000000000000000000000000000000000000000828d60018f510381518110611ed157fe5b60200260200101516001600160a01b03166131369092919063ffffffff16565b505b611add8a60018c510381518110611f0657fe5b60200260200101518a88888861318d565b611f54611f22612c49565b6001600160a01b038416907f000000000000000000000000000000000000000000000000000000000000000084612e75565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635f7bc119836040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015611fc357600080fd5b505af11580156114ad573d6000803e3d6000fd5b600260209081526000928352604080842090915290825290205460ff1681565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168960008151811061202e57fe5b60200260200101516001600160a01b031614612089576040805162461bcd60e51b81526020600482015260156024820152740a4deeae8cae47440d2dcecc2d8d2c840bee0c2e8d605b1b604482015290519081900360640190fd5b61209281612ae1565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156120eb57600080fd5b505afa1580156120ff573d6000803e3d6000fd5b505050506040513d602081101561211557600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018590526001600160a01b03909216916329adf8ba91869186918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b15801561218b57600080fd5b505af115801561219f573d6000803e3d6000fd5b5050505060003411156121b4576121b4612b7c565b600189511180156121c55750600034115b156122135760006121da8a89306116ca612c49565b90506122117f0000000000000000000000000000000000000000000000000000000000000000828c60018e510381518110611ed157fe5b505b6114c88960018b51038151811061222657fe5b60200260200101518988888861318d565b6000546001600160a01b0316331461228a576040805162461bcd60e51b81526020600482015260116024820152702937baba32b91d103337b93134b23232b760791b604482015290519081900360640190fd5b6001600160a01b03166000908152600160205260409020805460ff19169055565b6114ad8686868686866000612601565b3360009081526002602090815260408083206001600160a01b0394909416835292905220805460ff19169055565b6000546001600160a01b0316331461233c576040805162461bcd60e51b81526020600482015260116024820152702937baba32b91d103337b93134b23232b760791b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146123b1576040805162461bcd60e51b81526020600482015260116024820152702937baba32b91d103337b93134b23232b760791b604482015290519081900360640190fd5b6001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168a60018c51038151811061241257fe5b60200260200101516001600160a01b03161461246d576040805162461bcd60e51b81526020600482015260156024820152740a4deeae8cae47440d2dcecc2d8d2c840bee0c2e8d605b1b604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156124c657600080fd5b505afa1580156124da573d6000803e3d6000fd5b505050506040513d60208110156124f057600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018490526001600160a01b03909216916329adf8ba91859185918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b15801561256657600080fd5b505af115801561257a573d6000803e3d6000fd5b5050505060006125a38b60008151811061259057fe5b60200260200101518b8b8b8b308b612ecf565b90506125d77f0000000000000000000000000000000000000000000000000000000000000000828d600081518110611ed157fe5b60006125e78c86306116ca612c49565b90506125f381886133e2565b505050505050505050505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168760018951038151811061263b57fe5b60200260200101516001600160a01b031614612696576040805162461bcd60e51b81526020600482015260156024820152740a4deeae8cae47440d2dcecc2d8d2c840bee0c2e8d605b1b604482015290519081900360640190fd5b61269f81612ae1565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156126f857600080fd5b505afa15801561270c573d6000803e3d6000fd5b505050506040513d602081101561272257600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018590526001600160a01b03909216916329adf8ba91869186918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b15801561279857600080fd5b505af11580156127ac573d6000803e3d6000fd5b505050506127bb611c0e612c49565b60006127cb8887306116ca612c49565b90506127d781866133e2565b7fcd3829a3813dc3cdd188fd3d01dcf3268c16be2fdd2dd21d0665418816e460623389600081518110611c9f57fe5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561285f57600080fd5b505afa158015612873573d6000803e3d6000fd5b505050506040513d602081101561288957600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018490526001600160a01b03909216916329adf8ba91859185918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b1580156128ff57600080fd5b505af1158015612913573d6000803e3d6000fd5b5050505060006129288a8a8a8a8a308a612ecf565b9050611add81866133e2565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561298d57600080fd5b505afa1580156129a1573d6000803e3d6000fd5b505050506040513d60208110156129b757600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018490526001600160a01b03909216916329adf8ba91859185918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b158015612a2d57600080fd5b505af1158015612a41573d6000803e3d6000fd5b505050506000612a578b60008151811061259057fe5b9050612a8b7f0000000000000000000000000000000000000000000000000000000000000000828d600081518110611ed157fe5b6125f38b85886116ca612c49565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637543e3f0612b18612c49565b836040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b0316815260200192505050600060405180830381600087803b158015612b6857600080fd5b505af11580156119a1573d6000803e3d6000fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015612bd757600080fd5b505af1158015612beb573d6000803e3d6000fd5b50612c479350506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691507f0000000000000000000000000000000000000000000000000000000000000000905034613136565b565b3390565b6000845160021415612c9557612c8e85600081518110612c6957fe5b602002602001015186600181518110612c7e57fe5b6020026020010151868686613478565b9050612d95565b845160031415612d48576000612cd786600081518110612cb157fe5b602002602001015187600181518110612cc657fe5b602002602001015160003087613478565b9050612d0b7f00000000000000000000000000000000000000000000000000000000000000008288600181518110611ed157fe5b612d4086600181518110612d1b57fe5b602002602001015187600281518110612d3057fe5b6020026020010151878787613478565b915050612d95565b6040805162461bcd60e51b815260206004820152601c60248201527f526f757465723a20696e76616c6964205f706174682e6c656e67746800000000604482015290519081900360640190fd5b949350505050565b3360009081526001602052604090205460ff16612dfa576040805162461bcd60e51b81526020600482015260166024820152752937baba32b91d1034b73b30b634b21038363ab3b4b760511b604482015290519081900360640190fd5b6001600160a01b038116600090815260026020908152604080832033845290915290205460ff16612e72576040805162461bcd60e51b815260206004820152601b60248201527f526f757465723a20706c7567696e206e6f7420617070726f7665640000000000604482015290519081900360640190fd5b50565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611795908590613735565b60008315612fb357817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166381a612d6896040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612f4557600080fd5b505afa158015612f59573d6000803e3d6000fd5b505050506040513d6020811015612f6f57600080fd5b50511015612fae5760405162461bcd60e51b8152600401808060200182810382526023815260200180613b4b6023913960400191505060405180910390fd5b61308a565b817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e124e6d2896040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561302157600080fd5b505afa158015613035573d6000803e3d6000fd5b505050506040513d602081101561304b57600080fd5b5051111561308a5760405162461bcd60e51b8152600401808060200182810382526024815260200180613b986024913960400191505060405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166382a084906130c1612c49565b604080516001600160e01b031960e085901b1681526001600160a01b039283166004820152828d166024820152828c166044820152606481018b9052608481018a905288151560a482015291871660c48301525160e48083019260209291908290030181600087803b15801561190557600080fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052613188908490613735565b505050565b811561326f57807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e124e6d2866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561320157600080fd5b505afa158015613215573d6000803e3d6000fd5b505050506040513d602081101561322b57600080fd5b5051111561326a5760405162461bcd60e51b8152600401808060200182810382526024815260200180613b986024913960400191505060405180910390fd5b613346565b807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166381a612d6866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156132dd57600080fd5b505afa1580156132f1573d6000803e3d6000fd5b505050506040513d602081101561330757600080fd5b505110156133465760405162461bcd60e51b8152600401808060200182810382526023815260200180613b4b6023913960400191505060405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166348d91abf61337d612c49565b604080516001600160e01b031960e085901b1681526001600160a01b039283166004820152828a16602482015291881660448301526064820187905285151560848301525160a480830192600092919082900301818387803b15801561182f57600080fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632e1a7d4d836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561344857600080fd5b505af115801561345c573d6000803e3d6000fd5b50613474925050506001600160a01b038216836137e6565b5050565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316866001600160a01b03161415613568577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663817bb85788866040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b0316815260200192505050602060405180830381600087803b15801561353557600080fd5b505af1158015613549573d6000803e3d6000fd5b505050506040513d602081101561355f57600080fd5b505190506136d6565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316876001600160a01b03161415613622577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663711e619087866040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b0316815260200192505050602060405180830381600087803b15801561353557600080fd5b604080516324894b5960e01b81526001600160a01b03898116600483015288811660248301528681166044830152858116606483015291517f0000000000000000000000000000000000000000000000000000000000000000909216916324894b59916084808201926020929091908290030181600087803b1580156136a757600080fd5b505af11580156136bb573d6000803e3d6000fd5b505050506040513d60208110156136d157600080fd5b505190505b8481101561372b576040805162461bcd60e51b815260206004820152601e60248201527f526f757465723a20696e73756666696369656e7420616d6f756e744f75740000604482015290519081900360640190fd5b9695505050505050565b606061378a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138cb9092919063ffffffff16565b805190915015613188578080602001905160208110156137a957600080fd5b50516131885760405162461bcd60e51b815260040180806020018281038252602a815260200180613b6e602a913960400191505060405180910390fd5b8047101561383b576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114613886576040519150601f19603f3d011682016040523d82523d6000602084013e61388b565b606091505b50509050806131885760405162461bcd60e51b815260040180806020018281038252603a815260200180613aeb603a913960400191505060405180910390fd5b60606138da84846000856138e4565b90505b9392505050565b6060824710156139255760405162461bcd60e51b8152600401808060200182810382526026815260200180613b256026913960400191505060405180910390fd5b61392e85613a40565b61397f576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106139be5780518252601f19909201916020918201910161399f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613a20576040519150601f19603f3d011682016040523d82523d6000602084013e613a25565b606091505b5091509150613a35828286613a46565b979650505050505050565b3b151590565b60608315613a555750816138dd565b825115613a655782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613aaf578181015183820152602001613a97565b50505050905090810190601f168015613adc5780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c526f757465723a206d61726b207072696365206c6f776572207468616e206c696d69745361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564526f757465723a206d61726b20707269636520686967686572207468616e206c696d6974a26469706673582212205be2c43f3031249fda20cf6f0ad02def5f44fa8a6ff077056d561214645b1c5464736f6c634300060c00330000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a000000000000000000000000823412ac2ffd566cfe35560a850efec81337e67f00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000eababd4d5b4807b709e24ceb9ecea753d4a97ff5

Deployed Bytecode

0x6080604052600436106101d15760003560e01c8063877c7b8a116100f7578063cfad57a211610095578063e8d91a3a11610064578063e8d91a3a14611282578063f060febd1461133b578063f5b91b7b14611473578063fbfa77cf146114885761024e565b8063cfad57a214610fc3578063d8867fc814610ff6578063daffc8ec14611029578063e49b7329146111615761024e565b8063980a0578116100d1578063980a057814610d25578063a4d95b6414610e45578063cccc6e0514610e78578063cedd437514610f905761024e565b8063877c7b8a14610b7c57806390b64ad314610cb1578063956f285e14610cea5761024e565b806325ecda9a1161016f578063481e17e31161013e578063481e17e3146108565780634b12e6431461095b5780634f6970d9146109a25780636bb2529214610a5b5761024e565b806325ecda9a146106855780632662166b1461079b57806338c74dd91461080e5780633fc8cef3146108415761024e565b80631441a5a9116101ab5780631441a5a9146104c85780631b417cc8146104dd5780631b827878146105eb5780631f1dd176146106345761024e565b80630dde87fd1461025357806310a523161461036b57806312d43a51146104975761024e565b3661024e57336001600160a01b037f00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1161461024c576040805162461bcd60e51b81526020600482015260166024820152752937baba32b91d1034b73b30b634b21039b2b73232b960511b604482015290519081900360640190fd5b005b600080fd5b34801561025f57600080fd5b5061024c600480360360a081101561027657600080fd5b810190602081018135600160201b81111561029057600080fd5b8201836020820111156102a257600080fd5b803590602001918460208302840111600160201b831117156102c357600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435956020860135956001600160a01b0360408201351695509193509150608081019060600135600160201b81111561032d57600080fd5b82018360208201111561033f57600080fd5b803590602001918460018302840111600160201b8311171561036057600080fd5b50909250905061149d565b34801561037757600080fd5b5061024c600480360361010081101561038f57600080fd5b810190602081018135600160201b8111156103a957600080fd5b8201836020820111156103bb57600080fd5b803590602001918460208302840111600160201b831117156103dc57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092956001600160a01b0385351695602086013595604081013595506060810135945060808101351515935060a081013592919060e081019060c00135600160201b81111561045957600080fd5b82018360208201111561046b57600080fd5b803590602001918460018302840111600160201b8311171561048c57600080fd5b5090925090506114b5565b3480156104a357600080fd5b506104ac6114d3565b604080516001600160a01b039092168252519081900360200190f35b3480156104d457600080fd5b506104ac6114e2565b61024c600480360360a08110156104f357600080fd5b810190602081018135600160201b81111561050d57600080fd5b82018360208201111561051f57600080fd5b803590602001918460208302840111600160201b8311171561054057600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435956001600160a01b0360208701351695919450925060608101915060400135600160201b8111156105a457600080fd5b8201836020820111156105b657600080fd5b803590602001918460018302840111600160201b831117156105d757600080fd5b9193509150356001600160a01b0316611506565b3480156105f757600080fd5b5061024c6004803603608081101561060e57600080fd5b506001600160a01b03813581169160208101358216916040820135169060600135611777565b34801561064057600080fd5b5061024c600480360360a081101561065757600080fd5b506001600160a01b03813581169160208101358216916040820135169060608101359060800135151561179b565b61024c600480360360e081101561069b57600080fd5b810190602081018135600160201b8111156106b557600080fd5b8201836020820111156106c757600080fd5b803590602001918460208302840111600160201b831117156106e857600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092956001600160a01b0385351695602086013595604081013595506060810135151594506080810135935060c081019060a00135600160201b81111561075d57600080fd5b82018360208201111561076f57600080fd5b803590602001918460018302840111600160201b8311171561079057600080fd5b509092509050611843565b3480156107a757600080fd5b506107fc600480360360e08110156107be57600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359160808201359160a081013515159160c0909101351661185f565b60408051918252519081900360200190f35b34801561081a57600080fd5b5061024c6004803603602081101561083157600080fd5b50356001600160a01b031661193d565b34801561084d57600080fd5b506104ac61196e565b61024c6004803603608081101561086c57600080fd5b810190602081018135600160201b81111561088657600080fd5b82018360208201111561089857600080fd5b803590602001918460208302840111600160201b831117156108b957600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435956001600160a01b0360208701351695919450925060608101915060400135600160201b81111561091d57600080fd5b82018360208201111561092f57600080fd5b803590602001918460018302840111600160201b8311171561095057600080fd5b509092509050611992565b34801561096757600080fd5b5061098e6004803603602081101561097e57600080fd5b50356001600160a01b03166119a8565b604080519115158252519081900360200190f35b3480156109ae57600080fd5b5061024c60048036036101008110156109c657600080fd5b6001600160a01b0382358116926020810135821692604082013592606083013592608081013515159260a08201359092169160c08201359190810190610100810160e0820135600160201b811115610a1d57600080fd5b820183602082011115610a2f57600080fd5b803590602001918460018302840111600160201b83111715610a5057600080fd5b5090925090506119bd565b348015610a6757600080fd5b5061024c600480360360c0811015610a7e57600080fd5b810190602081018135600160201b811115610a9857600080fd5b820183602082011115610aaa57600080fd5b803590602001918460208302840111600160201b83111715610acb57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435956020860135956001600160a01b0360408201351695509193509150608081019060600135600160201b811115610b3557600080fd5b820183602082011115610b4757600080fd5b803590602001918460018302840111600160201b83111715610b6857600080fd5b9193509150356001600160a01b0316611ae9565b348015610b8857600080fd5b5061024c6004803603610120811015610ba057600080fd5b810190602081018135600160201b811115610bba57600080fd5b820183602082011115610bcc57600080fd5b803590602001918460208302840111600160201b83111715610bed57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092956001600160a01b0385351695602086013595604081013595506060810135945060808101351515935060a081013592919060e081019060c00135600160201b811115610c6a57600080fd5b820183602082011115610c7c57600080fd5b803590602001918460018302840111600160201b83111715610c9d57600080fd5b9193509150356001600160a01b0316611d17565b348015610cbd57600080fd5b5061024c60048036036040811015610cd457600080fd5b506001600160a01b038135169060200135611f17565b348015610cf657600080fd5b5061098e60048036036040811015610d0d57600080fd5b506001600160a01b0381358116916020013516611fd7565b61024c6004803603610100811015610d3c57600080fd5b810190602081018135600160201b811115610d5657600080fd5b820183602082011115610d6857600080fd5b803590602001918460208302840111600160201b83111715610d8957600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092956001600160a01b0385351695602086013595604081013595506060810135151594506080810135935060c081019060a00135600160201b811115610dfe57600080fd5b820183602082011115610e1057600080fd5b803590602001918460018302840111600160201b83111715610e3157600080fd5b9193509150356001600160a01b0316611ff7565b348015610e5157600080fd5b5061024c60048036036020811015610e6857600080fd5b50356001600160a01b0316612237565b348015610e8457600080fd5b5061024c600480360360a0811015610e9b57600080fd5b810190602081018135600160201b811115610eb557600080fd5b820183602082011115610ec757600080fd5b803590602001918460208302840111600160201b83111715610ee857600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435956020860135956001600160a01b0360408201351695509193509150608081019060600135600160201b811115610f5257600080fd5b820183602082011115610f6457600080fd5b803590602001918460018302840111600160201b83111715610f8557600080fd5b5090925090506122ab565b348015610f9c57600080fd5b5061024c60048036036020811015610fb357600080fd5b50356001600160a01b03166122bb565b348015610fcf57600080fd5b5061024c60048036036020811015610fe657600080fd5b50356001600160a01b03166122e9565b34801561100257600080fd5b5061024c6004803603602081101561101957600080fd5b50356001600160a01b031661235e565b34801561103557600080fd5b5061024c600480360361012081101561104d57600080fd5b810190602081018135600160201b81111561106757600080fd5b82018360208201111561107957600080fd5b803590602001918460208302840111600160201b8311171561109a57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092956001600160a01b038535811696602087013596604081013596506060810135151595506080810135909216935060a08201359260c08301359290919061010081019060e00135600160201b81111561112357600080fd5b82018360208201111561113557600080fd5b803590602001918460018302840111600160201b8311171561115657600080fd5b5090925090506123d8565b34801561116d57600080fd5b5061024c600480360360c081101561118457600080fd5b810190602081018135600160201b81111561119e57600080fd5b8201836020820111156111b057600080fd5b803590602001918460208302840111600160201b831117156111d157600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092958435956020860135956001600160a01b0360408201351695509193509150608081019060600135600160201b81111561123b57600080fd5b82018360208201111561124d57600080fd5b803590602001918460018302840111600160201b8311171561126e57600080fd5b9193509150356001600160a01b0316612601565b34801561128e57600080fd5b5061024c60048036036101008110156112a657600080fd5b6001600160a01b0382358116926020810135821692604082013592606083013592608081013515159260a08201359092169160c08201359190810190610100810160e0820135600160201b8111156112fd57600080fd5b82018360208201111561130f57600080fd5b803590602001918460018302840111600160201b8311171561133057600080fd5b509092509050612806565b34801561134757600080fd5b5061024c600480360361012081101561135f57600080fd5b810190602081018135600160201b81111561137957600080fd5b82018360208201111561138b57600080fd5b803590602001918460208302840111600160201b831117156113ac57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092956001600160a01b038535811696602087013596604081013596506060810135151595506080810135909216935060a08201359260c08301359290919061010081019060e00135600160201b81111561143557600080fd5b82018360208201111561144757600080fd5b803590602001918460018302840111600160201b8311171561146857600080fd5b509092509050612934565b34801561147f57600080fd5b506104ac612a99565b34801561149457600080fd5b506104ac612abd565b6114ad8686868686866000611ae9565b505050505050565b6114c88989898989898989896000611d17565b505050505050505050565b6000546001600160a01b031681565b7f000000000000000000000000eababd4d5b4807b709e24ceb9ecea753d4a97ff581565b7f00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab16001600160a01b03168660008151811061153d57fe5b60200260200101516001600160a01b031614611598576040805162461bcd60e51b81526020600482015260156024820152740a4deeae8cae47440d2dcecc2d8d2c840bee0c2e8d605b1b604482015290519081900360640190fd5b6115a181612ae1565b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156115fa57600080fd5b505afa15801561160e573d6000803e3d6000fd5b505050506040513d602081101561162457600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018590526001600160a01b03909216916329adf8ba91869186918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b15801561169a57600080fd5b505af11580156116ae573d6000803e3d6000fd5b505050506116ba612b7c565b60006116cf8787876116ca612c49565b612c4d565b90507fcd3829a3813dc3cdd188fd3d01dcf3268c16be2fdd2dd21d0665418816e46062338860008151811061170057fe5b60200260200101518960018b51038151811061171857fe5b6020026020010151348560405180866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b031681526020018381526020018281526020019550505050505060405180910390a150505050505050565b61178083612d9d565b6117956001600160a01b038516848484612e75565b50505050565b6117a485612d9d565b604080516348d91abf60e01b81526001600160a01b0387811660048301528681166024830152858116604483015260648201859052831515608483015291517f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a909216916348d91abf9160a48082019260009290919082900301818387803b15801561182f57600080fd5b505af11580156114c8573d6000803e3d6000fd5b61185588888888888888886000611ff7565b5050505050505050565b600061186a88612d9d565b6040805163082a084960e41b81526001600160a01b038a8116600483015289811660248301528881166044830152606482018890526084820187905285151560a483015284811660c483015291517f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a909216916382a084909160e4808201926020929091908290030181600087803b15801561190557600080fd5b505af1158015611919573d6000803e3d6000fd5b505050506040513d602081101561192f57600080fd5b505198975050505050505050565b3360009081526002602090815260408083206001600160a01b0394909416835292905220805460ff19166001179055565b7f00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab181565b6119a185858585856000611506565b5050505050565b60016020526000908152604090205460ff1681565b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b158015611a1657600080fd5b505afa158015611a2a573d6000803e3d6000fd5b505050506040513d6020811015611a4057600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018490526001600160a01b03909216916329adf8ba91859185918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b158015611ab657600080fd5b505af1158015611aca573d6000803e3d6000fd5b50505050611add89898989898989612ecf565b50505050505050505050565b611af281612ae1565b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b4b57600080fd5b505afa158015611b5f573d6000803e3d6000fd5b505050506040513d6020811015611b7557600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018590526001600160a01b03909216916329adf8ba91869186918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b158015611beb57600080fd5b505af1158015611bff573d6000803e3d6000fd5b50505050611c5e611c0e612c49565b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a888a600081518110611c3d57fe5b60200260200101516001600160a01b0316612e75909392919063ffffffff16565b6000611c6e8887876116ca612c49565b90507fcd3829a3813dc3cdd188fd3d01dcf3268c16be2fdd2dd21d0665418816e460623389600081518110611c9f57fe5b60200260200101518a60018c510381518110611cb757fe5b60200260200101518a8560405180866001600160a01b03168152602001856001600160a01b03168152602001846001600160a01b031681526020018381526020018281526020019550505050505060405180910390a15050505050505050565b611d2081612ae1565b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b158015611d7957600080fd5b505afa158015611d8d573d6000803e3d6000fd5b505050506040513d6020811015611da357600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018590526001600160a01b03909216916329adf8ba91869186918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b158015611e1957600080fd5b505af1158015611e2d573d6000803e3d6000fd5b505050506000881115611e7457611e74611e45612c49565b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a8a8d600081518110611c3d57fe5b60018a51118015611e855750600088115b15611ef3576000611e9a8b89306116ca612c49565b9050611ef17f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a828d60018f510381518110611ed157fe5b60200260200101516001600160a01b03166131369092919063ffffffff16565b505b611add8a60018c510381518110611f0657fe5b60200260200101518a88888861318d565b611f54611f22612c49565b6001600160a01b038416907f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a84612e75565b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b0316635f7bc119836040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015611fc357600080fd5b505af11580156114ad573d6000803e3d6000fd5b600260209081526000928352604080842090915290825290205460ff1681565b7f00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab16001600160a01b03168960008151811061202e57fe5b60200260200101516001600160a01b031614612089576040805162461bcd60e51b81526020600482015260156024820152740a4deeae8cae47440d2dcecc2d8d2c840bee0c2e8d605b1b604482015290519081900360640190fd5b61209281612ae1565b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156120eb57600080fd5b505afa1580156120ff573d6000803e3d6000fd5b505050506040513d602081101561211557600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018590526001600160a01b03909216916329adf8ba91869186918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b15801561218b57600080fd5b505af115801561219f573d6000803e3d6000fd5b5050505060003411156121b4576121b4612b7c565b600189511180156121c55750600034115b156122135760006121da8a89306116ca612c49565b90506122117f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a828c60018e510381518110611ed157fe5b505b6114c88960018b51038151811061222657fe5b60200260200101518988888861318d565b6000546001600160a01b0316331461228a576040805162461bcd60e51b81526020600482015260116024820152702937baba32b91d103337b93134b23232b760791b604482015290519081900360640190fd5b6001600160a01b03166000908152600160205260409020805460ff19169055565b6114ad8686868686866000612601565b3360009081526002602090815260408083206001600160a01b0394909416835292905220805460ff19169055565b6000546001600160a01b0316331461233c576040805162461bcd60e51b81526020600482015260116024820152702937baba32b91d103337b93134b23232b760791b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146123b1576040805162461bcd60e51b81526020600482015260116024820152702937baba32b91d103337b93134b23232b760791b604482015290519081900360640190fd5b6001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b7f00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab16001600160a01b03168a60018c51038151811061241257fe5b60200260200101516001600160a01b03161461246d576040805162461bcd60e51b81526020600482015260156024820152740a4deeae8cae47440d2dcecc2d8d2c840bee0c2e8d605b1b604482015290519081900360640190fd5b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156124c657600080fd5b505afa1580156124da573d6000803e3d6000fd5b505050506040513d60208110156124f057600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018490526001600160a01b03909216916329adf8ba91859185918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b15801561256657600080fd5b505af115801561257a573d6000803e3d6000fd5b5050505060006125a38b60008151811061259057fe5b60200260200101518b8b8b8b308b612ecf565b90506125d77f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a828d600081518110611ed157fe5b60006125e78c86306116ca612c49565b90506125f381886133e2565b505050505050505050505050565b7f00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab16001600160a01b03168760018951038151811061263b57fe5b60200260200101516001600160a01b031614612696576040805162461bcd60e51b81526020600482015260156024820152740a4deeae8cae47440d2dcecc2d8d2c840bee0c2e8d605b1b604482015290519081900360640190fd5b61269f81612ae1565b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156126f857600080fd5b505afa15801561270c573d6000803e3d6000fd5b505050506040513d602081101561272257600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018590526001600160a01b03909216916329adf8ba91869186918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b15801561279857600080fd5b505af11580156127ac573d6000803e3d6000fd5b505050506127bb611c0e612c49565b60006127cb8887306116ca612c49565b90506127d781866133e2565b7fcd3829a3813dc3cdd188fd3d01dcf3268c16be2fdd2dd21d0665418816e460623389600081518110611c9f57fe5b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561285f57600080fd5b505afa158015612873573d6000803e3d6000fd5b505050506040513d602081101561288957600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018490526001600160a01b03909216916329adf8ba91859185918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b1580156128ff57600080fd5b505af1158015612913573d6000803e3d6000fd5b5050505060006129288a8a8a8a8a308a612ecf565b9050611add81866133e2565b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663741bef1a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561298d57600080fd5b505afa1580156129a1573d6000803e3d6000fd5b505050506040513d60208110156129b757600080fd5b50516040516314d6fc5d60e11b8152602060048201908152602482018490526001600160a01b03909216916329adf8ba91859185918190604401848480828437600081840152601f19601f8201169050808301925050509350505050600060405180830381600087803b158015612a2d57600080fd5b505af1158015612a41573d6000803e3d6000fd5b505050506000612a578b60008151811061259057fe5b9050612a8b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a828d600081518110611ed157fe5b6125f38b85886116ca612c49565b7f000000000000000000000000823412ac2ffd566cfe35560a850efec81337e67f81565b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a81565b7f000000000000000000000000eababd4d5b4807b709e24ceb9ecea753d4a97ff56001600160a01b0316637543e3f0612b18612c49565b836040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b0316815260200192505050600060405180830381600087803b158015612b6857600080fd5b505af11580156119a1573d6000803e3d6000fd5b7f00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab16001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015612bd757600080fd5b505af1158015612beb573d6000803e3d6000fd5b50612c479350506001600160a01b037f00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab11691507f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a905034613136565b565b3390565b6000845160021415612c9557612c8e85600081518110612c6957fe5b602002602001015186600181518110612c7e57fe5b6020026020010151868686613478565b9050612d95565b845160031415612d48576000612cd786600081518110612cb157fe5b602002602001015187600181518110612cc657fe5b602002602001015160003087613478565b9050612d0b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a8288600181518110611ed157fe5b612d4086600181518110612d1b57fe5b602002602001015187600281518110612d3057fe5b6020026020010151878787613478565b915050612d95565b6040805162461bcd60e51b815260206004820152601c60248201527f526f757465723a20696e76616c6964205f706174682e6c656e67746800000000604482015290519081900360640190fd5b949350505050565b3360009081526001602052604090205460ff16612dfa576040805162461bcd60e51b81526020600482015260166024820152752937baba32b91d1034b73b30b634b21038363ab3b4b760511b604482015290519081900360640190fd5b6001600160a01b038116600090815260026020908152604080832033845290915290205460ff16612e72576040805162461bcd60e51b815260206004820152601b60248201527f526f757465723a20706c7567696e206e6f7420617070726f7665640000000000604482015290519081900360640190fd5b50565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611795908590613735565b60008315612fb357817f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b03166381a612d6896040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612f4557600080fd5b505afa158015612f59573d6000803e3d6000fd5b505050506040513d6020811015612f6f57600080fd5b50511015612fae5760405162461bcd60e51b8152600401808060200182810382526023815260200180613b4b6023913960400191505060405180910390fd5b61308a565b817f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663e124e6d2896040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561302157600080fd5b505afa158015613035573d6000803e3d6000fd5b505050506040513d602081101561304b57600080fd5b5051111561308a5760405162461bcd60e51b8152600401808060200182810382526024815260200180613b986024913960400191505060405180910390fd5b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b03166382a084906130c1612c49565b604080516001600160e01b031960e085901b1681526001600160a01b039283166004820152828d166024820152828c166044820152606481018b9052608481018a905288151560a482015291871660c48301525160e48083019260209291908290030181600087803b15801561190557600080fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052613188908490613735565b505050565b811561326f57807f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663e124e6d2866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561320157600080fd5b505afa158015613215573d6000803e3d6000fd5b505050506040513d602081101561322b57600080fd5b5051111561326a5760405162461bcd60e51b8152600401808060200182810382526024815260200180613b986024913960400191505060405180910390fd5b613346565b807f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b03166381a612d6866040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156132dd57600080fd5b505afa1580156132f1573d6000803e3d6000fd5b505050506040513d602081101561330757600080fd5b505110156133465760405162461bcd60e51b8152600401808060200182810382526023815260200180613b4b6023913960400191505060405180910390fd5b7f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b03166348d91abf61337d612c49565b604080516001600160e01b031960e085901b1681526001600160a01b039283166004820152828a16602482015291881660448301526064820187905285151560848301525160a480830192600092919082900301818387803b15801561182f57600080fd5b7f00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab16001600160a01b0316632e1a7d4d836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561344857600080fd5b505af115801561345c573d6000803e3d6000fd5b50613474925050506001600160a01b038216836137e6565b5050565b6000807f000000000000000000000000823412ac2ffd566cfe35560a850efec81337e67f6001600160a01b0316866001600160a01b03161415613568577f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663817bb85788866040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b0316815260200192505050602060405180830381600087803b15801561353557600080fd5b505af1158015613549573d6000803e3d6000fd5b505050506040513d602081101561355f57600080fd5b505190506136d6565b7f000000000000000000000000823412ac2ffd566cfe35560a850efec81337e67f6001600160a01b0316876001600160a01b03161415613622577f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a6001600160a01b031663711e619087866040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b0316815260200192505050602060405180830381600087803b15801561353557600080fd5b604080516324894b5960e01b81526001600160a01b03898116600483015288811660248301528681166044830152858116606483015291517f0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a909216916324894b59916084808201926020929091908290030181600087803b1580156136a757600080fd5b505af11580156136bb573d6000803e3d6000fd5b505050506040513d60208110156136d157600080fd5b505190505b8481101561372b576040805162461bcd60e51b815260206004820152601e60248201527f526f757465723a20696e73756666696369656e7420616d6f756e744f75740000604482015290519081900360640190fd5b9695505050505050565b606061378a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138cb9092919063ffffffff16565b805190915015613188578080602001905160208110156137a957600080fd5b50516131885760405162461bcd60e51b815260040180806020018281038252602a815260200180613b6e602a913960400191505060405180910390fd5b8047101561383b576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114613886576040519150601f19603f3d011682016040523d82523d6000602084013e61388b565b606091505b50509050806131885760405162461bcd60e51b815260040180806020018281038252603a815260200180613aeb603a913960400191505060405180910390fd5b60606138da84846000856138e4565b90505b9392505050565b6060824710156139255760405162461bcd60e51b8152600401808060200182810382526026815260200180613b256026913960400191505060405180910390fd5b61392e85613a40565b61397f576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106139be5780518252601f19909201916020918201910161399f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613a20576040519150601f19603f3d011682016040523d82523d6000602084013e613a25565b606091505b5091509150613a35828286613a46565b979650505050505050565b3b151590565b60608315613a555750816138dd565b825115613a655782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613aaf578181015183820152602001613a97565b50505050905090810190601f168015613adc5780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c526f757465723a206d61726b207072696365206c6f776572207468616e206c696d69745361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564526f757465723a206d61726b20707269636520686967686572207468616e206c696d6974a26469706673582212205be2c43f3031249fda20cf6f0ad02def5f44fa8a6ff077056d561214645b1c5464736f6c634300060c0033

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

0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a000000000000000000000000823412ac2ffd566cfe35560a850efec81337e67f00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000eababd4d5b4807b709e24ceb9ecea753d4a97ff5

-----Decoded View---------------
Arg [0] : _vault (address): 0x1785e8491e7e9d771b2A6E9E389c25265F06326A
Arg [1] : _usdg (address): 0x823412ac2FfD566cFE35560A850EFec81337e67f
Arg [2] : _weth (address): 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
Arg [3] : _referral (address): 0xeabABd4D5B4807b709E24ceB9EcEA753d4a97FF5

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000001785e8491e7e9d771b2a6e9e389c25265f06326a
Arg [1] : 000000000000000000000000823412ac2ffd566cfe35560a850efec81337e67f
Arg [2] : 00000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1
Arg [3] : 000000000000000000000000eababd4d5b4807b709e24ceb9ecea753d4a97ff5


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.