ETH Price: $3,323.82 (-1.07%)

Contract

0xF3cb43F19C668e34173D4Bb59E551a2c6E37d778
 

Multichain Info

1 address found via
Transaction Hash
Method
Block
From
To
Swap Native To V...212466472024-11-22 23:47:232 mins ago1732319243IN
0xF3cb43F1...c6E37d778
0.09030821 ETH0.0029749715.60962386
Swap Native To V...212465662024-11-22 23:30:5918 mins ago1732318259IN
0xF3cb43F1...c6E37d778
0.24149753 ETH0.0028999814.64216811
Swap Native To V...212456862024-11-22 20:34:233 hrs ago1732307663IN
0xF3cb43F1...c6E37d778
0.15218145 ETH0.0023118612.64327383
Swap Native To V...212455732024-11-22 20:11:473 hrs ago1732306307IN
0xF3cb43F1...c6E37d778
0.15257628 ETH0.0021840511.49345798
Swap Native To V...212455592024-11-22 20:08:593 hrs ago1732306139IN
0xF3cb43F1...c6E37d778
0.61030515 ETH0.0016797311.0322278
Swap Native To V...212455522024-11-22 20:07:353 hrs ago1732306055IN
0xF3cb43F1...c6E37d778
0.30515257 ETH0.002285412.38425287
Swap Native To V...212451022024-11-22 18:37:235 hrs ago1732300643IN
0xF3cb43F1...c6E37d778
0.03 ETH0.0038844122.04796972
Swap Native To V...212446282024-11-22 17:01:356 hrs ago1732294895IN
0xF3cb43F1...c6E37d778
0.057017 ETH0.0029579716.9779876
Swap Native To V...212444822024-11-22 16:31:477 hrs ago1732293107IN
0xF3cb43F1...c6E37d778
0.06057114 ETH0.0038339515.78729137
Swap Native To V...212442532024-11-22 15:45:358 hrs ago1732290335IN
0xF3cb43F1...c6E37d778
0.04 ETH0.003397518.32565526
Swap To Native V...212438032024-11-22 14:15:239 hrs ago1732284923IN
0xF3cb43F1...c6E37d778
0 ETH0.0037992518.02415356
Swap Uniswap V3212437952024-11-22 14:13:479 hrs ago1732284827IN
0xF3cb43F1...c6E37d778
0 ETH0.0040367920.25751152
Swap Native To V...212431482024-11-22 12:03:3511 hrs ago1732277015IN
0xF3cb43F1...c6E37d778
0.14944734 ETH0.0025912613.46587314
Swap Uniswap V3212426412024-11-22 10:21:4713 hrs ago1732270907IN
0xF3cb43F1...c6E37d778
0.08 ETH0.0022740814.80372899
Swap Uniswap V3212426272024-11-22 10:18:5913 hrs ago1732270739IN
0xF3cb43F1...c6E37d778
0 ETH0.0023127613.79198098
Swap Native To V...212426132024-11-22 10:16:1113 hrs ago1732270571IN
0xF3cb43F1...c6E37d778
0.003 ETH0.0026116614.28678601
Swap Uniswap V3212425702024-11-22 10:07:3513 hrs ago1732270055IN
0xF3cb43F1...c6E37d778
0.09 ETH0.0019550612.72720693
Swap Uniswap V3212425182024-11-22 9:57:1113 hrs ago1732269431IN
0xF3cb43F1...c6E37d778
0 ETH0.0017380310.69956769
Swap Uniswap V3212425012024-11-22 9:53:4713 hrs ago1732269227IN
0xF3cb43F1...c6E37d778
0 ETH0.0019541111.59659571
Swap Uniswap V3212422872024-11-22 9:10:3514 hrs ago1732266635IN
0xF3cb43F1...c6E37d778
0.01479881 ETH0.002011913.09708729
Swap Native To V...212422812024-11-22 9:09:2314 hrs ago1732266563IN
0xF3cb43F1...c6E37d778
0.01479881 ETH0.0018748111.68765392
Swap Uniswap V3212422732024-11-22 9:07:4714 hrs ago1732266467IN
0xF3cb43F1...c6E37d778
0.01481899 ETH0.0018651712.48928733
Swap Native To V...212421902024-11-22 8:50:5914 hrs ago1732265459IN
0xF3cb43F1...c6E37d778
0.03846324 ETH0.0021943611.67110809
Swap To Native V...212421522024-11-22 8:43:2315 hrs ago1732265003IN
0xF3cb43F1...c6E37d778
0 ETH0.001929169.51385563
Swap Uniswap V3212421052024-11-22 8:33:4715 hrs ago1732264427IN
0xF3cb43F1...c6E37d778
0 ETH0.0020680611.57673275
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
212466472024-11-22 23:47:232 mins ago1732319243
0xF3cb43F1...c6E37d778
0.08964987 ETH
212465662024-11-22 23:30:5918 mins ago1732318259
0xF3cb43F1...c6E37d778
0.23973701 ETH
212456862024-11-22 20:34:233 hrs ago1732307663
0xF3cb43F1...c6E37d778
0.15107205 ETH
212455732024-11-22 20:11:473 hrs ago1732306307
0xF3cb43F1...c6E37d778
0.151464 ETH
212455592024-11-22 20:08:593 hrs ago1732306139
0xF3cb43F1...c6E37d778
0.60585602 ETH
212455522024-11-22 20:07:353 hrs ago1732306055
0xF3cb43F1...c6E37d778
0.30292801 ETH
212451022024-11-22 18:37:235 hrs ago1732300643
0xF3cb43F1...c6E37d778
0.0297813 ETH
212446282024-11-22 17:01:356 hrs ago1732294895
0xF3cb43F1...c6E37d778
0.05660134 ETH
212444822024-11-22 16:31:477 hrs ago1732293107
0xF3cb43F1...c6E37d778
0.06012958 ETH
212442532024-11-22 15:45:358 hrs ago1732290335
0xF3cb43F1...c6E37d778
0.0397084 ETH
212438032024-11-22 14:15:239 hrs ago1732284923
0xF3cb43F1...c6E37d778
0.02833616 ETH
212438032024-11-22 14:15:239 hrs ago1732284923
0xF3cb43F1...c6E37d778
0.02854425 ETH
212437952024-11-22 14:13:479 hrs ago1732284827
0xF3cb43F1...c6E37d778
0.01638049 ETH
212437952024-11-22 14:13:479 hrs ago1732284827
0xF3cb43F1...c6E37d778
0.01650078 ETH
212431482024-11-22 12:03:3511 hrs ago1732277015
0xF3cb43F1...c6E37d778
0.14835787 ETH
212426412024-11-22 10:21:4713 hrs ago1732270907
0xF3cb43F1...c6E37d778
0.0794168 ETH
212426272024-11-22 10:18:5913 hrs ago1732270739
0xF3cb43F1...c6E37d778
0.09326616 ETH
212426272024-11-22 10:18:5913 hrs ago1732270739
0xF3cb43F1...c6E37d778
0.09395106 ETH
212426132024-11-22 10:16:1113 hrs ago1732270571
0xF3cb43F1...c6E37d778
0.00297813 ETH
212425702024-11-22 10:07:3513 hrs ago1732270055
0xF3cb43F1...c6E37d778
0.0893439 ETH
212425182024-11-22 9:57:1113 hrs ago1732269431
0xF3cb43F1...c6E37d778
0.07112119 ETH
212425182024-11-22 9:57:1113 hrs ago1732269431
0xF3cb43F1...c6E37d778
0.07164347 ETH
212425012024-11-22 9:53:4713 hrs ago1732269227
0xF3cb43F1...c6E37d778
0.02868686 ETH
212425012024-11-22 9:53:4713 hrs ago1732269227
0xF3cb43F1...c6E37d778
0.02889752 ETH
212422872024-11-22 9:10:3514 hrs ago1732266635
0xF3cb43F1...c6E37d778
0.01469092 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
InternetMoneySwapRouter

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
File 1 of 34 : InternetMoneySwapRouter.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import "@uniswap/swap-router-contracts/contracts/interfaces/IV3SwapRouter.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { IVault, IAsset } from "@balancer-labs/v2-interfaces/contracts/vault/IVault.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "../interfaces/IWETH.sol";
import "../Migratable.sol";
import "./OracleReader.sol";
import "./Utils.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./Distributor.sol";
import "./DexTracker.sol";
import "./BytesLib.sol";
import "./UniV3PathEncoding.sol";
import "../interfaces/IPiteasRouter.sol";

/**
 * @title contract for swapping tokens
 * @notice use this contract for only the most basic simulation
 * @dev function calls are currently implemented without side effects
 * @notice multicall was not included here because sender
 * is less relevant outside of a swap
 * which already allows for multiple swaps
 */
contract InternetMoneySwapRouter is Utils, Migratable, OracleReader, Distributor, DexTracker {
    using Address for address payable;
    using SafeERC20 for IERC20;
    /** a single dex entry */

    error NativeMissing(uint256 pathIndex);
    error FeeMissing(uint256 expected, uint256 provided, string message);
    error ValueMismatch(uint256 consumed, uint256 provided);
    error FunderMismatch(address expected, address provided);
    error Deadline();

    event IMSwap(
        // keccak256 of inToken and outToken addresses
        bytes32 indexed inAndOutTokens,
        uint256 amountIn,
        address indexed sender,
        uint256 indexed dexId
    );

    event FeesCollected(
        uint256 indexed amount,
        bool indexed isNative
    );

    /**
     * sets up the wallet swap contract
     * @param _destination where native currency will be sent
     * @param _wNative the address that is used to wrap and unwrap tokens
     * @notice wNative does not have to have the name wNative
     * it is just a placeholder for wrapped native currency
     * @notice the destination address must have a receive / fallback method
     * to receive native currency
     */
    constructor(
        address payable _destination, address payable _wNative, uint96 _fee
    )
        Utils(_wNative, _destination, _fee)
    {}

    /**
     * this method transfers funds from the sending address
     * and returns the delta of the balance of this contracat
     * @param sourceTokenId is the token id to transfer from the sender
     * @param amountIn is the amount that you desire to transfer from the sender
     * @return delta the amount that was actually transferred, using a `balanceOf` check
     */
    function collectFunds(address sourceTokenId, uint256 amountIn) internal returns(uint256) {
        uint256 balanceBefore = IERC20(sourceTokenId).balanceOf(address(this));
        IERC20(sourceTokenId).safeTransferFrom(msg.sender, address(this), amountIn);
        return IERC20(sourceTokenId).balanceOf(address(this)) - balanceBefore;
    }

    function _wNativeFromDex(address payable _wNative) internal view returns(address payable) {
        return _wNative == address(0) ? wNative : _wNative;
    }

    function _handleBalancerV2FeeMath(uint256 dexId, uint256 amountIn, uint256 msgValue, address inToken, address outToken ) internal {
        address[] memory assetAddresses = new address[](2);
        assetAddresses[0] = inToken;
        assetAddresses[1] = outToken;
        (, uint256 minimum) = _getFeeMinimum(
            IUniswapV2Router02(dexInfo[dexId >> 128].router).factory(),
            amountIn,
            assetAddresses
        );
        _feeWithTolerance(msgValue, minimum);
        emit FeesCollected(msgValue, true);
    }

    /**
     * @notice This function is used to swap tokens on Balancer V2, with our fee being taken either before or after as ETH or WETH, depending on tokens swapped
     * @dev "uint256(deltas[deltas.length - 1] * -1))" is because
     * (1) fewer vars because stack too deep
     * (2) deltas are negative for tokens that exit balancer's vault, so we take the last one, our outToken, multiply by negative one, then cast to uint
     */
    function swapBalancerV2(
        uint256 dexId,
        IVault.BatchSwapStep[] memory swaps,
        IAsset[] memory assets,
        IVault.FundManagement memory funds,
        int256[] memory limits,
        uint256 deadline,
        uint256 inTokenIndex,  // Index of the input token in the assets array
        uint256 outTokenIndex,  // Index of the output token in the assets array
        uint256 amountIn  // Amount of input tokens
    ) external payable {
        if (dexInfo[dexId].disabled) {
            revert DexDisabled();
        }

        bool outIsNative = address(assets[outTokenIndex]) == address(0) || address(assets[outTokenIndex]) == _wNativeFromDex(dexInfo[dexId].wNative);
        uint256 remainingValue = msg.value;
        address payable recipient = funds.recipient;
        if (address(assets[inTokenIndex]) == address(0)) {
            // set limit for ETH (inToken is 0 address)
            limits[inTokenIndex] == int256(msg.value - (msg.value * feeNumerator / feeDenominator));
            remainingValue -= (msg.value * feeNumerator / feeDenominator);
            emit FeesCollected((msg.value * feeNumerator / feeDenominator), true);
        } else if (address(assets[inTokenIndex]) == _wNativeFromDex(dexInfo[dexId].wNative)) {
            // set limit for wNative (inToken is wNative)
            limits[inTokenIndex] == int256(amountIn - (amountIn * feeNumerator / feeDenominator));
            remainingValue = 0;
            emit FeesCollected((amountIn * feeNumerator / feeDenominator), false);
        } else if (!outIsNative) {
            _handleBalancerV2FeeMath(
                dexId,
                amountIn,
                msg.value,
                address(assets[inTokenIndex]),
                address(assets[outTokenIndex])
            );
        }

        if (address(this) != funds.sender) {
            revert FunderMismatch(address(this), funds.sender);
        }

        if (address(assets[inTokenIndex]) != address(0)) {
            // Dealing with an ERC20 contract
            // ik this is spaghetti code because of local var constraints but basically only deduct fee from erc20 amount if not weth
            amountIn = collectFunds(address(assets[inTokenIndex]), amountIn) - (
                address(assets[inTokenIndex]) == _wNativeFromDex(dexInfo[dexId].wNative)
                ? (amountIn * feeNumerator / feeDenominator)
                : 0
            );
            limits[inTokenIndex] = int256(amountIn);
            IERC20(address(assets[inTokenIndex])).approve(dexInfo[dexId].router, amountIn);
        }

        if (outIsNative) {
            funds.recipient = payable(address(this));
        }

        int256[] memory deltas = IVault(dexInfo[dexId].router)
        .batchSwap
        {value: remainingValue}
        (IVault.SwapKind.GIVEN_IN, swaps, assets, funds, limits, deadline);

        if (address(assets[outTokenIndex]) == _wNativeFromDex(dexInfo[dexId].wNative)) {
            IERC20(address(assets[outTokenIndex]))
                .safeTransfer(recipient, _removeFees(uint256(deltas[deltas.length - 1] * -1)));
            emit FeesCollected(
                uint256(deltas[deltas.length - 1] * -1) - _removeFees(uint256(deltas[deltas.length - 1] * -1)),
                false
            );
        } else if (address(assets[outTokenIndex]) == address(0)) {
            recipient.sendValue(_removeFees(uint256(deltas[deltas.length - 1] * -1)));
            emit FeesCollected(
                uint256(deltas[deltas.length - 1] * -1) - _removeFees(uint256(deltas[deltas.length - 1] * -1)),
                true
            );
        }

        emit IMSwap(
            keccak256(abi.encode(address(assets[inTokenIndex]), address(assets[outTokenIndex]))),
            amountIn,
            recipient,
            dexId
        );
    }

    function swapUniswapV3(
        uint256 dexId,
        IV3SwapRouter.ExactInputParams memory params
    ) external payable {
        Dex memory dex = dexInfo[dexId];
        if (dex.disabled) {
            revert DexDisabled();
        }
        uint256 msgValue = msg.value;
        address[] memory pathDecoded = UniV3PathEncoding._decodePath(params.path);
        address tokenIn = pathDecoded[0];
        address tokenOut = pathDecoded[pathDecoded.length - 1];
        address payable _wNative = _wNativeFromDex(dex.wNative);
        bool outIsNative = tokenOut == address(0) || tokenOut == _wNative;
        uint256 amountIn = params.amountIn;
        address recipient = params.recipient;
        uint256 requiredFee;

        // this event is at the beginning of the function because we change some of these values to account for native assets/fees/etc. to be consistent we want the event to be the raw amounts and values put in by the user. we can always cross reference with other events
        emit IMSwap(
            keccak256(abi.encode(tokenIn, tokenOut)),
            amountIn,
            recipient,
            dexId
        );

        if (tokenIn == address(0)) {
            uint256 nativeFee = (msgValue * feeNumerator) / feeDenominator;
            msgValue -= nativeFee;
            emit FeesCollected(
                nativeFee,
                true
            );
        } else if (tokenIn == _wNative) {
            requiredFee = (amountIn * feeNumerator) / feeDenominator;
            emit FeesCollected(
                requiredFee,
                false
            );
        } else if (!outIsNative) {
            (, uint256 minimum) = _getFeeMinimum(
                IUniswapV2Router02(dexInfo[dexId >> 128].router).factory(),
                amountIn,
                pathDecoded
            );
            _feeWithTolerance(msgValue, minimum);
            emit FeesCollected(
                msgValue,
                true
            );
        }
        if (tokenIn == address(0)) {
            tokenIn = _wNative;
            params.path = UniV3PathEncoding._replaceFirstAddress(params.path, _wNative);
            amountIn = msgValue;
            params.amountIn = amountIn;
            IWETH(_wNative).deposit{ value: amountIn }();
        } else {
            // dealing with erc20 contract
            amountIn = collectFunds(tokenIn, amountIn) - requiredFee;
            params.amountIn = amountIn;
        }
        // if native is coming out, make a pit stop to collect fees
        if (outIsNative) {
            params.recipient = address(this);
        }
        // if tokenOut is address(0) use the address that the factory understands
        if (tokenOut == address(0)) {
            params.path = UniV3PathEncoding._replaceLastAddress(params.path, wNative);
        }
        // does not handle native so we have to approve
        IERC20(tokenIn).approve(dex.router, amountIn);
        // do swap
        uint256 amountOut = IV3SwapRouter(dex.router)
            .exactInput(params);
        if (tokenOut == _wNative) {
            if (msgValue > 0) {
                revert FeeMissing(0, msgValue, "fees paid from output");
            }
            IERC20(tokenOut).safeTransfer(recipient, _removeFees(amountOut));
            emit FeesCollected(
                amountOut - _removeFees(amountOut),
                false
            );
        } else if (tokenOut == address(0)) {
            _sendNativeTokensOutAfterUnwrap(_wNative, _removeFees(amountOut), payable(recipient));
            emit FeesCollected(
                amountOut - _removeFees(amountOut),
                true
            );
        }

    }

    /**
     * @dev piteasCalldata should not include the first four bytes for the function selector, have the client truncate it: 8218b58f
     */
    function swapPiteas(uint256 dexId, bytes calldata piteasCalldata) external payable {
        Dex memory dex = dexInfo[dexId];
        if (dex.disabled) {
            revert DexDisabled();
        }

        (IPiteasRouter.Detail memory detail, bytes memory remainingCalldata) = abi.decode(
        piteasCalldata,
        (IPiteasRouter.Detail, bytes));

        uint256 msgValue = msg.value;
        address tokenIn = address(detail.srcToken);
        address tokenOut = address(detail.destToken);
        uint256 amountIn = detail.srcAmount;
        detail.destAccount = payable(address(this));
        bool outIsNative = tokenOut == address(0) || tokenOut == _wNativeFromDex(dex.wNative);


        if (tokenIn == address(0)) {
            uint256 nativeFee = (msgValue * feeNumerator) / feeDenominator;
            uint256 expectedAmount = amountIn + nativeFee;
            if (msgValue != expectedAmount) {
                revert FeeMissing(expectedAmount, msgValue, "swapPiteas():: insuff msg.value fee when native asset is inToken");
            }
            msgValue = amountIn;
            emit FeesCollected(
                nativeFee,
                true
            );

        } else if (tokenIn == _wNativeFromDex(dex.wNative)) {
            uint256 amountToCollect = (amountIn * feeDenominator) / (feeDenominator - feeNumerator);
            uint256 wNativeFee = amountToCollect - amountIn;
            uint256 amountCollected = collectFunds(tokenIn, amountToCollect);
            IERC20(_wNativeFromDex(dex.wNative)).approve(dex.router, amountIn);
            if (amountCollected < amountToCollect) {
                revert FeeMissing(amountToCollect, amountCollected, "swapPiteas():: insuff fee for wNative asset");
            }
            emit FeesCollected(
                wNativeFee,
                false
            );
        } else if (!outIsNative) {
            address[] memory assetAddresses = new address[](2);
            assetAddresses[0] = tokenIn;
            assetAddresses[1] = tokenOut;
            (, uint256 minimum) = _getFeeMinimum(
                IUniswapV2Router02(dexInfo[dexId >> 128].router).factory(),
                amountIn,
                assetAddresses
            );
            _feeWithTolerance(msgValue, minimum);
            emit FeesCollected(
                msgValue,
                true
            );
        } else {
            if (msgValue != 0) {
                revert ValueMismatch(0, msgValue);
            }
        }

        if (tokenIn != address(0) && tokenIn != _wNativeFromDex(dex.wNative)) {
            uint256 amountCollected = collectFunds(tokenIn, amountIn);
            if (amountCollected < amountIn) {
                revert ValueMismatch(amountIn, amountCollected);
            }
            IERC20(tokenIn).approve(dex.router, amountIn);
        }

        if (tokenIn != address(0)) {
            msgValue = 0;
        }

        uint256 amountBefore;
        if (tokenOut == address(0)) {
            amountBefore = address(this).balance;
        } else {
            amountBefore = IERC20(tokenOut).balanceOf(address(this));
        }

        uint256 amountOut = IPiteasRouter(dex.router).swap{value: msgValue}(detail, remainingCalldata);

        uint256 amountAfter;
        if (tokenOut == address(0)) {
            amountAfter = address(this).balance;
        } else {
            amountAfter = IERC20(tokenOut).balanceOf(address(this));
        }

        if (amountOut != amountAfter - amountBefore) {
            revert ValueMismatch(amountOut, amountAfter - amountBefore);
        }

        if (tokenOut == _wNativeFromDex(dex.wNative)) {
            IERC20(tokenOut).safeTransfer(msg.sender, _removeFees(amountOut));
            emit FeesCollected(
                amountOut - _removeFees(amountOut),
                false
            );
        } else if (tokenOut == address(0)) {
            _sendNativeTokensOutAfterUnwrap(_wNativeFromDex(dex.wNative), _removeFees(amountOut), payable(msg.sender));
            emit FeesCollected(
                amountOut - _removeFees(amountOut),
                true
            );
        } else {
            IERC20(tokenOut).safeTransfer(msg.sender, amountOut);
        }

        emit IMSwap(
            keccak256(abi.encode(tokenIn, tokenOut)),
            amountIn,
            msg.sender,
            dexId
        );

    }

    function _removeFees(uint256 amountOut) internal view returns(uint256) {
        return amountOut - (amountOut * feeNumerator) / feeDenominator;
    }
    function _sendNativeTokensOutAfterUnwrap(
        address payable _wNative,
        uint256 amountOut,
        address payable recipient
    ) internal {
        uint256 balance = IERC20(_wNative).balanceOf(address(this));
        if (balance > 0) {
            IWETH(_wNative).withdraw(balance);
        }
        recipient.sendValue(amountOut);
    }

    /**
     * @notice Swap erc20 token, end with erc20 token
     * @param _dexId ID of the Dex
     * @param recipient address to receive funds
     * @param _path Token address array
     * @param _amountIn Input amount
     * @param _minAmountOut Output token amount
     * @param _deadline the time at which this transaction can no longer be run
     * @notice anything extra in msg.value is treated as a donation
     * @notice anyone using this method will be costing themselves more
     * than simply going through the router they wish to swap through
     * so anything that comes through really acts like a high yeilding voluntary donation box
     * @notice if wNative is passed in as the first or last step of the path
     * then fees will be calculated from that number available at that time
     * @notice fee is only paid via msg.value if and only if the
     * first and last of the path are not a wrapped token
     * @notice if first or last of the path is wNative
     * then msg.value is required to be zero
     */
    function swapTokenV2(
        uint256 _dexId,
        address recipient,
        address[] calldata _path,
        uint256 _amountIn,
        uint256 _minAmountOut,
        uint256 _deadline
    ) external payable {
        _swapTokenV2(msg.value, _dexId, recipient, _path, _amountIn, _minAmountOut, _deadline);
        emit IMSwap(
            keccak256(abi.encode(_path[0], _path[_path.length - 1])),
            _amountIn,
            recipient,
            _dexId
        );
    }

     function _feeWithTolerance(uint256 msgValue, uint256 _minimum) internal pure returns(uint256 minimum) {
        // introduce fee tolerance here
        minimum = (_minimum * 9) / 10;
        if (minimum == 0) {
            revert FeeMissing(0, msgValue, "unable to compute fees");
        }
        if (msgValue < minimum) {
            revert FeeMissing(minimum, msgValue, "not enough fee value");
        }
    }

    function _swapTokenV2(
        uint256 msgValue,
        uint256 _dexId,
        address recipient,
        address[] calldata _path,
        uint256 _amountIn,
        uint256 _minAmountOut,
        uint256 _deadline
    ) internal {
        address first = _path[0];
        address last = _path[_path.length - 1];
        address payable _wNative = _wNativeFromDex(dexInfo[_dexId].wNative);
        uint256 nativeFee = 0;
        if (first == _wNative) {
            nativeFee = (_amountIn * feeNumerator) / feeDenominator;
            if (msgValue != 0) {
                revert FeeMissing(0, msgValue, "fees paid from input");
            }
            emit FeesCollected(
                nativeFee,
                false
            );
        } else if (last != _wNative) {
            (, uint256 minimum) = _getFeeMinimum(
                IUniswapV2Router02(dexInfo[_dexId].router).factory(),
                _amountIn,
                _path
            );
            _feeWithTolerance(msgValue, minimum);
            emit FeesCollected(
                msgValue,
                true
            );
        }
        // run transfer as normal
        uint256 actualAmountIn = collectFunds(first, _amountIn) - nativeFee;
        uint256 actualAmountOut = swapExactTokenForTokenV2(
            _dexId,
            _path,
            actualAmountIn,
            _minAmountOut,
            _deadline
        );
        uint256 actualAmountOutAfterFees = actualAmountOut;
        if (last == _wNative) {
            actualAmountOutAfterFees -= (actualAmountOut * feeNumerator) / feeDenominator;
            if (msgValue != 0) {
                revert FeeMissing(0, msgValue, "fees paid from output");
            }
            emit FeesCollected(
                actualAmountOut - actualAmountOutAfterFees,
                false
            );
        }
        IERC20(last).safeTransfer(recipient, actualAmountOutAfterFees);
    }

    /**
     * wraps the provided msg value to be used as a token
     * useful when chaining calls together
     */
    function wrap(address payable _wNative) public payable {
        IWETH(_wNative).deposit{value: msg.value}();
        IWETH(_wNative).transfer(msg.sender, msg.value);
    }

    /**
     * @notice Swap native currency, end with erc20 token
     * @param _dexId ID of the Dex
     * @param recipient address to receive funds
     * @param _path Token address array
     * @param _amountIn Input amount
     * @param _minAmountOut Output token amount
     * @param _deadline the time at which this transaction can no longer be run
     * @notice anything extra in msg.value is treated as a donation
     * @notice this method does not require an approval step from the user
     * @notice because of use of msg.value if this method is used with internal
     * delegatecall to chain calls together, it will, in most cases, not have any msg.value to use
     */
    function swapNativeToV2(
        uint256 _dexId,
        address recipient,
        address[] calldata _path,
        uint256 _amountIn,
        uint256 _minAmountOut,
        uint256 _deadline
    ) external payable {
        uint256 minimal = (msg.value * feeNumerator) / feeDenominator;
        address payable _wNative = _wNativeFromDex(dexInfo[_dexId].wNative);
        if (msg.value != _amountIn + minimal) {
            revert FeeMissing(_amountIn + minimal, msg.value, "amount + fees must = total");
        }
        if (_path[0] != _wNative) {
            revert NativeMissing(0);
        }
        emit FeesCollected(minimal, true);
        // convert native to wNative
        IWETH(_wNative).deposit{value: _amountIn}();
        uint256 actualAmountOut = swapExactTokenForTokenV2(_dexId, _path, _amountIn, _minAmountOut, _deadline);
        IERC20(_path[_path.length - 1]).safeTransfer(recipient, actualAmountOut);
        emit IMSwap(
            keccak256(abi.encode(_path[0], _path[_path.length - 1])),
            _amountIn,
            recipient,
            _dexId
        );
    }

    /**
     * @notice Swap ERC-20 Token, end with native currency
     * @param _dexId ID of the Dex
     * @param recipient address to receive funds
     * @param _path Token address array
     * @param _amountIn Input amount
     * @param _minAmountOut Output token amount
     * @param _deadline the time at which this transaction can no longer be run
     * @notice anything extra in msg.value is treated as a donation
     */
    function swapToNativeV2(
        uint256 _dexId,
        address payable recipient,
        address[] calldata _path,
        uint256 _amountIn,
        uint256 _minAmountOut,
        uint256 _deadline
    ) external payable {
        address payable _wNative = _wNativeFromDex(dexInfo[_dexId].wNative);
        if (_path[_path.length - 1] != _wNative) {
            revert NativeMissing(_path.length - 1);
        }
        uint256 actualAmountIn = collectFunds(_path[0], _amountIn);
        uint256 actualAmountOut = swapExactTokenForTokenV2(_dexId, _path, actualAmountIn, _minAmountOut, _deadline);
        uint256 actualAmountOutAfterFee = actualAmountOut - ((actualAmountOut * feeNumerator) / feeDenominator);
        emit FeesCollected(actualAmountOut - actualAmountOutAfterFee, false);
        _sendNativeTokensOutAfterUnwrap(_wNative, actualAmountOutAfterFee, recipient);
        emit IMSwap(
            keccak256(abi.encode(_path[0], _path[_path.length - 1])),
            _amountIn,
            recipient,
            _dexId
        );
    }

    function swapExactTokenForTokenV2(
        uint256 dexId,
        address[] calldata _path,
        uint256 _amountIn, // this value has been checked
        uint256 _minAmountOut, // this value will be met
        uint256 _deadline
    ) internal returns (uint256) {
        Dex memory dex = dexInfo[dexId];
        if (dex.disabled) {
            revert DexDisabled();
        }
        address last = _path[_path.length - 1];
        // approve router to swap tokens
        IERC20(_path[0]).approve(dex.router, _amountIn);
        // call to swap exact tokens
        uint256 balanceBefore = IERC20(last).balanceOf(address(this));
        IUniswapV2Router02(dex.router).swapExactTokensForTokensSupportingFeeOnTransferTokens(
            _amountIn,
            _minAmountOut,
            _path,
            address(this),
            _deadline
        );
        return IERC20(last).balanceOf(address(this)) - balanceBefore;
    }
}

