ETH Price: $3,990.31 (+2.19%)

Contract

0xe1A6D84604C5B17f5fd1fCcbA4c385A8b9670266
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ConvexLevSwapperFRAXBP

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
default evmVersion
File 1 of 17 : ConvexLevSwapperFRAXBP.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.17;

import "../CurveLevSwapperFRAXBP.sol";

/// @title ConvexLevSwapperFRAXBP
/// @author Angle Labs, Inc.
/// @notice Implements CurveLevSwapperFRAXBP with a Convex staker
contract ConvexLevSwapperFRAXBP is CurveLevSwapperFRAXBP {
    constructor(
        ICoreBorrow _core,
        IUniswapV3Router _uniV3Router,
        address _oneInch,
        IAngleRouterSidechain _angleRouter
    ) CurveLevSwapperFRAXBP(_core, _uniV3Router, _oneInch, _angleRouter) {}

    /// @inheritdoc BaseLevSwapper
    function angleStaker() public pure override returns (IBorrowStaker) {
        return IBorrowStaker(0xC68421f20bf6f0Eb475F00b9C5484f7D0AC0331e);
    }
}

File 2 of 17 : IBorrowStaker.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.7;

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

interface IBorrowStakerCheckpoint {
    function checkpointFromVaultManager(
        address from,
        uint256 amount,
        bool add
    ) external;
}

interface IBorrowStaker is IBorrowStakerCheckpoint, IERC20 {
    function asset() external returns (IERC20 stakingToken);

    function deposit(uint256 amount, address to) external;

    function withdraw(
        uint256 amount,
        address from,
        address to
    ) external;

    //solhint-disable-next-line
    function claim_rewards(address user) external returns (uint256[] memory);
}

File 3 of 17 : IMetaPool2.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.17;

import "./IMetaPoolBase.sol";

uint256 constant N_COINS = 2;

//solhint-disable
interface IMetaPool2 is IMetaPoolBase {
    function coins() external view returns (uint256[N_COINS] memory);

    // for basis pool
    function balances(uint256) external view returns (uint256);

    function get_balances() external view returns (uint256[N_COINS] memory);

    function get_previous_balances() external view returns (uint256[N_COINS] memory);

    function get_price_cumulative_last() external view returns (uint256[N_COINS] memory);

    function get_twap_balances(
        uint256[N_COINS] memory _first_balances,
        uint256[N_COINS] memory _last_balances,
        uint256 _time_elapsed
    ) external view returns (uint256[N_COINS] memory);

    function calc_token_amount(uint256[N_COINS] memory _amounts, bool _is_deposit) external view returns (uint256);

    function calc_token_amount(
        uint256[N_COINS] memory _amounts,
        bool _is_deposit,
        bool _previous
    ) external view returns (uint256);

    function add_liquidity(uint256[N_COINS] memory _amounts, uint256 _min_mint_amount) external returns (uint256);

    function add_liquidity(
        uint256[N_COINS] memory _amounts,
        uint256 _min_mint_amount,
        address _receiver
    ) external returns (uint256);

    function get_dy(
        int128 i,
        int128 j,
        uint256 dx,
        uint256[N_COINS] memory _balances
    ) external view returns (uint256);

    function get_dy_underlying(
        int128 i,
        int128 j,
        uint256 dx,
        uint256[N_COINS] memory _balances
    ) external view returns (uint256);

    function remove_liquidity(uint256 _burn_amount, uint256[N_COINS] memory _min_amounts)
        external
        returns (uint256[N_COINS] memory);

    function remove_liquidity(
        uint256 _burn_amount,
        uint256[N_COINS] memory _min_amounts,
        address _receiver
    ) external returns (uint256[N_COINS] memory);

    function remove_liquidity_imbalance(uint256[N_COINS] memory _amounts, uint256 _max_burn_amount)
        external
        returns (uint256);

    function remove_liquidity_imbalance(
        uint256[N_COINS] memory _amounts,
        uint256 _max_burn_amount,
        address _receiver
    ) external returns (uint256);
}

File 4 of 17 : IMetaPoolBase.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.17;

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

//solhint-disable
interface IMetaPoolBase is IERC20 {
    function admin_fee() external view returns (uint256);

    function A() external view returns (uint256);

    function A_precise() external view returns (uint256);

    function get_virtual_price() external view returns (uint256);

    function get_dy(
        int128 i,
        int128 j,
        uint256 dx
    ) external view returns (uint256);

    function get_dy_underlying(
        int128 i,
        int128 j,
        uint256 dx
    ) external view returns (uint256);

    function exchange(
        int128 i,
        int128 j,
        uint256 dx,
        uint256 min_dy
    ) external returns (uint256);

    function exchange(
        int128 i,
        int128 j,
        uint256 dx,
        uint256 min_dy,
        address _receiver
    ) external returns (uint256);

    function exchange_underlying(
        int128 i,
        int128 j,
        uint256 dx,
        uint256 min_dy
    ) external returns (uint256);

    function exchange_underlying(
        int128 i,
        int128 j,
        uint256 dx,
        uint256 min_dy,
        address _receiver
    ) external returns (uint256);

    function calc_withdraw_one_coin(uint256 _burn_amount, int128 i) external view returns (uint256);

    function calc_withdraw_one_coin(
        uint256 _burn_amount,
        int128 i,
        bool _previous
    ) external view returns (uint256);

    function remove_liquidity_one_coin(
        uint256 _burn_amount,
        int128 i,
        uint256 _min_received
    ) external returns (uint256);

    function remove_liquidity_one_coin(
        uint256 _burn_amount,
        int128 i,
        uint256 _min_received,
        address _receiver
    ) external returns (uint256);

    function admin_balances(uint256 i) external view returns (uint256);

    function withdraw_admin_fees() external;
}

File 5 of 17 : BaseLevSwapper.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.17;

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

import "borrow/interfaces/IAngleRouterSidechain.sol";
import "borrow/interfaces/ICoreBorrow.sol";
import "borrow/interfaces/external/uniswap/IUniswapRouter.sol";
import "../../interfaces/IBorrowStaker.sol";

import "borrow/swapper/Swapper.sol";

/// @title BaseLevSwapper
/// @author Angle Labs, Inc.
/// @notice Swapper contract facilitating interactions with Angle VaultManager contracts, notably
/// liquidation and leverage transactions
/// @dev This base implementation is for tokens like LP tokens which are not natively supported by 1inch
/// and need some wrapping/unwrapping
abstract contract BaseLevSwapper is Swapper {
    using SafeERC20 for IERC20;

    constructor(
        ICoreBorrow _core,
        IUniswapV3Router _uniV3Router,
        address _oneInch,
        IAngleRouterSidechain _angleRouter
    ) Swapper(_core, _uniV3Router, _oneInch, _angleRouter) {
        if (address(angleStaker()) != address(0))
            angleStaker().asset().safeIncreaseAllowance(address(angleStaker()), type(uint256).max);
    }

    // ============================= INTERNAL FUNCTIONS ============================

    /// @inheritdoc Swapper
    /// @param data Encoded data giving specific instruction to the bundle tx
    /// @dev The amountOut is unused so left as 0 in the case of a deleverage transaction
    /// @dev All token transfers must have been done beforehand
    /// @dev This function can support multiple swaps to get a desired token
    function _swapLeverage(bytes memory data) internal override returns (uint256 amountOut) {
        bool leverage;
        address to;
        bytes[] memory oneInchPayloads;
        (leverage, to, data) = abi.decode(data, (bool, address, bytes));
        if (leverage) {
            (oneInchPayloads, data) = abi.decode(data, (bytes[], bytes));
            // After sending all your tokens you have the possibility to swap them through 1inch
            // For instance when borrowing on Angle you receive agEUR, but may want to be LP on
            // the 3Pool, you can then swap 1/3 of the agEUR to USDC, 1/3 to USDT and 1/3 to DAI
            // before providing liquidity
            // These swaps are easy to anticipate as you know how many tokens have been sent when querying the 1inch API
            _multiSwap1inch(oneInchPayloads);
            // Hook to add liquidity to the underlying protocol
            amountOut = _add(data);
            // Deposit into the AngleStaker
            angleStaker().deposit(amountOut, to);
        } else {
            uint256 toUnstake;
            uint256 toRemove;
            IERC20[] memory sweepTokens;
            (toUnstake, toRemove, sweepTokens, oneInchPayloads, data) = abi.decode(
                data,
                (uint256, uint256, IERC20[], bytes[], bytes)
            );
            // Should transfer the token to the contract this will claim the rewards for the current owner of the wrapper
            angleStaker().withdraw(toUnstake, address(this), address(this));
            _remove(toRemove, data);
            // Taking the same example as in the `leverage` side, you can withdraw USDC, DAI and USDT while wanting to
            // to repay a debt in agEUR so you need to do a multiswap.
            // These swaps are not easy to anticipate the amounts received depend on the deleverage action which can be chaotic
            // Very often, it's better to swap a lower bound and then sweep the tokens, even though it's not the most efficient
            // thing to do
            _multiSwap1inch(oneInchPayloads);
            // After the swaps and/or the deleverage we can end up with useless tokens for repaying a debt and therefore let the
            // possibility to send it wherever
            _sweep(sweepTokens, to);
        }
    }

    /// @notice Allows to do an arbitrary number of swaps using 1inch API
    /// @param data Encoded info to execute the swaps from `_swapOn1inch`
    function _multiSwap1inch(bytes[] memory data) internal {
        uint256 dataLength = data.length;
        for (uint256 i; i < dataLength; ++i) {
            (address inToken, uint256 minAmount, bytes memory payload) = abi.decode(data[i], (address, uint256, bytes));
            uint256 amountOut = _swapOn1inch(IERC20(inToken), payload);
            // We check the slippage in this case as `swap()` will only check it for the `outToken`
            if (amountOut < minAmount) revert TooSmallAmountOut();
        }
    }

    /// @notice Sweeps tokens from the contract
    /// @param tokensOut Token to sweep
    /// @param to Address to which tokens should be sent
    function _sweep(IERC20[] memory tokensOut, address to) internal {
        uint256 tokensOutLength = tokensOut.length;
        for (uint256 i; i < tokensOutLength; ++i) {
            uint256 balanceToken = tokensOut[i].balanceOf(address(this));
            if (balanceToken != 0) {
                tokensOut[i].safeTransfer(to, balanceToken);
            }
        }
    }

    // ========================= EXTERNAL VIRTUAL FUNCTIONS ========================

    /// @notice Token used as collateral on the borrow module, which wraps the `true` collateral
    function angleStaker() public view virtual returns (IBorrowStaker);

    // ========================= INTERNAL VIRTUAL FUNCTIONS ========================

    /// @notice Implements the bundle transaction to increase exposure to a token
    /// @param data Encoded data giving specific instruction to the bundle tx
    function _add(bytes memory data) internal virtual returns (uint256 amountOut);

    /// @notice Implements the bundle transaction to decrease exposure to a token
    /// @param toRemove Amount of tokens to remove
    /// @param data Encoded data giving specific instruction to the bundle tx
    function _remove(uint256 toRemove, bytes memory data) internal virtual returns (uint256 amount);
}

