FTM Price: $0.67 (-8.45%)
Gas: 21 GWei

Contract

0x7E7A0e201FD38d3ADAA9523Da6C109a07118C96a
 

Multichain Info

Transaction Hash
Method
Block
From
To
Value
Bridge794475232024-04-16 2:15:087 hrs ago1713233708IN
Synapse: Router
4,560.69032126 FTM0.0024529425.18450882
Bridge794450692024-04-16 1:04:529 hrs ago1713229492IN
Synapse: Router
0 FTM0.176089021,387.07385554
Bridge794450682024-04-16 1:04:519 hrs ago1713229491IN
Synapse: Router
0 FTM0.0104254281.06612157
Bridge794308572024-04-15 20:03:1914 hrs ago1713211399IN
Synapse: Router
0 FTM0.0048029751.23560678
Bridge794261692024-04-15 18:40:4515 hrs ago1713206445IN
Synapse: Router
0 FTM0.0095973264.37742465
Bridge794227152024-04-15 17:40:1916 hrs ago1713202819IN
Synapse: Router
0 FTM0.0076271356.48596358
Bridge794161022024-04-15 15:43:3318 hrs ago1713195813IN
Synapse: Router
0 FTM0.0077413562.39909314
Bridge793667612024-04-14 21:21:3336 hrs ago1713129693IN
Synapse: Router
0 FTM0.0044025345.10890881
Bridge793132752024-04-14 2:41:402 days ago1713062500IN
Synapse: Router
0 FTM0.01816787199.33597804
Bridge792997672024-04-13 22:20:342 days ago1713046834IN
Synapse: Router
0 FTM0.0816493474.97033813
Bridge792965562024-04-13 21:27:262 days ago1713043646IN
Synapse: Router
0 FTM0.05306041368.44187673
Bridge792959832024-04-13 21:18:302 days ago1713043110IN
Synapse: Router
0 FTM0.03906744322.70872477
Bridge792942302024-04-13 20:53:162 days ago1713041596IN
Synapse: Router
0 FTM0.04944159366.73932654
Bridge792933572024-04-13 20:41:112 days ago1713040871IN
Synapse: Router
0 FTM0.06107247420.27938566
Bridge792911882024-04-13 20:09:322 days ago1713038972IN
Synapse: Router
0 FTM0.190388971,499.71626376
Bridge792905712024-04-13 19:59:122 days ago1713038352IN
Synapse: Router
0 FTM0.32253961,876.27746004
Bridge792904562024-04-13 19:57:032 days ago1713038223IN
Synapse: Router
0 FTM1.269887657,387.66358052
Bridge792814232024-04-13 17:25:462 days ago1713029146IN
Synapse: Router
0 FTM0.0039906736.72519755
Bridge792774872024-04-13 15:51:432 days ago1713023503IN
Synapse: Router
0 FTM0.0013477814.79549847
Bridge792724892024-04-13 12:13:422 days ago1713010422IN
Synapse: Router
0 FTM0.0013946515.16280149
Bridge792644372024-04-13 6:56:533 days ago1712991413IN
Synapse: Router
0 FTM0.0024018920.05591519
Bridge792511262024-04-13 2:02:203 days ago1712973740IN
Synapse: Router
0 FTM0.015096487.83004583
Bridge792508372024-04-13 1:57:033 days ago1712973423IN
Synapse: Router
0 FTM0.0150859387.75789876
Bridge792410022024-04-12 22:46:393 days ago1712961999IN
Synapse: Router
0 FTM0.011145376.69810124
Bridge792402842024-04-12 22:33:073 days ago1712961187IN
Synapse: Router
0 FTM0.02001839116.45099154
View all transactions

Latest 25 internal transactions (View All)

Parent Txn Hash Block From To Value
794475232024-04-16 2:15:087 hrs ago1713233708
Synapse: Router
4,560.69032126 FTM
794475232024-04-16 2:15:087 hrs ago1713233708
Synapse: Router
Synapse: Router
4,560.69032126 FTM
791017002024-04-10 14:41:555 days ago1712760115
Synapse: Router
279 FTM
791017002024-04-10 14:41:555 days ago1712760115
Synapse: Router
Synapse: Router
279 FTM
789913592024-04-09 8:59:217 days ago1712653161
Synapse: Router
3.9 FTM
789913592024-04-09 8:59:217 days ago1712653161
Synapse: Router
Synapse: Router
3.9 FTM
786719532024-04-03 10:51:2712 days ago1712141487
Synapse: Router
7 FTM
786719532024-04-03 10:51:2712 days ago1712141487
Synapse: Router
Synapse: Router
7 FTM
786706562024-04-03 10:05:2313 days ago1712138723
Synapse: Router
9 FTM
786706562024-04-03 10:05:2313 days ago1712138723
Synapse: Router
Synapse: Router
9 FTM
784384752024-03-29 20:20:0917 days ago1711743609
Synapse: Router
59.5 FTM
784384752024-03-29 20:20:0917 days ago1711743609
Synapse: Router
Synapse: Router
59.5 FTM
778502302024-03-21 3:43:0226 days ago1710992582
Synapse: Router
120 FTM
778502302024-03-21 3:43:0226 days ago1710992582
Synapse: Router
Synapse: Router
120 FTM
773244332024-03-14 13:17:1332 days ago1710422233
Synapse: Router
386 FTM
773244332024-03-14 13:17:1332 days ago1710422233
Synapse: Router
Synapse: Router
386 FTM
769284002024-03-07 13:55:0039 days ago1709819700
Synapse: Router
352 FTM
769284002024-03-07 13:55:0039 days ago1709819700
Synapse: Router
Synapse: Router
352 FTM
768681272024-03-06 18:04:4940 days ago1709748289
Synapse: Router
7 FTM
768681272024-03-06 18:04:4940 days ago1709748289
Synapse: Router
Synapse: Router
7 FTM
768395772024-03-06 7:21:5841 days ago1709709718
Synapse: Router
5.2 FTM
768395772024-03-06 7:21:5841 days ago1709709718
Synapse: Router
Synapse: Router
5.2 FTM
767877352024-03-05 14:28:5941 days ago1709648939
Synapse: Router
3 FTM
767877352024-03-05 14:28:5941 days ago1709648939
Synapse: Router
Synapse: Router
3 FTM
767835392024-03-05 11:42:4341 days ago1709638963
Synapse: Router
52.6141086 FTM
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SynapseRouter

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 20 : SynapseRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "../interfaces/ISynapseBridge.sol";
import "./LocalBridgeConfig.sol";
import "./SynapseAdapter.sol";
import "../utils/MulticallView.sol";

/**
 * @notice SynapseRouter contract that can be used together with SynapseBridge on any chain.
 * On every supported chain:
 * - SynapseRouter and SwapQuoter contracts need to be deployed.
 * - Chain pools that are present in the global BridgeConfig should be added to SwapQuoter.
 * - All supported bridge tokens should be added to SynapseRouter contract.
 * - router.setSwapQuoter(swapQuoter) should be executed to link these contracts.
 *
 * @dev Bridging workflow with SynapseRouter contract.
 * Initial assumptions:
 * - `routerOrigin` and `routerDest` are SynapseRouter deployments on origin and destination chain respectively.
 * - User wants to send `tokenIn` on origin chain, and receive `tokenOut` on destination chain.
 * - The amount of `tokenIn` tokens user wishes to send is `amountIn`.
 * - User wants to receives tokens to `userDest` address on destination chain.
 * - User has no idea what bridge tokens are supported on origin and destination chains.
 *
 * Under the hood, the cross-chain swap from `tokenIn` to `tokenOut` is:
 * 1. [*] `tokenIn` gets swapped to `bridgeToken` on origin chain. `bridgeToken` is a token supported by Synapse:Bridge.
 * 2. `bridgeToken` gets bridged from origin to destination chain
 * 3. [**] `bridgeToken` gets swapped to `tokenOut` on destination chain.
 * 4. `tokenOut` is transferred to the user on destination chain.
 * [*] : "origin swap" is skipped, if `tokenIn == bridgeToken` on origin chain.
 * [**]: "destination swap" is skipped, if `tokenOut == bridgeToken` on destination chain.
 *
 * Following set of actions is required (be aware, provided code is a pseudo code):
 * 1. Determine the set of bridge tokens that could fulfill "receive tokenOut on destination chain":
 *      // This will return a list of (string symbol, address token) tuples.
 *      bridgeTokens = routerDest.getConnectedBridgeTokens(tokenOut);
 * 2. Get the list of symbols for these tokens
 *      symbols = bridgeTokens.map(token => token.symbol);
 * 3. Get the list of structs with instructions for possible "origin swap":
 *      // This will return queries for all possible (tokenIn -> symbols[i]) swaps
 *      originQueries = routerOrigin.getOriginAmountOut(tokenIn, symbols, amountIn);
 * 4. Form the list of requests for the "destination swap" quotes:
 *      // Use symbols[i] and originQueries[i].minAmountOut to form a "request":
 *      requests = zipWith(symbols, originQueries, (symbol, query) => { return [symbol, query.minAmountOut] });
 * 5. Get the list of structs with instructions for possible "destination swap":
 *      // This will return quotes for all (symbols[i] => tokenOut) swaps
 *      // This will also take into account the bridge fee for getting a token to destination chain
 *      destQueries = routerDest.getDestinationAmountOut(requests, tokenOut);
 * 6. Pick any pair of (originQuery, destQuery):
 *      // For instance pick the one with the best destQuery.minAmountOut
 *      maxIndex = destQueries.indexOf(destQueries.maxBy, (query) => { return query.minAmountOut });
 *      originQuery = originQueries[maxIndex];
 *      // destQuery.minAmountOut is the full quote for tokenIn => tokenOut cross-chain swap
 *      destQuery = destQueries[maxIndex];
 * 7. Apply slippage, and set deadlines as per user settings:
 *      originQuery = applyUserSettings(originQuery);
 *      destQuery = applyUserSettings(destQuery);
 * 8. Call SynapseRouter using the obtained structs:
 *      // Check if user wants to send native ETH
 *      amountETH = (tokenIn == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) ? amountIn : 0;
 *      routerOrigin.bridge{value: amountETH}(userDest, chainIdDest, tokenIn, amountIn, originQuery, destQuery);
 */