File 2 of 34 : IAuthentication.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity >=0.7.0 <0.9.0;

interface IAuthentication {
    /**
     * @dev Returns the action identifier associated with the external function described by `selector`.
     */
    function getActionId(bytes4 selector) external view returns (bytes32);
}

File 3 of 34 : ISignaturesValidator.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity >=0.7.0 <0.9.0;

/**
 * @dev Interface for the SignatureValidator helper, used to support meta-transactions.
 */
interface ISignaturesValidator {
    /**
     * @dev Returns the EIP712 domain separator.
     */
    function getDomainSeparator() external view returns (bytes32);

    /**
     * @dev Returns the next nonce used by an address to sign messages.
     */
    function getNextNonce(address user) external view returns (uint256);
}

File 4 of 34 : ITemporarilyPausable.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity >=0.7.0 <0.9.0;

/**
 * @dev Interface for the TemporarilyPausable helper.
 */
interface ITemporarilyPausable {
    /**
     * @dev Emitted every time the pause state changes by `_setPaused`.
     */
    event PausedStateChanged(bool paused);

    /**
     * @dev Returns the current paused state.
     */
    function getPausedState()
        external
        view
        returns (
            bool paused,
            uint256 pauseWindowEndTime,
            uint256 bufferPeriodEndTime
        );
}

File 5 of 34 : IWETH.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity >=0.7.0 <0.9.0;

import "../openzeppelin/IERC20.sol";

/**
 * @dev Interface for WETH9.
 * See https://github.com/gnosis/canonical-weth/blob/0dd1ea3e295eef916d0c6223ec63141137d22d67/contracts/WETH9.sol
 */
interface IWETH is IERC20 {
    function deposit() external payable;

    function withdraw(uint256 amount) external;
}

File 6 of 34 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;

/**
 * @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 7 of 34 : IAsset.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity >=0.7.0 <0.9.0;

/**
 * @dev This is an empty interface used to represent either ERC20-conforming token contracts or ETH (using the zero
 * address sentinel value). We're just relying on the fact that `interface` can be used to declare new address-like
 * types.
 *
 * This concept is unrelated to a Pool's Asset Managers.
 */
interface IAsset {
    // solhint-disable-previous-line no-empty-blocks
}

File 8 of 34 : IAuthorizer.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity >=0.7.0 <0.9.0;

interface IAuthorizer {
    /**
     * @dev Returns true if `account` can perform the action described by `actionId` in the contract `where`.
     */
    function canPerform(
        bytes32 actionId,
        address account,
        address where
    ) external view returns (bool);
}

File 9 of 34 : IFlashLoanRecipient.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity >=0.7.0 <0.9.0;

// Inspired by Aave Protocol's IFlashLoanReceiver.

import "../solidity-utils/openzeppelin/IERC20.sol";

interface IFlashLoanRecipient {
    /**
     * @dev When `flashLoan` is called on the Vault, it invokes the `receiveFlashLoan` hook on the recipient.
     *
     * At the time of the call, the Vault will have transferred `amounts` for `tokens` to the recipient. Before this
     * call returns, the recipient must have transferred `amounts` plus `feeAmounts` for each token back to the
     * Vault, or else the entire flash loan will revert.
     *
     * `userData` is the same value passed in the `IVault.flashLoan` call.
     */
    function receiveFlashLoan(
        IERC20[] memory tokens,
        uint256[] memory amounts,
        uint256[] memory feeAmounts,
        bytes memory userData
    ) external;
}

File 10 of 34 : IProtocolFeesCollector.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity >=0.7.0 <0.9.0;
pragma experimental ABIEncoderV2;

import "../solidity-utils/openzeppelin/IERC20.sol";

import "./IVault.sol";
import "./IAuthorizer.sol";

interface IProtocolFeesCollector {
    event SwapFeePercentageChanged(uint256 newSwapFeePercentage);
    event FlashLoanFeePercentageChanged(uint256 newFlashLoanFeePercentage);

    function withdrawCollectedFees(
        IERC20[] calldata tokens,
        uint256[] calldata amounts,
        address recipient
    ) external;

    function setSwapFeePercentage(uint256 newSwapFeePercentage) external;

    function setFlashLoanFeePercentage(uint256 newFlashLoanFeePercentage) external;

    function getSwapFeePercentage() external view returns (uint256);

    function getFlashLoanFeePercentage() external view returns (uint256);

    function getCollectedFeeAmounts(IERC20[] memory tokens) external view returns (uint256[] memory feeAmounts);

    function getAuthorizer() external view returns (IAuthorizer);

    function vault() external view returns (IVault);
}

File 11 of 34 : IVault.sol
// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma experimental ABIEncoderV2;

import "../solidity-utils/openzeppelin/IERC20.sol";
import "../solidity-utils/helpers/IAuthentication.sol";
import "../solidity-utils/helpers/ISignaturesValidator.sol";
import "../solidity-utils/helpers/ITemporarilyPausable.sol";
import "../solidity-utils/misc/IWETH.sol";

import "./IAsset.sol";
import "./IAuthorizer.sol";
import "./IFlashLoanRecipient.sol";
import "./IProtocolFeesCollector.sol";

pragma solidity >=0.7.0 <0.9.0;

/**
 * @dev Full external interface for the Vault core contract - no external or public methods exist in the contract that
 * don't override one of these declarations.
 */
interface IVault is ISignaturesValidator, ITemporarilyPausable, IAuthentication {
    // Generalities about the Vault:
    //
    // - Whenever documentation refers to 'tokens', it strictly refers to ERC20-compliant token contracts. Tokens are
    // transferred out of the Vault by calling the `IERC20.transfer` function, and transferred in by calling
    // `IERC20.transferFrom`. In these cases, the sender must have previously allowed the Vault to use their tokens by
    // calling `IERC20.approve`. The only deviation from the ERC20 standard that is supported is functions not returning
    // a boolean value: in these scenarios, a non-reverting call is assumed to be successful.
    //
    // - All non-view functions in the Vault are non-reentrant: calling them while another one is mid-execution (e.g.
    // while execution control is transferred to a token contract during a swap) will result in a revert. View
    // functions can be called in a re-reentrant way, but doing so might cause them to return inconsistent results.
    // Contracts calling view functions in the Vault must make sure the Vault has not already been entered.
    //
    // - View functions revert if referring to either unregistered Pools, or unregistered tokens for registered Pools.

    // Authorizer
    //
    // Some system actions are permissioned, like setting and collecting protocol fees. This permissioning system exists
    // outside of the Vault in the Authorizer contract: the Vault simply calls the Authorizer to check if the caller
    // can perform a given action.

    /**
     * @dev Returns the Vault's Authorizer.
     */
    function getAuthorizer() external view returns (IAuthorizer);

    /**
     * @dev Sets a new Authorizer for the Vault. The caller must be allowed by the current Authorizer to do this.
     *
     * Emits an `AuthorizerChanged` event.
     */
    function setAuthorizer(IAuthorizer newAuthorizer) external;

    /**
     * @dev Emitted when a new authorizer is set by `setAuthorizer`.
     */
    event AuthorizerChanged(IAuthorizer indexed newAuthorizer);

    // Relayers
    //
    // Additionally, it is possible for an account to perform certain actions on behalf of another one, using their
    // Vault ERC20 allowance and Internal Balance. These accounts are said to be 'relayers' for these Vault functions,
    // and are expected to be smart contracts with sound authentication mechanisms. For an account to be able to wield
    // this power, two things must occur:
    //  - The Authorizer must grant the account the permission to be a relayer for the relevant Vault function. This
    //    means that Balancer governance must approve each individual contract to act as a relayer for the intended
    //    functions.
    //  - Each user must approve the relayer to act on their behalf.
    // This double protection means users cannot be tricked into approving malicious relayers (because they will not
    // have been allowed by the Authorizer via governance), nor can malicious relayers approved by a compromised
    // Authorizer or governance drain user funds, since they would also need to be approved by each individual user.

    /**
     * @dev Returns true if `user` has approved `relayer` to act as a relayer for them.
     */
    function hasApprovedRelayer(address user, address relayer) external view returns (bool);

    /**
     * @dev Allows `relayer` to act as a relayer for `sender` if `approved` is true, and disallows it otherwise.
     *
     * Emits a `RelayerApprovalChanged` event.
     */
    function setRelayerApproval(
        address sender,
        address relayer,
        bool approved
    ) external;

    /**
     * @dev Emitted every time a relayer is approved or disapproved by `setRelayerApproval`.
     */
    event RelayerApprovalChanged(address indexed relayer, address indexed sender, bool approved);

    // Internal Balance
    //
    // Users can deposit tokens into the Vault, where they are allocated to their Internal Balance, and later
    // transferred or withdrawn. It can also be used as a source of tokens when joining Pools, as a destination
    // when exiting them, and as either when performing swaps. This usage of Internal Balance results in greatly reduced
    // gas costs when compared to relying on plain ERC20 transfers, leading to large savings for frequent users.
    //
    // Internal Balance management features batching, which means a single contract call can be used to perform multiple
    // operations of different kinds, with different senders and recipients, at once.

    /**
     * @dev Returns `user`'s Internal Balance for a set of tokens.
     */
    function getInternalBalance(address user, IERC20[] memory tokens) external view returns (uint256[] memory);

    /**
     * @dev Performs a set of user balance operations, which involve Internal Balance (deposit, withdraw or transfer)
     * and plain ERC20 transfers using the Vault's allowance. This last feature is particularly useful for relayers, as
     * it lets integrators reuse a user's Vault allowance.
     *
     * For each operation, if the caller is not `sender`, it must be an authorized relayer for them.
     */
    function manageUserBalance(UserBalanceOp[] memory ops) external payable;

    /**
     * @dev Data for `manageUserBalance` operations, which include the possibility for ETH to be sent and received
     without manual WETH wrapping or unwrapping.
     */
    struct UserBalanceOp {
        UserBalanceOpKind kind;
        IAsset asset;
        uint256 amount;
        address sender;
        address payable recipient;
    }

    // There are four possible operations in `manageUserBalance`:
    //
    // - DEPOSIT_INTERNAL
    // Increases the Internal Balance of the `recipient` account by transferring tokens from the corresponding
    // `sender`. The sender must have allowed the Vault to use their tokens via `IERC20.approve()`.
    //
    // ETH can be used by passing the ETH sentinel value as the asset and forwarding ETH in the call: it will be wrapped
    // and deposited as WETH. Any ETH amount remaining will be sent back to the caller (not the sender, which is
    // relevant for relayers).
    //
    // Emits an `InternalBalanceChanged` event.
    //
    //
    // - WITHDRAW_INTERNAL
    // Decreases the Internal Balance of the `sender` account by transferring tokens to the `recipient`.
    //
    // ETH can be used by passing the ETH sentinel value as the asset. This will deduct WETH instead, unwrap it and send
    // it to the recipient as ETH.
    //
    // Emits an `InternalBalanceChanged` event.
    //
    //
    // - TRANSFER_INTERNAL
    // Transfers tokens from the Internal Balance of the `sender` account to the Internal Balance of `recipient`.
    //
    // Reverts if the ETH sentinel value is passed.
    //
    // Emits an `InternalBalanceChanged` event.
    //
    //
    // - TRANSFER_EXTERNAL
    // Transfers tokens from `sender` to `recipient`, using the Vault's ERC20 allowance. This is typically used by
    // relayers, as it lets them reuse a user's Vault allowance.
    //
    // Reverts if the ETH sentinel value is passed.
    //
    // Emits an `ExternalBalanceTransfer` event.

    enum UserBalanceOpKind { DEPOSIT_INTERNAL, WITHDRAW_INTERNAL, TRANSFER_INTERNAL, TRANSFER_EXTERNAL }

    /**
     * @dev Emitted when a user's Internal Balance changes, either from calls to `manageUserBalance`, or through
     * interacting with Pools using Internal Balance.
     *
     * Because Internal Balance works exclusively with ERC20 tokens, ETH deposits and withdrawals will use the WETH
     * address.
     */
    event InternalBalanceChanged(address indexed user, IERC20 indexed token, int256 delta);

    /**
     * @dev Emitted when a user's Vault ERC20 allowance is used by the Vault to transfer tokens to an external account.
     */
    event ExternalBalanceTransfer(IERC20 indexed token, address indexed sender, address recipient, uint256 amount);

    // Pools
    //
    // There are three specialization settings for Pools, which allow for cheaper swaps at the cost of reduced
    // functionality:
    //
    //  - General: no specialization, suited for all Pools. IGeneralPool is used for swap request callbacks, passing the
    // balance of all tokens in the Pool. These Pools have the largest swap costs (because of the extra storage reads),
    // which increase with the number of registered tokens.
    //
    //  - Minimal Swap Info: IMinimalSwapInfoPool is used instead of IGeneralPool, which saves gas by only passing the
    // balance of the two tokens involved in the swap. This is suitable for some pricing algorithms, like the weighted
    // constant product one popularized by Balancer V1. Swap costs are smaller compared to general Pools, and are
    // independent of the number of registered tokens.
    //
    //  - Two Token: only allows two tokens to be registered. This achieves the lowest possible swap gas cost. Like
    // minimal swap info Pools, these are called via IMinimalSwapInfoPool.