File 6 of 17 : CurveLevSwapper2Tokens.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.17;

import "../BaseLevSwapper.sol";
import "../../../interfaces/external/curve/IMetaPool2.sol";

/// @notice All possible removals on Curve
enum CurveRemovalType {
    oneCoin,
    balance,
    imbalance,
    none
}

/// @title CurveLevSwapper2Tokens
/// @author Angle Labs, Inc.
/// @dev Leverage swapper on Curve LP tokens
/// @dev This implementation is for Curve pools with 2 tokens
abstract contract CurveLevSwapper2Tokens is BaseLevSwapper {
    using SafeERC20 for IERC20;

    constructor(
        ICoreBorrow _core,
        IUniswapV3Router _uniV3Router,
        address _oneInch,
        IAngleRouterSidechain _angleRouter
    ) BaseLevSwapper(_core, _uniV3Router, _oneInch, _angleRouter) {
        if (address(metapool()) != address(0)) {
            tokens()[0].safeIncreaseAllowance(address(metapool()), type(uint256).max);
            tokens()[1].safeIncreaseAllowance(address(metapool()), type(uint256).max);
        }
    }

    // =============================== MAIN FUNCTIONS ==============================

    /// @inheritdoc BaseLevSwapper
    function _add(bytes memory) internal override returns (uint256 amountOut) {
        // Instead of doing sweeps at the end just use the full balance to add liquidity
        uint256 amountToken1 = tokens()[0].balanceOf(address(this));
        uint256 amountToken2 = tokens()[1].balanceOf(address(this));
        // Slippage is checked at the very end of the `swap` function
        if (amountToken1 != 0 || amountToken2 != 0) metapool().add_liquidity([amountToken1, amountToken2], 0);
        // Other solution is also to let the user specify how many tokens have been sent + get
        // the return value from `add_liquidity`: it's more gas efficient but adds more verbose
        amountOut = lpToken().balanceOf(address(this));
    }

    /// @inheritdoc BaseLevSwapper
    function _remove(uint256 burnAmount, bytes memory data) internal override returns (uint256 amountOut) {
        CurveRemovalType removalType;
        (removalType, data) = abi.decode(data, (CurveRemovalType, bytes));
        if (removalType == CurveRemovalType.oneCoin) {
            (int128 whichCoin, uint256 minAmountOut) = abi.decode(data, (int128, uint256));
            amountOut = metapool().remove_liquidity_one_coin(burnAmount, whichCoin, minAmountOut);
        } else if (removalType == CurveRemovalType.balance) {
            uint256[2] memory minAmountOuts = abi.decode(data, (uint256[2]));
            minAmountOuts = metapool().remove_liquidity(burnAmount, minAmountOuts);
        } else if (removalType == CurveRemovalType.imbalance) {
            (address to, uint256[2] memory amountOuts) = abi.decode(data, (address, uint256[2]));
            uint256 actualBurnAmount = metapool().remove_liquidity_imbalance(amountOuts, burnAmount);
            // We may have withdrawn more than needed: maybe not optimal because a user may not want to have
            // lp tokens staked. Solution is to do a sweep on all tokens in the `BaseLevSwapper` contract
            if (burnAmount > actualBurnAmount) angleStaker().deposit(burnAmount - actualBurnAmount, to);
        }
    }

    // ============================= VIRTUAL FUNCTIONS =============================

    /// @notice Reference to the native `tokens` of the Curve pool
    function tokens() public pure virtual returns (IERC20[2] memory);

    /// @notice Reference to the Curve Pool contract
    function metapool() public pure virtual returns (IMetaPool2);

    /// @notice Reference to the actual collateral contract
    /// @dev Most of the time this is the same address as the `metapool`
    function lpToken() public pure virtual returns (IERC20);
}

File 7 of 17 : CurveLevSwapperFRAXBP.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.17;

import "../../CurveLevSwapper2Tokens.sol";

/// @title CurveLevSwapperFRAXBP
/// @author Angle Labs, Inc
/// @notice Implements a leverage swapper to gain/reduce exposure to the FRAXBP Curve LP token
contract CurveLevSwapperFRAXBP is CurveLevSwapper2Tokens {
    constructor(
        ICoreBorrow _core,
        IUniswapV3Router _uniV3Router,
        address _oneInch,
        IAngleRouterSidechain _angleRouter
    ) CurveLevSwapper2Tokens(_core, _uniV3Router, _oneInch, _angleRouter) {}

    /// @inheritdoc BaseLevSwapper
    function angleStaker() public view virtual override returns (IBorrowStaker) {
        return IBorrowStaker(address(0));
    }

    /// @inheritdoc CurveLevSwapper2Tokens
    function tokens() public pure override returns (IERC20[2] memory) {
        return [IERC20(0x853d955aCEf822Db058eb8505911ED77F175b99e), IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48)];
    }

    /// @inheritdoc CurveLevSwapper2Tokens
    function metapool() public pure override returns (IMetaPool2) {
        return IMetaPool2(0xDcEF968d416a41Cdac0ED8702fAC8128A64241A2);
    }

    /// @inheritdoc CurveLevSwapper2Tokens
    function lpToken() public pure override returns (IERC20) {
        return IERC20(0x3175Df0976dFA876431C2E9eE6Bc45b65d3473CC);
    }
}

File 8 of 17 : IAngleRouterSidechain.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.12;

/// @notice Action types
enum ActionType {
    transfer,
    wrap,
    wrapNative,
    sweep,
    sweepNative,
    unwrap,
    unwrapNative,
    swapIn,
    swapOut,
    uniswapV3,
    oneInch,
    claimRewards,
    gaugeDeposit,
    borrower
}

/// @notice Data needed to get permits
struct PermitType {
    address token;
    address owner;
    uint256 value;
    uint256 deadline;
    uint8 v;
    bytes32 r;
    bytes32 s;
}

/// @title IAngleRouterSidechain
/// @author Angle Labs, Inc.
/// @notice Interface for the `AngleRouter` contract on other chains
interface IAngleRouterSidechain {
    function mixer(
        PermitType[] memory paramsPermit,
        ActionType[] memory actions,
        bytes[] calldata data
    ) external;
}

File 9 of 17 : ICoreBorrow.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.12;

/// @title ICoreBorrow
/// @author Angle Labs, Inc.
/// @notice Interface for the `CoreBorrow` contract
/// @dev This interface only contains functions of the `CoreBorrow` contract which are called by other contracts
/// of this module
interface ICoreBorrow {
    /// @notice Checks if an address corresponds to a treasury of a stablecoin with a flash loan
    /// module initialized on it
    /// @param treasury Address to check
    /// @return Whether the address has the `FLASHLOANER_TREASURY_ROLE` or not
    function isFlashLoanerTreasury(address treasury) external view returns (bool);

