Contract 0x9201cC18965792808549566e6B06B016d915313A 13

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x498df660200f821177ad97c027ce80925dd0e2d1ecda46dea48d6086cf78f41d0x61010060637765342023-02-23 12:32:37451 days 11 hrs agoAngle Protocol: Deployer IN  Create: ConvexLevSwapper2Pool0 ETH0.001907620.1
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x015fa87d6229ef9d118cb243f4070d89eb4bade6f788f119c4ddcd054359c597695713862023-03-13 23:20:08433 days 44 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x42dc54fb50db556fa6ffba765f1141536d4830ea0 ETH
0x015fa87d6229ef9d118cb243f4070d89eb4bade6f788f119c4ddcd054359c597695713862023-03-13 23:20:08433 days 44 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0x015fa87d6229ef9d118cb243f4070d89eb4bade6f788f119c4ddcd054359c597695713862023-03-13 23:20:08433 days 44 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0x015fa87d6229ef9d118cb243f4070d89eb4bade6f788f119c4ddcd054359c597695713862023-03-13 23:20:08433 days 44 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0x015fa87d6229ef9d118cb243f4070d89eb4bade6f788f119c4ddcd054359c597695713862023-03-13 23:20:08433 days 44 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0x015fa87d6229ef9d118cb243f4070d89eb4bade6f788f119c4ddcd054359c597695713862023-03-13 23:20:08433 days 44 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0x015fa87d6229ef9d118cb243f4070d89eb4bade6f788f119c4ddcd054359c597695713862023-03-13 23:20:08433 days 44 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x42dc54fb50db556fa6ffba765f1141536d4830ea0 ETH
0x015fa87d6229ef9d118cb243f4070d89eb4bade6f788f119c4ddcd054359c597695713862023-03-13 23:20:08433 days 44 mins ago Angle Protocol: Angle Router V2 0x9201cc18965792808549566e6b06b016d915313a0 ETH
0xa434747cfbb9b74004b0e9679686b5e675a603b767243c2488ca901e2e64c3f4695707492023-03-13 23:16:56433 days 47 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x42dc54fb50db556fa6ffba765f1141536d4830ea0 ETH
0xa434747cfbb9b74004b0e9679686b5e675a603b767243c2488ca901e2e64c3f4695707492023-03-13 23:16:56433 days 47 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0xa434747cfbb9b74004b0e9679686b5e675a603b767243c2488ca901e2e64c3f4695707492023-03-13 23:16:56433 days 47 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0xa434747cfbb9b74004b0e9679686b5e675a603b767243c2488ca901e2e64c3f4695707492023-03-13 23:16:56433 days 47 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0xa434747cfbb9b74004b0e9679686b5e675a603b767243c2488ca901e2e64c3f4695707492023-03-13 23:16:56433 days 47 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0xa434747cfbb9b74004b0e9679686b5e675a603b767243c2488ca901e2e64c3f4695707492023-03-13 23:16:56433 days 47 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0xa434747cfbb9b74004b0e9679686b5e675a603b767243c2488ca901e2e64c3f4695707492023-03-13 23:16:56433 days 47 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x42dc54fb50db556fa6ffba765f1141536d4830ea0 ETH
0xa434747cfbb9b74004b0e9679686b5e675a603b767243c2488ca901e2e64c3f4695707492023-03-13 23:16:56433 days 47 mins ago Angle Protocol: Angle Router V2 0x9201cc18965792808549566e6b06b016d915313a0 ETH
0x7243dee61c2926ce4bfad315e6ca7d158ae81e2e115a574070b587675e9470a5695690122023-03-13 23:07:35433 days 57 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x42dc54fb50db556fa6ffba765f1141536d4830ea0 ETH
0x7243dee61c2926ce4bfad315e6ca7d158ae81e2e115a574070b587675e9470a5695690122023-03-13 23:07:35433 days 57 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0x7243dee61c2926ce4bfad315e6ca7d158ae81e2e115a574070b587675e9470a5695690122023-03-13 23:07:35433 days 57 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0x7243dee61c2926ce4bfad315e6ca7d158ae81e2e115a574070b587675e9470a5695690122023-03-13 23:07:35433 days 57 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0x7243dee61c2926ce4bfad315e6ca7d158ae81e2e115a574070b587675e9470a5695690122023-03-13 23:07:35433 days 57 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0x7243dee61c2926ce4bfad315e6ca7d158ae81e2e115a574070b587675e9470a5695690122023-03-13 23:07:35433 days 57 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x7f90122bf0700f9e7e1f688fe926940e8839f3530 ETH
0x7243dee61c2926ce4bfad315e6ca7d158ae81e2e115a574070b587675e9470a5695690122023-03-13 23:07:35433 days 57 mins ago 0x9201cc18965792808549566e6b06b016d915313a 0x42dc54fb50db556fa6ffba765f1141536d4830ea0 ETH
0x7243dee61c2926ce4bfad315e6ca7d158ae81e2e115a574070b587675e9470a5695690122023-03-13 23:07:35433 days 57 mins ago Angle Protocol: Angle Router V2 0x9201cc18965792808549566e6b06b016d915313a0 ETH
0x13613706c90dbdbd8f4bb2bec43d04fc7e04be8b604feffef21e35035ac42468695642162023-03-13 22:42:50433 days 1 hr ago 0x9201cc18965792808549566e6b06b016d915313a 0x42dc54fb50db556fa6ffba765f1141536d4830ea0 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ConvexLevSwapper2Pool

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
default evmVersion
File 1 of 18 : 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 2 of 18 : 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;

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

    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_one_coin(
        uint256 _burn_amount,
        int128 i,
        uint256 _min_received
    ) external;

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

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

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

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