    enum PoolSpecialization { GENERAL, MINIMAL_SWAP_INFO, TWO_TOKEN }

    /**
     * @dev Registers the caller account as a Pool with a given specialization setting. Returns the Pool's ID, which
     * is used in all Pool-related functions. Pools cannot be deregistered, nor can the Pool's specialization be
     * changed.
     *
     * The caller is expected to be a smart contract that implements either `IGeneralPool` or `IMinimalSwapInfoPool`,
     * depending on the chosen specialization setting. This contract is known as the Pool's contract.
     *
     * Note that the same contract may register itself as multiple Pools with unique Pool IDs, or in other words,
     * multiple Pools may share the same contract.
     *
     * Emits a `PoolRegistered` event.
     */
    function registerPool(PoolSpecialization specialization) external returns (bytes32);

    /**
     * @dev Emitted when a Pool is registered by calling `registerPool`.
     */
    event PoolRegistered(bytes32 indexed poolId, address indexed poolAddress, PoolSpecialization specialization);

    /**
     * @dev Returns a Pool's contract address and specialization setting.
     */
    function getPool(bytes32 poolId) external view returns (address, PoolSpecialization);

    /**
     * @dev Registers `tokens` for the `poolId` Pool. Must be called by the Pool's contract.
     *
     * Pools can only interact with tokens they have registered. Users join a Pool by transferring registered tokens,
     * exit by receiving registered tokens, and can only swap registered tokens.
     *
     * Each token can only be registered once. For Pools with the Two Token specialization, `tokens` must have a length
     * of two, that is, both tokens must be registered in the same `registerTokens` call, and they must be sorted in
     * ascending order.
     *
     * The `tokens` and `assetManagers` arrays must have the same length, and each entry in these indicates the Asset
     * Manager for the corresponding token. Asset Managers can manage a Pool's tokens via `managePoolBalance`,
     * depositing and withdrawing them directly, and can even set their balance to arbitrary amounts. They are therefore
     * expected to be highly secured smart contracts with sound design principles, and the decision to register an
     * Asset Manager should not be made lightly.
     *
     * Pools can choose not to assign an Asset Manager to a given token by passing in the zero address. Once an Asset
     * Manager is set, it cannot be changed except by deregistering the associated token and registering again with a
     * different Asset Manager.
     *
     * Emits a `TokensRegistered` event.
     */
    function registerTokens(
        bytes32 poolId,
        IERC20[] memory tokens,
        address[] memory assetManagers
    ) external;

    /**
     * @dev Emitted when a Pool registers tokens by calling `registerTokens`.
     */
    event TokensRegistered(bytes32 indexed poolId, IERC20[] tokens, address[] assetManagers);

    /**
     * @dev Deregisters `tokens` for the `poolId` Pool. Must be called by the Pool's contract.
     *
     * Only registered tokens (via `registerTokens`) can be deregistered. Additionally, they must have zero total
     * balance. For Pools with the Two Token specialization, `tokens` must have a length of two, that is, both tokens
     * must be deregistered in the same `deregisterTokens` call.
     *
     * A deregistered token can be re-registered later on, possibly with a different Asset Manager.
     *
     * Emits a `TokensDeregistered` event.
     */
    function deregisterTokens(bytes32 poolId, IERC20[] memory tokens) external;

    /**
     * @dev Emitted when a Pool deregisters tokens by calling `deregisterTokens`.
     */
    event TokensDeregistered(bytes32 indexed poolId, IERC20[] tokens);

    /**
     * @dev Returns detailed information for a Pool's registered token.
     *
     * `cash` is the number of tokens the Vault currently holds for the Pool. `managed` is the number of tokens
     * withdrawn and held outside the Vault by the Pool's token Asset Manager. The Pool's total balance for `token`
     * equals the sum of `cash` and `managed`.
     *
     * Internally, `cash` and `managed` are stored using 112 bits. No action can ever cause a Pool's token `cash`,
     * `managed` or `total` balance to be greater than 2^112 - 1.
     *
     * `lastChangeBlock` is the number of the block in which `token`'s total balance was last modified (via either a
     * join, exit, swap, or Asset Manager update). This value is useful to avoid so-called 'sandwich attacks', for
     * example when developing price oracles. A change of zero (e.g. caused by a swap with amount zero) is considered a
     * change for this purpose, and will update `lastChangeBlock`.
     *
     * `assetManager` is the Pool's token Asset Manager.
     */
    function getPoolTokenInfo(bytes32 poolId, IERC20 token)
        external
        view
        returns (
            uint256 cash,
            uint256 managed,
            uint256 lastChangeBlock,
            address assetManager
        );

    /**
     * @dev Returns a Pool's registered tokens, the total balance for each, and the latest block when *any* of
     * the tokens' `balances` changed.
     *
     * The order of the `tokens` array is the same order that will be used in `joinPool`, `exitPool`, as well as in all
     * Pool hooks (where applicable). Calls to `registerTokens` and `deregisterTokens` may change this order.
     *
     * If a Pool only registers tokens once, and these are sorted in ascending order, they will be stored in the same
     * order as passed to `registerTokens`.
     *
     * Total balances include both tokens held by the Vault and those withdrawn by the Pool's Asset Managers. These are
     * the amounts used by joins, exits and swaps. For a detailed breakdown of token balances, use `getPoolTokenInfo`
     * instead.
     */
    function getPoolTokens(bytes32 poolId)
        external
        view
        returns (
            IERC20[] memory tokens,
            uint256[] memory balances,
            uint256 lastChangeBlock
        );

    /**
     * @dev Called by users to join a Pool, which transfers tokens from `sender` into the Pool's balance. This will
     * trigger custom Pool behavior, which will typically grant something in return to `recipient` - often tokenized
     * Pool shares.
     *
     * If the caller is not `sender`, it must be an authorized relayer for them.
     *
     * The `assets` and `maxAmountsIn` arrays must have the same length, and each entry indicates the maximum amount
     * to send for each asset. The amounts to send are decided by the Pool and not the Vault: it just enforces
     * these maximums.
     *
     * If joining a Pool that holds WETH, it is possible to send ETH directly: the Vault will do the wrapping. To enable
     * this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead of the
     * WETH address. Note that it is not possible to combine ETH and WETH in the same join. Any excess ETH will be sent
     * back to the caller (not the sender, which is important for relayers).
     *
     * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when
     * interacting with Pools that register and deregister tokens frequently. If sending ETH however, the array must be
     * sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the final
     * `assets` array might not be sorted. Pools with no registered tokens cannot be joined.
     *
     * If `fromInternalBalance` is true, the caller's Internal Balance will be preferred: ERC20 transfers will only
     * be made for the difference between the requested amount and Internal Balance (if any). Note that ETH cannot be
     * withdrawn from Internal Balance: attempting to do so will trigger a revert.
     *
     * This causes the Vault to call the `IBasePool.onJoinPool` hook on the Pool's contract, where Pools implement
     * their own custom logic. This typically requires additional information from the user (such as the expected number
     * of Pool shares). This can be encoded in the `userData` argument, which is ignored by the Vault and passed
     * directly to the Pool's contract, as is `recipient`.
     *
     * Emits a `PoolBalanceChanged` event.
     */
    function joinPool(
        bytes32 poolId,
        address sender,
        address recipient,
        JoinPoolRequest memory request
    ) external payable;

    struct JoinPoolRequest {
        IAsset[] assets;
        uint256[] maxAmountsIn;
        bytes userData;
        bool fromInternalBalance;
    }

    /**
     * @dev Called by users to exit a Pool, which transfers tokens from the Pool's balance to `recipient`. This will
     * trigger custom Pool behavior, which will typically ask for something in return from `sender` - often tokenized
     * Pool shares. The amount of tokens that can be withdrawn is limited by the Pool's `cash` balance (see
     * `getPoolTokenInfo`).
     *
     * If the caller is not `sender`, it must be an authorized relayer for them.
     *
     * The `tokens` and `minAmountsOut` arrays must have the same length, and each entry in these indicates the minimum
     * token amount to receive for each token contract. The amounts to send are decided by the Pool and not the Vault:
     * it just enforces these minimums.
     *
     * If exiting a Pool that holds WETH, it is possible to receive ETH directly: the Vault will do the unwrapping. To
     * enable this mechanism, the IAsset sentinel value (the zero address) must be passed in the `assets` array instead
     * of the WETH address. Note that it is not possible to combine ETH and WETH in the same exit.
     *
     * `assets` must have the same length and order as the array returned by `getPoolTokens`. This prevents issues when
     * interacting with Pools that register and deregister tokens frequently. If receiving ETH however, the array must
     * be sorted *before* replacing the WETH address with the ETH sentinel value (the zero address), which means the
     * final `assets` array might not be sorted. Pools with no registered tokens cannot be exited.
     *
     * If `toInternalBalance` is true, the tokens will be deposited to `recipient`'s Internal Balance. Otherwise,
     * an ERC20 transfer will be performed. Note that ETH cannot be deposited to Internal Balance: attempting to
     * do so will trigger a revert.
     *
     * `minAmountsOut` is the minimum amount of tokens the user expects to get out of the Pool, for each token in the
     * `tokens` array. This array must match the Pool's registered tokens.
     *
     * This causes the Vault to call the `IBasePool.onExitPool` hook on the Pool's contract, where Pools implement
     * their own custom logic. This typically requires additional information from the user (such as the expected number
     * of Pool shares to return). This can be encoded in the `userData` argument, which is ignored by the Vault and
     * passed directly to the Pool's contract.
     *
     * Emits a `PoolBalanceChanged` event.
     */
    function exitPool(
        bytes32 poolId,
        address sender,
        address payable recipient,
        ExitPoolRequest memory request
    ) external;

    struct ExitPoolRequest {
        IAsset[] assets;
        uint256[] minAmountsOut;
        bytes userData;
        bool toInternalBalance;
    }

    /**
     * @dev Emitted when a user joins or exits a Pool by calling `joinPool` or `exitPool`, respectively.
     */
    event PoolBalanceChanged(
        bytes32 indexed poolId,
        address indexed liquidityProvider,
        IERC20[] tokens,
        int256[] deltas,
        uint256[] protocolFeeAmounts
    );

    enum PoolBalanceChangeKind { JOIN, EXIT }

    // Swaps
    //
    // Users can swap tokens with Pools by calling the `swap` and `batchSwap` functions. To do this,
    // they need not trust Pool contracts in any way: all security checks are made by the Vault. They must however be
    // aware of the Pools' pricing algorithms in order to estimate the prices Pools will quote.
    //
    // The `swap` function executes a single swap, while `batchSwap` can perform multiple swaps in sequence.
    // In each individual swap, tokens of one kind are sent from the sender to the Pool (this is the 'token in'),
    // and tokens of another kind are sent from the Pool to the recipient in exchange (this is the 'token out').
    // More complex swaps, such as one token in to multiple tokens out can be achieved by batching together
    // individual swaps.
    //
    // There are two swap kinds:
    //  - 'given in' swaps, where the amount of tokens in (sent to the Pool) is known, and the Pool determines (via the
    // `onSwap` hook) the amount of tokens out (to send to the recipient).
    //  - 'given out' swaps, where the amount of tokens out (received from the Pool) is known, and the Pool determines
    // (via the `onSwap` hook) the amount of tokens in (to receive from the sender).
    //
    // Additionally, it is possible to chain swaps using a placeholder input amount, which the Vault replaces with
    // the calculated output of the previous swap. If the previous swap was 'given in', this will be the calculated
    // tokenOut amount. If the previous swap was 'given out', it will use the calculated tokenIn amount. These extended
    // swaps are known as 'multihop' swaps, since they 'hop' through a number of intermediate tokens before arriving at
    // the final intended token.
    //
    // In all cases, tokens are only transferred in and out of the Vault (or withdrawn from and deposited into Internal
    // Balance) after all individual swaps have been completed, and the net token balance change computed. This makes
    // certain swap patterns, such as multihops, or swaps that interact with the same token pair in multiple Pools, cost
    // much less gas than they would otherwise.
    //
    // It also means that under certain conditions it is possible to perform arbitrage by swapping with multiple
    // Pools in a way that results in net token movement out of the Vault (profit), with no tokens being sent in (only
    // updating the Pool's internal accounting).
    //
    // To protect users from front-running or the market changing rapidly, they supply a list of 'limits' for each token
    // involved in the swap, where either the maximum number of tokens to send (by passing a positive value) or the
    // minimum amount of tokens to receive (by passing a negative value) is specified.
    //
    // Additionally, a 'deadline' timestamp can also be provided, forcing the swap to fail if it occurs after
    // this point in time (e.g. if the transaction failed to be included in a block promptly).
    //
    // If interacting with Pools that hold WETH, it is possible to both send and receive ETH directly: the Vault will do
    // the wrapping and unwrapping. To enable this mechanism, the IAsset sentinel value (the zero address) must be
    // passed in the `assets` array instead of the WETH address. Note that it is possible to combine ETH and WETH in the
    // same swap. Any excess ETH will be sent back to the caller (not the sender, which is relevant for relayers).
    //
    // Finally, Internal Balance can be used when either sending or receiving tokens.

    enum SwapKind { GIVEN_IN, GIVEN_OUT }

    /**
     * @dev Performs a swap with a single Pool.
     *
     * If the swap is 'given in' (the number of tokens to send to the Pool is known), it returns the amount of tokens
     * taken from the Pool, which must be greater than or equal to `limit`.
     *
     * If the swap is 'given out' (the number of tokens to take from the Pool is known), it returns the amount of tokens
     * sent to the Pool, which must be less than or equal to `limit`.
     *
     * Internal Balance usage and the recipient are determined by the `funds` struct.
     *
     * Emits a `Swap` event.
     */
    function swap(
        SingleSwap memory singleSwap,
        FundManagement memory funds,
        uint256 limit,
        uint256 deadline
    ) external payable returns (uint256);

    /**
     * @dev Data for a single swap executed by `swap`. `amount` is either `amountIn` or `amountOut` depending on
     * the `kind` value.
     *
     * `assetIn` and `assetOut` are either token addresses, or the IAsset sentinel value for ETH (the zero address).
     * Note that Pools never interact with ETH directly: it will be wrapped to or unwrapped from WETH by the Vault.
     *
     * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be
     * used to extend swap behavior.
     */
    struct SingleSwap {
        bytes32 poolId;
        SwapKind kind;
        IAsset assetIn;
        IAsset assetOut;
        uint256 amount;
        bytes userData;
    }

    /**
     * @dev Performs a series of swaps with one or multiple Pools. In each individual swap, the caller determines either
     * the amount of tokens sent to or received from the Pool, depending on the `kind` value.
     *
     * Returns an array with the net Vault asset balance deltas. Positive amounts represent tokens (or ETH) sent to the
     * Vault, and negative amounts represent tokens (or ETH) sent by the Vault. Each delta corresponds to the asset at
     * the same index in the `assets` array.
     *
     * Swaps are executed sequentially, in the order specified by the `swaps` array. Each array element describes a
     * Pool, the token to be sent to this Pool, the token to receive from it, and an amount that is either `amountIn` or
     * `amountOut` depending on the swap kind.
     *
     * Multihop swaps can be executed by passing an `amount` value of zero for a swap. This will cause the amount in/out
     * of the previous swap to be used as the amount in for the current one. In a 'given in' swap, 'tokenIn' must equal
     * the previous swap's `tokenOut`. For a 'given out' swap, `tokenOut` must equal the previous swap's `tokenIn`.
     *
     * The `assets` array contains the addresses of all assets involved in the swaps. These are either token addresses,
     * or the IAsset sentinel value for ETH (the zero address). Each entry in the `swaps` array specifies tokens in and
     * out by referencing an index in `assets`. Note that Pools never interact with ETH directly: it will be wrapped to
     * or unwrapped from WETH by the Vault.
     *
     * Internal Balance usage, sender, and recipient are determined by the `funds` struct. The `limits` array specifies
     * the minimum or maximum amount of each token the vault is allowed to transfer.
     *
     * `batchSwap` can be used to make a single swap, like `swap` does, but doing so requires more gas than the
     * equivalent `swap` call.
     *
     * Emits `Swap` events.
     */
    function batchSwap(
        SwapKind kind,
        BatchSwapStep[] memory swaps,
        IAsset[] memory assets,
        FundManagement memory funds,
        int256[] memory limits,
        uint256 deadline
    ) external payable returns (int256[] memory);

    /**
     * @dev Data for each individual swap executed by `batchSwap`. The asset in and out fields are indexes into the
     * `assets` array passed to that function, and ETH assets are converted to WETH.
     *
     * If `amount` is zero, the multihop mechanism is used to determine the actual amount based on the amount in/out
     * from the previous swap, depending on the swap kind.
     *
     * The `userData` field is ignored by the Vault, but forwarded to the Pool in the `onSwap` hook, and may be
     * used to extend swap behavior.
     */
    struct BatchSwapStep {
        bytes32 poolId;
        uint256 assetInIndex;
        uint256 assetOutIndex;
        uint256 amount;
        bytes userData;
    }

    /**
     * @dev Emitted for each individual swap performed by `swap` or `batchSwap`.
     */
    event Swap(
        bytes32 indexed poolId,
        IERC20 indexed tokenIn,
        IERC20 indexed tokenOut,
        uint256 amountIn,
        uint256 amountOut
    );

    /**
     * @dev All tokens in a swap are either sent from the `sender` account to the Vault, or from the Vault to the
     * `recipient` account.
     *
     * If the caller is not `sender`, it must be an authorized relayer for them.
     *
     * If `fromInternalBalance` is true, the `sender`'s Internal Balance will be preferred, performing an ERC20
     * transfer for the difference between the requested amount and the User's Internal Balance (if any). The `sender`
     * must have allowed the Vault to use their tokens via `IERC20.approve()`. This matches the behavior of
     * `joinPool`.
     *
     * If `toInternalBalance` is true, tokens will be deposited to `recipient`'s internal balance instead of
     * transferred. This matches the behavior of `exitPool`.
     *
     * Note that ETH cannot be deposited to or withdrawn from Internal Balance: attempting to do so will trigger a
     * revert.
     */
    struct FundManagement {
        address sender;
        bool fromInternalBalance;
        address payable recipient;
        bool toInternalBalance;
    }

    /**
     * @dev Simulates a call to `batchSwap`, returning an array of Vault asset deltas. Calls to `swap` cannot be
     * simulated directly, but an equivalent `batchSwap` call can and will yield the exact same result.
     *
     * Each element in the array corresponds to the asset at the same index, and indicates the number of tokens (or ETH)
     * the Vault would take from the sender (if positive) or send to the recipient (if negative). The arguments it
     * receives are the same that an equivalent `batchSwap` call would receive.
     *
     * Unlike `batchSwap`, this function performs no checks on the sender or recipient field in the `funds` struct.
     * This makes it suitable to be called by off-chain applications via eth_call without needing to hold tokens,
     * approve them for the Vault, or even know a user's address.
     *
     * Note that this function is not 'view' (due to implementation details): the client code must explicitly execute
     * eth_call instead of eth_sendTransaction.
     */
    function queryBatchSwap(
        SwapKind kind,
        BatchSwapStep[] memory swaps,
        IAsset[] memory assets,
        FundManagement memory funds
    ) external returns (int256[] memory assetDeltas);

    // Flash Loans

    /**
     * @dev Performs a 'flash loan', sending tokens to `recipient`, executing the `receiveFlashLoan` hook on it,
     * and then reverting unless the tokens plus a proportional protocol fee have been returned.
     *
     * The `tokens` and `amounts` arrays must have the same length, and each entry in these indicates the loan amount
     * for each token contract. `tokens` must be sorted in ascending order.
     *
     * The 'userData' field is ignored by the Vault, and forwarded as-is to `recipient` as part of the
     * `receiveFlashLoan` call.
     *
     * Emits `FlashLoan` events.
     */
    function flashLoan(
        IFlashLoanRecipient recipient,
        IERC20[] memory tokens,
        uint256[] memory amounts,
        bytes memory userData
    ) external;

    /**
     * @dev Emitted for each individual flash loan performed by `flashLoan`.
     */
    event FlashLoan(IFlashLoanRecipient indexed recipient, IERC20 indexed token, uint256 amount, uint256 feeAmount);

    // Asset Management
    //
    // Each token registered for a Pool can be assigned an Asset Manager, which is able to freely withdraw the Pool's
    // tokens from the Vault, deposit them, or assign arbitrary values to its `managed` balance (see
    // `getPoolTokenInfo`). This makes them extremely powerful and dangerous. Even if an Asset Manager only directly
    // controls one of the tokens in a Pool, a malicious manager could set that token's balance to manipulate the
    // prices of the other tokens, and then drain the Pool with swaps. The risk of using Asset Managers is therefore
    // not constrained to the tokens they are managing, but extends to the entire Pool's holdings.
    //
    // However, a properly designed Asset Manager smart contract can be safely used for the Pool's benefit,
    // for example by lending unused tokens out for interest, or using them to participate in voting protocols.
    //
    // This concept is unrelated to the IAsset interface.

    /**
     * @dev Performs a set of Pool balance operations, which may be either withdrawals, deposits or updates.
     *
     * Pool Balance management features batching, which means a single contract call can be used to perform multiple
     * operations of different kinds, with different Pools and tokens, at once.
     *
     * For each operation, the caller must be registered as the Asset Manager for `token` in `poolId`.
     */
    function managePoolBalance(PoolBalanceOp[] memory ops) external;

    struct PoolBalanceOp {
        PoolBalanceOpKind kind;
        bytes32 poolId;
        IERC20 token;
        uint256 amount;
    }

    /**
     * Withdrawals decrease the Pool's cash, but increase its managed balance, leaving the total balance unchanged.
     *
     * Deposits increase the Pool's cash, but decrease its managed balance, leaving the total balance unchanged.
     *
     * Updates don't affect the Pool's cash balance, but because the managed balance changes, it does alter the total.
     * The external amount can be either increased or decreased by this call (i.e., reporting a gain or a loss).
     */
    enum PoolBalanceOpKind { WITHDRAW, DEPOSIT, UPDATE }