    /// @notice Checks whether an address is governor of the Angle Protocol or not
    /// @param admin Address to check
    /// @return Whether the address has the `GOVERNOR_ROLE` or not
    function isGovernor(address admin) external view returns (bool);

    /// @notice Checks whether an address is governor or a guardian of the Angle Protocol or not
    /// @param admin Address to check
    /// @return Whether the address has the `GUARDIAN_ROLE` or not
    /// @dev Governance should make sure when adding a governor to also give this governor the guardian
    /// role by calling the `addGovernor` function
    function isGovernorOrGuardian(address admin) external view returns (bool);
}

File 10 of 17 : ISwapper.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.12;

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

/// @title ISwapper
/// @author Angle Labs, Inc.
/// @notice Interface for Swapper contracts
/// @dev This interface defines the key functions `Swapper` contracts should have when interacting with
/// Angle
interface ISwapper {
    /// @notice Notifies a contract that an address should be given `outToken` from `inToken`
    /// @param inToken Address of the token received
    /// @param outToken Address of the token to obtain
    /// @param outTokenRecipient Address to which the outToken should be sent
    /// @param outTokenOwed Minimum amount of outToken the `outTokenRecipient` address should have at the end of the call
    /// @param inTokenObtained Amount of collateral obtained by a related address prior
    /// to the call to this function
    /// @param data Extra data needed (to encode Uniswap swaps for instance)
    function swap(
        IERC20 inToken,
        IERC20 outToken,
        address outTokenRecipient,
        uint256 outTokenOwed,
        uint256 inTokenObtained,
        bytes calldata data
    ) external;
}

File 11 of 17 : IWStETH.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.12;

/// @title IWStETH
/// @author Angle Labs, Inc.
/// @notice Interface for the `WStETH` contract
/// @dev This interface only contains functions of the `WStETH` which are called by other contracts
/// of this module
interface IWStETH {
    function wrap(uint256 _stETHAmount) external returns (uint256);

    function stETH() external view returns (address);
}

File 12 of 17 : IUniswapRouter.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.12;

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

/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface IUniswapV3Router {
    /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
    /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
    /// @return amountOut The amount of the received token
    function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);
}

/// @title Router for price estimation functionality
/// @notice Functions for getting the price of one token with respect to another using Uniswap V2
/// @dev This interface is only used for non critical elements of the protocol
interface IUniswapV2Router {
    /// @notice Given an input asset amount, returns the maximum output amount of the
    /// other asset (accounting for fees) given reserves.
    /// @param path Addresses of the pools used to get prices
    function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);

    function swapExactTokensForTokens(
        uint256 swapAmount,
        uint256 minExpected,
        address[] calldata path,
        address receiver,
        uint256 swapDeadline
    ) external;
}

File 13 of 17 : Swapper.sol
// SPDX-License-Identifier: GPL-3.0

/*
                  *                                                  █                              
                *****                                               ▓▓▓                             
                  *                                               ▓▓▓▓▓▓▓                         
                                   *            ///.           ▓▓▓▓▓▓▓▓▓▓▓▓▓                       
                                 *****        ////////            ▓▓▓▓▓▓▓                          
                                   *       /////////////            ▓▓▓                             
                     ▓▓                  //////////////////          █         ▓▓                   
                   ▓▓  ▓▓             ///////////////////////                ▓▓   ▓▓                
                ▓▓       ▓▓        ////////////////////////////           ▓▓        ▓▓              
              ▓▓            ▓▓    /////////▓▓▓///////▓▓▓/////////       ▓▓             ▓▓            
           ▓▓                 ,////////////////////////////////////// ▓▓                 ▓▓         
        ▓▓                  //////////////////////////////////////////                     ▓▓      
      ▓▓                  //////////////////////▓▓▓▓/////////////////////                          
                       ,////////////////////////////////////////////////////                        
                    .//////////////////////////////////////////////////////////                     
                     .//////////////////////////██.,//////////////////////////█                     
                       .//////////////////////████..,./////////////////////██                       
                        ...////////////////███████.....,.////////////////███                        
                          ,.,////////////████████ ........,///////////████                          
                            .,.,//////█████████      ,.......///////████                            
                               ,..//████████           ........./████                               
                                 ..,██████                .....,███                                 
                                    .██                     ,.,█                                    
                                                                                                    
                                                                                                    
                                                                                                    
               ▓▓            ▓▓▓▓▓▓▓▓▓▓       ▓▓▓▓▓▓▓▓▓▓        ▓▓               ▓▓▓▓▓▓▓▓▓▓          
             ▓▓▓▓▓▓          ▓▓▓    ▓▓▓       ▓▓▓               ▓▓               ▓▓   ▓▓▓▓         
           ▓▓▓    ▓▓▓        ▓▓▓    ▓▓▓       ▓▓▓    ▓▓▓        ▓▓               ▓▓▓▓▓             
          ▓▓▓        ▓▓      ▓▓▓    ▓▓▓       ▓▓▓▓▓▓▓▓▓▓        ▓▓▓▓▓▓▓▓▓▓       ▓▓▓▓▓▓▓▓▓▓          
*/

pragma solidity ^0.8.12;

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

import "../interfaces/IAngleRouterSidechain.sol";
import "../interfaces/ICoreBorrow.sol";
import "../interfaces/ISwapper.sol";
import "../interfaces/external/lido/IWStETH.sol";
import "../interfaces/external/uniswap/IUniswapRouter.sol";

// ==================================== ENUM ===================================

/// @notice All possible swaps
enum SwapType {
    UniswapV3,
    oneInch,
    AngleRouter,
    Leverage,
    None
}