File 3 of 18 : 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;

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

    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,
        address _receiver
    ) external;

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

    function withdraw_admin_fees() external;
}

File 4 of 18 : 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;
}

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

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

/// @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 {
        CurveRemovalType removalType;
        (removalType, data) = abi.decode(data, (CurveRemovalType, bytes));
        if (removalType == CurveRemovalType.oneCoin) {
            (int128 whichCoin, uint256 minAmountOut) = abi.decode(data, (int128, uint256));
            metapool().remove_liquidity_one_coin(burnAmount, whichCoin, minAmountOut);
        } else if (removalType == CurveRemovalType.balance) {
            uint256[2] memory minAmountOuts = abi.decode(data, (uint256[2]));
            metapool().remove_liquidity(burnAmount, minAmountOuts);
        } else if (removalType == CurveRemovalType.imbalance) {
            (address to, uint256[2] memory amountOuts) = abi.decode(data, (address, uint256[2]));
            metapool().remove_liquidity_imbalance(amountOuts, burnAmount);
            uint256 keptAmount = lpToken().balanceOf(address(this));
            // 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 (keptAmount > 0) angleStaker().deposit(keptAmount, 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 6 of 18 : CurveLevSwapper2Pool.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.17;

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

/// @title CurveLevSwapper2Pool
/// @author Angle Labs, Inc
/// @notice Implements a leverage swapper to gain/reduce exposure to the 2Pool Curve LP token
contract CurveLevSwapper2Pool 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(0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8), IERC20(0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9)];
    }

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

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

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

import "../CurveLevSwapper2Pool.sol";

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

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

File 8 of 18 : Enums.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.17;

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

File 9 of 18 : 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 10 of 18 : 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 11 of 18 : 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 12 of 18 : 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 13 of 18 : 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 14 of 18 : 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 15 of 18 : 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 16 of 18 : 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 17 of 18 : 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 18 of 18 : 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/",
    "borrow/=lib/borrow-contracts/contracts/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "eth-gas-reporter/=node_modules/eth-gas-reporter/",
    "forge-std/=lib/forge-std/src/",
    "hardhat-deploy/=node_modules/hardhat-deploy/",
    "hardhat/=node_modules/hardhat/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 1000000
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {}
}

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"}]