    /**
     * @dev Emitted when a Pool's token Asset Manager alters its balance via `managePoolBalance`.
     */
    event PoolBalanceManaged(
        bytes32 indexed poolId,
        address indexed assetManager,
        IERC20 indexed token,
        int256 cashDelta,
        int256 managedDelta
    );

    // Protocol Fees
    //
    // Some operations cause the Vault to collect tokens in the form of protocol fees, which can then be withdrawn by
    // permissioned accounts.
    //
    // There are two kinds of protocol fees:
    //
    //  - flash loan fees: charged on all flash loans, as a percentage of the amounts lent.
    //
    //  - swap fees: a percentage of the fees charged by Pools when performing swaps. For a number of reasons, including
    // swap gas costs and interface simplicity, protocol swap fees are not charged on each individual swap. Rather,
    // Pools are expected to keep track of how much they have charged in swap fees, and pay any outstanding debts to the
    // Vault when they are joined or exited. This prevents users from joining a Pool with unpaid debt, as well as
    // exiting a Pool in debt without first paying their share.

    /**
     * @dev Returns the current protocol fee module.
     */
    function getProtocolFeesCollector() external view returns (IProtocolFeesCollector);

    /**
     * @dev Safety mechanism to pause most Vault operations in the event of an emergency - typically detection of an
     * error in some part of the system.
     *
     * The Vault can only be paused during an initial time period, after which pausing is forever disabled.
     *
     * While the contract is paused, the following features are disabled:
     * - depositing and transferring internal balance
     * - transferring external balance (using the Vault's allowance)
     * - swaps
     * - joining Pools
     * - Asset Manager interactions
     *
     * Internal Balance can still be withdrawn, and Pools exited.
     */
    function setPaused(bool paused) external;

    /**
     * @dev Returns the Vault's WETH instance.
     */
    function WETH() external view returns (IWETH);
    // solhint-disable-previous-line func-name-mixedcase
}

File 12 of 34 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

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

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

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

pragma solidity ^0.8.0;

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

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

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

File 14 of 34 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 15 of 34 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

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

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 18 of 34 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 19 of 34 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 20 of 34 : IV3SwapRouter.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;

import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';

/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface IV3SwapRouter is IUniswapV3SwapCallback {
    struct ExactInputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 amountIn;
        uint256 amountOutMinimum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another token
    /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,
    /// and swap the entire amount, enabling contracts to send tokens before calling this function.
    /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);

    struct ExactInputParams {
        bytes path;
        address recipient;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
    /// @dev Setting `amountIn` to 0 will cause the contract to look up its own balance,
    /// and swap the entire amount, enabling contracts to send tokens before calling this function.
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);

    struct ExactOutputSingleParams {
        address tokenIn;
        address tokenOut;
        uint24 fee;
        address recipient;
        uint256 amountOut;
        uint256 amountInMaximum;
        uint160 sqrtPriceLimitX96;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another token
    /// that may remain in the router after the swap.
    /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);

    struct ExactOutputParams {
        bytes path;
        address recipient;
        uint256 amountOut;
        uint256 amountInMaximum;
    }

    /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
    /// that may remain in the router after the swap.
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
    /// @return amountIn The amount of the input token
    function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);
}

File 21 of 34 : IUniswapV2Factory.sol
pragma solidity >=0.5.0;

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

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

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

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

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

File 22 of 34 : IUniswapV2Pair.sol
pragma solidity >=0.5.0;

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

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

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

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

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

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

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

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

    function initialize(address, address) external;
}

File 23 of 34 : IUniswapV2Router01.sol
pragma solidity >=0.6.2;

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

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

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

File 24 of 34 : IUniswapV2Router02.sol
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

File 25 of 34 : IUniswapV3SwapCallback.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
    /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
    /// @dev In the implementation you must pay the pool tokens owed for the swap.
    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
    /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
    /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
    /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
    /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
    function uniswapV3SwapCallback(
        int256 amount0Delta,
        int256 amount1Delta,
        bytes calldata data
    ) external;
}

File 26 of 34 : IPiteasRouter.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IPiteasRouter {
  struct Detail {
        IERC20 srcToken;
        IERC20 destToken;
        address payable destAccount;
        uint256 srcAmount;
        uint256 destMinAmount;
    }

  function swap(
    Detail memory detail,
    bytes calldata data)
    external payable returns (uint256);
}

File 27 of 34 : IWETH.sol
// SPDX-License-Identifier: UNLICENSED
// !! THIS FILE WAS AUTOGENERATED BY abi-to-sol v0.6.6. SEE SOURCE BELOW. !!
pragma solidity 0.8.17;

interface IWETH {
    function name() external view returns (string memory);

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

    function totalSupply() external view returns (uint256);

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

    function withdraw(uint256 wad) external;

    function decimals() external view returns (uint8);

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

    function symbol() external view returns (string memory);

    function transfer(address dst, uint256 wad) external returns (bool);

    function deposit() external payable;

    function allowance(address, address) external view returns (uint256);

    receive() external payable;

    event Approval(address indexed src, address indexed guy, uint256 wad);
    event Transfer(address indexed src, address indexed dst, uint256 wad);
    event Deposit(address indexed dst, uint256 wad);
    event Withdrawal(address indexed src, uint256 wad);
}

// THIS FILE WAS AUTOGENERATED FROM THE FOLLOWING ABI JSON:
/*
[{"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"name":"guy","type":"address"},{"name":"wad","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"wad","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"},{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"address"},{"indexed":true,"name":"guy","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"address"},{"indexed":true,"name":"dst","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"dst","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"src","type":"address"},{"indexed":false,"name":"wad","type":"uint256"}],"name":"Withdrawal","type":"event"}]
*/

File 28 of 34 : Migratable.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import "@openzeppelin/contracts/access/Ownable.sol";

abstract contract Migratable is Ownable {
    address[] public migrationAddresses;
    event UpdateMigrationAddresses(address indexed executor, address[] addresses);
    function setMigrationAddress(address[] calldata _migrationAddresses) external onlyOwner {
        migrationAddresses = _migrationAddresses;
        emit UpdateMigrationAddresses(_msgSender(), _migrationAddresses);
    }
}

File 29 of 34 : BytesLib.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
// creds https://gist.github.com/rmeissner/76d6345796909ee41fb9f36fdaa4d15f - Stackoverflow

library BytesLib {  
  function slice(
        bytes memory _bytes,
        uint256 _start,
        uint256 _length
    )
        internal
        pure
        returns (bytes memory)
    {
        require(_length + 31 >= _length, "slice_overflow");
        require(_bytes.length >= _start + _length, "slice_outOfBounds");

        bytes memory tempBytes;

        // Check length is 0. `iszero` return 1 for `true` and 0 for `false`.
        assembly {
            switch iszero(_length)
            case 0 {
                // Get a location of some free memory and store it in tempBytes as
                // Solidity does for memory variables.
                tempBytes := mload(0x40)

                // Calculate length mod 32 to handle slices that are not a multiple of 32 in size.
                let lengthmod := and(_length, 31)

                // tempBytes will have the following format in memory: <length><data>
                // When copying data we will offset the start forward to avoid allocating additional memory
                // Therefore part of the length area will be written, but this will be overwritten later anyways.
                // In case no offset is require, the start is set to the data region (0x20 from the tempBytes)
                // mc will be used to keep track where to copy the data to.
                let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
                let end := add(mc, _length)

                for {
                    // Same logic as for mc is applied and additionally the start offset specified for the method is added
                    let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
                } lt(mc, end) {
                    // increase `mc` and `cc` to read the next word from memory
                    mc := add(mc, 0x20)
                    cc := add(cc, 0x20)
                } {
                    // Copy the data from source (cc location) to the slice data (mc location)
                    mstore(mc, mload(cc))
                }

                // Store the length of the slice. This will overwrite any partial data that 
                // was copied when having slices that are not a multiple of 32.
                mstore(tempBytes, _length)

                // update free-memory pointer
                // allocating the array padded to 32 bytes like the compiler does now
                // To set the used memory as a multiple of 32, add 31 to the actual memory usage (mc) 
                // and remove the modulo 32 (the `and` with `not(31)`)
                mstore(0x40, and(add(mc, 31), not(31)))
            }
            // if we want a zero-length slice let's just return a zero-length array
            default {
                tempBytes := mload(0x40)
                // zero out the 32 bytes slice we are about to return
                // we need to do it because Solidity does not garbage collect
                mstore(tempBytes, 0)

                // update free-memory pointer
                // tempBytes uses 32 bytes in memory (even when empty) for the length.
                mstore(0x40, add(tempBytes, 0x20))
            }
        }

        return tempBytes;
    }
}

File 30 of 34 : DexTracker.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import "@openzeppelin/contracts/access/Ownable.sol";

contract DexTracker is Ownable {
  error DexConflict(uint256 dexIndex);
  error DexDisabled();
  error DexTypeInvalid();
  event AddDex(address indexed executor, uint256 indexed dexId);
  event UpdateDex(address indexed executor, uint256 indexed dexId);

  struct Dex {
    uint64 id;
    address router;
    bool disabled;
    address payable wNative;
    DexType dexType;
    string name;
  }
  enum DexType {
    UNKNOWN,
    UNI_V2,
    UNI_V3,
    BAL_V2,
    PITEAS
  }
  Dex[] public dexInfo;
  function dexInfoSize() external view returns(uint256) {
    return dexInfo.length;
  }
  /**
   * @notice map a router to a dex to check
   * if the router was already added, the addition should fail
   */
  mapping(address => uint256) public routerToDex;
  /**
   * @notice Add new Dex
   * @dev This also generate id of the Dex
   * @param _dexName Name of the Dex
   * @param _router address of the dex router
   */
  function addDex(
    string calldata _dexName,
    address _router,
    address payable _wNative,
    DexType dexType
  ) external payable onlyOwner {
    _addDex(_dexName, _router, _wNative, dexType);
  }
  function _addDex(
    string calldata _dexName,
    address _router,
    address payable _wNative,
    DexType dexType
  ) internal {
    if (dexType == DexType.UNKNOWN) {
      revert DexTypeInvalid();
    }
    uint256 id = dexInfo.length;
    dexInfo.push(Dex({
      name: _dexName,
      router: _router,
      id: uint64(id),
      wNative: _wNative,
      dexType: dexType,
      disabled: false
    }));
    if (routerToDex[_router] != 0) {
      revert DexConflict(routerToDex[_router]);
    }
    routerToDex[_router] = dexInfo.length;
    emit AddDex(msg.sender, id);
  }

  /**
   * Updates dex info
   * @param index the id to update in dexInfo array
   * @param _name pass anything other than an empty string to update the name
   * @notice _factory is not used in these contracts
   * it is held for external services to utilize
   */
  function updateDex(
    uint256 index,
    string memory _name,
    address payable _wNative,
    DexType dexType
  ) external payable onlyOwner {
    _updateDex(index, _name, _wNative, dexType);
  }
  function _updateDex(
    uint256 index,
    string memory _name,
    address payable _wNative,
    DexType dexType
  ) internal {
    if (bytes(_name).length == 0) {
      return;
    }
    dexInfo[index].name = _name;
    dexInfo[index].wNative = _wNative;
    dexInfo[index].dexType = dexType;
    emit UpdateDex(msg.sender, index);
  }

  /**
   * sets disabled flag on a dex
   * @param id the dex id to disable
   * @param disabled the boolean denoting whether to disable or enable
   */
  function disableDex(uint256 id, bool disabled) external payable onlyOwner {
    if (dexInfo[id].disabled == disabled) {
      return;
    }
    dexInfo[id].disabled = disabled;
    emit UpdateDex(msg.sender, id);
  }
}

File 31 of 34 : Distributor.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import "@openzeppelin/contracts/utils/Address.sol";
import "../interfaces/IWETH.sol";
import "./Utils.sol";

abstract contract Distributor is Utils {
  using Address for address payable;

  event FeesDistributed(uint256 amount);

  /**
   * distributes all fees, after withdrawing wrapped native balance
   * @notice if the amount is 0, all funds will be drained
   * @notice if an amount is provided, the method will only unwrap
   * the wNative token if it does not have enough native balance to cover the amount
   * @notice the balance will change in the middle of the function
   * if the appropriate conditions are met. however, we do not use that updated balance
   * because the whole amount may not have been asked for
   */
  function distributeAll(uint256 amount) external payable {
    (uint256 nativeBalance, uint256 wNativeBalance) = pendingDistributionSegmented();
    _unwrapValue(amount, nativeBalance, wNativeBalance);
    _sendValue(amount, (nativeBalance + wNativeBalance));
  }

  /**
   * A public method to distribute fees
   * @param amount the amount of ether to distribute
   * @notice failure in receipt will cause this tx to fail as well
   */
  function distribute(uint256 amount) external payable {
    uint256 balance = address(this).balance;
    if (balance < 0) {
      return;
    }
    _sendValue(amount, balance);
  }
  function _unwrapValue(
    uint256 amount,
    uint256 _nativeBalance,
    uint256 _wNativeBalance
  ) internal {
    if ((amount == 0 || _nativeBalance < amount) && _wNativeBalance > 0) {
      IWETH(wNative).withdraw(_wNativeBalance);
    }
  }
  function _sendValue(uint256 amount, uint256 limit) internal {
    amount = _clamp(amount, limit);
    if (amount == 0) {
      return;
    }
    destination.sendValue(amount);
    emit FeesDistributed(amount);
  }

  /**
   * returns the balance in wNative token and native token as two separate numbers
   */
  function pendingDistributionSegmented() public view returns(uint256, uint256) {
    return (address(this).balance, IWETH(wNative).balanceOf(address(this)));
  }

  /**
   * returns the balance of wNative token and native token,
   * treating them as an aggregate balance for ease
   */
  function pendingDistribution() public view returns(uint256) {
    (uint256 nativeBalance, uint256 wNativeBalance) = pendingDistributionSegmented();
    return nativeBalance + wNativeBalance;
  }
}

File 32 of 34 : OracleReader.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
import "./Utils.sol";

abstract contract OracleReader is Utils {
    /**
     * checks the exchange factory pair for a pair with weth and its reserves
     * @param factory the factory to check for a pair and fee of the market
     * @param _amountIn the amount to simulate trading through the market
     * @param path the tokens being traded from and to
     */
    function getFeeMinimum(
        address factory,
        uint256 _amountIn,
        address[] calldata path
    ) public view returns(address, uint256) {
        return _getFeeMinimum(factory, _amountIn, path);
    }
    function _getFeeMinimum(
        address factory,
        uint256 _amountIn,
        address[] memory path
    ) internal view returns(address, uint256) {
        for (uint256 i = 0; i < path.length; ++i) {
            address target = path[i];
            uint256 minimum = getSingleFeeMinimum(factory, _amountIn, target);
            if (minimum > 0) {
                return (target, minimum);
            }
            if (i != path.length - 1) {
                _amountIn = amountOutFrom(factory, target, path[i + 1], _amountIn);
            }
        }
        return (address(0), 0);
    }

    /**
     * get the amount out from reserves
     * does not take into account fees charged along the way
     * @param factory the factory to derive a pair against
     * @param tokenIn the token being pushed into the pair
     * @param tokenOut the token to be pulled out
     * @param amountIn the magnitude of the swap
     */
    function amountOutFrom(address factory, address tokenIn, address tokenOut, uint256 amountIn) public view returns(uint256) {
        address pair = IUniswapV2Factory(factory).getPair(tokenIn, tokenOut);
        bool inIs0 = IUniswapV2Pair(pair).token0() == tokenIn;
        (uint256 reserveA, uint256 reserveB, ) = IUniswapV2Pair(pair).getReserves();
        if (inIs0) {
            return (reserveB * amountIn) / reserveA;
        }
        return (reserveA * amountIn) / reserveB;
    }

    /**
     * gets the fee for a single token from the exchange factory pair
     * @param factory the factory to check for a pair
     * @param _amountIn the amount of tokens being moved through the market
     * @param source the token to check against wNative
     * @notice the number returned from this method does not check
     * the fee for the market so the calculation will be off by ~0.3% for most markets
     */
    function getSingleFeeMinimum(
        address factory,
        uint256 _amountIn,
        address source
    ) public view returns(uint256 minimum) {
        (uint256 tokenAmount, uint256 wethAmount) = checkPairForValidPrice(factory, source);
        if (wethAmount > 1 ether) {
            return (_amountIn * wethAmount * feeNumerator) / (feeDenominator * tokenAmount);
        }
    }

    /**
     * pull a token and weth reserve out of a provided token and factory to derive a market
     * @param factory the address of the factory to derive a pair from (token + wNative)
     * @param token the token to derive against a wNative token
     * @return tokenReserve the amount of token in reserve
     * @return wethReserve the amount of weth in reserve
     */
    function checkPairForValidPrice(address factory, address token) public view returns(uint256 tokenReserve, uint256 wethReserve) {
        IUniswapV2Factory uniFactory = IUniswapV2Factory(factory);
        address _wNative = wNative;
        address pair = uniFactory.getPair(token, _wNative);
        if (pair != address(0)) {
            (uint256 _reserveA, uint256 _reserveB, ) = IUniswapV2Pair(pair).getReserves();
            address token0 = IUniswapV2Pair(pair).token0();
            bool zeroIsWeth = token0 == _wNative;
            tokenReserve = zeroIsWeth ? _reserveB : _reserveA;
            wethReserve = zeroIsWeth ? _reserveA : _reserveB;
        }
        // weth is always returned as denominator
    }
}

File 33 of 34 : UniV3PathEncoding.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import "./BytesLib.sol";

library UniV3PathEncoding {

    function _decodePath(bytes memory data) internal pure returns (address[] memory) {
        // the pattern of the data is "0x [token address (40 hex characters)] - [fee (6 hex characters)] - [token]"
        uint256 numberOfTokens = ((data.length - 20) / 23) + 1;
        address[] memory path = new address[](numberOfTokens);

        uint i = 0;
        do {
            uint256 offset = 20 + (i * 23);
            address tokenAddress;
            assembly {
                tokenAddress := mload(add(data, offset))
            }
            path[i] = tokenAddress;
            unchecked {
                i++;
            }
        } while (i < numberOfTokens);
        return path;
    }

    function _replaceFirstAddress(bytes memory data, address newAddress) internal pure returns (bytes memory) {
        bytes memory sliced = BytesLib.slice(data, 20, data.length - 20);
        bytes memory newData = abi.encodePacked(newAddress, sliced);
        return newData;
    }

    function _replaceLastAddress(bytes memory data, address newAddress) internal pure returns (bytes memory) {
        bytes memory sliced = BytesLib.slice(data, 0, data.length - 20);
        bytes memory newData = abi.encodePacked(sliced, newAddress);
        return newData;
    }
}

File 34 of 34 : Utils.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import "@openzeppelin/contracts/utils/Address.sol";