/// @title Swapper
/// @author Angle Labs, Inc.
/// @notice Swapper contract facilitating interactions with Angle VaultManager contracts, notably
/// liquidation and leverage transactions
contract Swapper is ISwapper {
    using SafeERC20 for IERC20;

    // ===================== CONSTANTS AND IMMUTABLE VARIABLES =====================

    /// @notice Reference to the `CoreBorrow` contract of the module which handles all AccessControl logic
    ICoreBorrow public immutable core;
    /// @notice Uniswap Router contract
    IUniswapV3Router public immutable uniV3Router;
    /// @notice 1inch Router
    address public immutable oneInch;
    /// @notice AngleRouter
    IAngleRouterSidechain public immutable angleRouter;

    // =================================== ERRORS ==================================

    error EmptyReturnMessage();
    error IncompatibleLengths();
    error NotGovernorOrGuardian();
    error TooSmallAmountOut();
    error ZeroAddress();

    /// @notice Constructor of the contract
    /// @param _core Core address
    /// @param _uniV3Router UniswapV3 Router address
    /// @param _oneInch 1inch Router address
    /// @param _angleRouter AngleRouter contract address
    constructor(
        ICoreBorrow _core,
        IUniswapV3Router _uniV3Router,
        address _oneInch,
        IAngleRouterSidechain _angleRouter
    ) {
        if (address(_core) == address(0) || _oneInch == address(0) || address(_angleRouter) == address(0))
            revert ZeroAddress();
        core = _core;
        uniV3Router = _uniV3Router;
        oneInch = _oneInch;
        angleRouter = _angleRouter;
    }

    // ========================= EXTERNAL ACCESS FUNCTIONS =========================

    /// @inheritdoc ISwapper
    /// @dev This function swaps the `inToken` to the `outToken` by doing a UniV3 swap, a 1inch swap or by interacting
    /// with the `AngleRouter` contract
    /// @dev One slippage check is performed at the end of the call
    /// @dev In this implementation, the function tries to make sure that the `outTokenRecipient` address has at the end
    /// of the call `outTokenOwed`, leftover tokens are sent to a `to` address which by default is the `outTokenRecipient`
    function swap(
        IERC20 inToken,
        IERC20 outToken,
        address outTokenRecipient,
        uint256 outTokenOwed,
        uint256 inTokenObtained,
        bytes memory data
    ) external {
        // Address to receive the surplus amount of token at the end of the call
        address to;
        // For slippage protection, it is checked at the end of the call
        uint256 minAmountOut;
        // Type of the swap to execute: if `swapType == 4`, then it is optional to swap
        uint256 swapType;
        // We're reusing the `data` variable (it can be `path` on UniswapV3, a payload for 1inch or like encoded actions
        // for a router call)
        (to, minAmountOut, swapType, data) = abi.decode(data, (address, uint256, uint256, bytes));

        to = (to == address(0)) ? outTokenRecipient : to;

        _swap(inToken, inTokenObtained, SwapType(swapType), data);

        // A final slippage check is performed after the swaps
        uint256 outTokenBalance = outToken.balanceOf(address(this));
        if (outTokenBalance < minAmountOut) revert TooSmallAmountOut();

        // The `outTokenRecipient` may already have enough in balance, in which case there's no need to transfer
        // to this address the token and everything can be given to the `to` address
        uint256 outTokenBalanceRecipient = outToken.balanceOf(outTokenRecipient);
        if (outTokenBalanceRecipient >= outTokenOwed || to == outTokenRecipient)
            outToken.safeTransfer(to, outTokenBalance);
        else {
            // The `outTokenRecipient` should receive the delta to make sure its end balance is equal to `outTokenOwed`
            // Any leftover in this case is sent to the `to` address
            // The function reverts if it did not obtain more than `outTokenOwed - outTokenBalanceRecipient` from the swap
            outToken.safeTransfer(outTokenRecipient, outTokenOwed - outTokenBalanceRecipient);
            outToken.safeTransfer(to, outTokenBalanceRecipient + outTokenBalance - outTokenOwed);
        }
        // Reusing the `inTokenObtained` variable for the `inToken` balance
        // Sending back the remaining amount of inTokens to the `to` address: it is possible that not the full `inTokenObtained`
        // is swapped to `outToken` if we're using the `1inch` payload
        inTokenObtained = inToken.balanceOf(address(this));
        if (inTokenObtained != 0) inToken.safeTransfer(to, inTokenObtained);
    }

    // ============================ GOVERNANCE FUNCTION ============================

    /// @notice Changes allowances of this contract for different tokens
    /// @param tokens Addresses of the tokens to allow
    /// @param spenders Addresses to allow transfer
    /// @param amounts Amounts to allow
    function changeAllowance(
        IERC20[] calldata tokens,
        address[] calldata spenders,
        uint256[] calldata amounts
    ) external {
        if (!core.isGovernorOrGuardian(msg.sender)) revert NotGovernorOrGuardian();
        uint256 tokensLength = tokens.length;
        if (tokensLength != spenders.length || tokensLength != amounts.length) revert IncompatibleLengths();
        for (uint256 i; i < tokensLength; ++i) {
            _changeAllowance(tokens[i], spenders[i], amounts[i]);
        }
    }

    // ========================= INTERNAL UTILITY FUNCTIONS ========================

    /// @notice Internal version of the `_changeAllowance` function
    function _changeAllowance(
        IERC20 token,
        address spender,
        uint256 amount
    ) internal {
        uint256 currentAllowance = token.allowance(address(this), spender);
        if (currentAllowance < amount) {
            token.safeIncreaseAllowance(spender, amount - currentAllowance);
        } else if (currentAllowance > amount) {
            token.safeDecreaseAllowance(spender, currentAllowance - amount);
        }
    }

    /// @notice Checks the allowance for a contract and updates it to the max if it is not big enough
    /// @param token Token for which allowance should be checked
    /// @param spender Address to grant allowance to
    /// @param amount Minimum amount of tokens needed for the allowance
    function _checkAllowance(
        IERC20 token,
        address spender,
        uint256 amount
    ) internal {
        uint256 currentAllowance = token.allowance(address(this), spender);
        if (currentAllowance < amount) token.safeIncreaseAllowance(spender, type(uint256).max - currentAllowance);
    }

    /// @notice Performs a swap using either Uniswap, 1inch. This function can also stake stETH to wstETH
    /// @param inToken Token to swap
    /// @param amount Amount of tokens to swap
    /// @param swapType Type of the swap to perform
    /// @param args Extra args for the swap: in the case of Uniswap it should be a path, for 1inch it should be
    /// a payload
    /// @dev This function does nothing if `swapType` is None and it simply passes on the `amount` it received
    /// @dev No slippage is specified in the actions given here as a final slippage check is performed
    /// after the call to this function
    function _swap(
        IERC20 inToken,
        uint256 amount,
        SwapType swapType,
        bytes memory args
    ) internal {
        if (swapType == SwapType.UniswapV3) _swapOnUniswapV3(inToken, amount, args);
        else if (swapType == SwapType.oneInch) _swapOn1inch(inToken, args);
        else if (swapType == SwapType.AngleRouter) _angleRouterActions(inToken, args);
        else if (swapType == SwapType.Leverage) _swapLeverage(args);
    }

    /// @notice Performs a UniswapV3 swap
    /// @param inToken Token to swap
    /// @param amount Amount of tokens to swap
    /// @param path Path for the UniswapV3 swap: this encodes the out token that is going to be obtained
    /// @dev This function does not check the out token obtained here: if it is wrongly specified, either
    /// the `swap` function could fail or these tokens could stay on the contract
    function _swapOnUniswapV3(
        IERC20 inToken,
        uint256 amount,
        bytes memory path
    ) internal returns (uint256 amountOut) {
        // We need more than `amount` of allowance to the contract
        _checkAllowance(inToken, address(uniV3Router), amount);
        amountOut = uniV3Router.exactInput(ExactInputParams(path, address(this), block.timestamp, amount, 0));
    }

    /// @notice Allows to swap any token to an accepted collateral via 1inch API
    /// @param inToken Token received for the 1inch swap
    /// @param payload Bytes needed for 1inch API
    function _swapOn1inch(IERC20 inToken, bytes memory payload) internal returns (uint256 amountOut) {
        _changeAllowance(inToken, oneInch, type(uint256).max);
        //solhint-disable-next-line
        (bool success, bytes memory result) = oneInch.call(payload);
        if (!success) _revertBytes(result);
        amountOut = abi.decode(result, (uint256));
    }

    /// @notice Performs actions with the router contract of the protocol on the corresponding chain
    /// @param inToken Token concerned by the action and for which
    function _angleRouterActions(IERC20 inToken, bytes memory args) internal {
        (ActionType[] memory actions, bytes[] memory actionData) = abi.decode(args, (ActionType[], bytes[]));
        _changeAllowance(inToken, address(angleRouter), type(uint256).max);
        PermitType[] memory permits;
        angleRouter.mixer(permits, actions, actionData);
    }

    /// @notice Allows to take leverage or deleverage via a specific contract
    /// @param payload Bytes needed for 1inch API
    /// @dev This function is to be implemented if the swapper concerns a token that requires some actions
    /// not supported by 1inch or UniV3
    function _swapLeverage(bytes memory payload) internal virtual returns (uint256 amountOut) {}

    /// @notice Internal function used for error handling
    /// @param errMsg Error message received
    function _revertBytes(bytes memory errMsg) internal pure {
        if (errMsg.length != 0) {
            //solhint-disable-next-line
            assembly {
                revert(add(32, errMsg), mload(errMsg))
            }
        }
        revert EmptyReturnMessage();
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

File 16 of 17 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

        (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");

        (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");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

Settings
{
  "remappings": [
    "@chainlink/=node_modules/@chainlink/",
    "@ensdomains/=lib/borrow-contracts/node_modules/@ensdomains/",
    "@openzeppelin/=node_modules/@openzeppelin/",
    "@uniswap/=lib/borrow-contracts/node_modules/@uniswap/",
    "borrow-contracts/=lib/borrow-contracts/contracts/",
    "borrow/=lib/borrow-contracts/contracts/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 1000000
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract ICoreBorrow","name":"_core","type":"address"},{"internalType":"contract IUniswapV3Router","name":"_uniV3Router","type":"address"},{"internalType":"address","name":"_oneInch","type":"address"},{"internalType":"contract IAngleRouterSidechain","name":"_angleRouter","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"EmptyReturnMessage","type":"error"},{"inputs":[],"name":"IncompatibleLengths","type":"error"},{"inputs":[],"name":"NotGovernorOrGuardian","type":"error"},{"inputs":[],"name":"TooSmallAmountOut","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"angleRouter","outputs":[{"internalType":"contract IAngleRouterSidechain","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"angleStaker","outputs":[{"internalType":"contract IBorrowStaker","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"contract IERC20[]","name":"tokens","type":"address[]"},{"internalType":"address[]","name":"spenders","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"changeAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"core","outputs":[{"internalType":"contract ICoreBorrow","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"metapool","outputs":[{"internalType":"contract IMetaPool2","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"oneInch","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"inToken","type":"address"},{"internalType":"contract IERC20","name":"outToken","type":"address"},{"internalType":"address","name":"outTokenRecipient","type":"address"},{"internalType":"uint256","name":"outTokenOwed","type":"uint256"},{"internalType":"uint256","name":"inTokenObtained","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"swap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tokens","outputs":[{"internalType":"contract IERC20[2]","name":"","type":"address[2]"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"uniV3Router","outputs":[{"internalType":"contract IUniswapV3Router","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6101006040523480156200001257600080fd5b50604051620031fc380380620031fc833981016040819052620000359162000608565b838383838383838383838383838383836001600160a01b03841615806200006357506001600160a01b038216155b806200007657506001600160a01b038116155b15620000955760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b0393841660805291831660a052821660c0521660e0526200016773c68421f20bf6f0eb475f00b9c5484f7d0ac0331e60001973c68421f20bf6f0eb475f00b9c5484f7d0ac0331e6001600160a01b03166338d52e0f6040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000123573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000149919062000670565b6001600160a01b03166200022660201b62000750179092919060201c565b50600092506200018b91505073dcef968d416a41cdac0ed8702fac8128a64241a290565b6001600160a01b0316146200021457620001e673dcef968d416a41cdac0ed8702fac8128a64241a2600019620001c06200030c565b60005b60200201516001600160a01b03166200022660201b62000750179092919060201c565b6200021473dcef968d416a41cdac0ed8702fac8128a64241a26000196200020c6200030c565b6001620001c3565b5050505050505050505050506200076f565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa15801562000278573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029e919062000690565b620002aa9190620006aa565b604080516001600160a01b038616602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b1790915291925062000306918691906200035516565b50505050565b62000316620005d1565b506040805180820190915273853d955acef822db058eb8505911ed77f175b99e815273a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48602082015290565b6000620003b1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166200043c60201b620008d2179092919060201c565b805190915015620004375780806020019051810190620003d29190620006d2565b620004375760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084015b60405180910390fd5b505050565b60606200044d848460008562000457565b90505b9392505050565b606082471015620004ba5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016200042e565b6001600160a01b0385163b620005135760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016200042e565b600080866001600160a01b031685876040516200053191906200071c565b60006040518083038185875af1925050503d806000811462000570576040519150601f19603f3d011682016040523d82523d6000602084013e62000575565b606091505b5090925090506200058882828662000593565b979650505050505050565b60608315620005a457508162000450565b825115620005b55782518084602001fd5b8160405162461bcd60e51b81526004016200042e91906200073a565b60405180604001604052806002906020820280368337509192915050565b6001600160a01b03811681146200060557600080fd5b50565b600080600080608085870312156200061f57600080fd5b84516200062c81620005ef565b60208601519094506200063f81620005ef565b60408601519093506200065281620005ef565b60608601519092506200066581620005ef565b939692955090935050565b6000602082840312156200068357600080fd5b81516200045081620005ef565b600060208284031215620006a357600080fd5b5051919050565b80820180821115620006cc57634e487b7160e01b600052601160045260246000fd5b92915050565b600060208284031215620006e557600080fd5b815180151581146200045057600080fd5b60005b8381101562000713578181015183820152602001620006f9565b50506000910152565b6000825162000730818460208701620006f6565b9190910192915050565b60208152600082518060208401526200075b816040850160208701620006f6565b601f01601f19169190910160400192915050565b60805160a05160c05160e051612a23620007d96000396000818161011901528181610fbd015261104201526000818160c801528181610e9d0152610ee701526000818161014001528181610d970152610e1e0152600081816101f201526105bf0152612a236000f3fe608060405234801561001057600080fd5b50600436106100be5760003560e01c8063990d60d211610076578063a5d4096b1161005b578063a5d4096b146101c5578063b82c4dc1146101da578063f2f4eb26146101ed57600080fd5b8063990d60d2146101965780639d63848a146101b057600080fd5b80635fafa589116100a75780635fafa5891461013b5780635fcbd285146101625780638a971d911461017c57600080fd5b8063045c08d5146100c35780630b6942c214610114575b600080fd5b6100ea7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100ea7f000000000000000000000000000000000000000000000000000000000000000081565b6100ea7f000000000000000000000000000000000000000000000000000000000000000081565b733175df0976dfa876431c2e9ee6bc45b65d3473cc6100ea565b73c68421f20bf6f0eb475f00b9c5484f7d0ac0331e6100ea565b73dcef968d416a41cdac0ed8702fac8128a64241a26100ea565b6101b8610214565b60405161010b9190611d78565b6101d86101d3366004611ea8565b61025b565b005b6101d86101e8366004611fbe565b610591565b6100ea7f000000000000000000000000000000000000000000000000000000000000000081565b61021c611d5a565b506040805180820190915273853d955acef822db058eb8505911ed77f175b99e815273a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48602082015290565b60008060008380602001905181019061027491906120c1565b96509194509250905073ffffffffffffffffffffffffffffffffffffffff83161561029f57826102a1565b865b92506102c089868360048111156102ba576102ba612126565b876108eb565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8a16906370a0823190602401602060405180830381865afa15801561032d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103519190612155565b90508281101561038d576040517fa1aabbe100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8981166004830152600091908b16906370a0823190602401602060405180830381865afa1580156103fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104219190612155565b9050878110158061045d57508873ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b156104885761048373ffffffffffffffffffffffffffffffffffffffff8b168684610989565b6104cd565b6104b489610496838b61219d565b73ffffffffffffffffffffffffffffffffffffffff8d169190610989565b6104cd85896104c385856121b6565b610496919061219d565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa158015610537573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061055b9190612155565b965086156105845761058473ffffffffffffffffffffffffffffffffffffffff8c168689610989565b5050505050505050505050565b6040517f521d4de90000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063521d4de990602401602060405180830381865afa15801561061b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063f91906121de565b610675576040517f99e120bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8483811415806106855750808214155b156106bc576040517f46282e8d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b81811015610746576107368888838181106106dc576106dc6121f9565b90506020020160208101906106f19190612228565b878784818110610703576107036121f9565b90506020020160208101906107189190612228565b86868581811061072a5761072a6121f9565b905060200201356109e4565b61073f81612245565b90506106bf565b5050505050505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa1580156107c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107eb9190612155565b6107f591906121b6565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506108cc9085907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610ae8565b50505050565b60606108e18484600085610bf9565b90505b9392505050565b60008260048111156108ff576108ff612126565b036109155761090f848483610d8f565b506108cc565b600182600481111561092957610929612126565b036109385761090f8482610e95565b600282600481111561094c5761094c612126565b036109605761095b8482610f9c565b6108cc565b600382600481111561097457610974612126565b036108cc57610982816110b4565b5050505050565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526109df9084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161084a565b505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610a5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7e9190612155565b905081811015610ab45761095b83610a96838561219d565b73ffffffffffffffffffffffffffffffffffffffff87169190610750565b818111156108cc576108cc83610aca848461219d565b73ffffffffffffffffffffffffffffffffffffffff8716919061129e565b6000610b4a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166108d29092919063ffffffff16565b8051909150156109df5780806020019051810190610b6891906121de565b6109df576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b606082471015610c8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610bf0565b73ffffffffffffffffffffffffffffffffffffffff85163b610d09576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610bf0565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610d32919061227d565b60006040518083038185875af1925050503d8060008114610d6f576040519150601f19603f3d011682016040523d82523d6000602084013e610d74565b606091505b5091509150610d84828286611424565b979650505050505050565b6000610dbc847f000000000000000000000000000000000000000000000000000000000000000085611477565b6040805160a0810182528381523060208201524281830152606081018590526000608082015290517fc04b8d5900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169163c04b8d5991610e5291906004016122e3565b6020604051808303816000875af1158015610e71573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e19190612155565b6000610ee2837f00000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6109e4565b6000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1684604051610f2a919061227d565b6000604051808303816000865af19150503d8060008114610f67576040519150601f19603f3d011682016040523d82523d6000602084013e610f6c565b606091505b509150915081610f7f57610f7f81611549565b80806020019051810190610f939190612155565b95945050505050565b60008082806020019051810190610fb391906123f8565b91509150611002847f00000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6109e4565b6040517f848c48da00000000000000000000000000000000000000000000000000000000815260609073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063848c48da9061107b90849087908790600401612586565b600060405180830381600087803b15801561109557600080fd5b505af11580156110a9573d6000803e3d6000fd5b505050505050505050565b60008060006060848060200190518101906110cf919061264b565b9650909350915082156111ac57848060200190518101906110f091906126ac565b955090506110fd8161158a565b6111068561162c565b935073c68421f20bf6f0eb475f00b9c5484f7d0ac0331e6040517f6e553f650000000000000000000000000000000000000000000000000000000081526004810186905273ffffffffffffffffffffffffffffffffffffffff84811660248301529190911690636e553f6590604401600060405180830381600087803b15801561118f57600080fd5b505af11580156111a3573d6000803e3d6000fd5b50505050611296565b6000806060878060200190518101906111c59190612706565b9b5096509194509250905073c68421f20bf6f0eb475f00b9c5484f7d0ac0331e6040517fb460af94000000000000000000000000000000000000000000000000000000008152600481018590523060248201819052604482015273ffffffffffffffffffffffffffffffffffffffff919091169063b460af9490606401600060405180830381600087803b15801561125c57600080fd5b505af1158015611270573d6000803e3d6000fd5b5050505061127e82896118d0565b506112888461158a565b6112928186611c42565b5050505b505050919050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015611314573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113389190612155565b9050818110156113ca576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f5361666545524332303a2064656372656173656420616c6c6f77616e6365206260448201527f656c6f77207a65726f00000000000000000000000000000000000000000000006064820152608401610bf0565b60405173ffffffffffffffffffffffffffffffffffffffff8416602482015282820360448201819052906109829086907f095ea7b3000000000000000000000000000000000000000000000000000000009060640161084a565b606083156114335750816108e4565b8251156114435782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf09190612803565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156114ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115119190612155565b9050818110156108cc576108cc83610a96837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61219d565b80511561155857805181602001fd5b6040517f6a8df6a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805160005b818110156109df5760008060008584815181106115ae576115ae6121f9565b60200260200101518060200190518101906115c99190612816565b92509250925060006115db8483610e95565b905082811015611617576040517fa1aabbe100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050508061162590612245565b905061158f565b600080611637610214565b516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa1580156116a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c79190612155565b905060006116d3610214565b602001516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611742573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117669190612155565b90508115158061177557508015155b15611823576040805180820182528381526020810183905290517f0b4c7e4d00000000000000000000000000000000000000000000000000000000815273dcef968d416a41cdac0ed8702fac8128a64241a291630b4c7e4d916117de919060009060040161287d565b6020604051808303816000875af11580156117fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118219190612155565b505b733175df0976dfa876431c2e9ee6bc45b65d3473cc6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91909116906370a0823190602401602060405180830381865afa1580156118a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118c89190612155565b949350505050565b600080828060200190518101906118e79190612898565b9350905060008160038111156118ff576118ff612126565b036119e7576000808480602001905181019061191b91906128e3565b9150915061193a73dcef968d416a41cdac0ed8702fac8128a64241a290565b6040517f1a4d01d200000000000000000000000000000000000000000000000000000000815260048101889052600f84900b60248201526044810183905273ffffffffffffffffffffffffffffffffffffffff9190911690631a4d01d2906064016020604051808303816000875af11580156119ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119de9190612155565b93505050611c3b565b60018160038111156119fb576119fb612126565b03611ab557600083806020019051810190611a169190612987565b6040517f5b36389c00000000000000000000000000000000000000000000000000000000815290915073dcef968d416a41cdac0ed8702fac8128a64241a290635b36389c90611a6b90889085906004016129a3565b60408051808303816000875af1158015611a89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aad9190612987565b905050611c3b565b6002816003811115611ac957611ac9612126565b03611c3b5760008084806020019051810190611ae591906129b7565b915091506000611b0673dcef968d416a41cdac0ed8702fac8128a64241a290565b73ffffffffffffffffffffffffffffffffffffffff1663e310327383896040518363ffffffff1660e01b8152600401611b4092919061287d565b6020604051808303816000875af1158015611b5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b839190612155565b905080871115611c375773c68421f20bf6f0eb475f00b9c5484f7d0ac0331e636e553f65611bb1838a61219d565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b168152600481019190915273ffffffffffffffffffffffffffffffffffffffff86166024820152604401600060405180830381600087803b158015611c1e57600080fd5b505af1158015611c32573d6000803e3d6000fd5b505050505b5050505b5092915050565b815160005b818110156108cc576000848281518110611c6357611c636121f9565b60209081029190910101516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611cd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfd9190612155565b90508015611d4957611d498482878581518110611d1c57611d1c6121f9565b602002602001015173ffffffffffffffffffffffffffffffffffffffff166109899092919063ffffffff16565b50611d5381612245565b9050611c47565b60405180604001604052806002906020820280368337509192915050565b60408101818360005b6002811015611db657815173ffffffffffffffffffffffffffffffffffffffff16835260209283019290910190600101611d81565b50505092915050565b73ffffffffffffffffffffffffffffffffffffffff81168114611de157600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e5a57611e5a611de4565b604052919050565b600067ffffffffffffffff821115611e7c57611e7c611de4565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60008060008060008060c08789031215611ec157600080fd5b8635611ecc81611dbf565b95506020870135611edc81611dbf565b94506040870135611eec81611dbf565b9350606087013592506080870135915060a087013567ffffffffffffffff811115611f1657600080fd5b8701601f81018913611f2757600080fd5b8035611f3a611f3582611e62565b611e13565b8181528a6020838501011115611f4f57600080fd5b816020840160208301376000602083830101528093505050509295509295509295565b60008083601f840112611f8457600080fd5b50813567ffffffffffffffff811115611f9c57600080fd5b6020830191508360208260051b8501011115611fb757600080fd5b9250929050565b60008060008060008060608789031215611fd757600080fd5b863567ffffffffffffffff80821115611fef57600080fd5b611ffb8a838b01611f72565b9098509650602089013591508082111561201457600080fd5b6120208a838b01611f72565b9096509450604089013591508082111561203957600080fd5b5061204689828a01611f72565b979a9699509497509295939492505050565b60005b8381101561207357818101518382015260200161205b565b50506000910152565b600082601f83011261208d57600080fd5b815161209b611f3582611e62565b8181528460208386010111156120b057600080fd5b6118c8826020830160208701612058565b600080600080608085870312156120d757600080fd5b84516120e281611dbf565b809450506020850151925060408501519150606085015167ffffffffffffffff81111561210e57600080fd5b61211a8782880161207c565b91505092959194509250565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60006020828403121561216757600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156121b0576121b061216e565b92915050565b808201808211156121b0576121b061216e565b805180151581146121d957600080fd5b919050565b6000602082840312156121f057600080fd5b6108e4826121c9565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561223a57600080fd5b81356108e481611dbf565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036122765761227661216e565b5060010190565b6000825161228f818460208701612058565b9190910192915050565b600081518084526122b1816020860160208601612058565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000825160a060208401526122ff60c0840182612299565b905073ffffffffffffffffffffffffffffffffffffffff60208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b600067ffffffffffffffff82111561236357612363611de4565b5060051b60200190565b600082601f83011261237e57600080fd5b8151602061238e611f3583612349565b82815260059290921b840181019181810190868411156123ad57600080fd5b8286015b848110156123ed57805167ffffffffffffffff8111156123d15760008081fd5b6123df8986838b010161207c565b8452509183019183016123b1565b509695505050505050565b6000806040838503121561240b57600080fd5b825167ffffffffffffffff8082111561242357600080fd5b818501915085601f83011261243757600080fd5b81516020612447611f3583612349565b82815260059290921b8401810191818101908984111561246657600080fd5b948201945b83861015612492578551600e81106124835760008081fd5b8252948201949082019061246b565b918801519196509093505050808211156124ab57600080fd5b506124b88582860161236d565b9150509250929050565b60008151808452602080850194508084016000805b84811015612528578251600e8110612516577f4e487b710000000000000000000000000000000000000000000000000000000083526021600452602483fd5b885296830196918301916001016124d7565b50959695505050505050565b6000815180845260208085019450848260051b860182860160005b85811015612579578383038952612567838351612299565b9885019892509084019060010161254f565b5090979650505050505050565b6060808252845182820181905260009190608090818501906020808a01865b83811015612617578151805173ffffffffffffffffffffffffffffffffffffffff90811687528482015116848701526040808201519087015287810151888701528681015160ff168787015260a0808201519087015260c0908101519086015260e090940193908201906001016125a5565b5050868303908701525061262b81886124c2565b9250505082810360408401526126418185612534565b9695505050505050565b60008060006060848603121561266057600080fd5b612669846121c9565b9250602084015161267981611dbf565b604085015190925067ffffffffffffffff81111561269657600080fd5b6126a28682870161207c565b9150509250925092565b600080604083850312156126bf57600080fd5b825167ffffffffffffffff808211156126d757600080fd5b6126e38683870161236d565b935060208501519150808211156126f957600080fd5b506124b88582860161207c565b600080600080600060a0868803121561271e57600080fd5b855194506020808701519450604087015167ffffffffffffffff8082111561274557600080fd5b818901915089601f83011261275957600080fd5b8151612767611f3582612349565b81815260059190911b8301840190848101908c83111561278657600080fd5b938501935b828510156127ad57845161279e81611dbf565b8252938501939085019061278b565b60608c015190985094505050808311156127c657600080fd5b6127d28a848b0161236d565b945060808901519250808311156127e857600080fd5b50506127f68882890161207c565b9150509295509295909350565b6020815260006108e46020830184612299565b60008060006060848603121561282b57600080fd5b835161283681611dbf565b60208501516040860151919450925067ffffffffffffffff81111561269657600080fd5b8060005b60028110156108cc57815184526020938401939091019060010161285e565b6060810161288b828561285a565b8260408301529392505050565b600080604083850312156128ab57600080fd5b8251600481106128ba57600080fd5b602084015190925067ffffffffffffffff8111156128d757600080fd5b6124b88582860161207c565b600080604083850312156128f657600080fd5b825180600f0b811461290757600080fd5b6020939093015192949293505050565b600082601f83011261292857600080fd5b6040516040810181811067ffffffffffffffff8211171561294b5761294b611de4565b806040525080604084018581111561296257600080fd5b845b8181101561297c578051835260209283019201612964565b509195945050505050565b60006040828403121561299957600080fd5b6108e48383612917565b828152606081016108e4602083018461285a565b600080606083850312156129ca57600080fd5b82516129d581611dbf565b91506129e48460208501612917565b9050925092905056fea26469706673582212201497da2b8e463378e2771803e68ba33bc1738398db82ff1439532dd53ec6352264736f6c634300081100330000000000000000000000005bc6bef80da563ebf6df6d6913513fa9a7ec89be000000000000000000000000e592427a0aece92de3edee1f18e0157c058615640000000000000000000000001111111254eeb25477b68fb85ed929f73a9605820000000000000000000000004579709627ca36bce92f51ac975746f431890930

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100be5760003560e01c8063990d60d211610076578063a5d4096b1161005b578063a5d4096b146101c5578063b82c4dc1146101da578063f2f4eb26146101ed57600080fd5b8063990d60d2146101965780639d63848a146101b057600080fd5b80635fafa589116100a75780635fafa5891461013b5780635fcbd285146101625780638a971d911461017c57600080fd5b8063045c08d5146100c35780630b6942c214610114575b600080fd5b6100ea7f0000000000000000000000001111111254eeb25477b68fb85ed929f73a96058281565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100ea7f0000000000000000000000004579709627ca36bce92f51ac975746f43189093081565b6100ea7f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156481565b733175df0976dfa876431c2e9ee6bc45b65d3473cc6100ea565b73c68421f20bf6f0eb475f00b9c5484f7d0ac0331e6100ea565b73dcef968d416a41cdac0ed8702fac8128a64241a26100ea565b6101b8610214565b60405161010b9190611d78565b6101d86101d3366004611ea8565b61025b565b005b6101d86101e8366004611fbe565b610591565b6100ea7f0000000000000000000000005bc6bef80da563ebf6df6d6913513fa9a7ec89be81565b61021c611d5a565b506040805180820190915273853d955acef822db058eb8505911ed77f175b99e815273a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48602082015290565b60008060008380602001905181019061027491906120c1565b96509194509250905073ffffffffffffffffffffffffffffffffffffffff83161561029f57826102a1565b865b92506102c089868360048111156102ba576102ba612126565b876108eb565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8a16906370a0823190602401602060405180830381865afa15801561032d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103519190612155565b90508281101561038d576040517fa1aabbe100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8981166004830152600091908b16906370a0823190602401602060405180830381865afa1580156103fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104219190612155565b9050878110158061045d57508873ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b156104885761048373ffffffffffffffffffffffffffffffffffffffff8b168684610989565b6104cd565b6104b489610496838b61219d565b73ffffffffffffffffffffffffffffffffffffffff8d169190610989565b6104cd85896104c385856121b6565b610496919061219d565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa158015610537573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061055b9190612155565b965086156105845761058473ffffffffffffffffffffffffffffffffffffffff8c168689610989565b5050505050505050505050565b6040517f521d4de90000000000000000000000000000000000000000000000000000000081523360048201527f0000000000000000000000005bc6bef80da563ebf6df6d6913513fa9a7ec89be73ffffffffffffffffffffffffffffffffffffffff169063521d4de990602401602060405180830381865afa15801561061b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063f91906121de565b610675576040517f99e120bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8483811415806106855750808214155b156106bc576040517f46282e8d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b81811015610746576107368888838181106106dc576106dc6121f9565b90506020020160208101906106f19190612228565b878784818110610703576107036121f9565b90506020020160208101906107189190612228565b86868581811061072a5761072a6121f9565b905060200201356109e4565b61073f81612245565b90506106bf565b5050505050505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa1580156107c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107eb9190612155565b6107f591906121b6565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506108cc9085907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610ae8565b50505050565b60606108e18484600085610bf9565b90505b9392505050565b60008260048111156108ff576108ff612126565b036109155761090f848483610d8f565b506108cc565b600182600481111561092957610929612126565b036109385761090f8482610e95565b600282600481111561094c5761094c612126565b036109605761095b8482610f9c565b6108cc565b600382600481111561097457610974612126565b036108cc57610982816110b4565b5050505050565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526109df9084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161084a565b505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610a5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7e9190612155565b905081811015610ab45761095b83610a96838561219d565b73ffffffffffffffffffffffffffffffffffffffff87169190610750565b818111156108cc576108cc83610aca848461219d565b73ffffffffffffffffffffffffffffffffffffffff8716919061129e565b6000610b4a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166108d29092919063ffffffff16565b8051909150156109df5780806020019051810190610b6891906121de565b6109df576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b606082471015610c8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610bf0565b73ffffffffffffffffffffffffffffffffffffffff85163b610d09576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610bf0565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610d32919061227d565b60006040518083038185875af1925050503d8060008114610d6f576040519150601f19603f3d011682016040523d82523d6000602084013e610d74565b606091505b5091509150610d84828286611424565b979650505050505050565b6000610dbc847f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156485611477565b6040805160a0810182528381523060208201524281830152606081018590526000608082015290517fc04b8d5900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564169163c04b8d5991610e5291906004016122e3565b6020604051808303816000875af1158015610e71573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e19190612155565b6000610ee2837f0000000000000000000000001111111254eeb25477b68fb85ed929f73a9605827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6109e4565b6000807f0000000000000000000000001111111254eeb25477b68fb85ed929f73a96058273ffffffffffffffffffffffffffffffffffffffff1684604051610f2a919061227d565b6000604051808303816000865af19150503d8060008114610f67576040519150601f19603f3d011682016040523d82523d6000602084013e610f6c565b606091505b509150915081610f7f57610f7f81611549565b80806020019051810190610f939190612155565b95945050505050565b60008082806020019051810190610fb391906123f8565b91509150611002847f0000000000000000000000004579709627ca36bce92f51ac975746f4318909307fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6109e4565b6040517f848c48da00000000000000000000000000000000000000000000000000000000815260609073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000004579709627ca36bce92f51ac975746f431890930169063848c48da9061107b90849087908790600401612586565b600060405180830381600087803b15801561109557600080fd5b505af11580156110a9573d6000803e3d6000fd5b505050505050505050565b60008060006060848060200190518101906110cf919061264b565b9650909350915082156111ac57848060200190518101906110f091906126ac565b955090506110fd8161158a565b6111068561162c565b935073c68421f20bf6f0eb475f00b9c5484f7d0ac0331e6040517f6e553f650000000000000000000000000000000000000000000000000000000081526004810186905273ffffffffffffffffffffffffffffffffffffffff84811660248301529190911690636e553f6590604401600060405180830381600087803b15801561118f57600080fd5b505af11580156111a3573d6000803e3d6000fd5b50505050611296565b6000806060878060200190518101906111c59190612706565b9b5096509194509250905073c68421f20bf6f0eb475f00b9c5484f7d0ac0331e6040517fb460af94000000000000000000000000000000000000000000000000000000008152600481018590523060248201819052604482015273ffffffffffffffffffffffffffffffffffffffff919091169063b460af9490606401600060405180830381600087803b15801561125c57600080fd5b505af1158015611270573d6000803e3d6000fd5b5050505061127e82896118d0565b506112888461158a565b6112928186611c42565b5050505b505050919050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015611314573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113389190612155565b9050818110156113ca576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f5361666545524332303a2064656372656173656420616c6c6f77616e6365206260448201527f656c6f77207a65726f00000000000000000000000000000000000000000000006064820152608401610bf0565b60405173ffffffffffffffffffffffffffffffffffffffff8416602482015282820360448201819052906109829086907f095ea7b3000000000000000000000000000000000000000000000000000000009060640161084a565b606083156114335750816108e4565b8251156114435782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf09190612803565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156114ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115119190612155565b9050818110156108cc576108cc83610a96837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61219d565b80511561155857805181602001fd5b6040517f6a8df6a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805160005b818110156109df5760008060008584815181106115ae576115ae6121f9565b60200260200101518060200190518101906115c99190612816565b92509250925060006115db8483610e95565b905082811015611617576040517fa1aabbe100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050508061162590612245565b905061158f565b600080611637610214565b516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa1580156116a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c79190612155565b905060006116d3610214565b602001516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611742573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117669190612155565b90508115158061177557508015155b15611823576040805180820182528381526020810183905290517f0b4c7e4d00000000000000000000000000000000000000000000000000000000815273dcef968d416a41cdac0ed8702fac8128a64241a291630b4c7e4d916117de919060009060040161287d565b6020604051808303816000875af11580156117fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118219190612155565b505b733175df0976dfa876431c2e9ee6bc45b65d3473cc6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91909116906370a0823190602401602060405180830381865afa1580156118a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118c89190612155565b949350505050565b600080828060200190518101906118e79190612898565b9350905060008160038111156118ff576118ff612126565b036119e7576000808480602001905181019061191b91906128e3565b9150915061193a73dcef968d416a41cdac0ed8702fac8128a64241a290565b6040517f1a4d01d200000000000000000000000000000000000000000000000000000000815260048101889052600f84900b60248201526044810183905273ffffffffffffffffffffffffffffffffffffffff9190911690631a4d01d2906064016020604051808303816000875af11580156119ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119de9190612155565b93505050611c3b565b60018160038111156119fb576119fb612126565b03611ab557600083806020019051810190611a169190612987565b6040517f5b36389c00000000000000000000000000000000000000000000000000000000815290915073dcef968d416a41cdac0ed8702fac8128a64241a290635b36389c90611a6b90889085906004016129a3565b60408051808303816000875af1158015611a89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aad9190612987565b905050611c3b565b6002816003811115611ac957611ac9612126565b03611c3b5760008084806020019051810190611ae591906129b7565b915091506000611b0673dcef968d416a41cdac0ed8702fac8128a64241a290565b73ffffffffffffffffffffffffffffffffffffffff1663e310327383896040518363ffffffff1660e01b8152600401611b4092919061287d565b6020604051808303816000875af1158015611b5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b839190612155565b905080871115611c375773c68421f20bf6f0eb475f00b9c5484f7d0ac0331e636e553f65611bb1838a61219d565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b168152600481019190915273ffffffffffffffffffffffffffffffffffffffff86166024820152604401600060405180830381600087803b158015611c1e57600080fd5b505af1158015611c32573d6000803e3d6000fd5b505050505b5050505b5092915050565b815160005b818110156108cc576000848281518110611c6357611c636121f9565b60209081029190910101516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611cd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfd9190612155565b90508015611d4957611d498482878581518110611d1c57611d1c6121f9565b602002602001015173ffffffffffffffffffffffffffffffffffffffff166109899092919063ffffffff16565b50611d5381612245565b9050611c47565b60405180604001604052806002906020820280368337509192915050565b60408101818360005b6002811015611db657815173ffffffffffffffffffffffffffffffffffffffff16835260209283019290910190600101611d81565b50505092915050565b73ffffffffffffffffffffffffffffffffffffffff81168114611de157600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e5a57611e5a611de4565b604052919050565b600067ffffffffffffffff821115611e7c57611e7c611de4565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60008060008060008060c08789031215611ec157600080fd5b8635611ecc81611dbf565b95506020870135611edc81611dbf565b94506040870135611eec81611dbf565b9350606087013592506080870135915060a087013567ffffffffffffffff811115611f1657600080fd5b8701601f81018913611f2757600080fd5b8035611f3a611f3582611e62565b611e13565b8181528a6020838501011115611f4f57600080fd5b816020840160208301376000602083830101528093505050509295509295509295565b60008083601f840112611f8457600080fd5b50813567ffffffffffffffff811115611f9c57600080fd5b6020830191508360208260051b8501011115611fb757600080fd5b9250929050565b60008060008060008060608789031215611fd757600080fd5b863567ffffffffffffffff80821115611fef57600080fd5b611ffb8a838b01611f72565b9098509650602089013591508082111561201457600080fd5b6120208a838b01611f72565b9096509450604089013591508082111561203957600080fd5b5061204689828a01611f72565b979a9699509497509295939492505050565b60005b8381101561207357818101518382015260200161205b565b50506000910152565b600082601f83011261208d57600080fd5b815161209b611f3582611e62565b8181528460208386010111156120b057600080fd5b6118c8826020830160208701612058565b600080600080608085870312156120d757600080fd5b84516120e281611dbf565b809450506020850151925060408501519150606085015167ffffffffffffffff81111561210e57600080fd5b61211a8782880161207c565b91505092959194509250565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60006020828403121561216757600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156121b0576121b061216e565b92915050565b808201808211156121b0576121b061216e565b805180151581146121d957600080fd5b919050565b6000602082840312156121f057600080fd5b6108e4826121c9565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561223a57600080fd5b81356108e481611dbf565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036122765761227661216e565b5060010190565b6000825161228f818460208701612058565b9190910192915050565b600081518084526122b1816020860160208601612058565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000825160a060208401526122ff60c0840182612299565b905073ffffffffffffffffffffffffffffffffffffffff60208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b600067ffffffffffffffff82111561236357612363611de4565b5060051b60200190565b600082601f83011261237e57600080fd5b8151602061238e611f3583612349565b82815260059290921b840181019181810190868411156123ad57600080fd5b8286015b848110156123ed57805167ffffffffffffffff8111156123d15760008081fd5b6123df8986838b010161207c565b8452509183019183016123b1565b509695505050505050565b6000806040838503121561240b57600080fd5b825167ffffffffffffffff8082111561242357600080fd5b818501915085601f83011261243757600080fd5b81516020612447611f3583612349565b82815260059290921b8401810191818101908984111561246657600080fd5b948201945b83861015612492578551600e81106124835760008081fd5b8252948201949082019061246b565b918801519196509093505050808211156124ab57600080fd5b506124b88582860161236d565b9150509250929050565b60008151808452602080850194508084016000805b84811015612528578251600e8110612516577f4e487b710000000000000000000000000000000000000000000000000000000083526021600452602483fd5b885296830196918301916001016124d7565b50959695505050505050565b6000815180845260208085019450848260051b860182860160005b85811015612579578383038952612567838351612299565b9885019892509084019060010161254f565b5090979650505050505050565b6060808252845182820181905260009190608090818501906020808a01865b83811015612617578151805173ffffffffffffffffffffffffffffffffffffffff90811687528482015116848701526040808201519087015287810151888701528681015160ff168787015260a0808201519087015260c0908101519086015260e090940193908201906001016125a5565b5050868303908701525061262b81886124c2565b9250505082810360408401526126418185612534565b9695505050505050565b60008060006060848603121561266057600080fd5b612669846121c9565b9250602084015161267981611dbf565b604085015190925067ffffffffffffffff81111561269657600080fd5b6126a28682870161207c565b9150509250925092565b600080604083850312156126bf57600080fd5b825167ffffffffffffffff808211156126d757600080fd5b6126e38683870161236d565b935060208501519150808211156126f957600080fd5b506124b88582860161207c565b600080600080600060a0868803121561271e57600080fd5b855194506020808701519450604087015167ffffffffffffffff8082111561274557600080fd5b818901915089601f83011261275957600080fd5b8151612767611f3582612349565b81815260059190911b8301840190848101908c83111561278657600080fd5b938501935b828510156127ad57845161279e81611dbf565b8252938501939085019061278b565b60608c015190985094505050808311156127c657600080fd5b6127d28a848b0161236d565b945060808901519250808311156127e857600080fd5b50506127f68882890161207c565b9150509295509295909350565b6020815260006108e46020830184612299565b60008060006060848603121561282b57600080fd5b835161283681611dbf565b60208501516040860151919450925067ffffffffffffffff81111561269657600080fd5b8060005b60028110156108cc57815184526020938401939091019060010161285e565b6060810161288b828561285a565b8260408301529392505050565b600080604083850312156128ab57600080fd5b8251600481106128ba57600080fd5b602084015190925067ffffffffffffffff8111156128d757600080fd5b6124b88582860161207c565b600080604083850312156128f657600080fd5b825180600f0b811461290757600080fd5b6020939093015192949293505050565b600082601f83011261292857600080fd5b6040516040810181811067ffffffffffffffff8211171561294b5761294b611de4565b806040525080604084018581111561296257600080fd5b845b8181101561297c578051835260209283019201612964565b509195945050505050565b60006040828403121561299957600080fd5b6108e48383612917565b828152606081016108e4602083018461285a565b600080606083850312156129ca57600080fd5b82516129d581611dbf565b91506129e48460208501612917565b9050925092905056fea26469706673582212201497da2b8e463378e2771803e68ba33bc1738398db82ff1439532dd53ec6352264736f6c63430008110033

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

0000000000000000000000005bc6bef80da563ebf6df6d6913513fa9a7ec89be000000000000000000000000e592427a0aece92de3edee1f18e0157c058615640000000000000000000000001111111254eeb25477b68fb85ed929f73a9605820000000000000000000000004579709627ca36bce92f51ac975746f431890930

-----Decoded View---------------
Arg [0] : _core (address): 0x5bc6BEf80DA563EBf6Df6D6913513fa9A7ec89BE
Arg [1] : _uniV3Router (address): 0xE592427A0AEce92De3Edee1F18E0157C05861564
Arg [2] : _oneInch (address): 0x1111111254EEB25477B68fb85Ed929f73A960582
Arg [3] : _angleRouter (address): 0x4579709627CA36BCe92f51ac975746f431890930

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000005bc6bef80da563ebf6df6d6913513fa9a7ec89be
Arg [1] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Arg [2] : 0000000000000000000000001111111254eeb25477b68fb85ed929f73a960582
Arg [3] : 0000000000000000000000004579709627ca36bce92f51ac975746f431890930


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

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.