6101006040523480156200001257600080fd5b50604051620031f6380380620031f6833981016040819052620000359162000608565b838383838383838383838383838383836001600160a01b03841615806200006357506001600160a01b038216155b806200007657506001600160a01b038116155b15620000955760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b0393841660805291831660a052821660c0521660e052620001677342dc54fb50db556fa6ffba765f1141536d4830ea6000197342dc54fb50db556fa6ffba765f1141536d4830ea6001600160a01b03166338d52e0f6040518163ffffffff1660e01b81526004016020604051808303816000875af115801562000123573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000149919062000670565b6001600160a01b03166200022660201b62000736179092919060201c565b50600092506200018b915050737f90122bf0700f9e7e1f688fe926940e8839f35390565b6001600160a01b0316146200021457620001e6737f90122bf0700f9e7e1f688fe926940e8839f353600019620001c06200030c565b60005b60200201516001600160a01b03166200022660201b62000736179092919060201c565b62000214737f90122bf0700f9e7e1f688fe926940e8839f3536000196200020c6200030c565b6001620001c3565b5050505050505050505050506200076f565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa15801562000278573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029e919062000690565b620002aa9190620006aa565b604080516001600160a01b038616602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b1790915291925062000306918691906200035516565b50505050565b62000316620005d1565b506040805180820190915273ff970a61a04b1ca14834a43f5de4533ebddb5cc8815273fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9602082015290565b6000620003b1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166200043c60201b620008b8179092919060201c565b805190915015620004375780806020019051810190620003d29190620006d2565b620004375760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084015b60405180910390fd5b505050565b60606200044d848460008562000457565b90505b9392505050565b606082471015620004ba5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016200042e565b6001600160a01b0385163b620005135760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016200042e565b600080866001600160a01b031685876040516200053191906200071c565b60006040518083038185875af1925050503d806000811462000570576040519150601f19603f3d011682016040523d82523d6000602084013e62000575565b606091505b5090925090506200058882828662000593565b979650505050505050565b60608315620005a457508162000450565b825115620005b55782518084602001fd5b8160405162461bcd60e51b81526004016200042e91906200073a565b60405180604001604052806002906020820280368337509192915050565b6001600160a01b03811681146200060557600080fd5b50565b600080600080608085870312156200061f57600080fd5b84516200062c81620005ef565b60208601519094506200063f81620005ef565b60408601519093506200065281620005ef565b60608601519092506200066581620005ef565b939692955090935050565b6000602082840312156200068357600080fd5b81516200045081620005ef565b600060208284031215620006a357600080fd5b5051919050565b80820180821115620006cc57634e487b7160e01b600052601160045260246000fd5b92915050565b600060208284031215620006e557600080fd5b815180151581146200045057600080fd5b60005b8381101562000713578181015183820152602001620006f9565b50506000910152565b6000825162000730818460208701620006f6565b9190910192915050565b60208152600082518060208401526200075b816040850160208701620006f6565b601f01601f19169190910160400192915050565b60805160a05160c05160e051612a1d620007d96000396000818161011901528181610fa3015261102801526000818160c801528181610e830152610ecd01526000818161014001528181610d7d0152610e040152600081816101d801526105a50152612a1d6000f3fe608060405234801561001057600080fd5b50600436106100be5760003560e01c8063990d60d211610076578063a5d4096b1161005b578063a5d4096b146101ab578063b82c4dc1146101c0578063f2f4eb26146101d357600080fd5b8063990d60d2146101625780639d63848a1461019657600080fd5b80635fafa589116100a75780635fafa5891461013b5780635fcbd285146101625780638a971d911461017c57600080fd5b8063045c08d5146100c35780630b6942c214610114575b600080fd5b6100ea7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100ea7f000000000000000000000000000000000000000000000000000000000000000081565b6100ea7f000000000000000000000000000000000000000000000000000000000000000081565b737f90122bf0700f9e7e1f688fe926940e8839f3536100ea565b7342dc54fb50db556fa6ffba765f1141536d4830ea6100ea565b61019e6101fa565b60405161010b9190611d72565b6101be6101b9366004611ea2565b610241565b005b6101be6101ce366004611fb8565b610577565b6100ea7f000000000000000000000000000000000000000000000000000000000000000081565b610202611d54565b506040805180820190915273ff970a61a04b1ca14834a43f5de4533ebddb5cc8815273fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9602082015290565b60008060008380602001905181019061025a91906120bb565b96509194509250905073ffffffffffffffffffffffffffffffffffffffff8316156102855782610287565b865b92506102a689868360048111156102a0576102a0612120565b876108d1565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8a16906370a0823190602401602060405180830381865afa158015610313573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610337919061214f565b905082811015610373576040517fa1aabbe100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8981166004830152600091908b16906370a0823190602401602060405180830381865afa1580156103e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610407919061214f565b9050878110158061044357508873ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b1561046e5761046973ffffffffffffffffffffffffffffffffffffffff8b16868461096f565b6104b3565b61049a8961047c838b612197565b73ffffffffffffffffffffffffffffffffffffffff8d16919061096f565b6104b385896104a985856121b0565b61047c9190612197565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801561051d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610541919061214f565b9650861561056a5761056a73ffffffffffffffffffffffffffffffffffffffff8c16868961096f565b5050505050505050505050565b6040517f521d4de90000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063521d4de990602401602060405180830381865afa158015610601573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061062591906121d8565b61065b576040517f99e120bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84838114158061066b5750808214155b156106a2576040517f46282e8d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8181101561072c5761071c8888838181106106c2576106c26121f3565b90506020020160208101906106d79190612222565b8787848181106106e9576106e96121f3565b90506020020160208101906106fe9190612222565b868685818110610710576107106121f3565b905060200201356109ca565b6107258161223f565b90506106a5565b5050505050505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa1580156107ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107d1919061214f565b6107db91906121b0565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506108b29085907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610ace565b50505050565b60606108c78484600085610bdf565b90505b9392505050565b60008260048111156108e5576108e5612120565b036108fb576108f5848483610d75565b506108b2565b600182600481111561090f5761090f612120565b0361091e576108f58482610e7b565b600282600481111561093257610932612120565b03610946576109418482610f82565b6108b2565b600382600481111561095a5761095a612120565b036108b2576109688161109a565b5050505050565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526109c59084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401610830565b505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610a40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a64919061214f565b905081811015610a9a5761094183610a7c8385612197565b73ffffffffffffffffffffffffffffffffffffffff87169190610736565b818111156108b2576108b283610ab08484612197565b73ffffffffffffffffffffffffffffffffffffffff87169190611283565b6000610b30826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166108b89092919063ffffffff16565b8051909150156109c55780806020019051810190610b4e91906121d8565b6109c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b606082471015610c71576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610bd6565b73ffffffffffffffffffffffffffffffffffffffff85163b610cef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610bd6565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610d189190612277565b60006040518083038185875af1925050503d8060008114610d55576040519150601f19603f3d011682016040523d82523d6000602084013e610d5a565b606091505b5091509150610d6a828286611409565b979650505050505050565b6000610da2847f00000000000000000000000000000000000000000000000000000000000000008561145c565b6040805160a0810182528381523060208201524281830152606081018590526000608082015290517fc04b8d5900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169163c04b8d5991610e3891906004016122dd565b6020604051808303816000875af1158015610e57573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c7919061214f565b6000610ec8837f00000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6109ca565b6000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1684604051610f109190612277565b6000604051808303816000865af19150503d8060008114610f4d576040519150601f19603f3d011682016040523d82523d6000602084013e610f52565b606091505b509150915081610f6557610f658161152e565b80806020019051810190610f79919061214f565b95945050505050565b60008082806020019051810190610f9991906123f2565b91509150610fe8847f00000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6109ca565b6040517f848c48da00000000000000000000000000000000000000000000000000000000815260609073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063848c48da9061106190849087908790600401612580565b600060405180830381600087803b15801561107b57600080fd5b505af115801561108f573d6000803e3d6000fd5b505050505050505050565b60008060006060848060200190518101906110b59190612645565b96509093509150821561119257848060200190518101906110d691906126a6565b955090506110e38161156f565b6110ec85611611565b93507342dc54fb50db556fa6ffba765f1141536d4830ea6040517f6e553f650000000000000000000000000000000000000000000000000000000081526004810186905273ffffffffffffffffffffffffffffffffffffffff84811660248301529190911690636e553f6590604401600060405180830381600087803b15801561117557600080fd5b505af1158015611189573d6000803e3d6000fd5b5050505061127b565b6000806060878060200190518101906111ab9190612700565b9b509650919450925090507342dc54fb50db556fa6ffba765f1141536d4830ea6040517fb460af94000000000000000000000000000000000000000000000000000000008152600481018590523060248201819052604482015273ffffffffffffffffffffffffffffffffffffffff919091169063b460af9490606401600060405180830381600087803b15801561124257600080fd5b505af1158015611256573d6000803e3d6000fd5b5050505061126482896118a3565b61126d8461156f565b6112778186611c3c565b5050505b505050919050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156112f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131d919061214f565b9050818110156113af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f5361666545524332303a2064656372656173656420616c6c6f77616e6365206260448201527f656c6f77207a65726f00000000000000000000000000000000000000000000006064820152608401610bd6565b60405173ffffffffffffffffffffffffffffffffffffffff8416602482015282820360448201819052906109689086907f095ea7b30000000000000000000000000000000000000000000000000000000090606401610830565b606083156114185750816108ca565b8251156114285782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd691906127fd565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156114d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f6919061214f565b9050818110156108b2576108b283610a7c837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612197565b80511561153d57805181602001fd5b6040517f6a8df6a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805160005b818110156109c5576000806000858481518110611593576115936121f3565b60200260200101518060200190518101906115ae9190612810565b92509250925060006115c08483610e7b565b9050828110156115fc576040517fa1aabbe100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050508061160a9061223f565b9050611574565b60008061161c6101fa565b516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611688573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ac919061214f565b905060006116b86101fa565b602001516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611727573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174b919061214f565b90508115158061175a57508015155b156117f6576040805180820182528381526020810183905290517f0b4c7e4d000000000000000000000000000000000000000000000000000000008152737f90122bf0700f9e7e1f688fe926940e8839f35391630b4c7e4d916117c39190600090600401612877565b600060405180830381600087803b1580156117dd57600080fd5b505af11580156117f1573d6000803e3d6000fd5b505050505b737f90122bf0700f9e7e1f688fe926940e8839f3536040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91909116906370a0823190602401602060405180830381865afa158015611877573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189b919061214f565b949350505050565b6000818060200190518101906118b99190612892565b9250905060008160038111156118d1576118d1612120565b0361197257600080838060200190518101906118ed91906128dd565b9150915061190c737f90122bf0700f9e7e1f688fe926940e8839f35390565b6040517f1a4d01d200000000000000000000000000000000000000000000000000000000815260048101879052600f84900b60248201526044810183905273ffffffffffffffffffffffffffffffffffffffff9190911690631a4d01d290606401611061565b600181600381111561198657611986612120565b03611a24576000828060200190518101906119a19190612981565b6040517f5b36389c000000000000000000000000000000000000000000000000000000008152909150737f90122bf0700f9e7e1f688fe926940e8839f35390635b36389c906119f6908790859060040161299d565b600060405180830381600087803b158015611a1057600080fd5b505af115801561072c573d6000803e3d6000fd5b6002816003811115611a3857611a38612120565b036109c55760008083806020019051810190611a5491906129b1565b91509150611a73737f90122bf0700f9e7e1f688fe926940e8839f35390565b73ffffffffffffffffffffffffffffffffffffffff1663e310327382876040518363ffffffff1660e01b8152600401611aad929190612877565b600060405180830381600087803b158015611ac757600080fd5b505af1158015611adb573d6000803e3d6000fd5b505050506000611afc737f90122bf0700f9e7e1f688fe926940e8839f35390565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91909116906370a0823190602401602060405180830381865afa158015611b68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b8c919061214f565b90508015611c34577342dc54fb50db556fa6ffba765f1141536d4830ea6040517f6e553f650000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff85811660248301529190911690636e553f6590604401600060405180830381600087803b158015611c1b57600080fd5b505af1158015611c2f573d6000803e3d6000fd5b505050505b505050505050565b815160005b818110156108b2576000848281518110611c5d57611c5d6121f3565b60209081029190910101516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611cd3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf7919061214f565b90508015611d4357611d438482878581518110611d1657611d166121f3565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1661096f9092919063ffffffff16565b50611d4d8161223f565b9050611c41565b60405180604001604052806002906020820280368337509192915050565b60408101818360005b6002811015611db057815173ffffffffffffffffffffffffffffffffffffffff16835260209283019290910190600101611d7b565b50505092915050565b73ffffffffffffffffffffffffffffffffffffffff81168114611ddb57600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e5457611e54611dde565b604052919050565b600067ffffffffffffffff821115611e7657611e76611dde565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60008060008060008060c08789031215611ebb57600080fd5b8635611ec681611db9565b95506020870135611ed681611db9565b94506040870135611ee681611db9565b9350606087013592506080870135915060a087013567ffffffffffffffff811115611f1057600080fd5b8701601f81018913611f2157600080fd5b8035611f34611f2f82611e5c565b611e0d565b8181528a6020838501011115611f4957600080fd5b816020840160208301376000602083830101528093505050509295509295509295565b60008083601f840112611f7e57600080fd5b50813567ffffffffffffffff811115611f9657600080fd5b6020830191508360208260051b8501011115611fb157600080fd5b9250929050565b60008060008060008060608789031215611fd157600080fd5b863567ffffffffffffffff80821115611fe957600080fd5b611ff58a838b01611f6c565b9098509650602089013591508082111561200e57600080fd5b61201a8a838b01611f6c565b9096509450604089013591508082111561203357600080fd5b5061204089828a01611f6c565b979a9699509497509295939492505050565b60005b8381101561206d578181015183820152602001612055565b50506000910152565b600082601f83011261208757600080fd5b8151612095611f2f82611e5c565b8181528460208386010111156120aa57600080fd5b61189b826020830160208701612052565b600080600080608085870312156120d157600080fd5b84516120dc81611db9565b809450506020850151925060408501519150606085015167ffffffffffffffff81111561210857600080fd5b61211487828801612076565b91505092959194509250565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60006020828403121561216157600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156121aa576121aa612168565b92915050565b808201808211156121aa576121aa612168565b805180151581146121d357600080fd5b919050565b6000602082840312156121ea57600080fd5b6108ca826121c3565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561223457600080fd5b81356108ca81611db9565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361227057612270612168565b5060010190565b60008251612289818460208701612052565b9190910192915050565b600081518084526122ab816020860160208601612052565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000825160a060208401526122f960c0840182612293565b905073ffffffffffffffffffffffffffffffffffffffff60208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b600067ffffffffffffffff82111561235d5761235d611dde565b5060051b60200190565b600082601f83011261237857600080fd5b81516020612388611f2f83612343565b82815260059290921b840181019181810190868411156123a757600080fd5b8286015b848110156123e757805167ffffffffffffffff8111156123cb5760008081fd5b6123d98986838b0101612076565b8452509183019183016123ab565b509695505050505050565b6000806040838503121561240557600080fd5b825167ffffffffffffffff8082111561241d57600080fd5b818501915085601f83011261243157600080fd5b81516020612441611f2f83612343565b82815260059290921b8401810191818101908984111561246057600080fd5b948201945b8386101561248c578551600e811061247d5760008081fd5b82529482019490820190612465565b918801519196509093505050808211156124a557600080fd5b506124b285828601612367565b9150509250929050565b60008151808452602080850194508084016000805b84811015612522578251600e8110612510577f4e487b710000000000000000000000000000000000000000000000000000000083526021600452602483fd5b885296830196918301916001016124d1565b50959695505050505050565b6000815180845260208085019450848260051b860182860160005b85811015612573578383038952612561838351612293565b98850198925090840190600101612549565b5090979650505050505050565b6060808252845182820181905260009190608090818501906020808a01865b83811015612611578151805173ffffffffffffffffffffffffffffffffffffffff90811687528482015116848701526040808201519087015287810151888701528681015160ff168787015260a0808201519087015260c0908101519086015260e0909401939082019060010161259f565b5050868303908701525061262581886124bc565b92505050828103604084015261263b818561252e565b9695505050505050565b60008060006060848603121561265a57600080fd5b612663846121c3565b9250602084015161267381611db9565b604085015190925067ffffffffffffffff81111561269057600080fd5b61269c86828701612076565b9150509250925092565b600080604083850312156126b957600080fd5b825167ffffffffffffffff808211156126d157600080fd5b6126dd86838701612367565b935060208501519150808211156126f357600080fd5b506124b285828601612076565b600080600080600060a0868803121561271857600080fd5b855194506020808701519450604087015167ffffffffffffffff8082111561273f57600080fd5b818901915089601f83011261275357600080fd5b8151612761611f2f82612343565b81815260059190911b8301840190848101908c83111561278057600080fd5b938501935b828510156127a757845161279881611db9565b82529385019390850190612785565b60608c015190985094505050808311156127c057600080fd5b6127cc8a848b01612367565b945060808901519250808311156127e257600080fd5b50506127f088828901612076565b9150509295509295909350565b6020815260006108ca6020830184612293565b60008060006060848603121561282557600080fd5b835161283081611db9565b60208501516040860151919450925067ffffffffffffffff81111561269057600080fd5b8060005b60028110156108b2578151845260209384019390910190600101612858565b606081016128858285612854565b8260408301529392505050565b600080604083850312156128a557600080fd5b8251600481106128b457600080fd5b602084015190925067ffffffffffffffff8111156128d157600080fd5b6124b285828601612076565b600080604083850312156128f057600080fd5b825180600f0b811461290157600080fd5b6020939093015192949293505050565b600082601f83011261292257600080fd5b6040516040810181811067ffffffffffffffff8211171561294557612945611dde565b806040525080604084018581111561295c57600080fd5b845b8181101561297657805183526020928301920161295e565b509195945050505050565b60006040828403121561299357600080fd5b6108ca8383612911565b828152606081016108ca6020830184612854565b600080606083850312156129c457600080fd5b82516129cf81611db9565b91506129de8460208501612911565b9050925092905056fea264697066735822122085e4452bb33c0af28aeab31429c3e9f238d6070fb0e24342e4f06c81afba65d564736f6c6343000811003300000000000000000000000031429d1856ad1377a8a0079410b297e1a9e214c2000000000000000000000000e592427a0aece92de3edee1f18e0157c058615640000000000000000000000001111111254eeb25477b68fb85ed929f73a9605820000000000000000000000009a33e690aa78a4c346e72f7a5e16e5d7278be835

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100be5760003560e01c8063990d60d211610076578063a5d4096b1161005b578063a5d4096b146101ab578063b82c4dc1146101c0578063f2f4eb26146101d357600080fd5b8063990d60d2146101625780639d63848a1461019657600080fd5b80635fafa589116100a75780635fafa5891461013b5780635fcbd285146101625780638a971d911461017c57600080fd5b8063045c08d5146100c35780630b6942c214610114575b600080fd5b6100ea7f0000000000000000000000001111111254eeb25477b68fb85ed929f73a96058281565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100ea7f0000000000000000000000009a33e690aa78a4c346e72f7a5e16e5d7278be83581565b6100ea7f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156481565b737f90122bf0700f9e7e1f688fe926940e8839f3536100ea565b7342dc54fb50db556fa6ffba765f1141536d4830ea6100ea565b61019e6101fa565b60405161010b9190611d72565b6101be6101b9366004611ea2565b610241565b005b6101be6101ce366004611fb8565b610577565b6100ea7f00000000000000000000000031429d1856ad1377a8a0079410b297e1a9e214c281565b610202611d54565b506040805180820190915273ff970a61a04b1ca14834a43f5de4533ebddb5cc8815273fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9602082015290565b60008060008380602001905181019061025a91906120bb565b96509194509250905073ffffffffffffffffffffffffffffffffffffffff8316156102855782610287565b865b92506102a689868360048111156102a0576102a0612120565b876108d1565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8a16906370a0823190602401602060405180830381865afa158015610313573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610337919061214f565b905082811015610373576040517fa1aabbe100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8981166004830152600091908b16906370a0823190602401602060405180830381865afa1580156103e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610407919061214f565b9050878110158061044357508873ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b1561046e5761046973ffffffffffffffffffffffffffffffffffffffff8b16868461096f565b6104b3565b61049a8961047c838b612197565b73ffffffffffffffffffffffffffffffffffffffff8d16919061096f565b6104b385896104a985856121b0565b61047c9190612197565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801561051d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610541919061214f565b9650861561056a5761056a73ffffffffffffffffffffffffffffffffffffffff8c16868961096f565b5050505050505050505050565b6040517f521d4de90000000000000000000000000000000000000000000000000000000081523360048201527f00000000000000000000000031429d1856ad1377a8a0079410b297e1a9e214c273ffffffffffffffffffffffffffffffffffffffff169063521d4de990602401602060405180830381865afa158015610601573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061062591906121d8565b61065b576040517f99e120bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84838114158061066b5750808214155b156106a2576040517f46282e8d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8181101561072c5761071c8888838181106106c2576106c26121f3565b90506020020160208101906106d79190612222565b8787848181106106e9576106e96121f3565b90506020020160208101906106fe9190612222565b868685818110610710576107106121f3565b905060200201356109ca565b6107258161223f565b90506106a5565b5050505050505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa1580156107ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107d1919061214f565b6107db91906121b0565b60405173ffffffffffffffffffffffffffffffffffffffff85166024820152604481018290529091506108b29085907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610ace565b50505050565b60606108c78484600085610bdf565b90505b9392505050565b60008260048111156108e5576108e5612120565b036108fb576108f5848483610d75565b506108b2565b600182600481111561090f5761090f612120565b0361091e576108f58482610e7b565b600282600481111561093257610932612120565b03610946576109418482610f82565b6108b2565b600382600481111561095a5761095a612120565b036108b2576109688161109a565b5050505050565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526109c59084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401610830565b505050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610a40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a64919061214f565b905081811015610a9a5761094183610a7c8385612197565b73ffffffffffffffffffffffffffffffffffffffff87169190610736565b818111156108b2576108b283610ab08484612197565b73ffffffffffffffffffffffffffffffffffffffff87169190611283565b6000610b30826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166108b89092919063ffffffff16565b8051909150156109c55780806020019051810190610b4e91906121d8565b6109c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b606082471015610c71576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610bd6565b73ffffffffffffffffffffffffffffffffffffffff85163b610cef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610bd6565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610d189190612277565b60006040518083038185875af1925050503d8060008114610d55576040519150601f19603f3d011682016040523d82523d6000602084013e610d5a565b606091505b5091509150610d6a828286611409565b979650505050505050565b6000610da2847f000000000000000000000000e592427a0aece92de3edee1f18e0157c058615648561145c565b6040805160a0810182528381523060208201524281830152606081018590526000608082015290517fc04b8d5900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564169163c04b8d5991610e3891906004016122dd565b6020604051808303816000875af1158015610e57573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c7919061214f565b6000610ec8837f0000000000000000000000001111111254eeb25477b68fb85ed929f73a9605827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6109ca565b6000807f0000000000000000000000001111111254eeb25477b68fb85ed929f73a96058273ffffffffffffffffffffffffffffffffffffffff1684604051610f109190612277565b6000604051808303816000865af19150503d8060008114610f4d576040519150601f19603f3d011682016040523d82523d6000602084013e610f52565b606091505b509150915081610f6557610f658161152e565b80806020019051810190610f79919061214f565b95945050505050565b60008082806020019051810190610f9991906123f2565b91509150610fe8847f0000000000000000000000009a33e690aa78a4c346e72f7a5e16e5d7278be8357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6109ca565b6040517f848c48da00000000000000000000000000000000000000000000000000000000815260609073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000009a33e690aa78a4c346e72f7a5e16e5d7278be835169063848c48da9061106190849087908790600401612580565b600060405180830381600087803b15801561107b57600080fd5b505af115801561108f573d6000803e3d6000fd5b505050505050505050565b60008060006060848060200190518101906110b59190612645565b96509093509150821561119257848060200190518101906110d691906126a6565b955090506110e38161156f565b6110ec85611611565b93507342dc54fb50db556fa6ffba765f1141536d4830ea6040517f6e553f650000000000000000000000000000000000000000000000000000000081526004810186905273ffffffffffffffffffffffffffffffffffffffff84811660248301529190911690636e553f6590604401600060405180830381600087803b15801561117557600080fd5b505af1158015611189573d6000803e3d6000fd5b5050505061127b565b6000806060878060200190518101906111ab9190612700565b9b509650919450925090507342dc54fb50db556fa6ffba765f1141536d4830ea6040517fb460af94000000000000000000000000000000000000000000000000000000008152600481018590523060248201819052604482015273ffffffffffffffffffffffffffffffffffffffff919091169063b460af9490606401600060405180830381600087803b15801561124257600080fd5b505af1158015611256573d6000803e3d6000fd5b5050505061126482896118a3565b61126d8461156f565b6112778186611c3c565b5050505b505050919050565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156112f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131d919061214f565b9050818110156113af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f5361666545524332303a2064656372656173656420616c6c6f77616e6365206260448201527f656c6f77207a65726f00000000000000000000000000000000000000000000006064820152608401610bd6565b60405173ffffffffffffffffffffffffffffffffffffffff8416602482015282820360448201819052906109689086907f095ea7b30000000000000000000000000000000000000000000000000000000090606401610830565b606083156114185750816108ca565b8251156114285782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd691906127fd565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156114d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f6919061214f565b9050818110156108b2576108b283610a7c837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612197565b80511561153d57805181602001fd5b6040517f6a8df6a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805160005b818110156109c5576000806000858481518110611593576115936121f3565b60200260200101518060200190518101906115ae9190612810565b92509250925060006115c08483610e7b565b9050828110156115fc576040517fa1aabbe100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050508061160a9061223f565b9050611574565b60008061161c6101fa565b516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611688573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116ac919061214f565b905060006116b86101fa565b602001516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611727573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174b919061214f565b90508115158061175a57508015155b156117f6576040805180820182528381526020810183905290517f0b4c7e4d000000000000000000000000000000000000000000000000000000008152737f90122bf0700f9e7e1f688fe926940e8839f35391630b4c7e4d916117c39190600090600401612877565b600060405180830381600087803b1580156117dd57600080fd5b505af11580156117f1573d6000803e3d6000fd5b505050505b737f90122bf0700f9e7e1f688fe926940e8839f3536040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91909116906370a0823190602401602060405180830381865afa158015611877573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189b919061214f565b949350505050565b6000818060200190518101906118b99190612892565b9250905060008160038111156118d1576118d1612120565b0361197257600080838060200190518101906118ed91906128dd565b9150915061190c737f90122bf0700f9e7e1f688fe926940e8839f35390565b6040517f1a4d01d200000000000000000000000000000000000000000000000000000000815260048101879052600f84900b60248201526044810183905273ffffffffffffffffffffffffffffffffffffffff9190911690631a4d01d290606401611061565b600181600381111561198657611986612120565b03611a24576000828060200190518101906119a19190612981565b6040517f5b36389c000000000000000000000000000000000000000000000000000000008152909150737f90122bf0700f9e7e1f688fe926940e8839f35390635b36389c906119f6908790859060040161299d565b600060405180830381600087803b158015611a1057600080fd5b505af115801561072c573d6000803e3d6000fd5b6002816003811115611a3857611a38612120565b036109c55760008083806020019051810190611a5491906129b1565b91509150611a73737f90122bf0700f9e7e1f688fe926940e8839f35390565b73ffffffffffffffffffffffffffffffffffffffff1663e310327382876040518363ffffffff1660e01b8152600401611aad929190612877565b600060405180830381600087803b158015611ac757600080fd5b505af1158015611adb573d6000803e3d6000fd5b505050506000611afc737f90122bf0700f9e7e1f688fe926940e8839f35390565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91909116906370a0823190602401602060405180830381865afa158015611b68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b8c919061214f565b90508015611c34577342dc54fb50db556fa6ffba765f1141536d4830ea6040517f6e553f650000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff85811660248301529190911690636e553f6590604401600060405180830381600087803b158015611c1b57600080fd5b505af1158015611c2f573d6000803e3d6000fd5b505050505b505050505050565b815160005b818110156108b2576000848281518110611c5d57611c5d6121f3565b60209081029190910101516040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116906370a0823190602401602060405180830381865afa158015611cd3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf7919061214f565b90508015611d4357611d438482878581518110611d1657611d166121f3565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1661096f9092919063ffffffff16565b50611d4d8161223f565b9050611c41565b60405180604001604052806002906020820280368337509192915050565b60408101818360005b6002811015611db057815173ffffffffffffffffffffffffffffffffffffffff16835260209283019290910190600101611d7b565b50505092915050565b73ffffffffffffffffffffffffffffffffffffffff81168114611ddb57600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e5457611e54611dde565b604052919050565b600067ffffffffffffffff821115611e7657611e76611dde565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60008060008060008060c08789031215611ebb57600080fd5b8635611ec681611db9565b95506020870135611ed681611db9565b94506040870135611ee681611db9565b9350606087013592506080870135915060a087013567ffffffffffffffff811115611f1057600080fd5b8701601f81018913611f2157600080fd5b8035611f34611f2f82611e5c565b611e0d565b8181528a6020838501011115611f4957600080fd5b816020840160208301376000602083830101528093505050509295509295509295565b60008083601f840112611f7e57600080fd5b50813567ffffffffffffffff811115611f9657600080fd5b6020830191508360208260051b8501011115611fb157600080fd5b9250929050565b60008060008060008060608789031215611fd157600080fd5b863567ffffffffffffffff80821115611fe957600080fd5b611ff58a838b01611f6c565b9098509650602089013591508082111561200e57600080fd5b61201a8a838b01611f6c565b9096509450604089013591508082111561203357600080fd5b5061204089828a01611f6c565b979a9699509497509295939492505050565b60005b8381101561206d578181015183820152602001612055565b50506000910152565b600082601f83011261208757600080fd5b8151612095611f2f82611e5c565b8181528460208386010111156120aa57600080fd5b61189b826020830160208701612052565b600080600080608085870312156120d157600080fd5b84516120dc81611db9565b809450506020850151925060408501519150606085015167ffffffffffffffff81111561210857600080fd5b61211487828801612076565b91505092959194509250565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b60006020828403121561216157600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156121aa576121aa612168565b92915050565b808201808211156121aa576121aa612168565b805180151581146121d357600080fd5b919050565b6000602082840312156121ea57600080fd5b6108ca826121c3565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561223457600080fd5b81356108ca81611db9565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361227057612270612168565b5060010190565b60008251612289818460208701612052565b9190910192915050565b600081518084526122ab816020860160208601612052565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000825160a060208401526122f960c0840182612293565b905073ffffffffffffffffffffffffffffffffffffffff60208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b600067ffffffffffffffff82111561235d5761235d611dde565b5060051b60200190565b600082601f83011261237857600080fd5b81516020612388611f2f83612343565b82815260059290921b840181019181810190868411156123a757600080fd5b8286015b848110156123e757805167ffffffffffffffff8111156123cb5760008081fd5b6123d98986838b0101612076565b8452509183019183016123ab565b509695505050505050565b6000806040838503121561240557600080fd5b825167ffffffffffffffff8082111561241d57600080fd5b818501915085601f83011261243157600080fd5b81516020612441611f2f83612343565b82815260059290921b8401810191818101908984111561246057600080fd5b948201945b8386101561248c578551600e811061247d5760008081fd5b82529482019490820190612465565b918801519196509093505050808211156124a557600080fd5b506124b285828601612367565b9150509250929050565b60008151808452602080850194508084016000805b84811015612522578251600e8110612510577f4e487b710000000000000000000000000000000000000000000000000000000083526021600452602483fd5b885296830196918301916001016124d1565b50959695505050505050565b6000815180845260208085019450848260051b860182860160005b85811015612573578383038952612561838351612293565b98850198925090840190600101612549565b5090979650505050505050565b6060808252845182820181905260009190608090818501906020808a01865b83811015612611578151805173ffffffffffffffffffffffffffffffffffffffff90811687528482015116848701526040808201519087015287810151888701528681015160ff168787015260a0808201519087015260c0908101519086015260e0909401939082019060010161259f565b5050868303908701525061262581886124bc565b92505050828103604084015261263b818561252e565b9695505050505050565b60008060006060848603121561265a57600080fd5b612663846121c3565b9250602084015161267381611db9565b604085015190925067ffffffffffffffff81111561269057600080fd5b61269c86828701612076565b9150509250925092565b600080604083850312156126b957600080fd5b825167ffffffffffffffff808211156126d157600080fd5b6126dd86838701612367565b935060208501519150808211156126f357600080fd5b506124b285828601612076565b600080600080600060a0868803121561271857600080fd5b855194506020808701519450604087015167ffffffffffffffff8082111561273f57600080fd5b818901915089601f83011261275357600080fd5b8151612761611f2f82612343565b81815260059190911b8301840190848101908c83111561278057600080fd5b938501935b828510156127a757845161279881611db9565b82529385019390850190612785565b60608c015190985094505050808311156127c057600080fd5b6127cc8a848b01612367565b945060808901519250808311156127e257600080fd5b50506127f088828901612076565b9150509295509295909350565b6020815260006108ca6020830184612293565b60008060006060848603121561282557600080fd5b835161283081611db9565b60208501516040860151919450925067ffffffffffffffff81111561269057600080fd5b8060005b60028110156108b2578151845260209384019390910190600101612858565b606081016128858285612854565b8260408301529392505050565b600080604083850312156128a557600080fd5b8251600481106128b457600080fd5b602084015190925067ffffffffffffffff8111156128d157600080fd5b6124b285828601612076565b600080604083850312156128f057600080fd5b825180600f0b811461290157600080fd5b6020939093015192949293505050565b600082601f83011261292257600080fd5b6040516040810181811067ffffffffffffffff8211171561294557612945611dde565b806040525080604084018581111561295c57600080fd5b845b8181101561297657805183526020928301920161295e565b509195945050505050565b60006040828403121561299357600080fd5b6108ca8383612911565b828152606081016108ca6020830184612854565b600080606083850312156129c457600080fd5b82516129cf81611db9565b91506129de8460208501612911565b9050925092905056fea264697066735822122085e4452bb33c0af28aeab31429c3e9f238d6070fb0e24342e4f06c81afba65d564736f6c63430008110033

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

00000000000000000000000031429d1856ad1377a8a0079410b297e1a9e214c2000000000000000000000000e592427a0aece92de3edee1f18e0157c058615640000000000000000000000001111111254eeb25477b68fb85ed929f73a9605820000000000000000000000009a33e690aa78a4c346e72f7a5e16e5d7278be835

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

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 00000000000000000000000031429d1856ad1377a8a0079410b297e1a9e214c2
Arg [1] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Arg [2] : 0000000000000000000000001111111254eeb25477b68fb85ed929f73a960582
Arg [3] : 0000000000000000000000009a33e690aa78a4c346e72f7a5e16e5d7278be835


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.