abstract contract Utils {
  using Address for address payable;
  error DestinationMissing();
  error FallbackNotAllowed();
  // fee = 0.729% Fee
  uint256 public constant feeDenominator = 100_000;
  uint256 public immutable feeNumerator;
  /**
   * where the fees will end up
   * @notice this address cannot be updated after it is set during constructor
   * @notice the destination must be payable + have a receive function
   * that has gas consumption less than limit
   */
  address payable public immutable destination;
  /**
   * the native address to deposit and withdraw from in the swap methods
   * @notice this address cannot be updated after it is set during constructor
   */
  address payable public immutable wNative;
  constructor(address payable _wNative, address payable _destination, uint256 _fee) {
    wNative = _wNative;
    destination = _destination;
    feeNumerator = _fee;
  }
  /** clamp the amount provided to a maximum, defaulting to provided maximum if 0 provided */
  function clamp(uint256 amount, uint256 max) pure public returns(uint256) {
    return _clamp(amount, max);
  }
  function _clamp(uint256 amount, uint256 max) internal pure returns(uint256) {
    return amount == 0 || amount > max ? max : amount;
  }

  receive() external payable {
    _receiveNative();
  }
  function _receiveNative() internal view {
    // the protocol thanks you for your donation
    if (destination == address(0)) {
      revert DestinationMissing();
    }
  }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address payable","name":"_destination","type":"address"},{"internalType":"address payable","name":"_wNative","type":"address"},{"internalType":"uint96","name":"_fee","type":"uint96"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"Deadline","type":"error"},{"inputs":[],"name":"DestinationMissing","type":"error"},{"inputs":[{"internalType":"uint256","name":"dexIndex","type":"uint256"}],"name":"DexConflict","type":"error"},{"inputs":[],"name":"DexDisabled","type":"error"},{"inputs":[],"name":"DexTypeInvalid","type":"error"},{"inputs":[],"name":"FallbackNotAllowed","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"provided","type":"uint256"},{"internalType":"string","name":"message","type":"string"}],"name":"FeeMissing","type":"error"},{"inputs":[{"internalType":"address","name":"expected","type":"address"},{"internalType":"address","name":"provided","type":"address"}],"name":"FunderMismatch","type":"error"},{"inputs":[{"internalType":"uint256","name":"pathIndex","type":"uint256"}],"name":"NativeMissing","type":"error"},{"inputs":[{"internalType":"uint256","name":"consumed","type":"uint256"},{"internalType":"uint256","name":"provided","type":"uint256"}],"name":"ValueMismatch","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"executor","type":"address"},{"indexed":true,"internalType":"uint256","name":"dexId","type":"uint256"}],"name":"AddDex","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"bool","name":"isNative","type":"bool"}],"name":"FeesCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeesDistributed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"inAndOutTokens","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"uint256","name":"dexId","type":"uint256"}],"name":"IMSwap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"executor","type":"address"},{"indexed":true,"internalType":"uint256","name":"dexId","type":"uint256"}],"name":"UpdateDex","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"executor","type":"address"},{"indexed":false,"internalType":"address[]","name":"addresses","type":"address[]"}],"name":"UpdateMigrationAddresses","type":"event"},{"inputs":[{"internalType":"string","name":"_dexName","type":"string"},{"internalType":"address","name":"_router","type":"address"},{"internalType":"address payable","name":"_wNative","type":"address"},{"internalType":"enum DexTracker.DexType","name":"dexType","type":"uint8"}],"name":"addDex","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"factory","type":"address"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"amountOutFrom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"factory","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"checkPairForValidPrice","outputs":[{"internalType":"uint256","name":"tokenReserve","type":"uint256"},{"internalType":"uint256","name":"wethReserve","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"clamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"destination","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"dexInfo","outputs":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"address","name":"router","type":"address"},{"internalType":"bool","name":"disabled","type":"bool"},{"internalType":"address payable","name":"wNative","type":"address"},{"internalType":"enum DexTracker.DexType","name":"dexType","type":"uint8"},{"internalType":"string","name":"name","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dexInfoSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"bool","name":"disabled","type":"bool"}],"name":"disableDex","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"distribute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"distributeAll","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"feeDenominator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"factory","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getFeeMinimum","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"factory","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address","name":"source","type":"address"}],"name":"getSingleFeeMinimum","outputs":[{"internalType":"uint256","name":"minimum","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"migrationAddresses","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDistribution","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDistributionSegmented","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"routerToDex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_migrationAddresses","type":"address[]"}],"name":"setMigrationAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dexId","type":"uint256"},{"components":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"uint256","name":"assetInIndex","type":"uint256"},{"internalType":"uint256","name":"assetOutIndex","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"internalType":"struct IVault.BatchSwapStep[]","name":"swaps","type":"tuple[]"},{"internalType":"contract IAsset[]","name":"assets","type":"address[]"},{"components":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"bool","name":"fromInternalBalance","type":"bool"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"bool","name":"toInternalBalance","type":"bool"}],"internalType":"struct IVault.FundManagement","name":"funds","type":"tuple"},{"internalType":"int256[]","name":"limits","type":"int256[]"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"inTokenIndex","type":"uint256"},{"internalType":"uint256","name":"outTokenIndex","type":"uint256"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"swapBalancerV2","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_dexId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_minAmountOut","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"}],"name":"swapNativeToV2","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dexId","type":"uint256"},{"internalType":"bytes","name":"piteasCalldata","type":"bytes"}],"name":"swapPiteas","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_dexId","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_minAmountOut","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"}],"name":"swapToNativeV2","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_dexId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_minAmountOut","type":"uint256"},{"internalType":"uint256","name":"_deadline","type":"uint256"}],"name":"swapTokenV2","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dexId","type":"uint256"},{"components":[{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct IV3SwapRouter.ExactInputParams","name":"params","type":"tuple"}],"name":"swapUniswapV3","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"address payable","name":"_wNative","type":"address"},{"internalType":"enum DexTracker.DexType","name":"dexType","type":"uint8"}],"name":"updateDex","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"wNative","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"_wNative","type":"address"}],"name":"wrap","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60e06040523480156200001157600080fd5b5060405162005ced38038062005ced8339810160408190526200003491620000d5565b6001600160a01b0382811660c052831660a0526001600160601b0381166080526200005f3362000068565b5050506200012f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620000d057600080fd5b919050565b600080600060608486031215620000eb57600080fd5b620000f684620000b8565b92506200010660208501620000b8565b60408501519092506001600160601b03811681146200012457600080fd5b809150509250925092565b60805160a05160c051615aed62000200600039600081816102bd01528181610b4a01528181611c0901528181611dfa015281816130b60152613e51015260008181610477015281816105b90152613a0801526000818161054f015281816108cd0152818161094f01528181610fb3015281816113b3015281816114cc01528181611fd20152818161244c015281816124a5015281816124eb01528181612586015281816125e40152818161272e01528181612d09015281816133ea0152818161363301526138460152615aed6000f3fe6080604052600436106101dc5760003560e01c80638da5cb5b11610102578063bdf7068611610095578063e86dea4a11610064578063e86dea4a1461053d578063f1d85b6514610571578063f2fde38b14610584578063fdf59b8e146105a457600080fd5b8063bdf7068614610499578063d63a4d5c146104cb578063e1e13980146104eb578063e329c80d146104fe57600080fd5b80639c22b9a6116100d15780639c22b9a61461042a578063a961e2431461043f578063b231d68b14610452578063b269681d1461046557600080fd5b80638da5cb5b146103d357806391c05b0b146103f15780639321111d1461040457806394c176e41461041757600080fd5b80632f0807e21161017a5780635d39ba9b116101495780635d39ba9b14610354578063715018a61461038957806372f23fd91461039e57806386f9bfa8146103b357600080fd5b80632f0807e2146102df578063394ce9c7146102f45780635517b46e14610314578063574b64a71461034157600080fd5b8063180b0d7e116101b6578063180b0d7e14610229578063235b77dc146102535780632d5969771461028b5780632d68efc9146102ab57600080fd5b80630119e16c146101f0578063012e74a314610203578063023276f01461021657600080fd5b366101eb576101e96105b7565b005b600080fd5b6101e96101fe366004614a56565b610619565b6101e9610211366004614b45565b610da3565b6101e9610224366004614bbc565b610e8e565b34801561023557600080fd5b50610240620186a081565b6040519081526020015b60405180910390f35b34801561025f57600080fd5b5061027361026e366004614bd9565b610f57565b6040516001600160a01b03909116815260200161024a565b34801561029757600080fd5b506102406102a6366004614bf2565b610f81565b3480156102b757600080fd5b506102737f000000000000000000000000000000000000000000000000000000000000000081565b3480156102eb57600080fd5b50600254610240565b34801561030057600080fd5b5061024061030f366004614c34565b611003565b34801561032057600080fd5b5061024061032f366004614bbc565b60036020526000908152604090205481565b6101e961034f366004614cc7565b6111ca565b34801561036057600080fd5b5061037461036f366004614d13565b611bea565b6040805192835260208301919091520161024a565b34801561039557600080fd5b506101e9611dc4565b3480156103aa57600080fd5b50610374611dd6565b3480156103bf57600080fd5b506101e96103ce366004614d4c565b611e6d565b3480156103df57600080fd5b506000546001600160a01b0316610273565b6101e96103ff366004614bd9565b611ec9565b6101e9610412366004614b45565b611ed4565b6101e9610425366004614bd9565b61211a565b34801561043657600080fd5b5061024061214c565b6101e961044d366004614da2565b61216f565b6101e9610460366004614e2e565b612189565b34801561047157600080fd5b506102737f000000000000000000000000000000000000000000000000000000000000000081565b3480156104a557600080fd5b506104b96104b4366004614bd9565b612236565b60405161024a96959493929190614eb9565b3480156104d757600080fd5b506102406104e6366004614f1d565b612331565b6101e96104f936600461517e565b612346565b34801561050a57600080fd5b5061051e61051936600461524a565b612c04565b604080516001600160a01b03909316835260208301919091520161024a565b34801561054957600080fd5b506102407f000000000000000000000000000000000000000000000000000000000000000081565b6101e961057f3660046152a6565b612c52565b34801561059057600080fd5b506101e961059f366004614bbc565b612c6e565b6101e96105b2366004614b45565b612cfe565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610617576040517f79dd500900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b60006002838154811061062e5761062e61531f565b60009182526020918290206040805160c0810182526003909302909101805467ffffffffffffffff811684526001600160a01b0368010000000000000000820481169585019590955260ff600160e01b90910481161515928401929092526001810154938416606084015291926080840191600160a01b9091041660048111156106ba576106ba614e53565b60048111156106cb576106cb614e53565b81526020016002820180546106df90615335565b80601f016020809104026020016040519081016040528092919081815260200182805461070b90615335565b80156107585780601f1061072d57610100808354040283529160200191610758565b820191906000526020600020905b81548152906001019060200180831161073b57829003601f168201915b505050505081525050905080604001511561078657604051633d8c23c960e01b815260040160405180910390fd5b8151349060009061079690612fc7565b90506000816000815181106107ad576107ad61531f565b60200260200101519050600082600184516107c8919061537f565b815181106107d8576107d861531f565b6020026020010151905060006107f1866060015161309d565b905060006001600160a01b038316158061081c5750816001600160a01b0316836001600160a01b0316145b905060008860400151905060008960200151905060008b826001600160a01b031688886040516020016108659291906001600160a01b0392831681529116602082015260400190565b604051602081830303815290604052805190602001207fb2c680c61107ad1f3fc37c2a8f8a842318cde79fa88c4263a7ac104cc6d93ae0866040516108ac91815260200190565b60405180910390a46001600160a01b03871661092d576000620186a06108f27f00000000000000000000000000000000000000000000000000000000000000008c615392565b6108fc91906153a9565b9050610908818b61537f565b604051909a506001908290600080516020615a9883398151915290600090a350610a7b565b846001600160a01b0316876001600160a01b0316036109a157620186a06109747f000000000000000000000000000000000000000000000000000000000000000085615392565b61097e91906153a9565b6040519091506000908290600080516020615a98833981519152908390a3610a7b565b83610a7b576000610a4f600260808f901c815481106109c2576109c261531f565b906000526020600020906003020160000160089054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4891906153cb565b858b6130db565b915050610a5c8a82613193565b506040516001908b90600080516020615a9883398151915290600090a3505b6001600160a01b038716610b0857849650610a9a8b600001518661326c565b8b60000181905250889250828b6040018181525050846001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b158015610aea57600080fd5b505af1158015610afe573d6000803e3d6000fd5b5050505050610b27565b80610b1388856132b8565b610b1d919061537f565b60408c0181905292505b8315610b34573060208c01525b6001600160a01b038616610b71578a51610b6e907f00000000000000000000000000000000000000000000000000000000000000006133b0565b8b525b60208a015160405163095ea7b360e01b81526001600160a01b039182166004820152602481018590529088169063095ea7b3906044016020604051808303816000875af1158015610bc6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bea91906153e8565b5060208a01516040517fb858183f0000000000000000000000000000000000000000000000000000000081526000916001600160a01b03169063b858183f90610c37908f90600401615405565b6020604051808303816000875af1158015610c56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7a9190615454565b9050856001600160a01b0316876001600160a01b031603610d46578915610cf757604051630a09945f60e21b815260006004820152602481018b905260606044820152601560648201527f6665657320706169642066726f6d206f75747075740000000000000000000000608482015260a4015b60405180910390fd5b610d1583610d04836133df565b6001600160a01b038a169190613423565b6000610d20826133df565b610d2a908361537f565b604051600080516020615a9883398151915290600090a3610d94565b6001600160a01b038716610d9457610d6786610d61836133df565b856134b3565b6001610d72826133df565b610d7c908361537f565b604051600080516020615a9883398151915290600090a35b50505050505050505050505050565b610db33488888888888888613594565b86866001600160a01b031686866000818110610dd157610dd161531f565b9050602002016020810190610de69190614bbc565b8787610df360018261537f565b818110610e0257610e0261531f565b9050602002016020810190610e179190614bbc565b604080516001600160a01b0393841660208201529290911690820152606001604051602081830303815290604052805190602001207fb2c680c61107ad1f3fc37c2a8f8a842318cde79fa88c4263a7ac104cc6d93ae086604051610e7d91815260200190565b60405180910390a450505050505050565b806001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015610ec957600080fd5b505af1158015610edd573d6000803e3d6000fd5b505060405163a9059cbb60e01b81523360048201523460248201526001600160a01b038516935063a9059cbb925060440190506020604051808303816000875af1158015610f2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5391906153e8565b5050565b60018181548110610f6757600080fd5b6000918252602090912001546001600160a01b0316905081565b6000806000610f908685611bea565b91509150670de0b6b3a7640000811115610ff957610fb182620186a0615392565b7f0000000000000000000000000000000000000000000000000000000000000000610fdc8388615392565b610fe69190615392565b610ff091906153a9565b92505050610ffc565b50505b9392505050565b60405163e6a4390560e01b81526001600160a01b0384811660048301528381166024830152600091829187169063e6a4390590604401602060405180830381865afa158015611056573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107a91906153cb565b90506000856001600160a01b0316826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ea91906153cb565b6001600160a01b0316149050600080836001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015611137573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115b919061548b565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff16915082156111a657816111918783615392565b61119b91906153a9565b9450505050506111c2565b806111b18784615392565b6111bb91906153a9565b9450505050505b949350505050565b6000600284815481106111df576111df61531f565b60009182526020918290206040805160c0810182526003909302909101805467ffffffffffffffff811684526001600160a01b0368010000000000000000820481169585019590955260ff600160e01b90910481161515928401929092526001810154938416606084015291926080840191600160a01b90910416600481111561126b5761126b614e53565b600481111561127c5761127c614e53565b815260200160028201805461129090615335565b80601f01602080910402602001604051908101604052809291908181526020018280546112bc90615335565b80156113095780601f106112de57610100808354040283529160200191611309565b820191906000526020600020905b8154815290600101906020018083116112ec57829003601f168201915b505050505081525050905080604001511561133757604051633d8c23c960e01b815260040160405180910390fd5b600080611346848601866154d0565b815160208301516060840151306040860152939550919350349290919060006001600160a01b03831615806113985750611383886060015161309d565b6001600160a01b0316836001600160a01b0316145b90506001600160a01b0384166114a0576000620186a06113d87f000000000000000000000000000000000000000000000000000000000000000088615392565b6113e291906153a9565b905060006113f08285615574565b90508087146114785760408051630a09945f60e21b815260048101839052602481018990526060604482015260648101919091527f7377617050697465617328293a3a20696e73756666206d73672e76616c75652060848201527f666565207768656e206e617469766520617373657420697320696e546f6b656e60a482015260c401610cee565b60405193965086936001908390600080516020615a9883398151915290600090a350506117e8565b6114ad886060015161309d565b6001600160a01b0316846001600160a01b0316036116575760006114f47f0000000000000000000000000000000000000000000000000000000000000000620186a061537f565b611501620186a085615392565b61150b91906153a9565b90506000611519848361537f565b9050600061152787846132b8565b90506115368b6060015161309d565b60208c015160405163095ea7b360e01b81526001600160a01b0391821660048201526024810188905291169063095ea7b3906044016020604051808303816000875af115801561158a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ae91906153e8565b508281101561163457604051630a09945f60e21b8152600481018490526024810182905260606044820152602b60648201527f7377617050697465617328293a3a20696e737566662066656520666f7220774e60848201527f617469766520617373657400000000000000000000000000000000000000000060a482015260c401610cee565b6040516000908390600080516020615a98833981519152908390a35050506117e8565b806117bf5760408051600280825260608201835260009260208301908036833701905050905084816000815181106116915761169161531f565b60200260200101906001600160a01b031690816001600160a01b03168152505083816001815181106116c5576116c561531f565b60200260200101906001600160a01b031690816001600160a01b031681525050600061178e600260808f901c815481106117015761170161531f565b906000526020600020906003020160000160089054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015611763573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178791906153cb565b85846130db565b91505061179b8782613193565b506040516001908890600080516020615a9883398151915290600090a350506117e8565b84156117e857604051630626ade360e41b81526000600482015260248101869052604401610cee565b6001600160a01b0384161580159061181e5750611808886060015161309d565b6001600160a01b0316846001600160a01b031614155b156118d857600061182f85846132b8565b90508281101561185c57604051630626ade360e41b81526004810184905260248101829052604401610cee565b602089015160405163095ea7b360e01b81526001600160a01b039182166004820152602481018590529086169063095ea7b3906044016020604051808303816000875af11580156118b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d591906153e8565b50505b6001600160a01b038416156118ec57600094505b60006001600160a01b03841661190357504761196e565b6040516370a0823160e01b81523060048201526001600160a01b038516906370a0823190602401602060405180830381865afa158015611947573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196b9190615454565b90505b600089602001516001600160a01b0316638218b58f888b8b6040518463ffffffff1660e01b81526004016119a3929190615587565b60206040518083038185885af11580156119c1573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906119e69190615454565b905060006001600160a01b0386166119ff575047611a6a565b6040516370a0823160e01b81523060048201526001600160a01b038716906370a0823190602401602060405180830381865afa158015611a43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a679190615454565b90505b611a74838261537f565b8214611aa75781611a85848361537f565b604051630626ade360e41b815260048101929092526024820152604401610cee565b611ab48b6060015161309d565b6001600160a01b0316866001600160a01b031603611b1b57611aea33611ad9846133df565b6001600160a01b0389169190613423565b6000611af5836133df565b611aff908461537f565b604051600080516020615a9883398151915290600090a3611b67565b6001600160a01b038616611b5357611b48611b398c6060015161309d565b611b42846133df565b336134b3565b6001611af5836133df565b611b676001600160a01b0387163384613423565b604080516001600160a01b0389811660208301528816918101919091528e903390606001604051602081830303815290604052805190602001207fb2c680c61107ad1f3fc37c2a8f8a842318cde79fa88c4263a7ac104cc6d93ae088604051611bd291815260200190565b60405180910390a45050505050505050505050505050565b60405163e6a4390560e01b81526001600160a01b0382811660048301527f000000000000000000000000000000000000000000000000000000000000000081811660248401526000928392869291849184169063e6a4390590604401602060405180830381865afa158015611c63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c8791906153cb565b90506001600160a01b03811615611dba57600080826001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015611cd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfd919061548b565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff1691506000836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8691906153cb565b90506001600160a01b038082169086161480611da25783611da4565b825b985080611db15782611db3565b835b9750505050505b5050509250929050565b611dcc61392c565b6106176000613986565b6040516370a0823160e01b8152306004820152600090819047906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015611e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e659190615454565b915091509091565b611e7561392c565b611e81600183836148b1565b50336001600160a01b03167f43a7b7252c812355611a4161c33c1026045c1a89763cfaef223712907d805d8b8383604051611ebd929190615621565b60405180910390a25050565b47610f5382826139e3565b6000611f0e60028981548110611eec57611eec61531f565b60009182526020909120600160039092020101546001600160a01b031661309d565b90506001600160a01b0381168686611f2760018261537f565b818110611f3657611f3661531f565b9050602002016020810190611f4b9190614bbc565b6001600160a01b031614611f8057611f6460018661537f565b604051631b02683560e31b8152600401610cee91815260200190565b6000611fb387876000818110611f9857611f9861531f565b9050602002016020810190611fad9190614bbc565b866132b8565b90506000611fc58a8989858989613a65565b90506000620186a0611ff77f000000000000000000000000000000000000000000000000000000000000000084615392565b61200191906153a9565b61200b908361537f565b90506000612019828461537f565b604051600080516020615a9883398151915290600090a361203b84828c6134b3565b8a8a6001600160a01b03168a8a60008181106120595761205961531f565b905060200201602081019061206e9190614bbc565b8b8b61207b60018261537f565b81811061208a5761208a61531f565b905060200201602081019061209f9190614bbc565b604080516001600160a01b0393841660208201529290911690820152606001604051602081830303815290604052805190602001207fb2c680c61107ad1f3fc37c2a8f8a842318cde79fa88c4263a7ac104cc6d93ae08a60405161210591815260200190565b60405180910390a45050505050505050505050565b600080612125611dd6565b91509150612134838383613e1e565b612147836121428385615574565b6139e3565b505050565b6000806000612159611dd6565b90925090506121688183615574565b9250505090565b61217761392c565b61218384848484613eba565b50505050565b61219161392c565b801515600283815481106121a7576121a761531f565b6000918252602090912060039091020154600160e01b900460ff16151514610f535780600283815481106121dd576121dd61531f565b6000918252602082206003909102018054921515600160e01b0260ff60e01b1990931692909217909155604051839133917ff46467fbac738ac4d46eb7aff18d9f1e807be9993f9a05f54ca83b066b8ce6409190a35050565b6002818154811061224657600080fd5b600091825260209091206003909102018054600182015460028301805467ffffffffffffffff841695506001600160a01b0368010000000000000000850481169560ff600160e01b90960486169591851694600160a01b90049091169290916122ae90615335565b80601f01602080910402602001604051908101604052809291908181526020018280546122da90615335565b80156123275780601f106122fc57610100808354040283529160200191612327565b820191906000526020600020905b81548152906001019060200180831161230a57829003601f168201915b5050505050905086565b600061233d8383613fd6565b90505b92915050565b600289815481106123595761235961531f565b6000918252602090912060039091020154600160e01b900460ff161561239257604051633d8c23c960e01b815260040160405180910390fd5b6000806001600160a01b03168884815181106123b0576123b061531f565b60200260200101516001600160a01b0316148061240c57506123de60028b81548110611eec57611eec61531f565b6001600160a01b03168884815181106123f9576123f961531f565b60200260200101516001600160a01b0316145b6040880151895191925034916000908b908890811061242d5761242d61531f565b60200260200101516001600160a01b03160361253657620186a06124717f000000000000000000000000000000000000000000000000000000000000000034615392565b61247b91906153a9565b612485903461537f565b8887815181106124975761249761531f565b50620186a091506124ca90507f000000000000000000000000000000000000000000000000000000000000000034615392565b6124d491906153a9565b6124de908361537f565b91506001620186a06125107f000000000000000000000000000000000000000000000000000000000000000034615392565b61251a91906153a9565b604051600080516020615a9883398151915290600090a361264d565b61254c60028d81548110611eec57611eec61531f565b6001600160a01b03168a87815181106125675761256761531f565b60200260200101516001600160a01b03160361260957620186a06125ab7f000000000000000000000000000000000000000000000000000000000000000086615392565b6125b591906153a9565b6125bf908561537f565b8887815181106125d1576125d161531f565b5060009350839150620186a090506125107f000000000000000000000000000000000000000000000000000000000000000087615392565b8261264d5761264d8c85348d8a815181106126265761262661531f565b60200260200101518e8a815181106126405761264061531f565b6020026020010151613ff4565b88516001600160a01b031630146126a45788516040517fee8427160000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b039091166024820152604401610cee565b60006001600160a01b03168a87815181106126c1576126c161531f565b60200260200101516001600160a01b03161461288d576126ed60028d81548110611eec57611eec61531f565b6001600160a01b03168a87815181106127085761270861531f565b60200260200101516001600160a01b03161461272557600061275d565b620186a06127537f000000000000000000000000000000000000000000000000000000000000000086615392565b61275d91906153a9565b6127808b88815181106127725761277261531f565b6020026020010151866132b8565b61278a919061537f565b93508388878151811061279f5761279f61531f565b6020026020010181815250508986815181106127bd576127bd61531f565b60200260200101516001600160a01b031663095ea7b360028e815481106127e6576127e661531f565b600091825260209091206003909102015460405160e083901b7fffffffff00000000000000000000000000000000000000000000000000000000168152680100000000000000009091046001600160a01b03166004820152602481018790526044016020604051808303816000875af1158015612867573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061288b91906153e8565b505b821561289a573060408a01525b600060028d815481106128af576128af61531f565b906000526020600020906003020160000160089054906101000a90046001600160a01b03166001600160a01b031663945bcec98460008f8f8f8f8f6040518863ffffffff1660e01b815260040161290b9695949392919061569e565b60006040518083038185885af1158015612929573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261295291908101906157c2565b905061296a60028e81548110611eec57611eec61531f565b6001600160a01b03168b87815181106129855761298561531f565b60200260200101516001600160a01b031603612a7d57612a0d826129db83600185516129b1919061537f565b815181106129c1576129c161531f565b60200260200101516000196129d69190615848565b6133df565b8d89815181106129ed576129ed61531f565b60200260200101516001600160a01b03166134239092919063ffffffff16565b60001515612a2382600184516129b1919061537f565b8260018451612a32919061537f565b81518110612a4257612a4261531f565b6020026020010151600019612a579190615848565b612a61919061537f565b604051600080516020615a9883398151915290600090a3612b41565b60006001600160a01b03168b8781518110612a9a57612a9a61531f565b60200260200101516001600160a01b031603612b4157612ad5612ac582600184516129b1919061537f565b6001600160a01b03841690614159565b60011515612aeb82600184516129b1919061537f565b8260018451612afa919061537f565b81518110612b0a57612b0a61531f565b6020026020010151600019612b1f9190615848565b612b29919061537f565b604051600080516020615a9883398151915290600090a35b8c826001600160a01b03168c8981518110612b5e57612b5e61531f565b60200260200101518d8981518110612b7857612b7861531f565b6020026020010151604051602001612ba69291906001600160a01b0392831681529116602082015260400190565b604051602081830303815290604052805190602001207fb2c680c61107ad1f3fc37c2a8f8a842318cde79fa88c4263a7ac104cc6d93ae088604051612bed91815260200190565b60405180910390a450505050505050505050505050565b600080612c4586868686808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506130db92505050565b9150915094509492505050565b612c5a61392c565b612c678585858585614272565b5050505050565b612c7661392c565b6001600160a01b038116612cf25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610cee565b612cfb81613986565b50565b6000620186a0612d2e7f000000000000000000000000000000000000000000000000000000000000000034615392565b612d3891906153a9565b90506000612d5260028a81548110611eec57611eec61531f565b9050612d5e8286615574565b3414612dc557612d6e8286615574565b604051630a09945f60e21b8152600481019190915234602482015260606044820152601a60648201527f616d6f756e74202b2066656573206d757374203d20746f74616c000000000000608482015260a401610cee565b806001600160a01b031687876000818110612de257612de261531f565b9050602002016020810190612df79190614bbc565b6001600160a01b031614612e2157604051631b02683560e31b815260006004820152602401610cee565b6040516001908390600080516020615a9883398151915290600090a3806001600160a01b031663d0e30db0866040518263ffffffff1660e01b81526004016000604051808303818588803b158015612e7857600080fd5b505af1158015612e8c573d6000803e3d6000fd5b50505050506000612ea18a8989898989613a65565b9050612ee989828a8a612eb560018261537f565b818110612ec457612ec461531f565b9050602002016020810190612ed99190614bbc565b6001600160a01b03169190613423565b89896001600160a01b031689896000818110612f0757612f0761531f565b9050602002016020810190612f1c9190614bbc565b8a8a612f2960018261537f565b818110612f3857612f3861531f565b9050602002016020810190612f4d9190614bbc565b604080516001600160a01b0393841660208201529290911690820152606001604051602081830303815290604052805190602001207fb2c680c61107ad1f3fc37c2a8f8a842318cde79fa88c4263a7ac104cc6d93ae089604051612fb391815260200190565b60405180910390a450505050505050505050565b60606000601760148451612fdb919061537f565b612fe591906153a9565b612ff0906001615574565b905060008167ffffffffffffffff81111561300d5761300d614936565b604051908082528060200260200182016040528015613036578160200160208202803683370190505b50905060005b6000613049826017615392565b613054906014615574565b90506000818701519050808484815181106130715761307161531f565b6001600160a01b0390921660209283029190910190910152505060010182811061303c57509392505050565b60006001600160a01b038216156130b45781612340565b7f000000000000000000000000000000000000000000000000000000000000000092915050565b60008060005b83518110156131825760008482815181106130fe576130fe61531f565b602002602001015190506000613115888884610f81565b9050801561312957909350915061318b9050565b60018651613137919061537f565b831461316f5761316c88838861314e876001615574565b8151811061315e5761315e61531f565b60200260200101518a611003565b96505b50508061317b90615894565b90506130e1565b50600080915091505b935093915050565b6000600a6131a2836009615392565b6131ac91906153a9565b90508060000361320d57604051630a09945f60e21b8152600060048201526024810184905260606044820152601660648201527f756e61626c6520746f20636f6d70757465206665657300000000000000000000608482015260a401610cee565b8083101561234057604051630a09945f60e21b8152600481018290526024810184905260606044820152601460648201527f6e6f7420656e6f756768206665652076616c7565000000000000000000000000608482015260a401610cee565b60606000613288846014808751613283919061537f565b614530565b90506000838260405160200161329f9291906158ad565b60408051808303601f1901815291905295945050505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa158015613301573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133259190615454565b905061333c6001600160a01b038516333086614658565b6040516370a0823160e01b815230600482015281906001600160a01b038616906370a0823190602401602060405180830381865afa158015613382573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133a69190615454565b6111c2919061537f565b606060006133c884600060148751613283919061537f565b90506000818460405160200161329f9291906158e5565b6000620186a061340f7f000000000000000000000000000000000000000000000000000000000000000084615392565b61341991906153a9565b612340908361537f565b6040516001600160a01b03831660248201526044810182905261214790849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526146a9565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa1580156134fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061351e9190615454565b9050801561358157604051632e1a7d4d60e01b8152600481018290526001600160a01b03851690632e1a7d4d90602401600060405180830381600087803b15801561356857600080fd5b505af115801561357c573d6000803e3d6000fd5b505050505b6121836001600160a01b03831684614159565b6000858560008181106135a9576135a961531f565b90506020020160208101906135be9190614bbc565b9050600086866135cf60018261537f565b8181106135de576135de61531f565b90506020020160208101906135f39190614bbc565b9050600061360d60028b81548110611eec57611eec61531f565b90506000816001600160a01b0316846001600160a01b0316036136e157620186a06136587f000000000000000000000000000000000000000000000000000000000000000089615392565b61366291906153a9565b90508b156136c157604051630a09945f60e21b815260006004820152602481018d905260606044820152601460648201527f6665657320706169642066726f6d20696e707574000000000000000000000000608482015260a401610cee565b6040516000908290600080516020615a98833981519152908390a36137fe565b816001600160a01b0316836001600160a01b0316146137fe5760006137d260028d815481106137125761371261531f565b906000526020600020906003020160000160089054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015613774573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379891906153cb565b898c8c808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506130db92505050565b9150506137df8d82613193565b506040516001908e90600080516020615a9883398151915290600090a3505b60008161380b868a6132b8565b613815919061537f565b905060006138278d8c8c858c8c613a65565b9050806001600160a01b038086169087160361390757620186a061386b7f000000000000000000000000000000000000000000000000000000000000000084615392565b61387591906153a9565b61387f908261537f565b90508e156138e35760008f604051630a09945f60e21b8152600401610cee92919091825260208201526060604082018190526015908201527f6665657320706169642066726f6d206f75747075740000000000000000000000608082015260a00190565b60006138ef828461537f565b604051600080516020615a9883398151915290600090a35b61391b6001600160a01b0387168e83613423565b505050505050505050505050505050565b6000546001600160a01b031633146106175760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610cee565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6139ed8282613fd6565b9150816000036139fb575050565b613a2e6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001683614159565b6040518281527f8959421a1320789a49eeec01a4750caf8a30733c3db14f000d84484df89300f99060200160405180910390a15050565b60008060028881548110613a7b57613a7b61531f565b60009182526020918290206040805160c0810182526003909302909101805467ffffffffffffffff811684526001600160a01b0368010000000000000000820481169585019590955260ff600160e01b90910481161515928401929092526001810154938416606084015291926080840191600160a01b909104166004811115613b0757613b07614e53565b6004811115613b1857613b18614e53565b8152602001600282018054613b2c90615335565b80601f0160208091040260200160405190810160405280929190818152602001828054613b5890615335565b8015613ba55780601f10613b7a57610100808354040283529160200191613ba5565b820191906000526020600020905b815481529060010190602001808311613b8857829003601f168201915b5050505050815250509050806040015115613bd357604051633d8c23c960e01b815260040160405180910390fd5b60008787613be260018261537f565b818110613bf157613bf161531f565b9050602002016020810190613c069190614bbc565b905087876000818110613c1b57613c1b61531f565b9050602002016020810190613c309190614bbc565b602083015160405163095ea7b360e01b81526001600160a01b0391821660048201526024810189905291169063095ea7b3906044016020604051808303816000875af1158015613c84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ca891906153e8565b506040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015613cf0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d149190615454565b60208401516040517f5c11d7950000000000000000000000000000000000000000000000000000000081529192506001600160a01b031690635c11d79590613d6a908a908a908e908e9030908d9060040161591c565b600060405180830381600087803b158015613d8457600080fd5b505af1158015613d98573d6000803e3d6000fd5b50506040516370a0823160e01b81523060048201528392506001600160a01b03851691506370a0823190602401602060405180830381865afa158015613de2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e069190615454565b613e10919061537f565b9a9950505050505050505050565b821580613e2a57508282105b8015613e365750600081115b1561214757604051632e1a7d4d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015613e9d57600080fd5b505af1158015613eb1573d6000803e3d6000fd5b50505050505050565b825115612183578260028581548110613ed557613ed561531f565b90600052602060002090600302016002019081613ef291906159a8565b508160028581548110613f0757613f0761531f565b906000526020600020906003020160010160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508060028581548110613f5057613f5061531f565b6000918252602090912060016003909202010180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b836004811115613f9e57613f9e614e53565b0217905550604051849033907ff46467fbac738ac4d46eb7aff18d9f1e807be9993f9a05f54ca83b066b8ce64090600090a350505050565b6000821580613fe457508183115b613fee578261233d565b50919050565b60408051600280825260608201835260009260208301908036833701905050905082816000815181106140295761402961531f565b60200260200101906001600160a01b031690816001600160a01b031681525050818160018151811061405d5761405d61531f565b60200260200101906001600160a01b031690816001600160a01b03168152505060006141266002608089901c815481106140995761409961531f565b906000526020600020906003020160000160089054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa1580156140fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061411f91906153cb565b87846130db565b9150506141338582613193565b506040516001908690600080516020615a9883398151915290600090a350505050505050565b804710156141a95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610cee565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146141f6576040519150601f19603f3d011682016040523d82523d6000602084013e6141fb565b606091505b50509050806121475760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610cee565b600081600481111561428657614286614e53565b036142bd576040517fcc36cd4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600280549050905060026040518060c001604052808367ffffffffffffffff168152602001866001600160a01b03168152602001600015158152602001856001600160a01b0316815260200184600481111561431d5761431d614e53565b815260200188888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509390945250508354600180820186559482526020918290208451600390920201805492850151604086015167ffffffffffffffff9093167fffffffff0000000000000000000000000000000000000000000000000000000090941693909317680100000000000000006001600160a01b03948516021760ff60e01b1916600160e01b921515929092029190911781556060840151948101805473ffffffffffffffffffffffffffffffffffffffff1981169690931695861781556080850151949591949350917fffffffffffffffffffffff0000000000000000000000000000000000000000001617600160a01b83600481111561445457614454614e53565b021790555060a0820151600282019061446d90826159a8565b5050506001600160a01b038416600090815260036020526040902054156144de576001600160a01b038416600090815260036020526040908190205490517f456c0cff0000000000000000000000000000000000000000000000000000000081526004810191909152602401610cee565b6002546001600160a01b038516600090815260036020526040808220929092559051829133917fca0cc3028eb486c2abb71c1a6f38d1e617ce1079f1be55c5cf422abfb2e4f4689190a3505050505050565b60608161453e81601f615574565b101561458c5760405162461bcd60e51b815260206004820152600e60248201527f736c6963655f6f766572666c6f770000000000000000000000000000000000006044820152606401610cee565b6145968284615574565b845110156145e65760405162461bcd60e51b815260206004820152601160248201527f736c6963655f6f75744f66426f756e64730000000000000000000000000000006044820152606401610cee565b606082158015614605576040519150600082526020820160405261464f565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561463e578051835260209283019201614626565b5050858452601f01601f1916604052505b50949350505050565b6040516001600160a01b03808516602483015283166044820152606481018290526121839085907f23b872dd000000000000000000000000000000000000000000000000000000009060840161344f565b60006146fe826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661478e9092919063ffffffff16565b805190915015612147578080602001905181019061471c91906153e8565b6121475760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610cee565b60606111c2848460008585600080866001600160a01b031685876040516147b59190615a68565b60006040518083038185875af1925050503d80600081146147f2576040519150601f19603f3d011682016040523d82523d6000602084013e6147f7565b606091505b509150915061480887838387614813565b979650505050505050565b6060831561488257825160000361487b576001600160a01b0385163b61487b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610cee565b50816111c2565b6111c283838151156148975781518083602001fd5b8060405162461bcd60e51b8152600401610cee9190615a84565b828054828255906000526020600020908101928215614911579160200282015b8281111561491157815473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038435161782556020909201916001909101906148d1565b5061491d929150614921565b5090565b5b8082111561491d5760008155600101614922565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff8111828210171561496f5761496f614936565b60405290565b60405160a0810167ffffffffffffffff8111828210171561496f5761496f614936565b604051601f8201601f1916810167ffffffffffffffff811182821017156149c1576149c1614936565b604052919050565b600067ffffffffffffffff8311156149e3576149e3614936565b6149f6601f8401601f1916602001614998565b9050828152838383011115614a0a57600080fd5b828260208301376000602084830101529392505050565b600082601f830112614a3257600080fd5b61233d838335602085016149c9565b6001600160a01b0381168114612cfb57600080fd5b60008060408385031215614a6957600080fd5b82359150602083013567ffffffffffffffff80821115614a8857600080fd5b9084019060808287031215614a9c57600080fd5b614aa461494c565b823582811115614ab357600080fd5b614abf88828601614a21565b82525060208301359150614ad282614a41565b81602082015260408301356040820152606083013560608201528093505050509250929050565b60008083601f840112614b0b57600080fd5b50813567ffffffffffffffff811115614b2357600080fd5b6020830191508360208260051b8501011115614b3e57600080fd5b9250929050565b600080600080600080600060c0888a031215614b6057600080fd5b873596506020880135614b7281614a41565b9550604088013567ffffffffffffffff811115614b8e57600080fd5b614b9a8a828b01614af9565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215614bce57600080fd5b8135610ffc81614a41565b600060208284031215614beb57600080fd5b5035919050565b600080600060608486031215614c0757600080fd5b8335614c1281614a41565b9250602084013591506040840135614c2981614a41565b809150509250925092565b60008060008060808587031215614c4a57600080fd5b8435614c5581614a41565b93506020850135614c6581614a41565b92506040850135614c7581614a41565b9396929550929360600135925050565b60008083601f840112614c9757600080fd5b50813567ffffffffffffffff811115614caf57600080fd5b602083019150836020828501011115614b3e57600080fd5b600080600060408486031215614cdc57600080fd5b83359250602084013567ffffffffffffffff811115614cfa57600080fd5b614d0686828701614c85565b9497909650939450505050565b60008060408385031215614d2657600080fd5b8235614d3181614a41565b91506020830135614d4181614a41565b809150509250929050565b60008060208385031215614d5f57600080fd5b823567ffffffffffffffff811115614d7657600080fd5b614d8285828601614af9565b90969095509350505050565b803560058110614d9d57600080fd5b919050565b60008060008060808587031215614db857600080fd5b84359350602085013567ffffffffffffffff811115614dd657600080fd5b8501601f81018713614de757600080fd5b614df6878235602084016149c9565b9350506040850135614e0781614a41565b9150614e1560608601614d8e565b905092959194509250565b8015158114612cfb57600080fd5b60008060408385031215614e4157600080fd5b823591506020830135614d4181614e20565b634e487b7160e01b600052602160045260246000fd5b60005b83811015614e84578181015183820152602001614e6c565b50506000910152565b60008151808452614ea5816020860160208601614e69565b601f01601f19169290920160200192915050565b67ffffffffffffffff871681526001600160a01b038681166020830152851515604083015284166060820152600060058410614ef757614ef7614e53565b83608083015260c060a0830152614f1160c0830184614e8d565b98975050505050505050565b60008060408385031215614f3057600080fd5b50508035926020909101359150565b600067ffffffffffffffff821115614f5957614f59614936565b5060051b60200190565b600082601f830112614f7457600080fd5b81356020614f89614f8483614f3f565b614998565b82815260059290921b84018101918181019086841115614fa857600080fd5b8286015b8481101561504c57803567ffffffffffffffff80821115614fcd5760008081fd5b9088019060a0828b03601f1901811315614fe75760008081fd5b614fef614975565b8784013581526040808501358983015260608086013582840152608091508186013581840152508285013592508383111561502a5760008081fd5b6150388d8a85880101614a21565b908201528652505050918301918301614fac565b509695505050505050565b600082601f83011261506857600080fd5b81356020615078614f8483614f3f565b82815260059290921b8401810191818101908684111561509757600080fd5b8286015b8481101561504c5780356150ae81614a41565b835291830191830161509b565b6000608082840312156150cd57600080fd5b6150d561494c565b905081356150e281614a41565b815260208201356150f281614e20565b6020820152604082013561510581614a41565b6040820152606082013561511881614e20565b606082015292915050565b600082601f83011261513457600080fd5b81356020615144614f8483614f3f565b82815260059290921b8401810191818101908684111561516357600080fd5b8286015b8481101561504c5780358352918301918301615167565b60008060008060008060008060006101808a8c03121561519d57600080fd5b8935985060208a013567ffffffffffffffff808211156151bc57600080fd5b6151c88d838e01614f63565b995060408c01359150808211156151de57600080fd5b6151ea8d838e01615057565b98506151f98d60608e016150bb565b975060e08c013591508082111561520f57600080fd5b5061521c8c828d01615123565b999c989b50969995989761010087013597506101208701359661014081013596506101600135945092505050565b6000806000806060858703121561526057600080fd5b843561526b81614a41565b935060208501359250604085013567ffffffffffffffff81111561528e57600080fd5b61529a87828801614af9565b95989497509550505050565b6000806000806000608086880312156152be57600080fd5b853567ffffffffffffffff8111156152d557600080fd5b6152e188828901614c85565b90965094505060208601356152f581614a41565b9250604086013561530581614a41565b915061531360608701614d8e565b90509295509295909350565b634e487b7160e01b600052603260045260246000fd5b600181811c9082168061534957607f821691505b602082108103613fee57634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561234057612340615369565b808202811582820484141761234057612340615369565b6000826153c657634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156153dd57600080fd5b8151610ffc81614a41565b6000602082840312156153fa57600080fd5b8151610ffc81614e20565b60208152600082516080602084015261542160a0840182614e8d565b90506001600160a01b03602085015116604084015260408401516060840152606084015160808401528091505092915050565b60006020828403121561546657600080fd5b5051919050565b80516dffffffffffffffffffffffffffff81168114614d9d57600080fd5b6000806000606084860312156154a057600080fd5b6154a98461546d565b92506154b76020850161546d565b9150604084015163ffffffff81168114614c2957600080fd5b60008082840360c08112156154e457600080fd5b60a08112156154f257600080fd5b506154fb614975565b833561550681614a41565b8152602084013561551681614a41565b6020820152604084013561552981614a41565b60408201526060848101359082015260808085013590820152915060a083013567ffffffffffffffff81111561555e57600080fd5b61556a85828601614a21565b9150509250929050565b8082018082111561234057612340615369565b60006001600160a01b0380855116835280602086015116602084015280604086015116604084015250606084015160608301526080840151608083015260c060a08301526111c260c0830184614e8d565b8183526000602080850194508260005b858110156156165781356155fb81614a41565b6001600160a01b0316875295820195908201906001016155e8565b509495945050505050565b6020815260006111c26020830184866155d8565b600081518084526020808501945080840160005b838110156156165781516001600160a01b031687529582019590820190600101615649565b600081518084526020808501945080840160005b8381101561561657815187529582019590820190600101615682565b600061012080830160028a106156b6576156b6614e53565b89845260208085019290925288519081905261014080850192600583901b8601909101918a820160005b828110156157435787850361013f190186528151805186528481015185870152604080820151908701526060808201519087015260809081015160a09187018290529061572f81880183614e8d565b9786019796505050908301906001016156e0565b5050505083810360408501526157598189615635565b91505061579b60608401876001600160a01b03808251168352602082015115156020840152806040830151166040840152506060810151151560608301525050565b82810360e08401526157ad818661566e565b91505082610100830152979650505050505050565b600060208083850312156157d557600080fd5b825167ffffffffffffffff8111156157ec57600080fd5b8301601f810185136157fd57600080fd5b805161580b614f8482614f3f565b81815260059190911b8201830190838101908783111561582a57600080fd5b928401925b828410156148085783518252928401929084019061582f565b808202600082127f80000000000000000000000000000000000000000000000000000000000000008414161561588057615880615369565b818105831482151761234057612340615369565b6000600182016158a6576158a6615369565b5060010190565b6bffffffffffffffffffffffff198360601b168152600082516158d7816014850160208701614e69565b919091016014019392505050565b600083516158f7818460208801614e69565b60609390931b6bffffffffffffffffffffffff19169190920190815260140192915050565b86815285602082015260a06040820152600061593c60a0830186886155d8565b6001600160a01b039490941660608301525060800152949350505050565b601f82111561214757600081815260208120601f850160051c810160208610156159815750805b601f850160051c820191505b818110156159a05782815560010161598d565b505050505050565b815167ffffffffffffffff8111156159c2576159c2614936565b6159d6816159d08454615335565b8461595a565b602080601f831160018114615a0b57600084156159f35750858301515b600019600386901b1c1916600185901b1785556159a0565b600085815260208120601f198616915b82811015615a3a57888601518255948401946001909101908401615a1b565b5085821015615a585787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60008251615a7a818460208701614e69565b9190910192915050565b60208152600061233d6020830184614e8d56fe48ac1440eee4f8d8cddb06238ff616d995159116b6e34ec7971766f61c0c4fe8a26469706673582212201e6dc362b9c01ed56996ff418a1341c24e53091d5849b450e679d861b029904664736f6c63430008110033000000000000000000000000d08481058399490b83a72676901d4e9db70e75ac000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000002d9