contract SynapseRouter is LocalBridgeConfig, SynapseAdapter, MulticallView {
    // SynapseRouter is also the Adapter for the Synapse pools (this reduces the amount of token transfers).
    // SynapseRouter address will be used as swapAdapter in SwapQueries returned by a local SwapQuoter.

    using SafeERC20 for IERC20;

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                        CONSTANTS & IMMUTABLES                        β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /// @notice Synapse:Bridge address
    ISynapseBridge public immutable synapseBridge;

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                      CONSTRUCTOR & INITIALIZER                       β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /**
     * @notice Deploys a Synapse Router implementation, saves local Synapse:Bridge address and transfers ownership.
     */
    constructor(address _synapseBridge, address owner_) public {
        synapseBridge = ISynapseBridge(_synapseBridge);
        transferOwnership(owner_);
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                              OWNER ONLY                              β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /**
     * @notice Sets a custom allowance for the given token.
     * @dev To be used for the wrapper token setups.
     */
    function setAllowance(
        IERC20 token,
        address spender,
        uint256 amount
    ) external onlyOwner {
        token.safeApprove(spender, amount);
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                            BRIDGE & SWAP                             β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /**
     * @notice Initiate a bridge transaction with an optional swap on both origin and destination chains.
     * @dev Note that method is payable.
     * If token is ETH_ADDRESS, this method should be invoked with `msg.value = amountIn`.
     * If token is ERC20, the tokens will be pulled from msg.sender (use `msg.value = 0`).
     * Make sure to approve this contract for spending `token` beforehand.
     * originQuery.tokenOut should never be ETH_ADDRESS, bridge only works with ERC20 tokens.
     *
     * `token` is always a token user is sending. In case token requires a wrapper token to be bridge,
     * use underlying address for `token` instead of the wrapper one.
     *
     * `originQuery` contains instructions for the swap on origin chain. As above, originQuery.tokenOut
     * should always use the underlying address. In other words, the concept of wrapper token is fully
     * abstracted away from the end user.
     *
     * `originQuery` is supposed to be fetched using SynapseRouter.getOriginAmountOut().
     * Alternatively one could use an external adapter for more complex swaps on the origin chain.
     *
     * `destQuery` is supposed to be fetched using SynapseRouter.getDestinationAmountOut().
     * Complex swaps on destination chain are not supported for the time being.
     * Check contract description above for more details.
     *
     * @param to            Address to receive tokens on destination chain
     * @param chainId       Destination chain id
     * @param token         Initial token for the bridge transaction to be pulled from the user
     * @param amount        Amount of the initial tokens for the bridge transaction
     * @param originQuery   Origin swap query. Empty struct indicates no swap is required
     * @param destQuery     Destination swap query. Empty struct indicates no swap is required
     */
    function bridge(
        address to,
        uint256 chainId,
        address token,
        uint256 amount,
        SwapQuery memory originQuery,
        SwapQuery memory destQuery
    ) external payable {
        if (_hasAdapter(originQuery)) {
            // Perform a swap using the swap adapter, transfer the swapped tokens to this contract
            (token, amount) = _adapterSwap(address(this), token, amount, originQuery);
        } else {
            // Pull initial token from the user to this contract
            _pullToken(address(this), token, amount);
        }
        // Either way, this contract has `amount` worth of `token`
        TokenConfig memory _config = config[token];
        require(_config.bridgeToken != address(0), "Token not supported");
        token = _config.bridgeToken;
        // Decode params for swapping via a Synapse pool on the destination chain, if they were requested.
        SynapseParams memory destParams;
        if (_hasAdapter(destQuery)) destParams = abi.decode(destQuery.rawParams, (SynapseParams));
        // Check if Swap/RemoveLiquidity Action on destination chain is required.
        // Swap adapter needs to be specified.
        // HandleETH action is done automatically by SynapseBridge.
        if (_hasAdapter(destQuery) && destParams.action != Action.HandleEth) {
            if (_config.tokenType == TokenType.Deposit) {
                require(destParams.action == Action.Swap, "Unsupported dest action");
                // Case 1: token needs to be deposited on origin chain.
                // We need to perform AndSwap() on destination chain.
                synapseBridge.depositAndSwap({
                    to: to,
                    chainId: chainId,
                    token: IERC20(token),
                    amount: amount,
                    tokenIndexFrom: destParams.tokenIndexFrom,
                    tokenIndexTo: destParams.tokenIndexTo,
                    minDy: destQuery.minAmountOut,
                    deadline: destQuery.deadline
                });
            } else if (destParams.action == Action.Swap) {
                // Case 2: token needs to be redeemed on origin chain.
                // We need to perform AndSwap() on destination chain.
                synapseBridge.redeemAndSwap({
                    to: to,
                    chainId: chainId,
                    token: IERC20(token),
                    amount: amount,
                    tokenIndexFrom: destParams.tokenIndexFrom,
                    tokenIndexTo: destParams.tokenIndexTo,
                    minDy: destQuery.minAmountOut,
                    deadline: destQuery.deadline
                });
            } else {
                require(destParams.action == Action.RemoveLiquidity, "Unsupported dest action");
                // Case 3: token needs to be redeemed on origin chain.
                // We need to perform AndRemove() on destination chain.
                synapseBridge.redeemAndRemove({
                    to: to,
                    chainId: chainId,
                    token: IERC20(token),
                    amount: amount,
                    liqTokenIndex: destParams.tokenIndexTo,
                    liqMinAmount: destQuery.minAmountOut,
                    liqDeadline: destQuery.deadline
                });
            }
        } else {
            if (_config.tokenType == TokenType.Deposit) {
                // Case 1 (Deposit): token needs to be deposited on origin chain
                synapseBridge.deposit(to, chainId, IERC20(token), amount);
            } else {
                // Case 2 (Redeem): token needs to be redeemed on origin chain
                synapseBridge.redeem(to, chainId, IERC20(token), amount);
            }
        }
    }

    /**
     * @notice Perform a swap using the supplied parameters.
     * @dev Note that method is payable.
     * If token is ETH_ADDRESS, this method should be invoked with `msg.value = amountIn`.
     * If token is ERC20, the tokens will be pulled from msg.sender (use `msg.value = 0`).
     * Make sure to approve this contract for spending `token` beforehand.
     * If query.tokenOut is ETH_ADDRESS, native ETH will be sent to the recipient (be aware of potential reentrancy).
     * If query.tokenOut is ERC20, the tokens will be transferred to the recipient.
     * @param to            Address to receive swapped tokens
     * @param token         Token to swap
     * @param amount        Amount of tokens to swap
     * @param query         Query with the swap parameters (see BridgeStructs.sol)
     * @return amountOut    Amount of swapped tokens received by the user
     */
    function swap(
        address to,
        address token,
        uint256 amount,
        SwapQuery memory query
    ) external payable returns (uint256 amountOut) {
        require(to != address(0), "!recipient: zero address");
        require(to != address(this), "!recipient: router address");
        require(_hasAdapter(query), "!swapAdapter");
        // Perform a swap through the Adapter. Adapter will be the one handling ETH/WETH interactions.
        (, amountOut) = _adapterSwap(to, token, amount, query);
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                         VIEWS: BRIDGE QUOTES                         β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /**
     * @notice Finds the best path between `tokenIn` and every supported bridge token from the given list,
     * treating the swap as "origin swap", without putting any restrictions on the swap.
     * @dev Will NOT revert if any of the tokens are not supported, instead will return an empty query for that symbol.
     * Check (query.minAmountOut != 0): this is true only if the swap is possible and bridge token is supported.
     * The returned queries with minAmountOut != 0 could be used as `originQuery` with SynapseRouter.
     * Note: it is possible to form a SwapQuery off-chain using alternative SwapAdapter for the origin swap.
     * @param tokenIn       Initial token that user wants to bridge/swap
     * @param tokenSymbols  List of symbols representing bridge tokens
     * @param amountIn      Amount of tokens user wants to bridge/swap
     * @return originQueries    List of structs that could be used as `originQuery` in SynapseRouter.
     *                          minAmountOut and deadline fields will need to be adjusted based on the user settings.
     */
    function getOriginAmountOut(
        address tokenIn,
        string[] memory tokenSymbols,
        uint256 amountIn
    ) external view returns (SwapQuery[] memory originQueries) {
        uint256 length = tokenSymbols.length;
        originQueries = new SwapQuery[](length);
        for (uint256 i = 0; i < length; ++i) {
            // Check if token with given symbol is supported on this chain
            address bridgeToken = symbolToToken[tokenSymbols[i]];
            // Skip not supported tokens
            if (bridgeToken == address(0)) continue;
            // Every possible action is supported for origin swap
            LimitedToken memory _tokenIn = LimitedToken(ActionLib.allActions(), tokenIn);
            originQueries[i] = swapQuoter.getAmountOut(_tokenIn, bridgeToken, amountIn);
        }
    }

    /**
     * @notice Finds the best path between every supported bridge token from the given list and `tokenOut`,
     * treating the swap as "destination swap", limiting possible actions to those available for every bridge token.
     * @dev Will NOT revert if any of the tokens are not supported, instead will return an empty query for that symbol.
     * Note: it is NOT possible to form a SwapQuery off-chain using alternative SwapAdapter for the destination swap.
     * For the time being, only swaps through the Synapse-supported pools are available on destination chain.
     * @param requests  List of structs with following information:
     *                  - symbol: unique token ID consistent among all chains
     *                  - amountIn: amount of bridge token to start with, before the bridge fee is applied
     * @param tokenOut  Token user wants to receive on destination chain
     * @return destQueries  List of structs that could be used as `destQuery` in SynapseRouter.
     *                      minAmountOut and deadline fields will need to be adjusted based on the user settings.
     */
    function getDestinationAmountOut(DestRequest[] memory requests, address tokenOut)
        external
        view
        returns (SwapQuery[] memory destQueries)
    {
        uint256 length = requests.length;
        destQueries = new SwapQuery[](length);
        for (uint256 i = 0; i < length; ++i) {
            address token = symbolToToken[requests[i].symbol];
            // Skip if token is not supported
            if (token == address(0)) continue;
            // token is confirmed to be a supported bridge token at this point
            uint256 amountIn = _calculateBridgeAmountOut(token, requests[i].amountIn);
            // Skip if fee is greater than amountIn
            if (amountIn == 0) continue;
            TokenType bridgeTokenType = config[token].tokenType;
            // See what kind of "Actions" are available for the given bridge token:
            LimitedToken memory tokenIn = LimitedToken(_bridgeTokenActions(bridgeTokenType), token);
            destQueries[i] = swapQuoter.getAmountOut(tokenIn, tokenOut, amountIn);
        }
    }

    /**
     * @notice Gets the list of all bridge tokens (and their symbols), such that destination swap
     * from a bridge token to `tokenOut` is possible.
     * @param tokenOut  Token address to swap to on destination chain
     * @return tokens   List of structs with following information:
     *                  - symbol: unique token ID consistent among all chains
     *                  - token: bridge token address
     */
    function getConnectedBridgeTokens(address tokenOut) external view returns (BridgeToken[] memory tokens) {
        uint256 amount = bridgeTokensAmount();
        // Try connecting every supported bridge token to tokenOut
        LimitedToken[] memory allTokens = new LimitedToken[](amount);
        for (uint256 i = 0; i < amount; ++i) {
            address token = _bridgeTokens.at(i);
            // Make sure only "supported actions" for destination swap are included
            allTokens[i].actionMask = _bridgeTokenActions(config[token].tokenType);
            allTokens[i].token = token;
        }
        (uint256 amountFound, bool[] memory isConnected) = swapQuoter.findConnectedTokens(allTokens, tokenOut);
        tokens = new BridgeToken[](amountFound);
        // This will now track amount of found connected tokens so far during the next for loop
        amountFound = 0;
        for (uint256 i = 0; i < amount; ++i) {
            if (isConnected[i]) {
                // Record the connected token
                address token = allTokens[i].token;
                tokens[amountFound].symbol = tokenToSymbol[token];
                tokens[amountFound].token = token;
                // Increase the counter
                ++amountFound;
            }
        }
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                            INTERNAL: SWAP                            β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /**
     * @notice Performs a swap from `token` using the provided query,
     * which includes the swap adapter, tokenOut and the swap execution parameters.
     * Swapped token is transferred to the specified recipient.
     */
    function _adapterSwap(
        address recipient,
        address token,
        uint256 amount,
        SwapQuery memory query
    ) internal returns (address tokenOut, uint256 amountOut) {
        // First, check the deadline for the swap
        // solhint-disable-next-line not-rely-on-time
        require(block.timestamp <= query.deadline, "Deadline not met");
        // Pull initial token from the user to specified swap adapter
        _pullToken(query.swapAdapter, token, amount);
        tokenOut = query.tokenOut;
        // If swapAdapter is this contract (which is the case for the supported Synapse pools),
        // this will be an external call to address(this), which we are fine with.
        // The external call is used because additional Adapters will be established in the future.
        // We are forwarding `msg.value` and are expecting the Adapter to handle ETH/WETH interactions.
        amountOut = ISwapAdapter(query.swapAdapter).adapterSwap{value: msg.value}({
            to: recipient,
            tokenIn: token,
            amountIn: amount,
            tokenOut: tokenOut,
            rawParams: query.rawParams
        });
        // We can trust the supported adapters to return the exact swapped amount
        // Finally, check that the recipient received at least as much as they wanted
        require(amountOut >= query.minAmountOut, "Swap didn't result in min tokens");
    }

    /**
     * Pulls a requested token from the user to the requested recipient.
     * Or, if msg.value was provided, check that ETH_ADDRESS was used and msg.value is correct.
     */
    function _pullToken(
        address recipient,
        address token,
        uint256 amount
    ) internal {
        if (msg.value == 0) {
            // Token needs to be pulled only if msg.value is zero
            // This way user can specify WETH as the origin asset
            IERC20(token).safeTransferFrom(msg.sender, recipient, amount);
        } else {
            // Otherwise, we need to check that ETH was specified
            require(token == UniversalToken.ETH_ADDRESS, "!eth");
            // And that amount matches msg.value
            require(msg.value == amount, "!msg.value");
            // We will forward msg.value in the external call to the recipient
        }
    }

    /**
     * @notice Checks whether the swap adapter was specified in the query.
     * Query without a swap adapter specifies that no action needs to be taken.
     */
    function _hasAdapter(SwapQuery memory query) internal pure returns (bool) {
        return query.swapAdapter != address(0);
    }

    function _bridgeTokenActions(TokenType tokenType) internal pure returns (uint256 actionMask) {
        if (tokenType == TokenType.Redeem) {
            // For tokens that are minted on destination chain
            // possible bridge functions are mint() and mintAndSwap(). Thus:
            // Swap: available via mintAndSwap()
            // (Add/Remove)Liquidity is unavailable
            // HandleETH is unavailable, as WETH could only be withdrawn by SynapseBridge
            actionMask = ActionLib.mask(Action.Swap);
        } else {
            // For tokens that are withdrawn on destination chain
            // possible bridge functions are withdraw() and withdrawAndRemove().
            // Swap/AddLiquidity: not available
            // RemoveLiquidity: available via withdrawAndRemove()
            // HandleETH: available via withdraw(). SwapQuoter will check if the bridge token is WETH or not.
            actionMask = ActionLib.mask(Action.RemoveLiquidity, Action.HandleEth);
        }
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                 INTERNAL: ADD & REMOVE BRIDGE TOKENS                 β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /// @dev Adds a bridge token config and its fee structure, if it's not present.
    /// If a token was added, approves it for spending by SynapseBridge.
    function _addToken(
        string memory symbol,
        address token,
        TokenType tokenType,
        address bridgeToken,
        uint256 bridgeFee,
        uint256 minFee,
        uint256 maxFee
    ) internal override returns (bool wasAdded) {
        // Add token and its fee structure
        wasAdded = LocalBridgeConfig._addToken(symbol, token, tokenType, bridgeToken, bridgeFee, minFee, maxFee);
        if (wasAdded) {
            // Approve token only if it wasn't previously added
            // Underlying token should always implement allowance(), approve()
            if (token == bridgeToken) token.universalApproveInfinity(address(synapseBridge));
            // Use {setAllowance} for custom wrapper token setups
        }
    }
}

File 1 of 20 : ISwap.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

interface ISwap {
    // pool data view functions
    function getA() external view returns (uint256);

    function getAPrecise() external view returns (uint256);

    function getToken(uint8 index) external view returns (IERC20);

    function getTokenIndex(address tokenAddress) external view returns (uint8);

    function getTokenBalance(uint8 index) external view returns (uint256);

    function getVirtualPrice() external view returns (uint256);

    function swapStorage()
        external
        view
        returns (
            uint256 initialA,
            uint256 futureA,
            uint256 initialATime,
            uint256 futureATime,
            uint256 swapFee,
            uint256 adminFee,
            address lpToken
        );

    // min return calculation functions
    function calculateSwap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx
    ) external view returns (uint256);

    function calculateTokenAmount(uint256[] calldata amounts, bool deposit) external view returns (uint256);

    function calculateRemoveLiquidity(uint256 amount) external view returns (uint256[] memory);

    function calculateRemoveLiquidityOneToken(uint256 tokenAmount, uint8 tokenIndex)
        external
        view
        returns (uint256 availableTokenAmount);

    // state modifying functions
    function initialize(
        IERC20[] memory pooledTokens,
        uint8[] memory decimals,
        string memory lpTokenName,
        string memory lpTokenSymbol,
        uint256 a,
        uint256 fee,
        uint256 adminFee,
        address lpTokenTargetAddress
    ) external;

    function swap(
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx,
        uint256 minDy,
        uint256 deadline
    ) external returns (uint256);

    function addLiquidity(
        uint256[] calldata amounts,
        uint256 minToMint,
        uint256 deadline
    ) external returns (uint256);

    function removeLiquidity(
        uint256 amount,
        uint256[] calldata minAmounts,
        uint256 deadline
    ) external returns (uint256[] memory);

    function removeLiquidityOneToken(
        uint256 tokenAmount,
        uint8 tokenIndex,
        uint256 minAmount,
        uint256 deadline
    ) external returns (uint256);

    function removeLiquidityImbalance(
        uint256[] calldata amounts,
        uint256 maxBurnAmount,
        uint256 deadline
    ) external returns (uint256);
}

File 1 of 20 : ISwapAdapter.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "../libraries/BridgeStructs.sol";

interface ISwapAdapter {
    /**
     * @notice Performs a tokenIn -> tokenOut swap, according to the provided params.
     * If tokenIn is ETH_ADDRESS, this method should be invoked with `msg.value = amountIn`.
     * If tokenIn is ERC20, the tokens should be already transferred to this contract (using `msg.value = 0`).
     * If tokenOut is ETH_ADDRESS, native ETH will be sent to the recipient (be aware of potential reentrancy).
     * If tokenOut is ERC20, the tokens will be transferred to the recipient.
     * @dev Contracts implementing {ISwapAdapter} interface are required to enforce the above restrictions.
     * On top of that, they must ensure that exactly `amountOut` worth of `tokenOut` is transferred to the recipient.
     * Swap deadline and slippage is checked outside of this contract.
     * @param to            Address to receive the swapped token
     * @param tokenIn       Token to sell (use ETH_ADDRESS to start from native ETH)
     * @param amountIn      Amount of tokens to sell
     * @param tokenOut      Token to buy (use ETH_ADDRESS to end with native ETH)
     * @param rawParams     Additional swap parameters
     * @return amountOut    Amount of bought tokens
     */
    function adapterSwap(
        address to,
        address tokenIn,
        uint256 amountIn,
        address tokenOut,
        bytes calldata rawParams
    ) external payable returns (uint256);
}

File 1 of 20 : ISwapQuoter.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "../libraries/BridgeStructs.sol";

interface ISwapQuoter {
    function findConnectedTokens(LimitedToken[] memory tokensIn, address tokenOut)
        external
        view
        returns (uint256 amountFound, bool[] memory isConnected);

    function getAmountOut(
        LimitedToken memory tokenIn,
        address tokenOut,
        uint256 amountIn
    ) external view returns (SwapQuery memory query);

    function allPools() external view returns (Pool[] memory pools);

    function poolsAmount() external view returns (uint256 tokens);

    function poolInfo(address pool) external view returns (uint256 tokens, address lpToken);

    function poolTokens(address pool) external view returns (PoolToken[] memory tokens);

    function calculateAddLiquidity(address pool, uint256[] memory amounts) external view returns (uint256 amountOut);

    function calculateSwap(
        address pool,
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx
    ) external view returns (uint256 amountOut);

    function calculateRemoveLiquidity(address pool, uint256 amount) external view returns (uint256[] memory amountsOut);

    function calculateWithdrawOneToken(
        address pool,
        uint256 tokenAmount,
        uint8 tokenIndex
    ) external view returns (uint256 amountOut);
}

File 1 of 20 : ISynapseBridge.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";

interface ISynapseBridge {
    using SafeERC20 for IERC20;

    function deposit(
        address to,
        uint256 chainId,
        IERC20 token,
        uint256 amount
    ) external;

    function depositAndSwap(
        address to,
        uint256 chainId,
        IERC20 token,
        uint256 amount,
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 minDy,
        uint256 deadline
    ) external;

    function redeem(
        address to,
        uint256 chainId,
        IERC20 token,
        uint256 amount
    ) external;

    function redeemv2(
        bytes32 to,
        uint256 chainId,
        IERC20 token,
        uint256 amount
    ) external;

    function redeemAndSwap(
        address to,
        uint256 chainId,
        IERC20 token,
        uint256 amount,
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 minDy,
        uint256 deadline
    ) external;

    function redeemAndRemove(
        address to,
        uint256 chainId,
        IERC20 token,
        uint256 amount,
        uint8 liqTokenIndex,
        uint256 liqMinAmount,
        uint256 liqDeadline
    ) external;
}

File 1 of 20 : IWETH9.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.4.0;

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

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

    function decimals() external view returns (uint8);

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

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

    receive() external payable;

    function deposit() external payable;

    function withdraw(uint256 wad) external;

    function totalSupply() external view returns (uint256);

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

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

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

File 1 of 20 : BridgeStructs.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

/// @notice Struct representing a request for SynapseRouter.
/// @dev tokenIn is supplied separately.
/// @param swapAdapter      Adapter address that will perform the swap. Address(0) specifies a "no swap" query.
/// @param tokenOut         Token address to swap to.
/// @param minAmountOut     Minimum amount of tokens to receive after the swap, or tx will be reverted.
/// @param deadline         Latest timestamp for when the transaction needs to be executed, or tx will be reverted.
/// @param rawParams        ABI-encoded params for the swap that will be passed to `swapAdapter`.
///                         Should be SynapseParams for swaps via SynapseAdapter.
struct SwapQuery {
    address swapAdapter;
    address tokenOut;
    uint256 minAmountOut;
    uint256 deadline;
    bytes rawParams;
}

/// @notice Struct representing parameters for swapping via SynapseAdapter.
/// @param action           Action that SynapseAdapter needs to perform.
/// @param pool             Liquidity pool that will be used for Swap/AddLiquidity/RemoveLiquidity actions.
/// @param tokenIndexFrom   Token index to swap from. Used for swap/addLiquidity actions.
/// @param tokenIndexTo     Token index to swap to. Used for swap/removeLiquidity actions.
struct SynapseParams {
    Action action;
    address pool;
    uint8 tokenIndexFrom;
    uint8 tokenIndexTo;
}

/// @notice All possible actions that SynapseAdapter could perform.
enum Action {
    Swap, // swap between two pools tokens
    AddLiquidity, // add liquidity in a form of a single pool token
    RemoveLiquidity, // remove liquidity in a form of a single pool token
    HandleEth // ETH <> WETH interaction
}

/// @notice Struct representing a token, and the available Actions for performing a swap.
/// @param actionMask   Bitmask representing what actions (see ActionLib) are available for swapping a token
/// @param token        Token address
struct LimitedToken {
    uint256 actionMask;
    address token;
}

/// @notice Struct representing a bridge token. Used as the return value in view functions.
/// @param symbol   Bridge token symbol: unique token ID consistent among all chains
/// @param token    Bridge token address
struct BridgeToken {
    string symbol;
    address token;
}

/// @notice Struct representing how pool tokens are stored by `SwapQuoter`.
/// @param isWeth   Whether the token represents Wrapped ETH.
/// @param token    Token address.
struct PoolToken {
    bool isWeth;
    address token;
}

/// @notice Struct representing a request for a swap quote from a bridge token.
/// @dev tokenOut is passed externally
/// @param symbol   Bridge token symbol: unique token ID consistent among all chains
/// @param amountIn Amount of bridge token to start with, before the bridge fee is applied
struct DestRequest {
    string symbol;
    uint256 amountIn;
}

/// @notice Struct representing a liquidity pool. Used as the return value in view functions.
/// @param pool         Pool address.
/// @param lpToken      Address of pool's LP token.
/// @param tokens       List of pool's tokens.
struct Pool {
    address pool;
    address lpToken;
    PoolToken[] tokens;
}

/// @notice Library for dealing with bit masks, describing what Actions are available.
library ActionLib {
    /// @notice Returns a bitmask with all possible actions set to True.
    function allActions() internal pure returns (uint256 actionMask) {
        actionMask = type(uint256).max;
    }

    /// @notice Returns whether the given action is set to True in the bitmask.
    function includes(uint256 actionMask, Action action) internal pure returns (bool) {
        return actionMask & mask(action) != 0;
    }

    /// @notice Returns a bitmask with only the given action set to True.
    function mask(Action action) internal pure returns (uint256) {
        return 1 << uint256(action);
    }

    /// @notice Returns a bitmask with only two given actions set to True.
    function mask(Action a, Action b) internal pure returns (uint256) {
        return mask(a) | mask(b);
    }
}

File 1 of 20 : UniversalToken.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import "./BridgeStructs.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";

/**
 * Library to unify handling of ETH/WETH and ERC20 tokens.
 */
library UniversalToken {
    using SafeERC20 for IERC20;

    address internal constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
    uint256 private constant MAX_UINT = type(uint256).max;

    /// @notice Returns token balance for the given account.
    function universalBalanceOf(address token, address account) internal view returns (uint256) {
        if (token == ETH_ADDRESS) {
            return account.balance;
        } else {
            return IERC20(token).balanceOf(account);
        }
    }

    /// @notice Compares two tokens. ETH_ADDRESS and WETH are deemed equal.
    function universalEquals(address token, PoolToken memory poolToken) internal pure returns (bool) {
        if (token == ETH_ADDRESS) {
            return poolToken.isWeth;
        } else {
            return token == poolToken.token;
        }
    }

    function universalApproveInfinity(address token, address spender) internal {
        // ETH Chad doesn't require your approval
        if (token == ETH_ADDRESS) return;
        // No need to approve own tokens
        if (spender == address(this)) return;
        uint256 allowance = IERC20(token).allowance(address(this), spender);
        // Set allowance to MAX_UINT if needed
        if (allowance != MAX_UINT) {
            // if allowance is neither zero nor infinity, reset if first
            if (allowance != 0) {
                IERC20(token).safeApprove(spender, 0);
            }
            IERC20(token).safeApprove(spender, MAX_UINT);
        }
    }

    /// @notice Transfers tokens to the given account. Reverts if transfer is not successful.
    /// @dev This might trigger fallback, if ETH is transferred to the contract.
    /// Make sure this can not lead to reentrancy attacks.
    function universalTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        // Don't do anything, if need to send tokens to this address
        if (to == address(this)) return;
        if (token == ETH_ADDRESS) {
            /// @dev Note: this can potentially lead to executing code in `to`.
            // solhint-disable-next-line avoid-low-level-calls
            (bool success, ) = to.call{value: value}("");
            require(success, "ETH transfer failed");
        } else {
            IERC20(token).safeTransfer(to, value);
        }
    }
}

File 1 of 20 : LocalBridgeConfig.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/EnumerableSet.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";

abstract contract LocalBridgeConfig is Ownable {
    using EnumerableSet for EnumerableSet.AddressSet;
    using SafeMath for uint256;

    /**
     * @notice Indicates the type of the supported bridge token on the local chain.
     * - TokenType.Redeem: token is burnt in order to initiate a bridge tx (bridge.redeem)
     * - TokenType.Deposit: token is locked in order to initiate a bridge tx (bridge.deposit)
     */
    enum TokenType {
        Redeem,
        Deposit
    }

    /**
     * @notice Config for a supported bridge token.
     * @dev Some of the tokens require a wrapper token to make them conform SynapseERC20 interface.
     * In these cases, `bridgeToken` will feature a different address.
     * Otherwise, the token address is saved.
     * @param tokenType     Method of bridging for the token: Redeem or Deposit
     * @param bridgeToken   Bridge token address
     */
    struct TokenConfig {
        TokenType tokenType;
        address bridgeToken;
    }

    /**
     * @notice Fee structure for a supported bridge token, optimized to fit in a single storage word.
     * @param bridgeFee     Fee % for bridging a token to this chain, multiplied by `FEE_DENOMINATOR`
     * @param minFee        Minimum fee for bridging a token to this chain, in token decimals
     * @param maxFee        Maximum fee for bridging a token to this chain, in token decimals
     */
    struct FeeStructure {
        uint40 bridgeFee;
        uint104 minFee;
        uint112 maxFee;
    }

    /**
     * @notice Struct defining a supported bridge token. This is not supposed to be stored on-chain,
     * so this is not optimized in terms of storage words.
     * @param id            ID for token used in BridgeConfigV3
     * @param token         "End" token, supported by SynapseBridge. This is the token user is receiving/sending.
     * @param decimals      Amount ot decimals used for `token`
     * @param tokenType     Method of bridging used for the token: Redeem or Deposit.
     * @param bridgeToken   Actual token used for bridging `token`. This is the token bridge is burning/locking.
     *                      Might differ from `token`, if `token` does not conform to bridge-supported interface.
     * @param bridgeFee     Fee % for bridging a token to this chain, multiplied by `FEE_DENOMINATOR`
     * @param minFee        Minimum fee for bridging a token to this chain, in token decimals
     * @param maxFee        Maximum fee for bridging a token to this chain, in token decimals
     */
    struct BridgeTokenConfig {
        string id;
        address token;
        uint256 decimals;
        LocalBridgeConfig.TokenType tokenType;
        address bridgeToken;
        uint256 bridgeFee;
        uint256 minFee;
        uint256 maxFee;
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                              CONSTANTS                               β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /// @dev Denominator used to calculate the bridge fee: amount.mul(bridgeFee).div(FEE_DENOMINATOR)
    uint256 private constant FEE_DENOMINATOR = 10**10;

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                               STORAGE                                β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /// @notice Config for each supported token.
    /// @dev If wrapper token is required for bridging, its address is stored in `.bridgeToken`
    /// i.e. for GMX: config[GMX].bridgeToken = GMXWrapper
    mapping(address => TokenConfig) public config;
    /// @notice Fee structure for each supported token.
    /// @dev If wrapper token is required for bridging, its underlying is used as key here
    mapping(address => FeeStructure) public fee;
    /// @notice Maps bridge token address into bridge token symbol
    mapping(address => string) public tokenToSymbol;
    /// @notice Maps bridge token symbol into bridge token address
    mapping(string => address) public symbolToToken;
    /// @dev A list of all supported bridge tokens
    EnumerableSet.AddressSet internal _bridgeTokens;

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                              ONLY OWNER                              β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /**
     * @notice Adds a bridge token and its fee structure to the local config, if it was not added before.
     * @param token         "End" token, supported by SynapseBridge. This is the token user is receiving/sending.
     * @param tokenType     Method of bridging used for the token: Redeem or Deposit.
     * @param bridgeToken   Actual token used for bridging `token`. This is the token bridge is burning/locking.
     *                      Might differ from `token`, if `token` does not conform to bridge-supported interface.
     * @param bridgeFee     Fee % for bridging a token to this chain, multiplied by `FEE_DENOMINATOR`
     * @param minFee        Minimum fee for bridging a token to this chain, in token decimals
     * @param maxFee        Maximum fee for bridging a token to this chain, in token decimals
     * @return wasAdded     True, if token was added to the config
     */
    function addToken(
        string memory symbol,
        address token,
        TokenType tokenType,
        address bridgeToken,
        uint256 bridgeFee,
        uint256 minFee,
        uint256 maxFee
    ) external onlyOwner returns (bool wasAdded) {
        wasAdded = _addToken(symbol, token, tokenType, bridgeToken, bridgeFee, minFee, maxFee);
    }

    /// @notice Adds a bunch of bridge tokens and their fee structure to the local config, if it was not added before.
    function addTokens(BridgeTokenConfig[] memory tokens) external onlyOwner {
        uint256 amount = tokens.length;
        for (uint256 i = 0; i < amount; ++i) {
            BridgeTokenConfig memory token = tokens[i];
            _addToken(
                token.id,
                token.token,
                token.tokenType,
                token.bridgeToken,
                token.bridgeFee,
                token.minFee,
                token.maxFee
            );
        }
    }

    /**
     * @notice Updates the bridge config for an already added bridge token.
     * @dev Will revert if token was not added before.
     * @param token         "End" token, supported by SynapseBridge. This is the token user is receiving/sending.
     * @param tokenType     Method of bridging used for the token: Redeem or Deposit.
     * @param bridgeToken   Actual token used for bridging `token`. This is the token bridge is burning/locking.
     *                      Might differ from `token`, if `token` does not conform to bridge-supported interface.
     */
    function setTokenConfig(
        address token,
        TokenType tokenType,
        address bridgeToken
    ) external onlyOwner {
        require(config[token].bridgeToken != address(0), "Unknown token");
        _setTokenConfig(token, tokenType, bridgeToken);
    }

    /**
     * @notice Updates the fee structure for an already added bridge token.
     * @dev Will revert if token was not added before.
     * @param token         "End" token, supported by SynapseBridge. This is the token user is receiving/sending.
     * @param bridgeFee     Fee % for bridging a token to this chain, multiplied by `FEE_DENOMINATOR`
     * @param minFee        Minimum fee for bridging a token to this chain, in token decimals
     * @param maxFee        Maximum fee for bridging a token to this chain, in token decimals
     */
    function setTokenFee(
        address token,
        uint256 bridgeFee,
        uint256 minFee,
        uint256 maxFee
    ) external onlyOwner {
        require(config[token].bridgeToken != address(0), "Unknown token");
        _setTokenFee(token, bridgeFee, minFee, maxFee);
    }

    /**
     * @notice Removes tokens from the local config, and deletes the associated bridge fee structure.
     * @dev If a token requires a bridge wrapper token, use the underlying token address for removing.
     * @param token         "End" token, supported by SynapseBridge. This is the token user is receiving/sending.
     * @return wasRemoved   True, if token was removed from the config
     */
    function removeToken(address token) external onlyOwner returns (bool wasRemoved) {
        wasRemoved = _removeToken(token);
    }

    /**
     * @notice Removes a list of tokens from the local config, and deletes their associated bridge fee structure.
     * @dev If a token requires a bridge wrapper token, use the underlying token address for removing.
     * @param tokens    List of "end" tokens, supported by SynapseBridge. These are the tokens user is receiving/sending.
     */
    function removeTokens(address[] calldata tokens) external onlyOwner {
        uint256 amount = tokens.length;
        for (uint256 i = 0; i < amount; ++i) {
            _removeToken(tokens[i]);
        }
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                                VIEWS                                 β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /// @notice Returns a list of all supported bridge tokens.
    function bridgeTokens() external view returns (address[] memory tokens) {
        uint256 amount = bridgeTokensAmount();
        tokens = new address[](amount);
        for (uint256 i = 0; i < amount; ++i) {
            tokens[i] = _bridgeTokens.at(i);
        }
    }

    /// @notice Returns the amount of the supported bridge tokens.
    function bridgeTokensAmount() public view returns (uint256 amount) {
        amount = _bridgeTokens.length();
    }

    /**
     * @notice Calculates a fee for bridging a token to this chain.
     * @dev If a token requires a bridge wrapper token, use the underlying token address for getting a fee quote.
     * @param token     "End" token, supported by SynapseBridge. This is the token user is receiving/sending.
     * @param amount    Amount of tokens to bridge to this chain.
     */
    function calculateBridgeFee(address token, uint256 amount) external view returns (uint256 feeAmount) {
        feeAmount = _calculateBridgeFee(token, amount);
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                 INTERNAL: ADD & REMOVE BRIDGE TOKENS                 β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /// @dev Adds a bridge token config, if it's not present and updates its fee structure.
    /// Child contract could implement additional logic upon adding a token.
    function _addToken(
        string memory _symbol,
        address token,
        TokenType tokenType,
        address bridgeToken,
        uint256 bridgeFee,
        uint256 minFee,
        uint256 maxFee
    ) internal virtual returns (bool wasAdded) {
        wasAdded = _bridgeTokens.add(token);
        if (wasAdded) {
            // Need to save config only once. Need to use "end user" address for symbol mappings.
            _setTokenSymbol(_symbol, token);
            _setTokenConfig(token, tokenType, bridgeToken);
            _setTokenFee(token, bridgeFee, minFee, maxFee);
        }
    }

    /// @dev Sets the symbol for the bridge token
    function _setTokenSymbol(string memory symbol, address token) internal {
        // tokenToSymbol[token] is guaranteed to be empty, as token was just added
        require(bytes(symbol).length != 0, "Empty symbol");
        require(symbolToToken[symbol] == address(0), "Symbol already in use");
        symbolToToken[symbol] = token;
        tokenToSymbol[token] = symbol;
    }

    /// @dev Updates the token config for an already known bridge token.
    function _setTokenConfig(
        address token,
        TokenType tokenType,
        address bridgeToken
    ) internal {
        // Sanity checks for the provided token values
        require(token != address(0) && bridgeToken != address(0), "Token can't be zero address");
        config[token] = TokenConfig(tokenType, bridgeToken);
    }

    /// @dev Updates the fee structure for an already known bridge token.
    function _setTokenFee(
        address token,
        uint256 bridgeFee,
        uint256 minFee,
        uint256 maxFee
    ) internal {
        // Sanity checks for the provided fee values
        require(bridgeFee < FEE_DENOMINATOR, "bridgeFee >= 100%");
        require(minFee <= maxFee, "minFee > maxFee");
        fee[token] = FeeStructure(uint40(bridgeFee), uint104(minFee), uint112(maxFee));
    }

    /// @dev Removes a bridge token config along with its fee structure.
    /// Child contract could implement additional logic upon removing a token.
    function _removeToken(address token) internal virtual returns (bool wasRemoved) {
        wasRemoved = _bridgeTokens.remove(token);
        if (wasRemoved) {
            string memory symbol = tokenToSymbol[token];
            delete tokenToSymbol[token];
            delete symbolToToken[symbol];
            delete config[token];
            delete fee[token];
        }
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                           INTERNAL: VIEWS                            β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /// @dev Returns the amount of tokens received after applying the bridge fee.
    /// Will return 0, if bridged amount is lower than a minimum bridge fee.
    function _calculateBridgeAmountOut(address token, uint256 amount) internal view returns (uint256 amountOut) {
        uint256 feeAmount = _calculateBridgeFee(token, amount);
        if (feeAmount < amount) {
            // No need for SafeMath here
            amountOut = amount - feeAmount;
        }
        // Return 0, if fee amount >= amount
    }

    /// @dev Returns the fee for bridging a given token to this chain.
    function _calculateBridgeFee(address token, uint256 amount) internal view returns (uint256 feeAmount) {
        require(config[token].bridgeToken != address(0), "Token not supported");
        FeeStructure memory tokenFee = fee[token];
        feeAmount = amount.mul(tokenFee.bridgeFee).div(FEE_DENOMINATOR);
        if (feeAmount < tokenFee.minFee) {
            feeAmount = tokenFee.minFee;
        } else if (feeAmount > tokenFee.maxFee) {
            feeAmount = tokenFee.maxFee;
        }
    }
}

File 1 of 20 : SynapseAdapter.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "../interfaces/ISwap.sol";
import "../interfaces/ISwapAdapter.sol";
import "../interfaces/ISwapQuoter.sol";
import "../interfaces/IWETH9.sol";
import "../libraries/UniversalToken.sol";

import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

abstract contract SynapseAdapter is Ownable, ISwapAdapter {
    using SafeERC20 for IERC20;
    using UniversalToken for address;

    uint256 internal constant MAX_UINT = type(uint256).max;

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                               STORAGE                                β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /// @notice Address of the local SwapQuoter contract
    ISwapQuoter public swapQuoter;

    /// @notice Receive function to enable unwrapping ETH into this contract
    receive() external payable {} // solhint-disable-line no-empty-blocks

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                              OWNER ONLY                              β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /// @notice Sets the Swap Quoter address to get the swap quotes from.
    function setSwapQuoter(ISwapQuoter _swapQuoter) external onlyOwner {
        swapQuoter = _swapQuoter;
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                          EXTERNAL FUNCTIONS                          β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /**
     * @notice Performs a tokenIn -> tokenOut swap, according to the provided params.
     * If tokenIn is ETH_ADDRESS, this method should be invoked with `msg.value = amountIn`.
     * If tokenIn is ERC20, the tokens should be already transferred to this contract (using `msg.value = 0`).
     * If tokenOut is ETH_ADDRESS, native ETH will be sent to the recipient (be aware of potential reentrancy).
     * If tokenOut is ERC20, the tokens will be transferred to the recipient.
     * @dev Contracts implementing {ISwapAdapter} interface are required to enforce the above restrictions.
     * On top of that, they must ensure that exactly `amountOut` worth of `tokenOut` is transferred to the recipient.
     * Swap deadline and slippage is checked outside of this contract.
     * @dev Applied to SynapseAdapter only:
     * Use `params.pool = address(this)` for ETH handling without swaps:
     * 1. For wrapping ETH: tokenIn = ETH_ADDRESS, tokenOut = WETH, params.pool = address(this)
     * 2. For unwrapping WETH: tokenIn = WETH, tokenOut = ETH_ADDRESS, params.pool = address(this)
     * If `params.pool != address(this)`, and ETH_ADDRESS was supplied as tokenIn or tokenOut,
     * a corresponding pool token will be treated as WETH.
     * @param to            Address to receive the swapped token
     * @param tokenIn       Token to sell (use ETH_ADDRESS to start from native ETH)
     * @param amountIn      Amount of tokens to sell
     * @param tokenOut      Token to buy (use ETH_ADDRESS to end with native ETH)
     * @param rawParams     Additional swap parameters
     * @return amountOut    Amount of bought tokens
     */
    function adapterSwap(
        address to,
        address tokenIn,
        uint256 amountIn,
        address tokenOut,
        bytes calldata rawParams
    ) external payable override returns (uint256 amountOut) {
        // We define a few phases for the whole swap process.
        // (?) means the phase is optional.
        // (!) means the phase is mandatory.

        // ============================== PHASE 0(!): CHECK ALL THE PARAMS =========================
        require(tokenIn != tokenOut, "Swap tokens should differ");
        // Decode params for swapping via a Synapse pool
        SynapseParams memory params = abi.decode(rawParams, (SynapseParams));
        // Swap pool should exist, if action other than HandleEth was requested
        require(params.pool != address(0) || params.action == Action.HandleEth, "!pool");

        // ============================== PHASE 1(?): WRAP RECEIVED ETH ============================
        // tokenIn was already transferred to this contract, check if we start from native ETH
        if (tokenIn == UniversalToken.ETH_ADDRESS) {
            // Determine WETH address: this is either tokenOut (if no swap is needed),
            // or a pool token with index `tokenIndexFrom` (if swap is needed).
            tokenIn = _deriveWethAddress({token: tokenOut, params: params, isWethIn: true});
            // Wrap ETH into WETH and leave it in this contract
            _wrapETH(tokenIn, amountIn);
        } else {
            // For ERC20 tokens msg.value should be zero
            require(msg.value == 0, "Incorrect tokenIn for ETH swap");
        }
        // Either way, this contract has `amountIn` worth of `tokenIn`; tokenIn != ETH_ADDRESS

        // ============================== PHASE 2(?): PREPARE TO UNWRAP SWAPPED WETH ===============
        address tokenSwapTo = tokenOut;
        // Check if swap to native ETH was requested
        if (tokenOut == UniversalToken.ETH_ADDRESS) {
            // Determine WETH address: this is either tokenIn (if no swap is needed),
            // or a pool token with index `tokenIndexTo` (if swap is needed).
            tokenSwapTo = _deriveWethAddress({token: tokenIn, params: params, isWethIn: false});
        }
        // Either way, we need to perform tokenIn -> tokenSwapTo swap.
        // Then we need to send tokenOut to the recipient.
        // The last step includes WETH unwrapping, if tokenOut is ETH_ADDRESS

        // ============================== PHASE 3(?): PERFORM A REQUESTED SWAP =====================
        // Determine if we need to perform a swap
        if (params.action == Action.HandleEth) {
            // If no swap is required, amountOut doesn't change
            amountOut = amountIn;
        } else {
            // Approve token for spending if needed
            tokenIn.universalApproveInfinity(params.pool);
            if (params.action == Action.Swap) {
                // Perform a swap through the pool
                amountOut = _swap(ISwap(params.pool), params, amountIn, tokenSwapTo);
            } else if (params.action == Action.AddLiquidity) {
                // Add liquidity to the pool
                amountOut = _addLiquidity(ISwap(params.pool), params, amountIn, tokenSwapTo);
            } else {
                // Remove liquidity to the pool
                amountOut = _removeLiquidity(ISwap(params.pool), params, amountIn, tokenSwapTo);
            }
        }
        // Either way, this contract has `amountOut` worth of `tokenSwapTo`

        // ============================== PHASE 4(?): UNWRAP SWAPPED WETH ==========================
        // Check if swap to native ETH was requested
        if (tokenOut == UniversalToken.ETH_ADDRESS) {
            // We stored WETH address in `tokenSwapTo` previously, let's unwrap it
            _unwrapETH(tokenSwapTo, amountOut);
        }
        // Either way, we need to transfer `amountOut` worth of `tokenOut`

        // ============================== PHASE 5(!): TRANSFER SWAPPED TOKENS ======================
        tokenOut.universalTransfer(to, amountOut);
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                            VIEWS: QUOTES                             β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /**
     * @notice Finds the best pool for tokenIn -> tokenOut swap from the list of supported pools.
     * Returns the `SwapQuery` struct, that can be used on SynapseRouter.
     * minAmountOut and deadline fields will need to be adjusted based on the swap settings.
     */
    function getAmountOut(
        address tokenIn,
        address tokenOut,
        uint256 amountIn
    ) external view returns (SwapQuery memory) {
        // All actions are allowed by default
        LimitedToken memory _tokenIn = LimitedToken(ActionLib.allActions(), tokenIn);
        return swapQuoter.getAmountOut(_tokenIn, tokenOut, amountIn);
    }

    /**
     * @notice Returns the exact quote for adding liquidity to a given pool
     * in a form of a single token.
     * @param pool      The pool to add tokens to
     * @param amounts   An array of token amounts to deposit.
     *                  The amount should be in each pooled token's native precision.
     *                  If a token charges a fee on transfers, use the amount that gets transferred after the fee.
     * @return LP token amount the user will receive
     */
    function calculateAddLiquidity(address pool, uint256[] memory amounts) external view returns (uint256) {
        return swapQuoter.calculateAddLiquidity(pool, amounts);
    }

    /**
     * @notice Returns the exact quote for swapping between two given tokens.
     * @param pool              The pool to use for the swap
     * @param tokenIndexFrom    The token the user wants to sell
     * @param tokenIndexTo      The token the user wants to buy
     * @param dx                The amount of tokens the user wants to sell. If the token charges a fee on transfers,
     *                          use the amount that gets transferred after the fee.
     * @return amountOut        amount of tokens the user will receive
     */
    function calculateSwap(
        address pool,
        uint8 tokenIndexFrom,
        uint8 tokenIndexTo,
        uint256 dx
    ) external view returns (uint256 amountOut) {
        amountOut = swapQuoter.calculateSwap(pool, tokenIndexFrom, tokenIndexTo, dx);
    }

    /**
     * @notice Returns the exact quote for withdrawing pools tokens in a balanced way.
     * @param pool          The pool to withdraw tokens from
     * @param amount        The amount of LP tokens that would be burned on withdrawal
     * @return amountsOut   Array of token balances that the user will receive
     */
    function calculateRemoveLiquidity(address pool, uint256 amount)
        external
        view
        returns (uint256[] memory amountsOut)
    {
        amountsOut = swapQuoter.calculateRemoveLiquidity(pool, amount);
    }

    /**
     * @notice Returns the exact quote for withdrawing a single pool token.
     * @param pool          The pool to withdraw a token from
     * @param tokenAmount   The amount of LP token to burn
     * @param tokenIndex    Index of which token will be withdrawn
     * @return amountOut    Calculated amount of underlying token available to withdraw
     */
    function calculateWithdrawOneToken(
        address pool,
        uint256 tokenAmount,
        uint8 tokenIndex
    ) external view returns (uint256 amountOut) {
        amountOut = swapQuoter.calculateWithdrawOneToken(pool, tokenAmount, tokenIndex);
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                             VIEWS: POOLS                             β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /**
     * @notice Returns a list of all supported pools.
     */
    function allPools() public view returns (Pool[] memory pools) {
        pools = swapQuoter.allPools();
    }

    /**
     * @notice Returns the amount of tokens the given pool supports and the pool's LP token.
     */
    function poolInfo(address pool) public view returns (uint256, address) {
        return swapQuoter.poolInfo(pool);
    }

    /**
     * @notice Returns a list of pool tokens for the given pool.
     */
    function poolTokens(address pool) public view returns (PoolToken[] memory tokens) {
        tokens = swapQuoter.poolTokens(pool);
    }

    /**
     * @notice Returns the amount of supported pools.
     */
    function poolsAmount() public view returns (uint256 amount) {
        amount = swapQuoter.poolsAmount();
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                           INTERNAL HELPERS                           β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /**
     * @notice Performs a swap through the given pool.
     * The pool token is already approved for spending.
     */
    function _swap(
        ISwap pool,
        SynapseParams memory params,
        uint256 amountIn,
        address tokenOut
    ) internal returns (uint256 amountOut) {
        // tokenOut should match the "swap to" token
        require(pool.getToken(params.tokenIndexTo) == IERC20(tokenOut), "!tokenOut");
        // amountOut and deadline are not checked in SwapAdapter
        amountOut = pool.swap({
            tokenIndexFrom: params.tokenIndexFrom,
            tokenIndexTo: params.tokenIndexTo,
            dx: amountIn,
            minDy: 0,
            deadline: MAX_UINT
        });
    }

    /**
     * @notice Adds liquidity in a form of a single token to the given pool.
     * The pool token is already approved for spending.
     */
    function _addLiquidity(
        ISwap pool,
        SynapseParams memory params,
        uint256 amountIn,
        address tokenOut
    ) internal returns (uint256 amountOut) {
        (uint256 tokens, address lpToken) = swapQuoter.poolInfo(address(pool));
        // tokenOut should match the LP token
        require(tokenOut == lpToken, "!tokenOut");
        uint256[] memory amounts = new uint256[](tokens);
        amounts[params.tokenIndexFrom] = amountIn;
        // amountOut and deadline are not checked in SwapAdapter
        amountOut = pool.addLiquidity({amounts: amounts, minToMint: 0, deadline: MAX_UINT});
    }

    /**
     * @notice Removes liquidity in a form of a single token from the given pool.
     * The pool LP token is already approved for spending.
     */
    function _removeLiquidity(
        ISwap pool,
        SynapseParams memory params,
        uint256 amountIn,
        address tokenOut
    ) internal returns (uint256 amountOut) {
        // tokenOut should match the "swap to" token
        require(pool.getToken(params.tokenIndexTo) == IERC20(tokenOut), "!tokenOut");
        // amountOut and deadline are not checked in SwapAdapter
        amountOut = pool.removeLiquidityOneToken({
            tokenAmount: amountIn,
            tokenIndex: params.tokenIndexTo,
            minAmount: 0,
            deadline: MAX_UINT
        });
    }

    /*╔══════════════════════════════════════════════════════════════════════╗*\
    ▏*β•‘                         INTERNAL: WETH LOGIC                         β•‘*β–•
    \*β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•*/

    /// @dev Derives WETH address from swap parameters.
    function _deriveWethAddress(
        address token,
        SynapseParams memory params,
        bool isWethIn
    ) internal view returns (address weth) {
        if (params.action == Action.HandleEth) {
            // If we only need to wrap/unwrap ETH, WETH address should be specified as the other token
            weth = token;
        } else {
            // Otherwise, we need to get WETH address from the liquidity pool
            weth = address(ISwap(params.pool).getToken(isWethIn ? params.tokenIndexFrom : params.tokenIndexTo));
        }
    }

    /// @dev Wraps ETH into WETH.
    function _wrapETH(address weth, uint256 amount) internal {
        require(msg.value == amount, "!msg.value");
        // Deposit in order to have WETH in this contract
        IWETH9(payable(weth)).deposit{value: amount}();
    }

    /// @dev Unwraps WETH into ETH.
    function _unwrapETH(address weth, uint256 amount) internal {
        // Withdraw ETH to this contract
        IWETH9(payable(weth)).withdraw(amount);
    }
}

File 2 of 20 : MulticallView.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

/// @notice Multicall utility for view/pure functions. Inspired by Multicall3:
/// https://github.com/mds1/multicall/blob/master/src/Multicall3.sol
abstract contract MulticallView {
    struct Result {
        bool success;
        bytes returnData;
    }

    /// @notice Aggregates a few static calls to this contract into one multicall.
    /// Any of the calls could revert without having impact on other calls. That includes the scenario,
    /// where a data for state modifying call was supplied, which would lead to one of the calls being reverted.
    function multicallView(bytes[] memory data) external view returns (Result[] memory callResults) {
        uint256 amount = data.length;
        callResults = new Result[](amount);
        for (uint256 i = 0; i < amount; ++i) {
            // We perform a static call to ourselves here. This will record `success` as false,
            // should the static call be reverted. The other calls will still be performed regardless.
            // Note: `success` will be set to false, if data for state modifying call was supplied.
            // No data will be modified, as this is a view function.
            (callResults[i].success, callResults[i].returnData) = address(this).staticcall(data[i]);
        }
    }
}

File 2 of 20 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        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 {
        emit OwnershipTransferred(_owner, address(0));
        _owner = 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");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

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

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

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

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

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

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

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

File 2 of 20 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20 {
    using SafeMath for uint256;

    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) public {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return _decimals;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal virtual {
        _decimals = decimals_;
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}

File 2 of 20 : ERC20Burnable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    using SafeMath for uint256;

    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");

        _approve(account, _msgSender(), decreasedAllowance);
        _burn(account, amount);
    }
}

File 2 of 20 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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 2 of 20 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

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

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

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

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

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

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

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

File 2 of 20 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 2 of 20 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 GSN 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 payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 2 of 20 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

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

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

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

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

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

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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


    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

Settings
{
  "remappings": [
    "@boringcrypto/=node_modules/@boringcrypto/",
    "@ensdomains/=node_modules/@ensdomains/",
    "@openzeppelin/=node_modules/@openzeppelin/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "eth-gas-reporter/=node_modules/eth-gas-reporter/",
    "forge-std/=lib/forge-std/src/",
    "hardhat-deploy/=node_modules/hardhat-deploy/",
    "hardhat/=node_modules/hardhat/",
    "sol-explore/=node_modules/sol-explore/",
    "solmate/=lib/solmate/src/",
    "synthetix/=node_modules/synthetix/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "istanbul",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_synapseBridge","type":"address"},{"internalType":"address","name":"owner_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"bytes","name":"rawParams","type":"bytes"}],"name":"adapterSwap","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"symbol","type":"string"},{"internalType":"address","name":"token","type":"address"},{"internalType":"enum LocalBridgeConfig.TokenType","name":"tokenType","type":"uint8"},{"internalType":"address","name":"bridgeToken","type":"address"},{"internalType":"uint256","name":"bridgeFee","type":"uint256"},{"internalType":"uint256","name":"minFee","type":"uint256"},{"internalType":"uint256","name":"maxFee","type":"uint256"}],"name":"addToken","outputs":[{"internalType":"bool","name":"wasAdded","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"id","type":"string"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"enum LocalBridgeConfig.TokenType","name":"tokenType","type":"uint8"},{"internalType":"address","name":"bridgeToken","type":"address"},{"internalType":"uint256","name":"bridgeFee","type":"uint256"},{"internalType":"uint256","name":"minFee","type":"uint256"},{"internalType":"uint256","name":"maxFee","type":"uint256"}],"internalType":"struct LocalBridgeConfig.BridgeTokenConfig[]","name":"tokens","type":"tuple[]"}],"name":"addTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"allPools","outputs":[{"components":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"address","name":"lpToken","type":"address"},{"components":[{"internalType":"bool","name":"isWeth","type":"bool"},{"internalType":"address","name":"token","type":"address"}],"internalType":"struct PoolToken[]","name":"tokens","type":"tuple[]"}],"internalType":"struct Pool[]","name":"pools","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"components":[{"internalType":"address","name":"swapAdapter","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"rawParams","type":"bytes"}],"internalType":"struct SwapQuery","name":"originQuery","type":"tuple"},{"components":[{"internalType":"address","name":"swapAdapter","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"rawParams","type":"bytes"}],"internalType":"struct SwapQuery","name":"destQuery","type":"tuple"}],"name":"bridge","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"bridgeTokens","outputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bridgeTokensAmount","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"calculateAddLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calculateBridgeFee","outputs":[{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calculateRemoveLiquidity","outputs":[{"internalType":"uint256[]","name":"amountsOut","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint8","name":"tokenIndexFrom","type":"uint8"},{"internalType":"uint8","name":"tokenIndexTo","type":"uint8"},{"internalType":"uint256","name":"dx","type":"uint256"}],"name":"calculateSwap","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"internalType":"uint8","name":"tokenIndex","type":"uint8"}],"name":"calculateWithdrawOneToken","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"config","outputs":[{"internalType":"enum LocalBridgeConfig.TokenType","name":"tokenType","type":"uint8"},{"internalType":"address","name":"bridgeToken","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"fee","outputs":[{"internalType":"uint40","name":"bridgeFee","type":"uint40"},{"internalType":"uint104","name":"minFee","type":"uint104"},{"internalType":"uint112","name":"maxFee","type":"uint112"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"getAmountOut","outputs":[{"components":[{"internalType":"address","name":"swapAdapter","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"rawParams","type":"bytes"}],"internalType":"struct SwapQuery","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOut","type":"address"}],"name":"getConnectedBridgeTokens","outputs":[{"components":[{"internalType":"string","name":"symbol","type":"string"},{"internalType":"address","name":"token","type":"address"}],"internalType":"struct BridgeToken[]","name":"tokens","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"internalType":"struct DestRequest[]","name":"requests","type":"tuple[]"},{"internalType":"address","name":"tokenOut","type":"address"}],"name":"getDestinationAmountOut","outputs":[{"components":[{"internalType":"address","name":"swapAdapter","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"rawParams","type":"bytes"}],"internalType":"struct SwapQuery[]","name":"destQueries","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"string[]","name":"tokenSymbols","type":"string[]"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"getOriginAmountOut","outputs":[{"components":[{"internalType":"address","name":"swapAdapter","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"rawParams","type":"bytes"}],"internalType":"struct SwapQuery[]","name":"originQueries","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicallView","outputs":[{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct MulticallView.Result[]","name":"callResults","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"}],"name":"poolInfo","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"}],"name":"poolTokens","outputs":[{"components":[{"internalType":"bool","name":"isWeth","type":"bool"},{"internalType":"address","name":"token","type":"address"}],"internalType":"struct PoolToken[]","name":"tokens","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolsAmount","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"removeToken","outputs":[{"internalType":"bool","name":"wasRemoved","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"removeTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISwapQuoter","name":"_swapQuoter","type":"address"}],"name":"setSwapQuoter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"enum LocalBridgeConfig.TokenType","name":"tokenType","type":"uint8"},{"internalType":"address","name":"bridgeToken","type":"address"}],"name":"setTokenConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"bridgeFee","type":"uint256"},{"internalType":"uint256","name":"minFee","type":"uint256"},{"internalType":"uint256","name":"maxFee","type":"uint256"}],"name":"setTokenFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"components":[{"internalType":"address","name":"swapAdapter","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"rawParams","type":"bytes"}],"internalType":"struct SwapQuery","name":"query","type":"tuple"}],"name":"swap","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"swapQuoter","outputs":[{"internalType":"contract ISwapQuoter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"symbolToToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"synapseBridge","outputs":[{"internalType":"contract ISynapseBridge","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenToSymbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a06040523480156200001157600080fd5b506040516200558138038062005581833981016040819052620000349162000173565b6000620000406200009e565b600080546001600160a01b0319166001600160a01b03831690811782556040519293509160008051602062005561833981519152908290a3506001600160601b0319606083901b166080526200009681620000a2565b505062000245565b3390565b620000ac6200009e565b6001600160a01b0316620000bf62000164565b6001600160a01b031614620000f15760405162461bcd60e51b8152600401620000e890620001f7565b60405180910390fd5b6001600160a01b0381166200011a5760405162461bcd60e51b8152600401620000e890620001b1565b600080546040516001600160a01b03808516939216916000805160206200556183398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031690565b6000806040838503121562000186578182fd5b825162000193816200022c565b6020840151909250620001a6816200022c565b809150509250929050565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6001600160a01b03811681146200024257600080fd5b50565b60805160601c6152e0620002816000398061180f52806118c2528061195152806119f25280611a445280611fd35280612ac152506152e06000f3fe6080604052600436106102135760003560e01c80637c61e56111610118578063c2288147116100a0578063d62933e21161006f578063d62933e21461065b578063da46098c1461067b578063e80633771461069b578063f2fde38b146106b0578063f8a06888146106d05761021a565b8063c2288147146105d9578063c5c63e65146105ec578063ccc1bbc11461060e578063d38e78881461062e5761021a565b8063a5bc29c2116100e7578063a5bc29c214610537578063a734c44114610557578063a912616914610584578063b5d1cdd4146105b1578063ba7d536e146105c45761021a565b80637c61e561146104a7578063804b3dff146104d45780638da5cb5b146104f45780639a7b5f11146105095761021a565b80634d8644961161019b5780635ff30c0a1161016a5780635ff30c0a1461040e5780636c3824ef146104235780636fcca69b14610443578063715018a614610472578063798af720146104875761021a565b80634d86449614610381578063530d95f6146103a157806358b5b777146103ce5780635fa7b584146103ee5761021a565b806324a98f11116101e257806324a98f11146102d2578063302fee96146102f257806334474c8c146103125780633bc758fd146103345780634aa06652146103545761021a565b8063077e11991461021f5780630ba36121146102555780630e68ec951461028257806310f60034146102b05761021a565b3661021a57005b600080fd5b34801561022b57600080fd5b5061023f61023a366004613f89565b6106f2565b60405161024c9190614a57565b60405180910390f35b34801561026157600080fd5b506102756102703660046138e9565b6108d0565b60405161024c9190614b20565b34801561028e57600080fd5b506102a261029d3660046138e9565b61096b565b60405161024c929190614afa565b3480156102bc57600080fd5b506102d06102cb366004613ba4565b610990565b005b6102e56102e0366004613945565b610a24565b60405161024c919061513d565b3480156102fe57600080fd5b506102d061030d366004613caf565b610c30565b34801561031e57600080fd5b50610327610cbd565b60405161024c9190614679565b34801561034057600080fd5b5061023f61034f366004613a5b565b610ccc565b34801561036057600080fd5b5061037461036f366004613905565b610e57565b60405161024c919061512a565b34801561038d57600080fd5b506102e561039c366004613b00565b610f1c565b3480156103ad57600080fd5b506103c16103bc366004614282565b610fa8565b60405161024c9190614aef565b3480156103da57600080fd5b506102e56103e9366004613bed565b611004565b3480156103fa57600080fd5b506103c16104093660046138e9565b611010565b34801561041a57600080fd5b506102e561105a565b34801561042f57600080fd5b506102d061043e366004613d6f565b61106b565b34801561044f57600080fd5b5061046361045e3660046138e9565b6110e8565b60405161024c9392919061517b565b34801561047e57600080fd5b506102d0611126565b34801561049357600080fd5b506102e56104a2366004613d1f565b6111af565b3480156104b357600080fd5b506104c76104c2366004613bed565b61123f565b60405161024c9190614ab7565b3480156104e057600080fd5b506102d06104ef3660046138e9565b6112c6565b34801561050057600080fd5b50610327611327565b34801561051557600080fd5b506105296105243660046138e9565b611336565b60405161024c929190615146565b34801561054357600080fd5b50610327610552366004614250565b6113c3565b34801561056357600080fd5b50610577610572366004613ddd565b6113e9565b60405161024c91906149f2565b34801561059057600080fd5b506105a461059f3660046138e9565b611500565b60405161024c9190614965565b6102e56105bf3660046139f2565b611585565b3480156105d057600080fd5b506102e5611611565b6102d06105e7366004613c18565b61168e565b3480156105f857600080fd5b50610601611abc565b60405161024c9190614978565b34801561061a57600080fd5b506102e5610629366004613ce9565b611b3d565b34801561063a57600080fd5b5061064e6106493660046138e9565b611bca565b60405161024c9190614899565b34801561066757600080fd5b506102d0610676366004613e65565b611edf565b34801561068757600080fd5b506102d061069636600461423c565b611f7e565b3480156106a757600080fd5b50610327611fd1565b3480156106bc57600080fd5b506102d06106cb3660046138e9565b611ff5565b3480156106dc57600080fd5b506106e56120b5565b60405161024c919061484c565b8151606090806001600160401b038111801561070d57600080fd5b5060405190808252806020026020018201604052801561074757816020015b6107346134eb565b81526020019060019003908161072c5790505b50915060005b818110156108c8576000600486838151811061076557fe5b60200260200101516000015160405161077e919061465a565b908152604051908190036020019020546001600160a01b03169050806107a457506108c0565b60006107c7828885815181106107b657fe5b60200260200101516020015161214d565b9050806107d55750506108c0565b6001600160a01b03821660009081526001602052604090205460ff166107f961352c565b604051806040016040528061080d84612171565b81526001600160a01b0380871660209092019190915260075460405163e6b0000960e01b8152929350169063e6b00009906108509084908c908890600401615102565b60006040518083038186803b15801561086857600080fd5b505afa15801561087c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108a4919081019061430e565b8786815181106108b057fe5b6020026020010181905250505050505b60010161074d565b505092915050565b60036020908152600091825260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156109635780601f1061093857610100808354040283529160200191610963565b820191906000526020600020905b81548152906001019060200180831161094657829003601f168201915b505050505081565b60016020526000908152604090205460ff81169061010090046001600160a01b031682565b6109986121a8565b6001600160a01b03166109a9611327565b6001600160a01b0316146109d85760405162461bcd60e51b81526004016109cf90614eb2565b60405180910390fd5b6001600160a01b03838116600090815260016020526040902054610100900416610a145760405162461bcd60e51b81526004016109cf90614c58565b610a1f8383836121ac565b505050565b6000836001600160a01b0316866001600160a01b03161415610a585760405162461bcd60e51b81526004016109cf90614e03565b610a60613543565b610a6c838501856143b0565b60208101519091506001600160a01b0316151580610a965750600381516003811115610a9457fe5b145b610ab25760405162461bcd60e51b81526004016109cf9061506a565b6001600160a01b03871673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610af457610ae385826001612271565b9650610aef8787612323565b610b12565b3415610b125760405162461bcd60e51b81526004016109cf90614e3a565b846001600160a01b03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610b4757610b4488836000612271565b90505b600382516003811115610b5657fe5b1415610b6457869250610be1565b6020820151610b7d906001600160a01b038a169061239a565b600082516003811115610b8c57fe5b1415610ba957610ba2826020015183898461249b565b9250610be1565b600182516003811115610bb857fe5b1415610bce57610ba282602001518389846125ba565b610bde826020015183898461275c565b92505b6001600160a01b03861673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610c1057610c108184612846565b610c246001600160a01b0387168a856128a8565b50509695505050505050565b610c386121a8565b6001600160a01b0316610c49611327565b6001600160a01b031614610c6f5760405162461bcd60e51b81526004016109cf90614eb2565b6001600160a01b03848116600090815260016020526040902054610100900416610cab5760405162461bcd60e51b81526004016109cf90614c58565b610cb784848484612979565b50505050565b6007546001600160a01b031681565b8151606090806001600160401b0381118015610ce757600080fd5b50604051908082528060200260200182016040528015610d2157816020015b610d0e6134eb565b815260200190600190039081610d065790505b50915060005b81811015610e4e5760006004868381518110610d3f57fe5b6020026020010151604051610d54919061465a565b908152604051908190036020019020546001600160a01b0316905080610d7a5750610e46565b610d8261352c565b6040518060400160405280610d95612a79565b81526001600160a01b03808b1660209092019190915260075460405163e6b0000960e01b8152929350169063e6b0000990610dd890849086908b90600401615102565b60006040518083038186803b158015610df057600080fd5b505afa158015610e04573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e2c919081019061430e565b858481518110610e3857fe5b602002602001018190525050505b600101610d27565b50509392505050565b610e5f6134eb565b610e6761352c565b6040518060400160405280610e7a612a79565b81526001600160a01b0380881660209092019190915260075460405163e6b0000960e01b8152929350169063e6b0000990610ebd90849088908890600401615102565b60006040518083038186803b158015610ed557600080fd5b505afa158015610ee9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f11919081019061430e565b9150505b9392505050565b6007546040516326c3224b60e11b81526000916001600160a01b031690634d86449690610f4f9086908690600401614706565b60206040518083038186803b158015610f6757600080fd5b505afa158015610f7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9f9190614474565b90505b92915050565b6000610fb26121a8565b6001600160a01b0316610fc3611327565b6001600160a01b031614610fe95760405162461bcd60e51b81526004016109cf90614eb2565b610ff888888888888888612a7f565b98975050505050505050565b6000610f9f8383612af0565b600061101a6121a8565b6001600160a01b031661102b611327565b6001600160a01b0316146110515760405162461bcd60e51b81526004016109cf90614eb2565b610fa282612c0a565b60006110666005612d4b565b905090565b6110736121a8565b6001600160a01b0316611084611327565b6001600160a01b0316146110aa5760405162461bcd60e51b81526004016109cf90614eb2565b8060005b81811015610cb7576110df8484838181106110c557fe5b90506020020160208101906110da91906138e9565b612c0a565b506001016110ae565b60026020526000908152604090205464ffffffffff8116906501000000000081046001600160681b031690600160901b90046001600160701b031683565b61112e6121a8565b6001600160a01b031661113f611327565b6001600160a01b0316146111655760405162461bcd60e51b81526004016109cf90614eb2565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6007546040516303cc57b960e51b81526000916001600160a01b03169063798af720906111e6908890889088908890600401614822565b60206040518083038186803b1580156111fe57600080fd5b505afa158015611212573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112369190614474565b95945050505050565b600754604051637c61e56160e01b81526060916001600160a01b031690637c61e56190611272908690869060040161472a565b60006040518083038186803b15801561128a57600080fd5b505afa15801561129e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f9f9190810190614171565b6112ce6121a8565b6001600160a01b03166112df611327565b6001600160a01b0316146113055760405162461bcd60e51b81526004016109cf90614eb2565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031690565b600754604051639a7b5f1160e01b815260009182916001600160a01b0390911690639a7b5f119061136b908690600401614679565b604080518083038186803b15801561138257600080fd5b505afa158015611396573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ba919061448c565b91509150915091565b80516020818301810180516004825292820191909301209152546001600160a01b031681565b8051606090806001600160401b038111801561140457600080fd5b5060405190808252806020026020018201604052801561143e57816020015b61142b61356c565b8152602001906001900390816114235790505b50915060005b818110156114f957306001600160a01b031684828151811061146257fe5b6020026020010151604051611477919061465a565b600060405180830381855afa9150503d80600081146114b2576040519150601f19603f3d011682016040523d82523d6000602084013e6114b7565b606091505b508483815181106114c457fe5b60200260200101516000018584815181106114db57fe5b60209081029190910181015101919091529015159052600101611444565b5050919050565b60075460405163a912616960e01b81526060916001600160a01b03169063a912616990611531908590600401614679565b60006040518083038186803b15801561154957600080fd5b505afa15801561155d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610fa29190810190614068565b60006001600160a01b0385166115ad5760405162461bcd60e51b81526004016109cf90614dcc565b6001600160a01b0385163014156115d65760405162461bcd60e51b81526004016109cf90614fe9565b6115df82612d56565b6115fb5760405162461bcd60e51b81526004016109cf90614d20565b61160785858585612d65565b9695505050505050565b60075460408051635d3ea9b760e11b815290516000926001600160a01b03169163ba7d536e916004808301926020929190829003018186803b15801561165657600080fd5b505afa15801561166a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110669190614474565b61169782612d56565b156116b2576116a830858585612d65565b90945092506116bd565b6116bd308585612e5e565b6116c561352c565b6001600160a01b038516600090815260016020819052604091829020825180840190935280549091839160ff16908111156116fc57fe5b600181111561170757fe5b815290546001600160a01b03610100909104811660209283015290820151919250166117455760405162461bcd60e51b81526004016109cf90614ee7565b80602001519450611754613543565b61175d83612d56565b1561177d57826080015180602001905181019061177a9190614418565b90505b61178683612d56565b801561179f575060038151600381111561179c57fe5b14155b156119c6576001825160018111156117b357fe5b1415611883576000815160038111156117c857fe5b146117e55760405162461bcd60e51b81526004016109cf90614c21565b6040808201516060808401518684015191870151935163a2a2af0b60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169463a2a2af0b9461184c948f948f948f948f9493916004016147b1565b600060405180830381600087803b15801561186657600080fd5b505af115801561187a573d6000803e3d6000fd5b505050506119c1565b60008151600381111561189257fe5b14156118ff57604080820151606080840151868401519187015193516341cf6c8560e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169463839ed90a9461184c948f948f948f948f9493916004016147b1565b60028151600381111561190e57fe5b1461192b5760405162461bcd60e51b81526004016109cf90614c21565b6060808201516040808601519286015190516336e712ed60e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016936336e712ed9361198e938e938e938e938e93909260040161476d565b600060405180830381600087803b1580156119a857600080fd5b505af11580156119bc573d6000803e3d6000fd5b505050505b611ab2565b6001825160018111156119d557fe5b1415611a2d57604051632434941d60e21b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906390d250749061198e908b908b908b908b90600401614743565b60405163f3f094a160e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063f3f094a190611a7f908b908b908b908b90600401614743565b600060405180830381600087803b158015611a9957600080fd5b505af1158015611aad573d6000803e3d6000fd5b505050505b5050505050505050565b6007546040805163c5c63e6560e01b815290516060926001600160a01b03169163c5c63e65916004808301926000929190829003018186803b158015611b0157600080fd5b505afa158015611b15573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611066919081019061409a565b60075460405163ccc1bbc160e01b81526000916001600160a01b03169063ccc1bbc190611b72908790879087906004016147fe565b60206040518083038186803b158015611b8a57600080fd5b505afa158015611b9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc29190614474565b949350505050565b60606000611bd661105a565b90506060816001600160401b0381118015611bf057600080fd5b50604051908082528060200260200182016040528015611c2a57816020015b611c1761352c565b815260200190600190039081611c0f5790505b50905060005b82811015611cb9576000611c45600583612ed8565b6001600160a01b038116600090815260016020526040902054909150611c6d9060ff16612171565b838381518110611c7957fe5b6020026020010151600001818152505080838381518110611c9657fe5b6020908102919091018101516001600160a01b0390921691015250600101611c30565b5060075460405163504094e760e11b81526000916060916001600160a01b039091169063a08129ce90611cf29086908a90600401614907565b60006040518083038186803b158015611d0a57600080fd5b505afa158015611d1e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d4691908101906144bb565b91509150816001600160401b0381118015611d6057600080fd5b50604051908082528060200260200182016040528015611d9a57816020015b611d87613584565b815260200190600190039081611d7f5790505b5094506000915060005b84811015611ed557818181518110611db857fe5b602002602001015115611ecd576000848281518110611dd357fe5b6020908102919091018101518101516001600160a01b0381166000908152600383526040908190208054825160026001831615610100026000190190921691909104601f81018690048602820186019093528281529294509192830182828015611e7e5780601f10611e5357610100808354040283529160200191611e7e565b820191906000526020600020905b815481529060010190602001808311611e6157829003601f168201915b5050505050878581518110611e8f57fe5b60200260200101516000018190525080878581518110611eab57fe5b6020908102919091018101516001600160a01b03909216910152506001909201915b600101611da4565b5050505050919050565b611ee76121a8565b6001600160a01b0316611ef8611327565b6001600160a01b031614611f1e5760405162461bcd60e51b81526004016109cf90614eb2565b805160005b81811015610a1f57611f3361359c565b838281518110611f3f57fe5b60200260200101519050611f7481600001518260200151836060015184608001518560a001518660c001518760e00151612a7f565b5050600101611f23565b611f866121a8565b6001600160a01b0316611f97611327565b6001600160a01b031614611fbd5760405162461bcd60e51b81526004016109cf90614eb2565b610a1f6001600160a01b0384168383612ee4565b7f000000000000000000000000000000000000000000000000000000000000000081565b611ffd6121a8565b6001600160a01b031661200e611327565b6001600160a01b0316146120345760405162461bcd60e51b81526004016109cf90614eb2565b6001600160a01b03811661205a5760405162461bcd60e51b81526004016109cf90614bac565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b606060006120c161105a565b9050806001600160401b03811180156120d957600080fd5b50604051908082528060200260200182016040528015612103578160200160208202803683370190505b50915060005b818110156121485761211c600582612ed8565b83828151811061212857fe5b6001600160a01b0390921660209283029190910190910152600101612109565b505090565b60008061215a8484612af0565b90508281101561216a5780830391505b5092915050565b60008082600181111561218057fe5b1415612197576121906000612fde565b90506121a3565b610fa260026003612ff6565b919050565b3390565b6001600160a01b038316158015906121cc57506001600160a01b03811615155b6121e85760405162461bcd60e51b81526004016109cf90614b75565b60405180604001604052808360018111156121ff57fe5b81526001600160a01b0380841660209283015285166000908152600191829052604090208251815491929091839160ff1990911690838181111561223f57fe5b02179055506020919091015181546001600160a01b0390911661010002610100600160a81b0319909116179055505050565b600060038351600381111561228257fe5b141561228f575082610f15565b82602001516001600160a01b03166382b86600836122b15784606001516122b7565b84604001515b6040518263ffffffff1660e01b81526004016122d391906151ac565b60206040518083038186803b1580156122eb57600080fd5b505afa1580156122ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc29190614220565b8034146123425760405162461bcd60e51b81526004016109cf90614cfc565b816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561237d57600080fd5b505af1158015612391573d6000803e3d6000fd5b50505050505050565b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156123c457612497565b6001600160a01b0381163014156123da57612497565b604051636eb1769f60e11b81526000906001600160a01b0384169063dd62ed3e9061240b903090869060040161468d565b60206040518083038186803b15801561242357600080fd5b505afa158015612437573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061245b9190614474565b90506000198114610a1f578015612481576124816001600160a01b038416836000612ee4565b610a1f6001600160a01b03841683600019612ee4565b5050565b6000816001600160a01b0316856001600160a01b03166382b8660086606001516040518263ffffffff1660e01b81526004016124d791906151ac565b60206040518083038186803b1580156124ef57600080fd5b505afa158015612503573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125279190614220565b6001600160a01b03161461254d5760405162461bcd60e51b81526004016109cf906150df565b846001600160a01b03166391695586856040015186606001518660006000196040518663ffffffff1660e01b815260040161258c9594939291906151ba565b602060405180830381600087803b1580156125a657600080fd5b505af1158015611212573d6000803e3d6000fd5b600754604051639a7b5f1160e01b8152600091829182916001600160a01b031690639a7b5f11906125ef908a90600401614679565b604080518083038186803b15801561260657600080fd5b505afa15801561261a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263e919061448c565b91509150806001600160a01b0316846001600160a01b0316146126735760405162461bcd60e51b81526004016109cf906150df565b6060826001600160401b038111801561268b57600080fd5b506040519080825280602002602001820160405280156126b5578160200160208202803683370190505b5090508581886040015160ff16815181106126cc57fe5b6020908102919091010152604051634d49e87d60e01b81526001600160a01b03891690634d49e87d9061270a90849060009060001990600401614aca565b602060405180830381600087803b15801561272457600080fd5b505af1158015612738573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff89190614474565b6000816001600160a01b0316856001600160a01b03166382b8660086606001516040518263ffffffff1660e01b815260040161279891906151ac565b60206040518083038186803b1580156127b057600080fd5b505afa1580156127c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127e89190614220565b6001600160a01b03161461280e5760405162461bcd60e51b81526004016109cf906150df565b60608401516040516301f1d0ab60e51b81526001600160a01b03871691633e3a15609161258c9187916000906000199060040161515d565b604051632e1a7d4d60e01b81526001600160a01b03831690632e1a7d4d9061287290849060040161513d565b600060405180830381600087803b15801561288c57600080fd5b505af11580156128a0573d6000803e3d6000fd5b505050505050565b6001600160a01b0382163014156128be57610a1f565b6001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415612965576000826001600160a01b0316826040516128fc90614676565b60006040518083038185875af1925050503d8060008114612939576040519150601f19603f3d011682016040523d82523d6000602084013e61293e565b606091505b505090508061295f5760405162461bcd60e51b81526004016109cf90614f5c565b50610a1f565b610a1f6001600160a01b0384168383613012565b6402540be400831061299d5760405162461bcd60e51b81526004016109cf90614d46565b808211156129bd5760405162461bcd60e51b81526004016109cf90614fc0565b6040805160608101825264ffffffffff94851681526001600160681b0393841660208083019182526001600160701b039485168385019081526001600160a01b0390981660009081526002909152929092209051815492519651909316600160901b0271ffffffffffffffffffffffffffffffffffff96909416650100000000000271ffffffffffffffffffffffffff0000000000199390951664ffffffffff1990921691909117919091169290921792909216919091179055565b60001990565b6000612a9088888888888888613031565b90508015612ae557846001600160a01b0316876001600160a01b03161415612ae557612ae56001600160a01b0388167f000000000000000000000000000000000000000000000000000000000000000061239a565b979650505050505050565b6001600160a01b03828116600090815260016020526040812054909161010090910416612b2f5760405162461bcd60e51b81526004016109cf90614ee7565b612b376135fe565b506001600160a01b0383166000908152600260209081526040918290208251606081018452905464ffffffffff81168083526501000000000082046001600160681b031693830193909352600160901b90046001600160701b031692810192909252612bb5906402540be40090612baf908690613067565b906130a1565b915080602001516001600160681b0316821015612be15780602001516001600160681b0316915061216a565b80604001516001600160701b031682111561216a57604001516001600160701b03169392505050565b6000612c176005836130d3565b905080156121a3576001600160a01b03821660009081526003602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845260609392830182828015612cbe5780601f10612c9357610100808354040283529160200191612cbe565b820191906000526020600020905b815481529060010190602001808311612ca157829003601f168201915b505050506001600160a01b0385166000908152600360205260408120929350612ce892915061361e565b600481604051612cf8919061465a565b9081526040805191829003602090810190922080546001600160a01b03191690556001600160a01b03851660009081526001835281812080546001600160a81b0319169055600290925281205550919050565b6000610fa2826130e8565b516001600160a01b0316151590565b6000808260600151421115612d8c5760405162461bcd60e51b81526004016109cf90614f14565b8251612d99908686612e5e565b8260200151915082600001516001600160a01b03166324a98f11348888888789608001516040518763ffffffff1660e01b8152600401612ddd9594939291906146cb565b6020604051808303818588803b158015612df657600080fd5b505af1158015612e0a573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612e2f9190614474565b90508260400151811015612e555760405162461bcd60e51b81526004016109cf90614d71565b94509492505050565b34612e7d57612e786001600160a01b0383163385846130ec565b610a1f565b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14612eb95760405162461bcd60e51b81526004016109cf90614f3e565b803414610a1f5760405162461bcd60e51b81526004016109cf90614cfc565b6000610f9f838361310d565b801580612f6c5750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90612f1a903090869060040161468d565b60206040518083038186803b158015612f3257600080fd5b505afa158015612f46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f6a9190614474565b155b612f885760405162461bcd60e51b81526004016109cf90615089565b610a1f8363095ea7b360e01b8484604051602401612fa792919061472a565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613152565b6000816003811115612fec57fe5b6001901b92915050565b600061300182612fde565b61300a84612fde565b179392505050565b610a1f8363a9059cbb60e01b8484604051602401612fa792919061472a565b600061303e6005886131e1565b90508015612ae55761305088886131f6565b61305b8787876121ac565b612ae587858585612979565b60008261307657506000610fa2565b8282028284828161308357fe5b0414610f9f5760405162461bcd60e51b81526004016109cf90614e71565b60008082116130c25760405162461bcd60e51b81526004016109cf90614cc5565b8183816130cb57fe5b049392505050565b6000610f9f836001600160a01b0384166132bf565b5490565b610cb7846323b872dd60e01b858585604051602401612fa7939291906146a7565b815460009082106131305760405162461bcd60e51b81526004016109cf90614b33565b82600001828154811061313f57fe5b9060005260206000200154905092915050565b60606131a7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166133859092919063ffffffff16565b805190915015610a1f57808060200190518101906131c59190614200565b610a1f5760405162461bcd60e51b81526004016109cf90615020565b6000610f9f836001600160a01b038416613394565b81516132145760405162461bcd60e51b81526004016109cf90614da6565b60006001600160a01b031660048360405161322f919061465a565b908152604051908190036020019020546001600160a01b0316146132655760405162461bcd60e51b81526004016109cf90614bf2565b80600483604051613276919061465a565b908152604080516020928190038301902080546001600160a01b0319166001600160a01b03948516179055918316600090815260038252919091208351610a1f92850190613665565b6000818152600183016020526040812054801561337b57835460001980830191908101906000908790839081106132f257fe5b906000526020600020015490508087600001848154811061330f57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061333f57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610fa2565b6000915050610fa2565b6060611bc284846000856133de565b60006133a08383613494565b6133d657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610fa2565b506000610fa2565b6060824710156134005760405162461bcd60e51b81526004016109cf90614c7f565b613409856134ac565b6134255760405162461bcd60e51b81526004016109cf90614f89565b60006060866001600160a01b03168587604051613442919061465a565b60006040518083038185875af1925050503d806000811461347f576040519150601f19603f3d011682016040523d82523d6000602084013e613484565b606091505b5091509150612ae58282866134b2565b60009081526001919091016020526040902054151590565b3b151590565b606083156134c1575081610f15565b8251156134d15782518084602001fd5b8160405162461bcd60e51b81526004016109cf9190614b20565b6040518060a0016040528060006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001606081525090565b604080518082019091526000808252602082015290565b604080516080810190915280600081526000602082018190526040820181905260609091015290565b60408051808201909152600081526060602082015290565b60408051808201909152606081526000602082015290565b6040518061010001604052806060815260200160006001600160a01b0316815260200160008152602001600060018111156135d357fe5b815260200160006001600160a01b031681526020016000815260200160008152602001600081525090565b604080516060810182526000808252602082018190529181019190915290565b50805460018160011615610100020316600290046000825580601f106136445750613662565b601f01602090049060005260206000209081019061366291906136e3565b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106136a657805160ff19168380011785556136d3565b828001600101855582156136d3579182015b828111156136d35782518255916020019190600101906136b8565b506136df9291506136e3565b5090565b5b808211156136df57600081556001016136e4565b8035610fa281615279565b8051610fa281615279565b600082601f83011261371e578081fd5b815161373161372c8261520b565b6151e5565b818152915060208083019084810160408085028701830188101561375457600080fd5b6000805b868110156137a55782848b03121561376e578182fd5b613777836151e5565b6137818b866137b2565b815261378f8b878701613703565b8187015286529484019492820192600101613758565b5050505050505092915050565b80518015158114610fa257600080fd5b600082601f8301126137d2578081fd5b81356137e061372c8261522a565b91508082528360208285010111156137f757600080fd5b8060208401602084013760009082016020015292915050565b600082601f830112613820578081fd5b815161382e61372c8261522a565b915080825283602082850101111561384557600080fd5b61216a81602084016020860161524d565b803560028110610fa257600080fd5b600060a08284031215613876578081fd5b61388060a06151e5565b9050813561388d81615279565b8152602082013561389d81615279565b80602083015250604082013560408201526060820135606082015260808201356001600160401b038111156138d157600080fd5b6138dd848285016137c2565b60808301525092915050565b6000602082840312156138fa578081fd5b8135610f9f81615279565b600080600060608486031215613919578182fd5b833561392481615279565b9250602084013561393481615279565b929592945050506040919091013590565b60008060008060008060a0878903121561395d578384fd5b863561396881615279565b9550602087013561397881615279565b945060408701359350606087013561398f81615279565b925060808701356001600160401b03808211156139aa578384fd5b818901915089601f8301126139bd578384fd5b8135818111156139cb578485fd5b8a60208285010111156139dc578485fd5b6020830194508093505050509295509295509295565b60008060008060808587031215613a07578182fd5b8435613a1281615279565b93506020850135613a2281615279565b92506040850135915060608501356001600160401b03811115613a43578182fd5b613a4f87828801613865565b91505092959194509250565b600080600060608486031215613a6f578081fd5b8335613a7a81615279565b92506020848101356001600160401b03811115613a95578283fd5b8501601f81018713613aa5578283fd5b8035613ab361372c8261520b565b81815283810190838501865b84811015613ae857613ad68c8884358901016137c2565b84529286019290860190600101613abf565b50508096505050505050604084013590509250925092565b60008060408385031215613b12578182fd5b8235613b1d81615279565b91506020838101356001600160401b03811115613b38578283fd5b8401601f81018613613b48578283fd5b8035613b5661372c8261520b565b81815283810190838501858402850186018a1015613b72578687fd5b8694505b83851015613b94578035835260019490940193918501918501613b76565b5080955050505050509250929050565b600080600060608486031215613bb8578081fd5b8335613bc381615279565b9250613bd28560208601613856565b91506040840135613be281615279565b809150509250925092565b60008060408385031215613bff578182fd5b8235613c0a81615279565b946020939093013593505050565b60008060008060008060c08789031215613c30578384fd5b8635613c3b81615279565b9550602087013594506040870135613c5281615279565b93506060870135925060808701356001600160401b0380821115613c74578384fd5b613c808a838b01613865565b935060a0890135915080821115613c95578283fd5b50613ca289828a01613865565b9150509295509295509295565b60008060008060808587031215613cc4578182fd5b8435613ccf81615279565b966020860135965060408601359560600135945092505050565b600080600060608486031215613cfd578081fd5b8335613d0881615279565b9250602084013591506040840135613be28161529b565b60008060008060808587031215613d34578182fd5b8435613d3f81615279565b93506020850135613d4f8161529b565b92506040850135613d5f8161529b565b9396929550929360600135925050565b60008060208385031215613d81578182fd5b82356001600160401b0380821115613d97578384fd5b818501915085601f830112613daa578384fd5b813581811115613db8578485fd5b8660208083028501011115613dcb578485fd5b60209290920196919550909350505050565b60006020808385031215613def578182fd5b82356001600160401b03811115613e04578283fd5b8301601f81018513613e14578283fd5b8035613e2261372c8261520b565b81815283810190838501865b84811015613e5757613e458a8884358901016137c2565b84529286019290860190600101613e2e565b509098975050505050505050565b60006020808385031215613e77578182fd5b82356001600160401b0380821115613e8d578384fd5b818501915085601f830112613ea0578384fd5b8135613eae61372c8261520b565b81815284810190848601875b84811015613f7a578135870161010080601f19838f03011215613edb578a8bfd5b613ee4816151e5565b8a83013589811115613ef4578c8dfd5b613f028f8d838701016137c2565b825250613f128e604085016136f8565b8b8201526060808401356040830152613f2e8f60808601613856565b9082015260a0613f408f8583016136f8565b608083015260c0848101359183019190915260e0808501359183019190915291909201359082015284529287019290870190600101613eba565b50909998505050505050505050565b60008060408385031215613f9b578182fd5b82356001600160401b0380821115613fb1578384fd5b818501915085601f830112613fc4578384fd5b8135613fd261372c8261520b565b81815260208082019190858101885b8581101561404857813588016040818e03601f19011215614000578a8bfd5b61400a60406151e5565b848201358981111561401a578c8dfd5b6140288f87838601016137c2565b825250604091909101358482015285529382019390820190600101613fe1565b50508197506140598a828b016136f8565b96505050505050509250929050565b600060208284031215614079578081fd5b81516001600160401b0381111561408e578182fd5b611bc28482850161370e565b600060208083850312156140ac578182fd5b82516001600160401b03808211156140c2578384fd5b818501915085601f8301126140d5578384fd5b81516140e361372c8261520b565b81815284810190848601875b84811015613f7a5781518701606080601f19838f0301121561410f578a8bfd5b614118816151e5565b8a83015161412581615279565b815260408381015161413681615279565b828d015291830151918983111561414b578c8dfd5b6141598f8d8587010161370e565b908201528652505092870192908701906001016140ef565b60006020808385031215614183578182fd5b82516001600160401b03811115614198578283fd5b8301601f810185136141a8578283fd5b80516141b661372c8261520b565b81815283810190838501858402850186018910156141d2578687fd5b8694505b838510156141f45780518352600194909401939185019185016141d6565b50979650505050505050565b600060208284031215614211578081fd5b81518015158114610f9f578182fd5b600060208284031215614231578081fd5b8151610f9f81615279565b600080600060608486031215613919578081fd5b600060208284031215614261578081fd5b81356001600160401b03811115614276578182fd5b611bc2848285016137c2565b600080600080600080600060e0888a03121561429c578485fd5b87356001600160401b038111156142b1578586fd5b6142bd8a828b016137c2565b97505060208801356142ce81615279565b95506142dd8960408a01613856565b945060608801356142ed81615279565b9699959850939660808101359560a0820135955060c0909101359350915050565b60006020828403121561431f578081fd5b81516001600160401b0380821115614335578283fd5b9083019060a08286031215614348578283fd5b61435260a06151e5565b61435c8684613703565b815261436b8660208501613703565b60208201526040830151604082015260608301516060820152608083015182811115614395578485fd5b6143a187828601613810565b60808301525095945050505050565b6000608082840312156143c1578081fd5b6143cb60806151e5565b82356143d68161528e565b815260208301356143e681615279565b602082015260408301356143f98161529b565b6040820152606083013561440c8161529b565b60608201529392505050565b600060808284031215614429578081fd5b61443360806151e5565b825161443e8161528e565b8152602083015161444e81615279565b602082015260408301516144618161529b565b6040820152606083015161440c8161529b565b600060208284031215614485578081fd5b5051919050565b6000806040838503121561449e578182fd5b8251915060208301516144b081615279565b809150509250929050565b600080604083850312156144cd578182fd5b825191506020808401516001600160401b038111156144ea578283fd5b8401601f810186136144fa578283fd5b805161450861372c8261520b565b81815283810190838501858402850186018a1015614524578687fd5b8694505b83851015613b945761453a8a826137b2565b835260019490940193918501918501614528565b6000815180845260208085019450808401835b838110156145935781518051151588528301516001600160a01b03168388015260409096019590820190600101614561565b509495945050505050565b6000815180845260208085019450808401835b83811015614593578151875295820195908201906001016145b1565b600081518084526145e581602086016020860161524d565b601f01601f19169290920160200192915050565b805182526020908101516001600160a01b0316910152565b600060018060a01b03808351168452806020840151166020850152506040820151604084015260608201516060840152608082015160a06080850152611bc260a08501826145cd565b6000825161466c81846020870161524d565b9190910192915050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0386811682528581166020830152604082018590528316606082015260a060808201819052600090612ae5908301846145cd565b6001600160a01b0383168152604060208201819052600090611bc29083018461459e565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039485168152602081019390935292166040820152606081019190915260800190565b6001600160a01b0397881681526020810196909652939095166040850152606084019190915260ff16608083015260a082019290925260c081019190915260e00190565b6001600160a01b0398891681526020810197909752949096166040860152606085019290925260ff90811660808501521660a083015260c082019290925260e08101919091526101000190565b6001600160a01b03939093168352602083019190915260ff16604082015260600190565b6001600160a01b0394909416845260ff928316602085015291166040830152606082015260800190565b6020808252825182820181905260009190848201906040850190845b8181101561488d5783516001600160a01b031683529284019291840191600101614868565b50909695505050505050565b60208082528251828201819052600091906040908185019080840286018301878501865b83811015613e5757888303603f19018552815180518785526148e1888601826145cd565b918901516001600160a01b031694890194909452948701949250908601906001016148bd565b60408082528351828201819052600091906020906060850190828801855b82811015614948576149388483516145f9565b9285019290840190600101614925565b5050506001600160a01b0395909516930192909252509092915050565b600060208252610f9f602083018461454e565b60208082528251828201819052600091906040908185019080840286018301878501865b83811015613e5757888303603f19018552815180516001600160a01b03908116855288820151168885015286015160608785018190526149de8186018361454e565b96890196945050509086019060010161499c565b60208082528251828201819052600091906040908185019080840286018301878501865b83811015613e5757888303603f190185528151805115158452870151878401879052614a44878501826145cd565b9588019593505090860190600101614a16565b6000602080830181845280855180835260408601915060408482028701019250838701855b82811015614aaa57603f19888603018452614a98858351614611565b94509285019290850190600101614a7c565b5092979650505050505050565b600060208252610f9f602083018461459e565b600060608252614add606083018661459e565b60208301949094525060400152919050565b901515815260200190565b6040810160028410614b0857fe5b9281526001600160a01b039190911660209091015290565b600060208252610f9f60208301846145cd565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252601b908201527f546f6b656e2063616e2774206265207a65726f20616464726573730000000000604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526015908201527453796d626f6c20616c726561647920696e2075736560581b604082015260600190565b60208082526017908201527f556e737570706f72746564206465737420616374696f6e000000000000000000604082015260600190565b6020808252600d908201526c2ab735b737bbb7103a37b5b2b760991b604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b6020808252600a9082015269216d73672e76616c756560b01b604082015260600190565b6020808252600c908201526b10b9bbb0b820b230b83a32b960a11b604082015260600190565b602080825260119082015270627269646765466565203e3d203130302560781b604082015260600190565b6020808252818101527f53776170206469646e277420726573756c7420696e206d696e20746f6b656e73604082015260600190565b6020808252600c908201526b115b5c1d1e481cde5b589bdb60a21b604082015260600190565b60208082526018908201527f21726563697069656e743a207a65726f20616464726573730000000000000000604082015260600190565b60208082526019908201527f5377617020746f6b656e732073686f756c642064696666657200000000000000604082015260600190565b6020808252601e908201527f496e636f727265637420746f6b656e496e20666f722045544820737761700000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b602080825260139082015272151bdad95b881b9bdd081cdd5c1c1bdc9d1959606a1b604082015260600190565b60208082526010908201526f111958591b1a5b99481b9bdd081b595d60821b604082015260600190565b602080825260049082015263042cae8d60e31b604082015260600190565b602080825260139082015272115512081d1c985b9cd9995c8819985a5b1959606a1b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600f908201526e6d696e466565203e206d617846656560881b604082015260600190565b6020808252601a908201527f21726563697069656e743a20726f757465722061646472657373000000000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b602080825260059082015264085c1bdbdb60da1b604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b602080825260099082015268085d1bdad95b93dd5d60ba1b604082015260600190565b6080810161511082866145f9565b6001600160a01b0393909316604082015260600152919050565b600060208252610f9f6020830184614611565b90815260200190565b9182526001600160a01b0316602082015260400190565b93845260ff9290921660208401526040830152606082015260800190565b64ffffffffff9390931683526001600160681b039190911660208301526001600160701b0316604082015260600190565b60ff91909116815260200190565b60ff958616815293909416602084015260408301919091526060820152608081019190915260a00190565b6040518181016001600160401b038111828210171561520357600080fd5b604052919050565b60006001600160401b03821115615220578081fd5b5060209081020190565b60006001600160401b0382111561523f578081fd5b50601f01601f191660200190565b60005b83811015615268578181015183820152602001615250565b83811115610cb75750506000910152565b6001600160a01b038116811461366257600080fd5b6004811061366257600080fd5b60ff8116811461366257600080fdfea26469706673582212202c66d45ebaed00279db776ac2ebe4bafbd1e2d3af18ef691a7bfedc4e0885dd164736f6c634300060c00338be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0000000000000000000000000af41a65f786339e7911f4acdad6bd49426f2dc6b000000000000000000000000b73acb429ba868984c0236bdf940d4fe1e643f27

Deployed Bytecode

0x6080604052600436106102135760003560e01c80637c61e56111610118578063c2288147116100a0578063d62933e21161006f578063d62933e21461065b578063da46098c1461067b578063e80633771461069b578063f2fde38b146106b0578063f8a06888146106d05761021a565b8063c2288147146105d9578063c5c63e65146105ec578063ccc1bbc11461060e578063d38e78881461062e5761021a565b8063a5bc29c2116100e7578063a5bc29c214610537578063a734c44114610557578063a912616914610584578063b5d1cdd4146105b1578063ba7d536e146105c45761021a565b80637c61e561146104a7578063804b3dff146104d45780638da5cb5b146104f45780639a7b5f11146105095761021a565b80634d8644961161019b5780635ff30c0a1161016a5780635ff30c0a1461040e5780636c3824ef146104235780636fcca69b14610443578063715018a614610472578063798af720146104875761021a565b80634d86449614610381578063530d95f6146103a157806358b5b777146103ce5780635fa7b584146103ee5761021a565b806324a98f11116101e257806324a98f11146102d2578063302fee96146102f257806334474c8c146103125780633bc758fd146103345780634aa06652146103545761021a565b8063077e11991461021f5780630ba36121146102555780630e68ec951461028257806310f60034146102b05761021a565b3661021a57005b600080fd5b34801561022b57600080fd5b5061023f61023a366004613f89565b6106f2565b60405161024c9190614a57565b60405180910390f35b34801561026157600080fd5b506102756102703660046138e9565b6108d0565b60405161024c9190614b20565b34801561028e57600080fd5b506102a261029d3660046138e9565b61096b565b60405161024c929190614afa565b3480156102bc57600080fd5b506102d06102cb366004613ba4565b610990565b005b6102e56102e0366004613945565b610a24565b60405161024c919061513d565b3480156102fe57600080fd5b506102d061030d366004613caf565b610c30565b34801561031e57600080fd5b50610327610cbd565b60405161024c9190614679565b34801561034057600080fd5b5061023f61034f366004613a5b565b610ccc565b34801561036057600080fd5b5061037461036f366004613905565b610e57565b60405161024c919061512a565b34801561038d57600080fd5b506102e561039c366004613b00565b610f1c565b3480156103ad57600080fd5b506103c16103bc366004614282565b610fa8565b60405161024c9190614aef565b3480156103da57600080fd5b506102e56103e9366004613bed565b611004565b3480156103fa57600080fd5b506103c16104093660046138e9565b611010565b34801561041a57600080fd5b506102e561105a565b34801561042f57600080fd5b506102d061043e366004613d6f565b61106b565b34801561044f57600080fd5b5061046361045e3660046138e9565b6110e8565b60405161024c9392919061517b565b34801561047e57600080fd5b506102d0611126565b34801561049357600080fd5b506102e56104a2366004613d1f565b6111af565b3480156104b357600080fd5b506104c76104c2366004613bed565b61123f565b60405161024c9190614ab7565b3480156104e057600080fd5b506102d06104ef3660046138e9565b6112c6565b34801561050057600080fd5b50610327611327565b34801561051557600080fd5b506105296105243660046138e9565b611336565b60405161024c929190615146565b34801561054357600080fd5b50610327610552366004614250565b6113c3565b34801561056357600080fd5b50610577610572366004613ddd565b6113e9565b60405161024c91906149f2565b34801561059057600080fd5b506105a461059f3660046138e9565b611500565b60405161024c9190614965565b6102e56105bf3660046139f2565b611585565b3480156105d057600080fd5b506102e5611611565b6102d06105e7366004613c18565b61168e565b3480156105f857600080fd5b50610601611abc565b60405161024c9190614978565b34801561061a57600080fd5b506102e5610629366004613ce9565b611b3d565b34801561063a57600080fd5b5061064e6106493660046138e9565b611bca565b60405161024c9190614899565b34801561066757600080fd5b506102d0610676366004613e65565b611edf565b34801561068757600080fd5b506102d061069636600461423c565b611f7e565b3480156106a757600080fd5b50610327611fd1565b3480156106bc57600080fd5b506102d06106cb3660046138e9565b611ff5565b3480156106dc57600080fd5b506106e56120b5565b60405161024c919061484c565b8151606090806001600160401b038111801561070d57600080fd5b5060405190808252806020026020018201604052801561074757816020015b6107346134eb565b81526020019060019003908161072c5790505b50915060005b818110156108c8576000600486838151811061076557fe5b60200260200101516000015160405161077e919061465a565b908152604051908190036020019020546001600160a01b03169050806107a457506108c0565b60006107c7828885815181106107b657fe5b60200260200101516020015161214d565b9050806107d55750506108c0565b6001600160a01b03821660009081526001602052604090205460ff166107f961352c565b604051806040016040528061080d84612171565b81526001600160a01b0380871660209092019190915260075460405163e6b0000960e01b8152929350169063e6b00009906108509084908c908890600401615102565b60006040518083038186803b15801561086857600080fd5b505afa15801561087c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108a4919081019061430e565b8786815181106108b057fe5b6020026020010181905250505050505b60010161074d565b505092915050565b60036020908152600091825260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156109635780601f1061093857610100808354040283529160200191610963565b820191906000526020600020905b81548152906001019060200180831161094657829003601f168201915b505050505081565b60016020526000908152604090205460ff81169061010090046001600160a01b031682565b6109986121a8565b6001600160a01b03166109a9611327565b6001600160a01b0316146109d85760405162461bcd60e51b81526004016109cf90614eb2565b60405180910390fd5b6001600160a01b03838116600090815260016020526040902054610100900416610a145760405162461bcd60e51b81526004016109cf90614c58565b610a1f8383836121ac565b505050565b6000836001600160a01b0316866001600160a01b03161415610a585760405162461bcd60e51b81526004016109cf90614e03565b610a60613543565b610a6c838501856143b0565b60208101519091506001600160a01b0316151580610a965750600381516003811115610a9457fe5b145b610ab25760405162461bcd60e51b81526004016109cf9061506a565b6001600160a01b03871673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610af457610ae385826001612271565b9650610aef8787612323565b610b12565b3415610b125760405162461bcd60e51b81526004016109cf90614e3a565b846001600160a01b03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610b4757610b4488836000612271565b90505b600382516003811115610b5657fe5b1415610b6457869250610be1565b6020820151610b7d906001600160a01b038a169061239a565b600082516003811115610b8c57fe5b1415610ba957610ba2826020015183898461249b565b9250610be1565b600182516003811115610bb857fe5b1415610bce57610ba282602001518389846125ba565b610bde826020015183898461275c565b92505b6001600160a01b03861673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610c1057610c108184612846565b610c246001600160a01b0387168a856128a8565b50509695505050505050565b610c386121a8565b6001600160a01b0316610c49611327565b6001600160a01b031614610c6f5760405162461bcd60e51b81526004016109cf90614eb2565b6001600160a01b03848116600090815260016020526040902054610100900416610cab5760405162461bcd60e51b81526004016109cf90614c58565b610cb784848484612979565b50505050565b6007546001600160a01b031681565b8151606090806001600160401b0381118015610ce757600080fd5b50604051908082528060200260200182016040528015610d2157816020015b610d0e6134eb565b815260200190600190039081610d065790505b50915060005b81811015610e4e5760006004868381518110610d3f57fe5b6020026020010151604051610d54919061465a565b908152604051908190036020019020546001600160a01b0316905080610d7a5750610e46565b610d8261352c565b6040518060400160405280610d95612a79565b81526001600160a01b03808b1660209092019190915260075460405163e6b0000960e01b8152929350169063e6b0000990610dd890849086908b90600401615102565b60006040518083038186803b158015610df057600080fd5b505afa158015610e04573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e2c919081019061430e565b858481518110610e3857fe5b602002602001018190525050505b600101610d27565b50509392505050565b610e5f6134eb565b610e6761352c565b6040518060400160405280610e7a612a79565b81526001600160a01b0380881660209092019190915260075460405163e6b0000960e01b8152929350169063e6b0000990610ebd90849088908890600401615102565b60006040518083038186803b158015610ed557600080fd5b505afa158015610ee9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f11919081019061430e565b9150505b9392505050565b6007546040516326c3224b60e11b81526000916001600160a01b031690634d86449690610f4f9086908690600401614706565b60206040518083038186803b158015610f6757600080fd5b505afa158015610f7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9f9190614474565b90505b92915050565b6000610fb26121a8565b6001600160a01b0316610fc3611327565b6001600160a01b031614610fe95760405162461bcd60e51b81526004016109cf90614eb2565b610ff888888888888888612a7f565b98975050505050505050565b6000610f9f8383612af0565b600061101a6121a8565b6001600160a01b031661102b611327565b6001600160a01b0316146110515760405162461bcd60e51b81526004016109cf90614eb2565b610fa282612c0a565b60006110666005612d4b565b905090565b6110736121a8565b6001600160a01b0316611084611327565b6001600160a01b0316146110aa5760405162461bcd60e51b81526004016109cf90614eb2565b8060005b81811015610cb7576110df8484838181106110c557fe5b90506020020160208101906110da91906138e9565b612c0a565b506001016110ae565b60026020526000908152604090205464ffffffffff8116906501000000000081046001600160681b031690600160901b90046001600160701b031683565b61112e6121a8565b6001600160a01b031661113f611327565b6001600160a01b0316146111655760405162461bcd60e51b81526004016109cf90614eb2565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6007546040516303cc57b960e51b81526000916001600160a01b03169063798af720906111e6908890889088908890600401614822565b60206040518083038186803b1580156111fe57600080fd5b505afa158015611212573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112369190614474565b95945050505050565b600754604051637c61e56160e01b81526060916001600160a01b031690637c61e56190611272908690869060040161472a565b60006040518083038186803b15801561128a57600080fd5b505afa15801561129e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f9f9190810190614171565b6112ce6121a8565b6001600160a01b03166112df611327565b6001600160a01b0316146113055760405162461bcd60e51b81526004016109cf90614eb2565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031690565b600754604051639a7b5f1160e01b815260009182916001600160a01b0390911690639a7b5f119061136b908690600401614679565b604080518083038186803b15801561138257600080fd5b505afa158015611396573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ba919061448c565b91509150915091565b80516020818301810180516004825292820191909301209152546001600160a01b031681565b8051606090806001600160401b038111801561140457600080fd5b5060405190808252806020026020018201604052801561143e57816020015b61142b61356c565b8152602001906001900390816114235790505b50915060005b818110156114f957306001600160a01b031684828151811061146257fe5b6020026020010151604051611477919061465a565b600060405180830381855afa9150503d80600081146114b2576040519150601f19603f3d011682016040523d82523d6000602084013e6114b7565b606091505b508483815181106114c457fe5b60200260200101516000018584815181106114db57fe5b60209081029190910181015101919091529015159052600101611444565b5050919050565b60075460405163a912616960e01b81526060916001600160a01b03169063a912616990611531908590600401614679565b60006040518083038186803b15801561154957600080fd5b505afa15801561155d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610fa29190810190614068565b60006001600160a01b0385166115ad5760405162461bcd60e51b81526004016109cf90614dcc565b6001600160a01b0385163014156115d65760405162461bcd60e51b81526004016109cf90614fe9565b6115df82612d56565b6115fb5760405162461bcd60e51b81526004016109cf90614d20565b61160785858585612d65565b9695505050505050565b60075460408051635d3ea9b760e11b815290516000926001600160a01b03169163ba7d536e916004808301926020929190829003018186803b15801561165657600080fd5b505afa15801561166a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110669190614474565b61169782612d56565b156116b2576116a830858585612d65565b90945092506116bd565b6116bd308585612e5e565b6116c561352c565b6001600160a01b038516600090815260016020819052604091829020825180840190935280549091839160ff16908111156116fc57fe5b600181111561170757fe5b815290546001600160a01b03610100909104811660209283015290820151919250166117455760405162461bcd60e51b81526004016109cf90614ee7565b80602001519450611754613543565b61175d83612d56565b1561177d57826080015180602001905181019061177a9190614418565b90505b61178683612d56565b801561179f575060038151600381111561179c57fe5b14155b156119c6576001825160018111156117b357fe5b1415611883576000815160038111156117c857fe5b146117e55760405162461bcd60e51b81526004016109cf90614c21565b6040808201516060808401518684015191870151935163a2a2af0b60e01b81526001600160a01b037f000000000000000000000000af41a65f786339e7911f4acdad6bd49426f2dc6b169463a2a2af0b9461184c948f948f948f948f9493916004016147b1565b600060405180830381600087803b15801561186657600080fd5b505af115801561187a573d6000803e3d6000fd5b505050506119c1565b60008151600381111561189257fe5b14156118ff57604080820151606080840151868401519187015193516341cf6c8560e11b81526001600160a01b037f000000000000000000000000af41a65f786339e7911f4acdad6bd49426f2dc6b169463839ed90a9461184c948f948f948f948f9493916004016147b1565b60028151600381111561190e57fe5b1461192b5760405162461bcd60e51b81526004016109cf90614c21565b6060808201516040808601519286015190516336e712ed60e01b81526001600160a01b037f000000000000000000000000af41a65f786339e7911f4acdad6bd49426f2dc6b16936336e712ed9361198e938e938e938e938e93909260040161476d565b600060405180830381600087803b1580156119a857600080fd5b505af11580156119bc573d6000803e3d6000fd5b505050505b611ab2565b6001825160018111156119d557fe5b1415611a2d57604051632434941d60e21b81526001600160a01b037f000000000000000000000000af41a65f786339e7911f4acdad6bd49426f2dc6b16906390d250749061198e908b908b908b908b90600401614743565b60405163f3f094a160e01b81526001600160a01b037f000000000000000000000000af41a65f786339e7911f4acdad6bd49426f2dc6b169063f3f094a190611a7f908b908b908b908b90600401614743565b600060405180830381600087803b158015611a9957600080fd5b505af1158015611aad573d6000803e3d6000fd5b505050505b5050505050505050565b6007546040805163c5c63e6560e01b815290516060926001600160a01b03169163c5c63e65916004808301926000929190829003018186803b158015611b0157600080fd5b505afa158015611b15573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611066919081019061409a565b60075460405163ccc1bbc160e01b81526000916001600160a01b03169063ccc1bbc190611b72908790879087906004016147fe565b60206040518083038186803b158015611b8a57600080fd5b505afa158015611b9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc29190614474565b949350505050565b60606000611bd661105a565b90506060816001600160401b0381118015611bf057600080fd5b50604051908082528060200260200182016040528015611c2a57816020015b611c1761352c565b815260200190600190039081611c0f5790505b50905060005b82811015611cb9576000611c45600583612ed8565b6001600160a01b038116600090815260016020526040902054909150611c6d9060ff16612171565b838381518110611c7957fe5b6020026020010151600001818152505080838381518110611c9657fe5b6020908102919091018101516001600160a01b0390921691015250600101611c30565b5060075460405163504094e760e11b81526000916060916001600160a01b039091169063a08129ce90611cf29086908a90600401614907565b60006040518083038186803b158015611d0a57600080fd5b505afa158015611d1e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611d4691908101906144bb565b91509150816001600160401b0381118015611d6057600080fd5b50604051908082528060200260200182016040528015611d9a57816020015b611d87613584565b815260200190600190039081611d7f5790505b5094506000915060005b84811015611ed557818181518110611db857fe5b602002602001015115611ecd576000848281518110611dd357fe5b6020908102919091018101518101516001600160a01b0381166000908152600383526040908190208054825160026001831615610100026000190190921691909104601f81018690048602820186019093528281529294509192830182828015611e7e5780601f10611e5357610100808354040283529160200191611e7e565b820191906000526020600020905b815481529060010190602001808311611e6157829003601f168201915b5050505050878581518110611e8f57fe5b60200260200101516000018190525080878581518110611eab57fe5b6020908102919091018101516001600160a01b03909216910152506001909201915b600101611da4565b5050505050919050565b611ee76121a8565b6001600160a01b0316611ef8611327565b6001600160a01b031614611f1e5760405162461bcd60e51b81526004016109cf90614eb2565b805160005b81811015610a1f57611f3361359c565b838281518110611f3f57fe5b60200260200101519050611f7481600001518260200151836060015184608001518560a001518660c001518760e00151612a7f565b5050600101611f23565b611f866121a8565b6001600160a01b0316611f97611327565b6001600160a01b031614611fbd5760405162461bcd60e51b81526004016109cf90614eb2565b610a1f6001600160a01b0384168383612ee4565b7f000000000000000000000000af41a65f786339e7911f4acdad6bd49426f2dc6b81565b611ffd6121a8565b6001600160a01b031661200e611327565b6001600160a01b0316146120345760405162461bcd60e51b81526004016109cf90614eb2565b6001600160a01b03811661205a5760405162461bcd60e51b81526004016109cf90614bac565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b606060006120c161105a565b9050806001600160401b03811180156120d957600080fd5b50604051908082528060200260200182016040528015612103578160200160208202803683370190505b50915060005b818110156121485761211c600582612ed8565b83828151811061212857fe5b6001600160a01b0390921660209283029190910190910152600101612109565b505090565b60008061215a8484612af0565b90508281101561216a5780830391505b5092915050565b60008082600181111561218057fe5b1415612197576121906000612fde565b90506121a3565b610fa260026003612ff6565b919050565b3390565b6001600160a01b038316158015906121cc57506001600160a01b03811615155b6121e85760405162461bcd60e51b81526004016109cf90614b75565b60405180604001604052808360018111156121ff57fe5b81526001600160a01b0380841660209283015285166000908152600191829052604090208251815491929091839160ff1990911690838181111561223f57fe5b02179055506020919091015181546001600160a01b0390911661010002610100600160a81b0319909116179055505050565b600060038351600381111561228257fe5b141561228f575082610f15565b82602001516001600160a01b03166382b86600836122b15784606001516122b7565b84604001515b6040518263ffffffff1660e01b81526004016122d391906151ac565b60206040518083038186803b1580156122eb57600080fd5b505afa1580156122ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc29190614220565b8034146123425760405162461bcd60e51b81526004016109cf90614cfc565b816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561237d57600080fd5b505af1158015612391573d6000803e3d6000fd5b50505050505050565b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156123c457612497565b6001600160a01b0381163014156123da57612497565b604051636eb1769f60e11b81526000906001600160a01b0384169063dd62ed3e9061240b903090869060040161468d565b60206040518083038186803b15801561242357600080fd5b505afa158015612437573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061245b9190614474565b90506000198114610a1f578015612481576124816001600160a01b038416836000612ee4565b610a1f6001600160a01b03841683600019612ee4565b5050565b6000816001600160a01b0316856001600160a01b03166382b8660086606001516040518263ffffffff1660e01b81526004016124d791906151ac565b60206040518083038186803b1580156124ef57600080fd5b505afa158015612503573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125279190614220565b6001600160a01b03161461254d5760405162461bcd60e51b81526004016109cf906150df565b846001600160a01b03166391695586856040015186606001518660006000196040518663ffffffff1660e01b815260040161258c9594939291906151ba565b602060405180830381600087803b1580156125a657600080fd5b505af1158015611212573d6000803e3d6000fd5b600754604051639a7b5f1160e01b8152600091829182916001600160a01b031690639a7b5f11906125ef908a90600401614679565b604080518083038186803b15801561260657600080fd5b505afa15801561261a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263e919061448c565b91509150806001600160a01b0316846001600160a01b0316146126735760405162461bcd60e51b81526004016109cf906150df565b6060826001600160401b038111801561268b57600080fd5b506040519080825280602002602001820160405280156126b5578160200160208202803683370190505b5090508581886040015160ff16815181106126cc57fe5b6020908102919091010152604051634d49e87d60e01b81526001600160a01b03891690634d49e87d9061270a90849060009060001990600401614aca565b602060405180830381600087803b15801561272457600080fd5b505af1158015612738573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff89190614474565b6000816001600160a01b0316856001600160a01b03166382b8660086606001516040518263ffffffff1660e01b815260040161279891906151ac565b60206040518083038186803b1580156127b057600080fd5b505afa1580156127c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127e89190614220565b6001600160a01b03161461280e5760405162461bcd60e51b81526004016109cf906150df565b60608401516040516301f1d0ab60e51b81526001600160a01b03871691633e3a15609161258c9187916000906000199060040161515d565b604051632e1a7d4d60e01b81526001600160a01b03831690632e1a7d4d9061287290849060040161513d565b600060405180830381600087803b15801561288c57600080fd5b505af11580156128a0573d6000803e3d6000fd5b505050505050565b6001600160a01b0382163014156128be57610a1f565b6001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415612965576000826001600160a01b0316826040516128fc90614676565b60006040518083038185875af1925050503d8060008114612939576040519150601f19603f3d011682016040523d82523d6000602084013e61293e565b606091505b505090508061295f5760405162461bcd60e51b81526004016109cf90614f5c565b50610a1f565b610a1f6001600160a01b0384168383613012565b6402540be400831061299d5760405162461bcd60e51b81526004016109cf90614d46565b808211156129bd5760405162461bcd60e51b81526004016109cf90614fc0565b6040805160608101825264ffffffffff94851681526001600160681b0393841660208083019182526001600160701b039485168385019081526001600160a01b0390981660009081526002909152929092209051815492519651909316600160901b0271ffffffffffffffffffffffffffffffffffff96909416650100000000000271ffffffffffffffffffffffffff0000000000199390951664ffffffffff1990921691909117919091169290921792909216919091179055565b60001990565b6000612a9088888888888888613031565b90508015612ae557846001600160a01b0316876001600160a01b03161415612ae557612ae56001600160a01b0388167f000000000000000000000000af41a65f786339e7911f4acdad6bd49426f2dc6b61239a565b979650505050505050565b6001600160a01b03828116600090815260016020526040812054909161010090910416612b2f5760405162461bcd60e51b81526004016109cf90614ee7565b612b376135fe565b506001600160a01b0383166000908152600260209081526040918290208251606081018452905464ffffffffff81168083526501000000000082046001600160681b031693830193909352600160901b90046001600160701b031692810192909252612bb5906402540be40090612baf908690613067565b906130a1565b915080602001516001600160681b0316821015612be15780602001516001600160681b0316915061216a565b80604001516001600160701b031682111561216a57604001516001600160701b03169392505050565b6000612c176005836130d3565b905080156121a3576001600160a01b03821660009081526003602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845260609392830182828015612cbe5780601f10612c9357610100808354040283529160200191612cbe565b820191906000526020600020905b815481529060010190602001808311612ca157829003601f168201915b505050506001600160a01b0385166000908152600360205260408120929350612ce892915061361e565b600481604051612cf8919061465a565b9081526040805191829003602090810190922080546001600160a01b03191690556001600160a01b03851660009081526001835281812080546001600160a81b0319169055600290925281205550919050565b6000610fa2826130e8565b516001600160a01b0316151590565b6000808260600151421115612d8c5760405162461bcd60e51b81526004016109cf90614f14565b8251612d99908686612e5e565b8260200151915082600001516001600160a01b03166324a98f11348888888789608001516040518763ffffffff1660e01b8152600401612ddd9594939291906146cb565b6020604051808303818588803b158015612df657600080fd5b505af1158015612e0a573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612e2f9190614474565b90508260400151811015612e555760405162461bcd60e51b81526004016109cf90614d71565b94509492505050565b34612e7d57612e786001600160a01b0383163385846130ec565b610a1f565b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14612eb95760405162461bcd60e51b81526004016109cf90614f3e565b803414610a1f5760405162461bcd60e51b81526004016109cf90614cfc565b6000610f9f838361310d565b801580612f6c5750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e90612f1a903090869060040161468d565b60206040518083038186803b158015612f3257600080fd5b505afa158015612f46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f6a9190614474565b155b612f885760405162461bcd60e51b81526004016109cf90615089565b610a1f8363095ea7b360e01b8484604051602401612fa792919061472a565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613152565b6000816003811115612fec57fe5b6001901b92915050565b600061300182612fde565b61300a84612fde565b179392505050565b610a1f8363a9059cbb60e01b8484604051602401612fa792919061472a565b600061303e6005886131e1565b90508015612ae55761305088886131f6565b61305b8787876121ac565b612ae587858585612979565b60008261307657506000610fa2565b8282028284828161308357fe5b0414610f9f5760405162461bcd60e51b81526004016109cf90614e71565b60008082116130c25760405162461bcd60e51b81526004016109cf90614cc5565b8183816130cb57fe5b049392505050565b6000610f9f836001600160a01b0384166132bf565b5490565b610cb7846323b872dd60e01b858585604051602401612fa7939291906146a7565b815460009082106131305760405162461bcd60e51b81526004016109cf90614b33565b82600001828154811061313f57fe5b9060005260206000200154905092915050565b60606131a7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166133859092919063ffffffff16565b805190915015610a1f57808060200190518101906131c59190614200565b610a1f5760405162461bcd60e51b81526004016109cf90615020565b6000610f9f836001600160a01b038416613394565b81516132145760405162461bcd60e51b81526004016109cf90614da6565b60006001600160a01b031660048360405161322f919061465a565b908152604051908190036020019020546001600160a01b0316146132655760405162461bcd60e51b81526004016109cf90614bf2565b80600483604051613276919061465a565b908152604080516020928190038301902080546001600160a01b0319166001600160a01b03948516179055918316600090815260038252919091208351610a1f92850190613665565b6000818152600183016020526040812054801561337b57835460001980830191908101906000908790839081106132f257fe5b906000526020600020015490508087600001848154811061330f57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061333f57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610fa2565b6000915050610fa2565b6060611bc284846000856133de565b60006133a08383613494565b6133d657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610fa2565b506000610fa2565b6060824710156134005760405162461bcd60e51b81526004016109cf90614c7f565b613409856134ac565b6134255760405162461bcd60e51b81526004016109cf90614f89565b60006060866001600160a01b03168587604051613442919061465a565b60006040518083038185875af1925050503d806000811461347f576040519150601f19603f3d011682016040523d82523d6000602084013e613484565b606091505b5091509150612ae58282866134b2565b60009081526001919091016020526040902054151590565b3b151590565b606083156134c1575081610f15565b8251156134d15782518084602001fd5b8160405162461bcd60e51b81526004016109cf9190614b20565b6040518060a0016040528060006001600160a01b0316815260200160006001600160a01b031681526020016000815260200160008152602001606081525090565b604080518082019091526000808252602082015290565b604080516080810190915280600081526000602082018190526040820181905260609091015290565b60408051808201909152600081526060602082015290565b60408051808201909152606081526000602082015290565b6040518061010001604052806060815260200160006001600160a01b0316815260200160008152602001600060018111156135d357fe5b815260200160006001600160a01b031681526020016000815260200160008152602001600081525090565b604080516060810182526000808252602082018190529181019190915290565b50805460018160011615610100020316600290046000825580601f106136445750613662565b601f01602090049060005260206000209081019061366291906136e3565b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106136a657805160ff19168380011785556136d3565b828001600101855582156136d3579182015b828111156136d35782518255916020019190600101906136b8565b506136df9291506136e3565b5090565b5b808211156136df57600081556001016136e4565b8035610fa281615279565b8051610fa281615279565b600082601f83011261371e578081fd5b815161373161372c8261520b565b6151e5565b818152915060208083019084810160408085028701830188101561375457600080fd5b6000805b868110156137a55782848b03121561376e578182fd5b613777836151e5565b6137818b866137b2565b815261378f8b878701613703565b8187015286529484019492820192600101613758565b5050505050505092915050565b80518015158114610fa257600080fd5b600082601f8301126137d2578081fd5b81356137e061372c8261522a565b91508082528360208285010111156137f757600080fd5b8060208401602084013760009082016020015292915050565b600082601f830112613820578081fd5b815161382e61372c8261522a565b915080825283602082850101111561384557600080fd5b61216a81602084016020860161524d565b803560028110610fa257600080fd5b600060a08284031215613876578081fd5b61388060a06151e5565b9050813561388d81615279565b8152602082013561389d81615279565b80602083015250604082013560408201526060820135606082015260808201356001600160401b038111156138d157600080fd5b6138dd848285016137c2565b60808301525092915050565b6000602082840312156138fa578081fd5b8135610f9f81615279565b600080600060608486031215613919578182fd5b833561392481615279565b9250602084013561393481615279565b929592945050506040919091013590565b60008060008060008060a0878903121561395d578384fd5b863561396881615279565b9550602087013561397881615279565b945060408701359350606087013561398f81615279565b925060808701356001600160401b03808211156139aa578384fd5b818901915089601f8301126139bd578384fd5b8135818111156139cb578485fd5b8a60208285010111156139dc578485fd5b6020830194508093505050509295509295509295565b60008060008060808587031215613a07578182fd5b8435613a1281615279565b93506020850135613a2281615279565b92506040850135915060608501356001600160401b03811115613a43578182fd5b613a4f87828801613865565b91505092959194509250565b600080600060608486031215613a6f578081fd5b8335613a7a81615279565b92506020848101356001600160401b03811115613a95578283fd5b8501601f81018713613aa5578283fd5b8035613ab361372c8261520b565b81815283810190838501865b84811015613ae857613ad68c8884358901016137c2565b84529286019290860190600101613abf565b50508096505050505050604084013590509250925092565b60008060408385031215613b12578182fd5b8235613b1d81615279565b91506020838101356001600160401b03811115613b38578283fd5b8401601f81018613613b48578283fd5b8035613b5661372c8261520b565b81815283810190838501858402850186018a1015613b72578687fd5b8694505b83851015613b94578035835260019490940193918501918501613b76565b5080955050505050509250929050565b600080600060608486031215613bb8578081fd5b8335613bc381615279565b9250613bd28560208601613856565b91506040840135613be281615279565b809150509250925092565b60008060408385031215613bff578182fd5b8235613c0a81615279565b946020939093013593505050565b60008060008060008060c08789031215613c30578384fd5b8635613c3b81615279565b9550602087013594506040870135613c5281615279565b93506060870135925060808701356001600160401b0380821115613c74578384fd5b613c808a838b01613865565b935060a0890135915080821115613c95578283fd5b50613ca289828a01613865565b9150509295509295509295565b60008060008060808587031215613cc4578182fd5b8435613ccf81615279565b966020860135965060408601359560600135945092505050565b600080600060608486031215613cfd578081fd5b8335613d0881615279565b9250602084013591506040840135613be28161529b565b60008060008060808587031215613d34578182fd5b8435613d3f81615279565b93506020850135613d4f8161529b565b92506040850135613d5f8161529b565b9396929550929360600135925050565b60008060208385031215613d81578182fd5b82356001600160401b0380821115613d97578384fd5b818501915085601f830112613daa578384fd5b813581811115613db8578485fd5b8660208083028501011115613dcb578485fd5b60209290920196919550909350505050565b60006020808385031215613def578182fd5b82356001600160401b03811115613e04578283fd5b8301601f81018513613e14578283fd5b8035613e2261372c8261520b565b81815283810190838501865b84811015613e5757613e458a8884358901016137c2565b84529286019290860190600101613e2e565b509098975050505050505050565b60006020808385031215613e77578182fd5b82356001600160401b0380821115613e8d578384fd5b818501915085601f830112613ea0578384fd5b8135613eae61372c8261520b565b81815284810190848601875b84811015613f7a578135870161010080601f19838f03011215613edb578a8bfd5b613ee4816151e5565b8a83013589811115613ef4578c8dfd5b613f028f8d838701016137c2565b825250613f128e604085016136f8565b8b8201526060808401356040830152613f2e8f60808601613856565b9082015260a0613f408f8583016136f8565b608083015260c0848101359183019190915260e0808501359183019190915291909201359082015284529287019290870190600101613eba565b50909998505050505050505050565b60008060408385031215613f9b578182fd5b82356001600160401b0380821115613fb1578384fd5b818501915085601f830112613fc4578384fd5b8135613fd261372c8261520b565b81815260208082019190858101885b8581101561404857813588016040818e03601f19011215614000578a8bfd5b61400a60406151e5565b848201358981111561401a578c8dfd5b6140288f87838601016137c2565b825250604091909101358482015285529382019390820190600101613fe1565b50508197506140598a828b016136f8565b96505050505050509250929050565b600060208284031215614079578081fd5b81516001600160401b0381111561408e578182fd5b611bc28482850161370e565b600060208083850312156140ac578182fd5b82516001600160401b03808211156140c2578384fd5b818501915085601f8301126140d5578384fd5b81516140e361372c8261520b565b81815284810190848601875b84811015613f7a5781518701606080601f19838f0301121561410f578a8bfd5b614118816151e5565b8a83015161412581615279565b815260408381015161413681615279565b828d015291830151918983111561414b578c8dfd5b6141598f8d8587010161370e565b908201528652505092870192908701906001016140ef565b60006020808385031215614183578182fd5b82516001600160401b03811115614198578283fd5b8301601f810185136141a8578283fd5b80516141b661372c8261520b565b81815283810190838501858402850186018910156141d2578687fd5b8694505b838510156141f45780518352600194909401939185019185016141d6565b50979650505050505050565b600060208284031215614211578081fd5b81518015158114610f9f578182fd5b600060208284031215614231578081fd5b8151610f9f81615279565b600080600060608486031215613919578081fd5b600060208284031215614261578081fd5b81356001600160401b03811115614276578182fd5b611bc2848285016137c2565b600080600080600080600060e0888a03121561429c578485fd5b87356001600160401b038111156142b1578586fd5b6142bd8a828b016137c2565b97505060208801356142ce81615279565b95506142dd8960408a01613856565b945060608801356142ed81615279565b9699959850939660808101359560a0820135955060c0909101359350915050565b60006020828403121561431f578081fd5b81516001600160401b0380821115614335578283fd5b9083019060a08286031215614348578283fd5b61435260a06151e5565b61435c8684613703565b815261436b8660208501613703565b60208201526040830151604082015260608301516060820152608083015182811115614395578485fd5b6143a187828601613810565b60808301525095945050505050565b6000608082840312156143c1578081fd5b6143cb60806151e5565b82356143d68161528e565b815260208301356143e681615279565b602082015260408301356143f98161529b565b6040820152606083013561440c8161529b565b60608201529392505050565b600060808284031215614429578081fd5b61443360806151e5565b825161443e8161528e565b8152602083015161444e81615279565b602082015260408301516144618161529b565b6040820152606083015161440c8161529b565b600060208284031215614485578081fd5b5051919050565b6000806040838503121561449e578182fd5b8251915060208301516144b081615279565b809150509250929050565b600080604083850312156144cd578182fd5b825191506020808401516001600160401b038111156144ea578283fd5b8401601f810186136144fa578283fd5b805161450861372c8261520b565b81815283810190838501858402850186018a1015614524578687fd5b8694505b83851015613b945761453a8a826137b2565b835260019490940193918501918501614528565b6000815180845260208085019450808401835b838110156145935781518051151588528301516001600160a01b03168388015260409096019590820190600101614561565b509495945050505050565b6000815180845260208085019450808401835b83811015614593578151875295820195908201906001016145b1565b600081518084526145e581602086016020860161524d565b601f01601f19169290920160200192915050565b805182526020908101516001600160a01b0316910152565b600060018060a01b03808351168452806020840151166020850152506040820151604084015260608201516060840152608082015160a06080850152611bc260a08501826145cd565b6000825161466c81846020870161524d565b9190910192915050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0386811682528581166020830152604082018590528316606082015260a060808201819052600090612ae5908301846145cd565b6001600160a01b0383168152604060208201819052600090611bc29083018461459e565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039485168152602081019390935292166040820152606081019190915260800190565b6001600160a01b0397881681526020810196909652939095166040850152606084019190915260ff16608083015260a082019290925260c081019190915260e00190565b6001600160a01b0398891681526020810197909752949096166040860152606085019290925260ff90811660808501521660a083015260c082019290925260e08101919091526101000190565b6001600160a01b03939093168352602083019190915260ff16604082015260600190565b6001600160a01b0394909416845260ff928316602085015291166040830152606082015260800190565b6020808252825182820181905260009190848201906040850190845b8181101561488d5783516001600160a01b031683529284019291840191600101614868565b50909695505050505050565b60208082528251828201819052600091906040908185019080840286018301878501865b83811015613e5757888303603f19018552815180518785526148e1888601826145cd565b918901516001600160a01b031694890194909452948701949250908601906001016148bd565b60408082528351828201819052600091906020906060850190828801855b82811015614948576149388483516145f9565b9285019290840190600101614925565b5050506001600160a01b0395909516930192909252509092915050565b600060208252610f9f602083018461454e565b60208082528251828201819052600091906040908185019080840286018301878501865b83811015613e5757888303603f19018552815180516001600160a01b03908116855288820151168885015286015160608785018190526149de8186018361454e565b96890196945050509086019060010161499c565b60208082528251828201819052600091906040908185019080840286018301878501865b83811015613e5757888303603f190185528151805115158452870151878401879052614a44878501826145cd565b9588019593505090860190600101614a16565b6000602080830181845280855180835260408601915060408482028701019250838701855b82811015614aaa57603f19888603018452614a98858351614611565b94509285019290850190600101614a7c565b5092979650505050505050565b600060208252610f9f602083018461459e565b600060608252614add606083018661459e565b60208301949094525060400152919050565b901515815260200190565b6040810160028410614b0857fe5b9281526001600160a01b039190911660209091015290565b600060208252610f9f60208301846145cd565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252601b908201527f546f6b656e2063616e2774206265207a65726f20616464726573730000000000604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526015908201527453796d626f6c20616c726561647920696e2075736560581b604082015260600190565b60208082526017908201527f556e737570706f72746564206465737420616374696f6e000000000000000000604082015260600190565b6020808252600d908201526c2ab735b737bbb7103a37b5b2b760991b604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b6020808252600a9082015269216d73672e76616c756560b01b604082015260600190565b6020808252600c908201526b10b9bbb0b820b230b83a32b960a11b604082015260600190565b602080825260119082015270627269646765466565203e3d203130302560781b604082015260600190565b6020808252818101527f53776170206469646e277420726573756c7420696e206d696e20746f6b656e73604082015260600190565b6020808252600c908201526b115b5c1d1e481cde5b589bdb60a21b604082015260600190565b60208082526018908201527f21726563697069656e743a207a65726f20616464726573730000000000000000604082015260600190565b60208082526019908201527f5377617020746f6b656e732073686f756c642064696666657200000000000000604082015260600190565b6020808252601e908201527f496e636f727265637420746f6b656e496e20666f722045544820737761700000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b602080825260139082015272151bdad95b881b9bdd081cdd5c1c1bdc9d1959606a1b604082015260600190565b60208082526010908201526f111958591b1a5b99481b9bdd081b595d60821b604082015260600190565b602080825260049082015263042cae8d60e31b604082015260600190565b602080825260139082015272115512081d1c985b9cd9995c8819985a5b1959606a1b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600f908201526e6d696e466565203e206d617846656560881b604082015260600190565b6020808252601a908201527f21726563697069656e743a20726f757465722061646472657373000000000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b602080825260059082015264085c1bdbdb60da1b604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b602080825260099082015268085d1bdad95b93dd5d60ba1b604082015260600190565b6080810161511082866145f9565b6001600160a01b0393909316604082015260600152919050565b600060208252610f9f6020830184614611565b90815260200190565b9182526001600160a01b0316602082015260400190565b93845260ff9290921660208401526040830152606082015260800190565b64ffffffffff9390931683526001600160681b039190911660208301526001600160701b0316604082015260600190565b60ff91909116815260200190565b60ff958616815293909416602084015260408301919091526060820152608081019190915260a00190565b6040518181016001600160401b038111828210171561520357600080fd5b604052919050565b60006001600160401b03821115615220578081fd5b5060209081020190565b60006001600160401b0382111561523f578081fd5b50601f01601f191660200190565b60005b83811015615268578181015183820152602001615250565b83811115610cb75750506000910152565b6001600160a01b038116811461366257600080fd5b6004811061366257600080fd5b60ff8116811461366257600080fdfea26469706673582212202c66d45ebaed00279db776ac2ebe4bafbd1e2d3af18ef691a7bfedc4e0885dd164736f6c634300060c0033

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

000000000000000000000000af41a65f786339e7911f4acdad6bd49426f2dc6b000000000000000000000000b73acb429ba868984c0236bdf940d4fe1e643f27

-----Decoded View---------------
Arg [0] : _synapseBridge (address): 0xAf41a65F786339e7911F4acDAD6BD49426F2Dc6b
Arg [1] : owner_ (address): 0xb73AcB429Ba868984c0236bdf940D4FE1E643F27

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000af41a65f786339e7911f4acdad6bd49426f2dc6b
Arg [1] : 000000000000000000000000b73acb429ba868984c0236bdf940d4fe1e643f27


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ 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.