Deployed Bytecode

0x6080604052600436106101dc5760003560e01c80638da5cb5b11610102578063bdf7068611610095578063e86dea4a11610064578063e86dea4a1461053d578063f1d85b6514610571578063f2fde38b14610584578063fdf59b8e146105a457600080fd5b8063bdf7068614610499578063d63a4d5c146104cb578063e1e13980146104eb578063e329c80d146104fe57600080fd5b80639c22b9a6116100d15780639c22b9a61461042a578063a961e2431461043f578063b231d68b14610452578063b269681d1461046557600080fd5b80638da5cb5b146103d357806391c05b0b146103f15780639321111d1461040457806394c176e41461041757600080fd5b80632f0807e21161017a5780635d39ba9b116101495780635d39ba9b14610354578063715018a61461038957806372f23fd91461039e57806386f9bfa8146103b357600080fd5b80632f0807e2146102df578063394ce9c7146102f45780635517b46e14610314578063574b64a71461034157600080fd5b8063180b0d7e116101b6578063180b0d7e14610229578063235b77dc146102535780632d5969771461028b5780632d68efc9146102ab57600080fd5b80630119e16c146101f0578063012e74a314610203578063023276f01461021657600080fd5b366101eb576101e96105b7565b005b600080fd5b6101e96101fe366004614a56565b610619565b6101e9610211366004614b45565b610da3565b6101e9610224366004614bbc565b610e8e565b34801561023557600080fd5b50610240620186a081565b6040519081526020015b60405180910390f35b34801561025f57600080fd5b5061027361026e366004614bd9565b610f57565b6040516001600160a01b03909116815260200161024a565b34801561029757600080fd5b506102406102a6366004614bf2565b610f81565b3480156102b757600080fd5b506102737f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b3480156102eb57600080fd5b50600254610240565b34801561030057600080fd5b5061024061030f366004614c34565b611003565b34801561032057600080fd5b5061024061032f366004614bbc565b60036020526000908152604090205481565b6101e961034f366004614cc7565b6111ca565b34801561036057600080fd5b5061037461036f366004614d13565b611bea565b6040805192835260208301919091520161024a565b34801561039557600080fd5b506101e9611dc4565b3480156103aa57600080fd5b50610374611dd6565b3480156103bf57600080fd5b506101e96103ce366004614d4c565b611e6d565b3480156103df57600080fd5b506000546001600160a01b0316610273565b6101e96103ff366004614bd9565b611ec9565b6101e9610412366004614b45565b611ed4565b6101e9610425366004614bd9565b61211a565b34801561043657600080fd5b5061024061214c565b6101e961044d366004614da2565b61216f565b6101e9610460366004614e2e565b612189565b34801561047157600080fd5b506102737f000000000000000000000000d08481058399490b83a72676901d4e9db70e75ac81565b3480156104a557600080fd5b506104b96104b4366004614bd9565b612236565b60405161024a96959493929190614eb9565b3480156104d757600080fd5b506102406104e6366004614f1d565b612331565b6101e96104f936600461517e565b612346565b34801561050a57600080fd5b5061051e61051936600461524a565b612c04565b604080516001600160a01b03909316835260208301919091520161024a565b34801561054957600080fd5b506102407f00000000000000000000000000000000000000000000000000000000000002d981565b6101e961057f3660046152a6565b612c52565b34801561059057600080fd5b506101e961059f366004614bbc565b612c6e565b6101e96105b2366004614b45565b612cfe565b7f000000000000000000000000d08481058399490b83a72676901d4e9db70e75ac6001600160a01b0316610617576040517f79dd500900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b60006002838154811061062e5761062e61531f565b60009182526020918290206040805160c0810182526003909302909101805467ffffffffffffffff811684526001600160a01b0368010000000000000000820481169585019590955260ff600160e01b90910481161515928401929092526001810154938416606084015291926080840191600160a01b9091041660048111156106ba576106ba614e53565b60048111156106cb576106cb614e53565b81526020016002820180546106df90615335565b80601f016020809104026020016040519081016040528092919081815260200182805461070b90615335565b80156107585780601f1061072d57610100808354040283529160200191610758565b820191906000526020600020905b81548152906001019060200180831161073b57829003601f168201915b505050505081525050905080604001511561078657604051633d8c23c960e01b815260040160405180910390fd5b8151349060009061079690612fc7565b90506000816000815181106107ad576107ad61531f565b60200260200101519050600082600184516107c8919061537f565b815181106107d8576107d861531f565b6020026020010151905060006107f1866060015161309d565b905060006001600160a01b038316158061081c5750816001600160a01b0316836001600160a01b0316145b905060008860400151905060008960200151905060008b826001600160a01b031688886040516020016108659291906001600160a01b0392831681529116602082015260400190565b604051602081830303815290604052805190602001207fb2c680c61107ad1f3fc37c2a8f8a842318cde79fa88c4263a7ac104cc6d93ae0866040516108ac91815260200190565b60405180910390a46001600160a01b03871661092d576000620186a06108f27f00000000000000000000000000000000000000000000000000000000000002d98c615392565b6108fc91906153a9565b9050610908818b61537f565b604051909a506001908290600080516020615a9883398151915290600090a350610a7b565b846001600160a01b0316876001600160a01b0316036109a157620186a06109747f00000000000000000000000000000000000000000000000000000000000002d985615392565b61097e91906153a9565b6040519091506000908290600080516020615a98833981519152908390a3610a7b565b83610a7b576000610a4f600260808f901c815481106109c2576109c261531f565b906000526020600020906003020160000160089054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4891906153cb565b858b6130db565b915050610a5c8a82613193565b506040516001908b90600080516020615a9883398151915290600090a3505b6001600160a01b038716610b0857849650610a9a8b600001518661326c565b8b60000181905250889250828b6040018181525050846001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b158015610aea57600080fd5b505af1158015610afe573d6000803e3d6000fd5b5050505050610b27565b80610b1388856132b8565b610b1d919061537f565b60408c0181905292505b8315610b34573060208c01525b6001600160a01b038616610b71578a51610b6e907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26133b0565b8b525b60208a015160405163095ea7b360e01b81526001600160a01b039182166004820152602481018590529088169063095ea7b3906044016020604051808303816000875af1158015610bc6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bea91906153e8565b5060208a01516040517fb858183f0000000000000000000000000000000000000000000000000000000081526000916001600160a01b03169063b858183f90610c37908f90600401615405565b6020604051808303816000875af1158015610c56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7a9190615454565b9050856001600160a01b0316876001600160a01b031603610d46578915610cf757604051630a09945f60e21b815260006004820152602481018b905260606044820152601560648201527f6665657320706169642066726f6d206f75747075740000000000000000000000608482015260a4015b60405180910390fd5b610d1583610d04836133df565b6001600160a01b038a169190613423565b6000610d20826133df565b610d2a908361537f565b604051600080516020615a9883398151915290600090a3610d94565b6001600160a01b038716610d9457610d6786610d61836133df565b856134b3565b6001610d72826133df565b610d7c908361537f565b604051600080516020615a9883398151915290600090a35b50505050505050505050505050565b610db33488888888888888613594565b86866001600160a01b031686866000818110610dd157610dd161531f565b9050602002016020810190610de69190614bbc565b8787610df360018261537f565b818110610e0257610e0261531f565b9050602002016020810190610e179190614bbc565b604080516001600160a01b0393841660208201529290911690820152606001604051602081830303815290604052805190602001207fb2c680c61107ad1f3fc37c2a8f8a842318cde79fa88c4263a7ac104cc6d93ae086604051610e7d91815260200190565b60405180910390a450505050505050565b806001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015610ec957600080fd5b505af1158015610edd573d6000803e3d6000fd5b505060405163a9059cbb60e01b81523360048201523460248201526001600160a01b038516935063a9059cbb925060440190506020604051808303816000875af1158015610f2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5391906153e8565b5050565b60018181548110610f6757600080fd5b6000918252602090912001546001600160a01b0316905081565b6000806000610f908685611bea565b91509150670de0b6b3a7640000811115610ff957610fb182620186a0615392565b7f00000000000000000000000000000000000000000000000000000000000002d9610fdc8388615392565b610fe69190615392565b610ff091906153a9565b92505050610ffc565b50505b9392505050565b60405163e6a4390560e01b81526001600160a01b0384811660048301528381166024830152600091829187169063e6a4390590604401602060405180830381865afa158015611056573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107a91906153cb565b90506000856001600160a01b0316826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ea91906153cb565b6001600160a01b0316149050600080836001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015611137573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115b919061548b565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff16915082156111a657816111918783615392565b61119b91906153a9565b9450505050506111c2565b806111b18784615392565b6111bb91906153a9565b9450505050505b949350505050565b6000600284815481106111df576111df61531f565b60009182526020918290206040805160c0810182526003909302909101805467ffffffffffffffff811684526001600160a01b0368010000000000000000820481169585019590955260ff600160e01b90910481161515928401929092526001810154938416606084015291926080840191600160a01b90910416600481111561126b5761126b614e53565b600481111561127c5761127c614e53565b815260200160028201805461129090615335565b80601f01602080910402602001604051908101604052809291908181526020018280546112bc90615335565b80156113095780601f106112de57610100808354040283529160200191611309565b820191906000526020600020905b8154815290600101906020018083116112ec57829003601f168201915b505050505081525050905080604001511561133757604051633d8c23c960e01b815260040160405180910390fd5b600080611346848601866154d0565b815160208301516060840151306040860152939550919350349290919060006001600160a01b03831615806113985750611383886060015161309d565b6001600160a01b0316836001600160a01b0316145b90506001600160a01b0384166114a0576000620186a06113d87f00000000000000000000000000000000000000000000000000000000000002d988615392565b6113e291906153a9565b905060006113f08285615574565b90508087146114785760408051630a09945f60e21b815260048101839052602481018990526060604482015260648101919091527f7377617050697465617328293a3a20696e73756666206d73672e76616c75652060848201527f666565207768656e206e617469766520617373657420697320696e546f6b656e60a482015260c401610cee565b60405193965086936001908390600080516020615a9883398151915290600090a350506117e8565b6114ad886060015161309d565b6001600160a01b0316846001600160a01b0316036116575760006114f47f00000000000000000000000000000000000000000000000000000000000002d9620186a061537f565b611501620186a085615392565b61150b91906153a9565b90506000611519848361537f565b9050600061152787846132b8565b90506115368b6060015161309d565b60208c015160405163095ea7b360e01b81526001600160a01b0391821660048201526024810188905291169063095ea7b3906044016020604051808303816000875af115801561158a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ae91906153e8565b508281101561163457604051630a09945f60e21b8152600481018490526024810182905260606044820152602b60648201527f7377617050697465617328293a3a20696e737566662066656520666f7220774e60848201527f617469766520617373657400000000000000000000000000000000000000000060a482015260c401610cee565b6040516000908390600080516020615a98833981519152908390a35050506117e8565b806117bf5760408051600280825260608201835260009260208301908036833701905050905084816000815181106116915761169161531f565b60200260200101906001600160a01b031690816001600160a01b03168152505083816001815181106116c5576116c561531f565b60200260200101906001600160a01b031690816001600160a01b031681525050600061178e600260808f901c815481106117015761170161531f565b906000526020600020906003020160000160089054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015611763573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178791906153cb565b85846130db565b91505061179b8782613193565b506040516001908890600080516020615a9883398151915290600090a350506117e8565b84156117e857604051630626ade360e41b81526000600482015260248101869052604401610cee565b6001600160a01b0384161580159061181e5750611808886060015161309d565b6001600160a01b0316846001600160a01b031614155b156118d857600061182f85846132b8565b90508281101561185c57604051630626ade360e41b81526004810184905260248101829052604401610cee565b602089015160405163095ea7b360e01b81526001600160a01b039182166004820152602481018590529086169063095ea7b3906044016020604051808303816000875af11580156118b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d591906153e8565b50505b6001600160a01b038416156118ec57600094505b60006001600160a01b03841661190357504761196e565b6040516370a0823160e01b81523060048201526001600160a01b038516906370a0823190602401602060405180830381865afa158015611947573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196b9190615454565b90505b600089602001516001600160a01b0316638218b58f888b8b6040518463ffffffff1660e01b81526004016119a3929190615587565b60206040518083038185885af11580156119c1573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906119e69190615454565b905060006001600160a01b0386166119ff575047611a6a565b6040516370a0823160e01b81523060048201526001600160a01b038716906370a0823190602401602060405180830381865afa158015611a43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a679190615454565b90505b611a74838261537f565b8214611aa75781611a85848361537f565b604051630626ade360e41b815260048101929092526024820152604401610cee565b611ab48b6060015161309d565b6001600160a01b0316866001600160a01b031603611b1b57611aea33611ad9846133df565b6001600160a01b0389169190613423565b6000611af5836133df565b611aff908461537f565b604051600080516020615a9883398151915290600090a3611b67565b6001600160a01b038616611b5357611b48611b398c6060015161309d565b611b42846133df565b336134b3565b6001611af5836133df565b611b676001600160a01b0387163384613423565b604080516001600160a01b0389811660208301528816918101919091528e903390606001604051602081830303815290604052805190602001207fb2c680c61107ad1f3fc37c2a8f8a842318cde79fa88c4263a7ac104cc6d93ae088604051611bd291815260200190565b60405180910390a45050505050505050505050505050565b60405163e6a4390560e01b81526001600160a01b0382811660048301527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281811660248401526000928392869291849184169063e6a4390590604401602060405180830381865afa158015611c63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c8791906153cb565b90506001600160a01b03811615611dba57600080826001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015611cd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfd919061548b565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff1691506000836001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8691906153cb565b90506001600160a01b038082169086161480611da25783611da4565b825b985080611db15782611db3565b835b9750505050505b5050509250929050565b611dcc61392c565b6106176000613986565b6040516370a0823160e01b8152306004820152600090819047906001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216906370a0823190602401602060405180830381865afa158015611e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e659190615454565b915091509091565b611e7561392c565b611e81600183836148b1565b50336001600160a01b03167f43a7b7252c812355611a4161c33c1026045c1a89763cfaef223712907d805d8b8383604051611ebd929190615621565b60405180910390a25050565b47610f5382826139e3565b6000611f0e60028981548110611eec57611eec61531f565b60009182526020909120600160039092020101546001600160a01b031661309d565b90506001600160a01b0381168686611f2760018261537f565b818110611f3657611f3661531f565b9050602002016020810190611f4b9190614bbc565b6001600160a01b031614611f8057611f6460018661537f565b604051631b02683560e31b8152600401610cee91815260200190565b6000611fb387876000818110611f9857611f9861531f565b9050602002016020810190611fad9190614bbc565b866132b8565b90506000611fc58a8989858989613a65565b90506000620186a0611ff77f00000000000000000000000000000000000000000000000000000000000002d984615392565b61200191906153a9565b61200b908361537f565b90506000612019828461537f565b604051600080516020615a9883398151915290600090a361203b84828c6134b3565b8a8a6001600160a01b03168a8a60008181106120595761205961531f565b905060200201602081019061206e9190614bbc565b8b8b61207b60018261537f565b81811061208a5761208a61531f565b905060200201602081019061209f9190614bbc565b604080516001600160a01b0393841660208201529290911690820152606001604051602081830303815290604052805190602001207fb2c680c61107ad1f3fc37c2a8f8a842318cde79fa88c4263a7ac104cc6d93ae08a60405161210591815260200190565b60405180910390a45050505050505050505050565b600080612125611dd6565b91509150612134838383613e1e565b612147836121428385615574565b6139e3565b505050565b6000806000612159611dd6565b90925090506121688183615574565b9250505090565b61217761392c565b61218384848484613eba565b50505050565b61219161392c565b801515600283815481106121a7576121a761531f565b6000918252602090912060039091020154600160e01b900460ff16151514610f535780600283815481106121dd576121dd61531f565b6000918252602082206003909102018054921515600160e01b0260ff60e01b1990931692909217909155604051839133917ff46467fbac738ac4d46eb7aff18d9f1e807be9993f9a05f54ca83b066b8ce6409190a35050565b6002818154811061224657600080fd5b600091825260209091206003909102018054600182015460028301805467ffffffffffffffff841695506001600160a01b0368010000000000000000850481169560ff600160e01b90960486169591851694600160a01b90049091169290916122ae90615335565b80601f01602080910402602001604051908101604052809291908181526020018280546122da90615335565b80156123275780601f106122fc57610100808354040283529160200191612327565b820191906000526020600020905b81548152906001019060200180831161230a57829003601f168201915b5050505050905086565b600061233d8383613fd6565b90505b92915050565b600289815481106123595761235961531f565b6000918252602090912060039091020154600160e01b900460ff161561239257604051633d8c23c960e01b815260040160405180910390fd5b6000806001600160a01b03168884815181106123b0576123b061531f565b60200260200101516001600160a01b0316148061240c57506123de60028b81548110611eec57611eec61531f565b6001600160a01b03168884815181106123f9576123f961531f565b60200260200101516001600160a01b0316145b6040880151895191925034916000908b908890811061242d5761242d61531f565b60200260200101516001600160a01b03160361253657620186a06124717f00000000000000000000000000000000000000000000000000000000000002d934615392565b61247b91906153a9565b612485903461537f565b8887815181106124975761249761531f565b50620186a091506124ca90507f00000000000000000000000000000000000000000000000000000000000002d934615392565b6124d491906153a9565b6124de908361537f565b91506001620186a06125107f00000000000000000000000000000000000000000000000000000000000002d934615392565b61251a91906153a9565b604051600080516020615a9883398151915290600090a361264d565b61254c60028d81548110611eec57611eec61531f565b6001600160a01b03168a87815181106125675761256761531f565b60200260200101516001600160a01b03160361260957620186a06125ab7f00000000000000000000000000000000000000000000000000000000000002d986615392565b6125b591906153a9565b6125bf908561537f565b8887815181106125d1576125d161531f565b5060009350839150620186a090506125107f00000000000000000000000000000000000000000000000000000000000002d987615392565b8261264d5761264d8c85348d8a815181106126265761262661531f565b60200260200101518e8a815181106126405761264061531f565b6020026020010151613ff4565b88516001600160a01b031630146126a45788516040517fee8427160000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b039091166024820152604401610cee565b60006001600160a01b03168a87815181106126c1576126c161531f565b60200260200101516001600160a01b03161461288d576126ed60028d81548110611eec57611eec61531f565b6001600160a01b03168a87815181106127085761270861531f565b60200260200101516001600160a01b03161461272557600061275d565b620186a06127537f00000000000000000000000000000000000000000000000000000000000002d986615392565b61275d91906153a9565b6127808b88815181106127725761277261531f565b6020026020010151866132b8565b61278a919061537f565b93508388878151811061279f5761279f61531f565b6020026020010181815250508986815181106127bd576127bd61531f565b60200260200101516001600160a01b031663095ea7b360028e815481106127e6576127e661531f565b600091825260209091206003909102015460405160e083901b7fffffffff00000000000000000000000000000000000000000000000000000000168152680100000000000000009091046001600160a01b03166004820152602481018790526044016020604051808303816000875af1158015612867573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061288b91906153e8565b505b821561289a573060408a01525b600060028d815481106128af576128af61531f565b906000526020600020906003020160000160089054906101000a90046001600160a01b03166001600160a01b031663945bcec98460008f8f8f8f8f6040518863ffffffff1660e01b815260040161290b9695949392919061569e565b60006040518083038185885af1158015612929573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f1916820160405261295291908101906157c2565b905061296a60028e81548110611eec57611eec61531f565b6001600160a01b03168b87815181106129855761298561531f565b60200260200101516001600160a01b031603612a7d57612a0d826129db83600185516129b1919061537f565b815181106129c1576129c161531f565b60200260200101516000196129d69190615848565b6133df565b8d89815181106129ed576129ed61531f565b60200260200101516001600160a01b03166134239092919063ffffffff16565b60001515612a2382600184516129b1919061537f565b8260018451612a32919061537f565b81518110612a4257612a4261531f565b6020026020010151600019612a579190615848565b612a61919061537f565b604051600080516020615a9883398151915290600090a3612b41565b60006001600160a01b03168b8781518110612a9a57612a9a61531f565b60200260200101516001600160a01b031603612b4157612ad5612ac582600184516129b1919061537f565b6001600160a01b03841690614159565b60011515612aeb82600184516129b1919061537f565b8260018451612afa919061537f565b81518110612b0a57612b0a61531f565b6020026020010151600019612b1f9190615848565b612b29919061537f565b604051600080516020615a9883398151915290600090a35b8c826001600160a01b03168c8981518110612b5e57612b5e61531f565b60200260200101518d8981518110612b7857612b7861531f565b6020026020010151604051602001612ba69291906001600160a01b0392831681529116602082015260400190565b604051602081830303815290604052805190602001207fb2c680c61107ad1f3fc37c2a8f8a842318cde79fa88c4263a7ac104cc6d93ae088604051612bed91815260200190565b60405180910390a450505050505050505050505050565b600080612c4586868686808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506130db92505050565b9150915094509492505050565b612c5a61392c565b612c678585858585614272565b5050505050565b612c7661392c565b6001600160a01b038116612cf25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610cee565b612cfb81613986565b50565b6000620186a0612d2e7f00000000000000000000000000000000000000000000000000000000000002d934615392565b612d3891906153a9565b90506000612d5260028a81548110611eec57611eec61531f565b9050612d5e8286615574565b3414612dc557612d6e8286615574565b604051630a09945f60e21b8152600481019190915234602482015260606044820152601a60648201527f616d6f756e74202b2066656573206d757374203d20746f74616c000000000000608482015260a401610cee565b806001600160a01b031687876000818110612de257612de261531f565b9050602002016020810190612df79190614bbc565b6001600160a01b031614612e2157604051631b02683560e31b815260006004820152602401610cee565b6040516001908390600080516020615a9883398151915290600090a3806001600160a01b031663d0e30db0866040518263ffffffff1660e01b81526004016000604051808303818588803b158015612e7857600080fd5b505af1158015612e8c573d6000803e3d6000fd5b50505050506000612ea18a8989898989613a65565b9050612ee989828a8a612eb560018261537f565b818110612ec457612ec461531f565b9050602002016020810190612ed99190614bbc565b6001600160a01b03169190613423565b89896001600160a01b031689896000818110612f0757612f0761531f565b9050602002016020810190612f1c9190614bbc565b8a8a612f2960018261537f565b818110612f3857612f3861531f565b9050602002016020810190612f4d9190614bbc565b604080516001600160a01b0393841660208201529290911690820152606001604051602081830303815290604052805190602001207fb2c680c61107ad1f3fc37c2a8f8a842318cde79fa88c4263a7ac104cc6d93ae089604051612fb391815260200190565b60405180910390a450505050505050505050565b60606000601760148451612fdb919061537f565b612fe591906153a9565b612ff0906001615574565b905060008167ffffffffffffffff81111561300d5761300d614936565b604051908082528060200260200182016040528015613036578160200160208202803683370190505b50905060005b6000613049826017615392565b613054906014615574565b90506000818701519050808484815181106130715761307161531f565b6001600160a01b0390921660209283029190910190910152505060010182811061303c57509392505050565b60006001600160a01b038216156130b45781612340565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc292915050565b60008060005b83518110156131825760008482815181106130fe576130fe61531f565b602002602001015190506000613115888884610f81565b9050801561312957909350915061318b9050565b60018651613137919061537f565b831461316f5761316c88838861314e876001615574565b8151811061315e5761315e61531f565b60200260200101518a611003565b96505b50508061317b90615894565b90506130e1565b50600080915091505b935093915050565b6000600a6131a2836009615392565b6131ac91906153a9565b90508060000361320d57604051630a09945f60e21b8152600060048201526024810184905260606044820152601660648201527f756e61626c6520746f20636f6d70757465206665657300000000000000000000608482015260a401610cee565b8083101561234057604051630a09945f60e21b8152600481018290526024810184905260606044820152601460648201527f6e6f7420656e6f756768206665652076616c7565000000000000000000000000608482015260a401610cee565b60606000613288846014808751613283919061537f565b614530565b90506000838260405160200161329f9291906158ad565b60408051808303601f1901815291905295945050505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa158015613301573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133259190615454565b905061333c6001600160a01b038516333086614658565b6040516370a0823160e01b815230600482015281906001600160a01b038616906370a0823190602401602060405180830381865afa158015613382573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133a69190615454565b6111c2919061537f565b606060006133c884600060148751613283919061537f565b90506000818460405160200161329f9291906158e5565b6000620186a061340f7f00000000000000000000000000000000000000000000000000000000000002d984615392565b61341991906153a9565b612340908361537f565b6040516001600160a01b03831660248201526044810182905261214790849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526146a9565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa1580156134fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061351e9190615454565b9050801561358157604051632e1a7d4d60e01b8152600481018290526001600160a01b03851690632e1a7d4d90602401600060405180830381600087803b15801561356857600080fd5b505af115801561357c573d6000803e3d6000fd5b505050505b6121836001600160a01b03831684614159565b6000858560008181106135a9576135a961531f565b90506020020160208101906135be9190614bbc565b9050600086866135cf60018261537f565b8181106135de576135de61531f565b90506020020160208101906135f39190614bbc565b9050600061360d60028b81548110611eec57611eec61531f565b90506000816001600160a01b0316846001600160a01b0316036136e157620186a06136587f00000000000000000000000000000000000000000000000000000000000002d989615392565b61366291906153a9565b90508b156136c157604051630a09945f60e21b815260006004820152602481018d905260606044820152601460648201527f6665657320706169642066726f6d20696e707574000000000000000000000000608482015260a401610cee565b6040516000908290600080516020615a98833981519152908390a36137fe565b816001600160a01b0316836001600160a01b0316146137fe5760006137d260028d815481106137125761371261531f565b906000526020600020906003020160000160089054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015613774573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379891906153cb565b898c8c808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506130db92505050565b9150506137df8d82613193565b506040516001908e90600080516020615a9883398151915290600090a3505b60008161380b868a6132b8565b613815919061537f565b905060006138278d8c8c858c8c613a65565b9050806001600160a01b038086169087160361390757620186a061386b7f00000000000000000000000000000000000000000000000000000000000002d984615392565b61387591906153a9565b61387f908261537f565b90508e156138e35760008f604051630a09945f60e21b8152600401610cee92919091825260208201526060604082018190526015908201527f6665657320706169642066726f6d206f75747075740000000000000000000000608082015260a00190565b60006138ef828461537f565b604051600080516020615a9883398151915290600090a35b61391b6001600160a01b0387168e83613423565b505050505050505050505050505050565b6000546001600160a01b031633146106175760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610cee565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6139ed8282613fd6565b9150816000036139fb575050565b613a2e6001600160a01b037f000000000000000000000000d08481058399490b83a72676901d4e9db70e75ac1683614159565b6040518281527f8959421a1320789a49eeec01a4750caf8a30733c3db14f000d84484df89300f99060200160405180910390a15050565b60008060028881548110613a7b57613a7b61531f565b60009182526020918290206040805160c0810182526003909302909101805467ffffffffffffffff811684526001600160a01b0368010000000000000000820481169585019590955260ff600160e01b90910481161515928401929092526001810154938416606084015291926080840191600160a01b909104166004811115613b0757613b07614e53565b6004811115613b1857613b18614e53565b8152602001600282018054613b2c90615335565b80601f0160208091040260200160405190810160405280929190818152602001828054613b5890615335565b8015613ba55780601f10613b7a57610100808354040283529160200191613ba5565b820191906000526020600020905b815481529060010190602001808311613b8857829003601f168201915b5050505050815250509050806040015115613bd357604051633d8c23c960e01b815260040160405180910390fd5b60008787613be260018261537f565b818110613bf157613bf161531f565b9050602002016020810190613c069190614bbc565b905087876000818110613c1b57613c1b61531f565b9050602002016020810190613c309190614bbc565b602083015160405163095ea7b360e01b81526001600160a01b0391821660048201526024810189905291169063095ea7b3906044016020604051808303816000875af1158015613c84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ca891906153e8565b506040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015613cf0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d149190615454565b60208401516040517f5c11d7950000000000000000000000000000000000000000000000000000000081529192506001600160a01b031690635c11d79590613d6a908a908a908e908e9030908d9060040161591c565b600060405180830381600087803b158015613d8457600080fd5b505af1158015613d98573d6000803e3d6000fd5b50506040516370a0823160e01b81523060048201528392506001600160a01b03851691506370a0823190602401602060405180830381865afa158015613de2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e069190615454565b613e10919061537f565b9a9950505050505050505050565b821580613e2a57508282105b8015613e365750600081115b1561214757604051632e1a7d4d60e01b8152600481018290527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015613e9d57600080fd5b505af1158015613eb1573d6000803e3d6000fd5b50505050505050565b825115612183578260028581548110613ed557613ed561531f565b90600052602060002090600302016002019081613ef291906159a8565b508160028581548110613f0757613f0761531f565b906000526020600020906003020160010160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508060028581548110613f5057613f5061531f565b6000918252602090912060016003909202010180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b836004811115613f9e57613f9e614e53565b0217905550604051849033907ff46467fbac738ac4d46eb7aff18d9f1e807be9993f9a05f54ca83b066b8ce64090600090a350505050565b6000821580613fe457508183115b613fee578261233d565b50919050565b60408051600280825260608201835260009260208301908036833701905050905082816000815181106140295761402961531f565b60200260200101906001600160a01b031690816001600160a01b031681525050818160018151811061405d5761405d61531f565b60200260200101906001600160a01b031690816001600160a01b03168152505060006141266002608089901c815481106140995761409961531f565b906000526020600020906003020160000160089054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa1580156140fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061411f91906153cb565b87846130db565b9150506141338582613193565b506040516001908690600080516020615a9883398151915290600090a350505050505050565b804710156141a95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610cee565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146141f6576040519150601f19603f3d011682016040523d82523d6000602084013e6141fb565b606091505b50509050806121475760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610cee565b600081600481111561428657614286614e53565b036142bd576040517fcc36cd4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600280549050905060026040518060c001604052808367ffffffffffffffff168152602001866001600160a01b03168152602001600015158152602001856001600160a01b0316815260200184600481111561431d5761431d614e53565b815260200188888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509390945250508354600180820186559482526020918290208451600390920201805492850151604086015167ffffffffffffffff9093167fffffffff0000000000000000000000000000000000000000000000000000000090941693909317680100000000000000006001600160a01b03948516021760ff60e01b1916600160e01b921515929092029190911781556060840151948101805473ffffffffffffffffffffffffffffffffffffffff1981169690931695861781556080850151949591949350917fffffffffffffffffffffff0000000000000000000000000000000000000000001617600160a01b83600481111561445457614454614e53565b021790555060a0820151600282019061446d90826159a8565b5050506001600160a01b038416600090815260036020526040902054156144de576001600160a01b038416600090815260036020526040908190205490517f456c0cff0000000000000000000000000000000000000000000000000000000081526004810191909152602401610cee565b6002546001600160a01b038516600090815260036020526040808220929092559051829133917fca0cc3028eb486c2abb71c1a6f38d1e617ce1079f1be55c5cf422abfb2e4f4689190a3505050505050565b60608161453e81601f615574565b101561458c5760405162461bcd60e51b815260206004820152600e60248201527f736c6963655f6f766572666c6f770000000000000000000000000000000000006044820152606401610cee565b6145968284615574565b845110156145e65760405162461bcd60e51b815260206004820152601160248201527f736c6963655f6f75744f66426f756e64730000000000000000000000000000006044820152606401610cee565b606082158015614605576040519150600082526020820160405261464f565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561463e578051835260209283019201614626565b5050858452601f01601f1916604052505b50949350505050565b6040516001600160a01b03808516602483015283166044820152606481018290526121839085907f23b872dd000000000000000000000000000000000000000000000000000000009060840161344f565b60006146fe826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661478e9092919063ffffffff16565b805190915015612147578080602001905181019061471c91906153e8565b6121475760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610cee565b60606111c2848460008585600080866001600160a01b031685876040516147b59190615a68565b60006040518083038185875af1925050503d80600081146147f2576040519150601f19603f3d011682016040523d82523d6000602084013e6147f7565b606091505b509150915061480887838387614813565b979650505050505050565b6060831561488257825160000361487b576001600160a01b0385163b61487b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610cee565b50816111c2565b6111c283838151156148975781518083602001fd5b8060405162461bcd60e51b8152600401610cee9190615a84565b828054828255906000526020600020908101928215614911579160200282015b8281111561491157815473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038435161782556020909201916001909101906148d1565b5061491d929150614921565b5090565b5b8082111561491d5760008155600101614922565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff8111828210171561496f5761496f614936565b60405290565b60405160a0810167ffffffffffffffff8111828210171561496f5761496f614936565b604051601f8201601f1916810167ffffffffffffffff811182821017156149c1576149c1614936565b604052919050565b600067ffffffffffffffff8311156149e3576149e3614936565b6149f6601f8401601f1916602001614998565b9050828152838383011115614a0a57600080fd5b828260208301376000602084830101529392505050565b600082601f830112614a3257600080fd5b61233d838335602085016149c9565b6001600160a01b0381168114612cfb57600080fd5b60008060408385031215614a6957600080fd5b82359150602083013567ffffffffffffffff80821115614a8857600080fd5b9084019060808287031215614a9c57600080fd5b614aa461494c565b823582811115614ab357600080fd5b614abf88828601614a21565b82525060208301359150614ad282614a41565b81602082015260408301356040820152606083013560608201528093505050509250929050565b60008083601f840112614b0b57600080fd5b50813567ffffffffffffffff811115614b2357600080fd5b6020830191508360208260051b8501011115614b3e57600080fd5b9250929050565b600080600080600080600060c0888a031215614b6057600080fd5b873596506020880135614b7281614a41565b9550604088013567ffffffffffffffff811115614b8e57600080fd5b614b9a8a828b01614af9565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215614bce57600080fd5b8135610ffc81614a41565b600060208284031215614beb57600080fd5b5035919050565b600080600060608486031215614c0757600080fd5b8335614c1281614a41565b9250602084013591506040840135614c2981614a41565b809150509250925092565b60008060008060808587031215614c4a57600080fd5b8435614c5581614a41565b93506020850135614c6581614a41565b92506040850135614c7581614a41565b9396929550929360600135925050565b60008083601f840112614c9757600080fd5b50813567ffffffffffffffff811115614caf57600080fd5b602083019150836020828501011115614b3e57600080fd5b600080600060408486031215614cdc57600080fd5b83359250602084013567ffffffffffffffff811115614cfa57600080fd5b614d0686828701614c85565b9497909650939450505050565b60008060408385031215614d2657600080fd5b8235614d3181614a41565b91506020830135614d4181614a41565b809150509250929050565b60008060208385031215614d5f57600080fd5b823567ffffffffffffffff811115614d7657600080fd5b614d8285828601614af9565b90969095509350505050565b803560058110614d9d57600080fd5b919050565b60008060008060808587031215614db857600080fd5b84359350602085013567ffffffffffffffff811115614dd657600080fd5b8501601f81018713614de757600080fd5b614df6878235602084016149c9565b9350506040850135614e0781614a41565b9150614e1560608601614d8e565b905092959194509250565b8015158114612cfb57600080fd5b60008060408385031215614e4157600080fd5b823591506020830135614d4181614e20565b634e487b7160e01b600052602160045260246000fd5b60005b83811015614e84578181015183820152602001614e6c565b50506000910152565b60008151808452614ea5816020860160208601614e69565b601f01601f19169290920160200192915050565b67ffffffffffffffff871681526001600160a01b038681166020830152851515604083015284166060820152600060058410614ef757614ef7614e53565b83608083015260c060a0830152614f1160c0830184614e8d565b98975050505050505050565b60008060408385031215614f3057600080fd5b50508035926020909101359150565b600067ffffffffffffffff821115614f5957614f59614936565b5060051b60200190565b600082601f830112614f7457600080fd5b81356020614f89614f8483614f3f565b614998565b82815260059290921b84018101918181019086841115614fa857600080fd5b8286015b8481101561504c57803567ffffffffffffffff80821115614fcd5760008081fd5b9088019060a0828b03601f1901811315614fe75760008081fd5b614fef614975565b8784013581526040808501358983015260608086013582840152608091508186013581840152508285013592508383111561502a5760008081fd5b6150388d8a85880101614a21565b908201528652505050918301918301614fac565b509695505050505050565b600082601f83011261506857600080fd5b81356020615078614f8483614f3f565b82815260059290921b8401810191818101908684111561509757600080fd5b8286015b8481101561504c5780356150ae81614a41565b835291830191830161509b565b6000608082840312156150cd57600080fd5b6150d561494c565b905081356150e281614a41565b815260208201356150f281614e20565b6020820152604082013561510581614a41565b6040820152606082013561511881614e20565b606082015292915050565b600082601f83011261513457600080fd5b81356020615144614f8483614f3f565b82815260059290921b8401810191818101908684111561516357600080fd5b8286015b8481101561504c5780358352918301918301615167565b60008060008060008060008060006101808a8c03121561519d57600080fd5b8935985060208a013567ffffffffffffffff808211156151bc57600080fd5b6151c88d838e01614f63565b995060408c01359150808211156151de57600080fd5b6151ea8d838e01615057565b98506151f98d60608e016150bb565b975060e08c013591508082111561520f57600080fd5b5061521c8c828d01615123565b999c989b50969995989761010087013597506101208701359661014081013596506101600135945092505050565b6000806000806060858703121561526057600080fd5b843561526b81614a41565b935060208501359250604085013567ffffffffffffffff81111561528e57600080fd5b61529a87828801614af9565b95989497509550505050565b6000806000806000608086880312156152be57600080fd5b853567ffffffffffffffff8111156152d557600080fd5b6152e188828901614c85565b90965094505060208601356152f581614a41565b9250604086013561530581614a41565b915061531360608701614d8e565b90509295509295909350565b634e487b7160e01b600052603260045260246000fd5b600181811c9082168061534957607f821691505b602082108103613fee57634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561234057612340615369565b808202811582820484141761234057612340615369565b6000826153c657634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156153dd57600080fd5b8151610ffc81614a41565b6000602082840312156153fa57600080fd5b8151610ffc81614e20565b60208152600082516080602084015261542160a0840182614e8d565b90506001600160a01b03602085015116604084015260408401516060840152606084015160808401528091505092915050565b60006020828403121561546657600080fd5b5051919050565b80516dffffffffffffffffffffffffffff81168114614d9d57600080fd5b6000806000606084860312156154a057600080fd5b6154a98461546d565b92506154b76020850161546d565b9150604084015163ffffffff81168114614c2957600080fd5b60008082840360c08112156154e457600080fd5b60a08112156154f257600080fd5b506154fb614975565b833561550681614a41565b8152602084013561551681614a41565b6020820152604084013561552981614a41565b60408201526060848101359082015260808085013590820152915060a083013567ffffffffffffffff81111561555e57600080fd5b61556a85828601614a21565b9150509250929050565b8082018082111561234057612340615369565b60006001600160a01b0380855116835280602086015116602084015280604086015116604084015250606084015160608301526080840151608083015260c060a08301526111c260c0830184614e8d565b8183526000602080850194508260005b858110156156165781356155fb81614a41565b6001600160a01b0316875295820195908201906001016155e8565b509495945050505050565b6020815260006111c26020830184866155d8565b600081518084526020808501945080840160005b838110156156165781516001600160a01b031687529582019590820190600101615649565b600081518084526020808501945080840160005b8381101561561657815187529582019590820190600101615682565b600061012080830160028a106156b6576156b6614e53565b89845260208085019290925288519081905261014080850192600583901b8601909101918a820160005b828110156157435787850361013f190186528151805186528481015185870152604080820151908701526060808201519087015260809081015160a09187018290529061572f81880183614e8d565b9786019796505050908301906001016156e0565b5050505083810360408501526157598189615635565b91505061579b60608401876001600160a01b03808251168352602082015115156020840152806040830151166040840152506060810151151560608301525050565b82810360e08401526157ad818661566e565b91505082610100830152979650505050505050565b600060208083850312156157d557600080fd5b825167ffffffffffffffff8111156157ec57600080fd5b8301601f810185136157fd57600080fd5b805161580b614f8482614f3f565b81815260059190911b8201830190838101908783111561582a57600080fd5b928401925b828410156148085783518252928401929084019061582f565b808202600082127f80000000000000000000000000000000000000000000000000000000000000008414161561588057615880615369565b818105831482151761234057612340615369565b6000600182016158a6576158a6615369565b5060010190565b6bffffffffffffffffffffffff198360601b168152600082516158d7816014850160208701614e69565b919091016014019392505050565b600083516158f7818460208801614e69565b60609390931b6bffffffffffffffffffffffff19169190920190815260140192915050565b86815285602082015260a06040820152600061593c60a0830186886155d8565b6001600160a01b039490941660608301525060800152949350505050565b601f82111561214757600081815260208120601f850160051c810160208610156159815750805b601f850160051c820191505b818110156159a05782815560010161598d565b505050505050565b815167ffffffffffffffff8111156159c2576159c2614936565b6159d6816159d08454615335565b8461595a565b602080601f831160018114615a0b57600084156159f35750858301515b600019600386901b1c1916600185901b1785556159a0565b600085815260208120601f198616915b82811015615a3a57888601518255948401946001909101908401615a1b565b5085821015615a585787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60008251615a7a818460208701614e69565b9190910192915050565b60208152600061233d6020830184614e8d56fe48ac1440eee4f8d8cddb06238ff616d995159116b6e34ec7971766f61c0c4fe8a26469706673582212201e6dc362b9c01ed56996ff418a1341c24e53091d5849b450e679d861b029904664736f6c63430008110033

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

000000000000000000000000d08481058399490b83a72676901d4e9db70e75ac000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000002d9

-----Decoded View---------------
Arg [0] : _destination (address): 0xd08481058399490B83a72676901d4e9dB70E75aC
Arg [1] : _wNative (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [2] : _fee (uint96): 729

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000d08481058399490b83a72676901d4e9db70e75ac
Arg [1] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [2] : 00000000000000000000000000000000000000000000000000000000000002d9


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.