Spend less on fees, more on crypto. Buy crypto easily with MoonPay Balance. 20M+ users trust MoonPay worldwide.
Ready to onboard to Ethereum? With MetaMask Portfolio, you're in control.
Don’t invest unless you’re prepared to lose all the money you invest.
Everyday giveaways up to 100 ETH, Lucky Spins. Deposit BONUS 300% and Cashbacks!
5000+ Slots & Live Casino Games, 50+cryptos. Register with Etherscan and get 760% deposit bonus. Win Big$, withdraw it fast.
Slots, Roulette, Poker & more - Proud sponsors of UFC, Everton & StakeF1 team!
5000+ Slots & Live Casino Games, 50+cryptos. Register with Etherscan and get 760% deposit bonus. Win Big$, withdraw it fast.
Anonymous play on awesome games - sign up now for 25 free jackpot spins - worth $100s!
100s of games, generous bonuses, 20+ years of trusted gaming. Join CryptoWins & start winning today!
Overview
ETH Balance
Eth Value
$0.00Token Holdings
Could not find any matches!
- ERC-20 Tokens (6)0 stETHstETH (stETH)$0.00@3,608.200 aSTETHAave interest bearing STETH$0.00@3,620.411 TokenERC-20 TOKEN*[Suspicious]3,999.99 TokenERC-20 TOKEN*[Spam]1,049 TokenERC-20 TOKEN*[Spam]3,999.99 TokenERC-20 TOKEN*[Spam]NFT Tokens (10)debridgeth.comdebridgeth.comERC-1155claim rewards on poolstaked.orgpoolstaked.orgERC-1155
More Info
Private Name Tags
ContractCreator
- Transactions
- Internal Transactions
- Token Transfers (ERC-20)
- NFT Transfers
- Contract
- Events
- Analytics
- Multichain Portfolio
- Cards New
Advanced Filter- Filter by Tx Type:
- Tx
- Internal Tx
- ERC-20
- NFTs
Latest 25 from a total of 142 transactions
Transaction Hash MethodBlockFromToRedeem Exact Set... 21306626 2024-12-01 9:00:47 24 hrs ago 1733043647 IN 0 ETH$0.00 0.01160369 9.63527967 Redeem Exact Set... 21293097 2024-11-29 11:36:47 2 days ago 1732880207 IN 0 ETH$0.00 0.01498287 12.44122351 Redeem Exact Set... 21285312 2024-11-28 9:29:59 3 days ago 1732786199 IN 0 ETH$0.00 0.00923626 8.18609738 Redeem Exact Set... 21280595 2024-11-27 17:32:35 4 days ago 1732728755 IN 0 ETH$0.00 0.02949132 24.48800783 Redeem Exact Set... 21074636 2024-10-29 23:39:23 33 days ago 1730245163 IN 0 ETH$0.00 0.00817736 6.8 Redeem Exact Set... 20535109 2024-08-15 16:05:11 108 days ago 1723737911 IN 0 ETH$0.00 0.00970939 8.06215956 Redeem Exact Set... 19846541 2024-05-11 11:38:11 204 days ago 1715427491 IN 0 ETH$0.00 0.00621202 5.38749122 Redeem Exact Set... 19838344 2024-05-10 8:08:47 206 days ago 1715328527 IN 0 ETH$0.00 0.00593912 5.15081317 Redeem Exact Set... 19698528 2024-04-20 18:51:23 225 days ago 1713639083 IN 0 ETH$0.00 0.00966582 8.01315983 Redeem Exact Set... 19698521 2024-04-20 18:49:59 225 days ago 1713638999 IN 0 ETH$0.00 0.00917497 7.57623417 Redeem Exact Set... 19654894 2024-04-14 16:14:11 231 days ago 1713111251 IN 0 ETH$0.00 0.01085805 9 Redeem Exact Set... 19650074 2024-04-14 0:01:35 232 days ago 1713052895 IN 0 ETH$0.00 0.03822917 31.43715144 Redeem Exact Set... 19643381 2024-04-13 1:26:59 233 days ago 1712971619 IN 0 ETH$0.00 0.01772115 15.34012451 Redeem Exact Set... 19633407 2024-04-11 15:56:11 234 days ago 1712850971 IN 0 ETH$0.00 0.03788236 33.05833191 Redeem Exact Set... 19626615 2024-04-10 17:07:35 235 days ago 1712768855 IN 0 ETH$0.00 0.0298456 26.39220708 Redeem Exact Set... 19626489 2024-04-10 16:42:11 235 days ago 1712767331 IN 0 ETH$0.00 0.03661634 31.48306287 Redeem Exact Set... 19609335 2024-04-08 7:01:59 238 days ago 1712559719 IN 0 ETH$0.00 0.01363723 11.34591702 Redeem Exact Set... 19557297 2024-04-01 0:01:47 245 days ago 1711929707 IN 0 ETH$0.00 0.02728069 22.32882661 Redeem Exact Set... 19542243 2024-03-29 21:11:35 247 days ago 1711746695 IN 0 ETH$0.00 0.03525339 29.0825884 Redeem Exact Set... 19530822 2024-03-28 6:27:47 249 days ago 1711607267 IN 0 ETH$0.00 0.02449844 20.2569973 Redeem Exact Set... 19528931 2024-03-28 0:01:47 249 days ago 1711584107 IN 0 ETH$0.00 0.05060916 43.23548047 Redeem Exact Set... 19526283 2024-03-27 14:36:47 249 days ago 1711550207 IN 0 ETH$0.00 0.06167263 54.35876766 Redeem Exact Set... 19507996 2024-03-25 0:36:59 252 days ago 1711327019 IN 0 ETH$0.00 0.01773435 14.71228948 Redeem Exact Set... 19507981 2024-03-25 0:33:59 252 days ago 1711326839 IN 0 ETH$0.00 0.0190673 15.65749648 Redeem Exact Set... 19488003 2024-03-22 5:11:59 255 days ago 1711084319 IN 0 ETH$0.00 0.02399328 19.85872295 Latest 25 internal transactions (View All)
Advanced mode:Parent Transaction Hash Block From To 21306626 2024-12-01 9:00:47 24 hrs ago 1733043647 1.11880625 ETH$4,049.15 21306626 2024-12-01 9:00:47 24 hrs ago 1733043647 1.11880625 ETH$4,049.15 21306626 2024-12-01 9:00:47 24 hrs ago 1733043647 1.11880625 ETH$4,049.15 21306626 2024-12-01 9:00:47 24 hrs ago 1733043647 1.11880625 ETH$4,049.15 21306626 2024-12-01 9:00:47 24 hrs ago 1733043647 1.90011882 ETH$6,876.85 21306626 2024-12-01 9:00:47 24 hrs ago 1733043647 1.11903005 ETH$4,049.96 21306626 2024-12-01 9:00:47 24 hrs ago 1733043647 3.01914887 ETH$10,926.81 21293097 2024-11-29 11:36:47 2 days ago 1732880207 0.67791885 ETH$2,453.50 21293097 2024-11-29 11:36:47 2 days ago 1732880207 0.67791885 ETH$2,453.50 21293097 2024-11-29 11:36:47 2 days ago 1732880207 0.67791885 ETH$2,453.50 21293097 2024-11-29 11:36:47 2 days ago 1732880207 0.67791885 ETH$2,453.50 21293097 2024-11-29 11:36:47 2 days ago 1732880207 1.15157563 ETH$4,167.75 21293097 2024-11-29 11:36:47 2 days ago 1732880207 0.67805445 ETH$2,453.99 21293097 2024-11-29 11:36:47 2 days ago 1732880207 1.82963008 ETH$6,621.74 21285312 2024-11-28 9:29:59 3 days ago 1732786199 4.20514302 ETH$15,219.12 21285312 2024-11-28 9:29:59 3 days ago 1732786199 2.47581766 ETH$8,960.40 21285312 2024-11-28 9:29:59 3 days ago 1732786199 6.68096068 ETH$24,179.53 21280595 2024-11-27 17:32:35 4 days ago 1732728755 66.45934669 ETH$240,527.61 21280595 2024-11-27 17:32:35 4 days ago 1732728755 66.45934669 ETH$240,527.61 21280595 2024-11-27 17:32:35 4 days ago 1732728755 66.45934669 ETH$240,527.61 21280595 2024-11-27 17:32:35 4 days ago 1732728755 66.45934669 ETH$240,527.61 21280595 2024-11-27 17:32:35 4 days ago 1732728755 112.91178425 ETH$408,646.83 21280595 2024-11-27 17:32:35 4 days ago 1732728755 66.47264054 ETH$240,575.72 21280595 2024-11-27 17:32:35 4 days ago 1732728755 179.3844248 ETH$649,222.56 21074636 2024-10-29 23:39:23 33 days ago 1730245163 12.42908871 ETH$44,982.97 Loading...LoadingThis contract contains unverified libraries: DEXAdapterThis contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.Contract Name:ExchangeIssuanceLeveraged
Compiler Versionv0.6.10+commit.00c0fcaf
Optimization Enabled:Yes with 200 runs
Other Settings:default evmVersionContract Source Code (Solidity Standard Json-Input format)
/* Copyright 2022 Index Cooperative Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { Math } from "@openzeppelin/contracts/math/Math.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import { IAToken } from "../interfaces/IAToken.sol"; import { IAaveLeverageModule } from "../interfaces/IAaveLeverageModule.sol"; import { IDebtIssuanceModule } from "../interfaces/IDebtIssuanceModule.sol"; import { IController } from "../interfaces/IController.sol"; import { ISetToken } from "../interfaces/ISetToken.sol"; import { IWETH } from "../interfaces/IWETH.sol"; import { PreciseUnitMath } from "../lib/PreciseUnitMath.sol"; import { UniSushiV2Library } from "../../external/contracts/UniSushiV2Library.sol"; import { FlashLoanReceiverBaseV2 } from "../../external/contracts/aaveV2/FlashLoanReceiverBaseV2.sol"; import { DEXAdapter } from "./DEXAdapter.sol"; /** * @title ExchangeIssuance * @author Index Coop * * Contract for issuing and redeeming a leveraged Set Token * Supports all tokens with one collateral Position in the form of an AToken and one debt position * Both the collateral as well as the debt token have to be available for flashloand and be * tradeable against each other on Sushi / Quickswap */ contract ExchangeIssuanceLeveraged is ReentrancyGuard, FlashLoanReceiverBaseV2{ using DEXAdapter for DEXAdapter.Addresses; using Address for address payable; using SafeMath for uint256; using PreciseUnitMath for uint256; using SafeERC20 for IERC20; using SafeERC20 for ISetToken; /* ============ Structs ============ */ struct LeveragedTokenData { address collateralAToken; address collateralToken; uint256 collateralAmount; address debtToken; uint256 debtAmount; } struct DecodedParams { ISetToken setToken; uint256 setAmount; address originalSender; bool isIssuance; address paymentToken; uint256 limitAmount; LeveragedTokenData leveragedTokenData; DEXAdapter.SwapData collateralAndDebtSwapData; DEXAdapter.SwapData paymentTokenSwapData; } /* ============ Constants ============= */ uint256 constant private MAX_UINT256 = type(uint256).max; uint256 public constant ROUNDING_ERROR_MARGIN = 2; /* ============ State Variables ============ */ IController public immutable setController; IDebtIssuanceModule public immutable debtIssuanceModule; IAaveLeverageModule public immutable aaveLeverageModule; DEXAdapter.Addresses public addresses; /* ============ Events ============ */ event ExchangeIssue( address indexed _recipient, // The recipient address of the issued SetTokens ISetToken indexed _setToken, // The issued SetToken address indexed _inputToken, // The address of the input asset(ERC20/ETH) used to issue the SetTokens uint256 _amountInputToken, // The amount of input tokens used for issuance uint256 _amountSetIssued // The amount of SetTokens received by the recipient ); event ExchangeRedeem( address indexed _recipient, // The recipient address which redeemed the SetTokens ISetToken indexed _setToken, // The redeemed SetToken address indexed _outputToken, // The address of output asset(ERC20/ETH) received by the recipient uint256 _amountSetRedeemed, // The amount of SetTokens redeemed for output tokens uint256 _amountOutputToken // The amount of output tokens received by the recipient ); /* ============ Modifiers ============ */ modifier onlyLendingPool() { require(msg.sender == address(LENDING_POOL), "ExchangeIssuance: LENDING POOL ONLY"); _; } modifier isValidPath( address[] memory _path, address _inputToken, address _outputToken ) { if(_inputToken != _outputToken){ require( _path[0] == _inputToken || (_inputToken == addresses.weth && _path[0] == DEXAdapter.ETH_ADDRESS), "ExchangeIssuance: INPUT_TOKEN_NOT_IN_PATH" ); require( _path[_path.length-1] == _outputToken || (_outputToken == addresses.weth && _path[_path.length-1] == DEXAdapter.ETH_ADDRESS), "ExchangeIssuance: OUTPUT_TOKEN_NOT_IN_PATH" ); } _; } /* ============ Constructor ============ */ /** * Sets various contract addresses * * @param _weth Address of wrapped native token * @param _quickRouter Address of quickswap router * @param _sushiRouter Address of sushiswap router * @param _uniV3Router Address of uniswap v3 router * @param _uniV3Quoter Address of uniswap v3 quoter * @param _setController SetToken controller used to verify a given token is a set * @param _debtIssuanceModule DebtIssuanceModule used to issue and redeem tokens * @param _aaveLeverageModule AaveLeverageModule to sync before every issuance / redemption * @param _aaveAddressProvider Address of address provider for aaves addresses * @param _curveAddressProvider Contract to get current implementation address of curve registry * @param _curveCalculator Contract to calculate required input to receive given output in curve (for exact output swaps) */ constructor( address _weth, address _quickRouter, address _sushiRouter, address _uniV3Router, address _uniV3Quoter, IController _setController, IDebtIssuanceModule _debtIssuanceModule, IAaveLeverageModule _aaveLeverageModule, address _aaveAddressProvider, address _curveAddressProvider, address _curveCalculator ) public FlashLoanReceiverBaseV2(_aaveAddressProvider) { setController = _setController; debtIssuanceModule = _debtIssuanceModule; aaveLeverageModule = _aaveLeverageModule; addresses.weth = _weth; addresses.quickRouter = _quickRouter; addresses.sushiRouter = _sushiRouter; addresses.uniV3Router = _uniV3Router; addresses.uniV3Quoter = _uniV3Quoter; addresses.curveAddressProvider = _curveAddressProvider; addresses.curveCalculator = _curveCalculator; } /* ============ External Functions ============ */ /** * Returns the collateral / debt token addresses and amounts for a leveraged index * * @param _setToken Address of the SetToken to be issued / redeemed * @param _setAmount Amount of SetTokens to issue / redeem * @param _isIssuance Boolean indicating if the SetToken is to be issued or redeemed * * @return Struct containing the collateral / debt token addresses and amounts */ function getLeveragedTokenData( ISetToken _setToken, uint256 _setAmount, bool _isIssuance ) external view returns (LeveragedTokenData memory) { return _getLeveragedTokenData(_setToken, _setAmount, _isIssuance); } /** * Runs all the necessary approval functions required for a given ERC20 token. * This function can be called when a new token is added to a SetToken during a * rebalance. * * @param _token Address of the token which needs approval */ function approveToken(IERC20 _token) external { _approveToken(_token); } /** * Gets the input cost of issuing a given amount of a set token. This * function is not marked view, but should be static called from frontends. * This constraint is due to the need to interact with the Uniswap V3 quoter * contract and call sync on AaveLeverageModule. Note: If the two SwapData * paths contain the same tokens, there will be a slight error introduced * in the result. * * @param _setToken the set token to issue * @param _setAmount amount of set tokens * @param _swapDataDebtForCollateral swap data for the debt to collateral swap * @param _swapDataInputToken swap data for the input token to collateral swap * * @return the amount of input tokens required to perfrom the issuance */ function getIssueExactSet( ISetToken _setToken, uint256 _setAmount, DEXAdapter.SwapData memory _swapDataDebtForCollateral, DEXAdapter.SwapData memory _swapDataInputToken ) external returns (uint256) { aaveLeverageModule.sync(_setToken); LeveragedTokenData memory issueInfo = _getLeveragedTokenData(_setToken, _setAmount, true); uint256 collateralOwed = issueInfo.collateralAmount.preciseMul(1.0009 ether); uint256 borrowSaleProceeds = DEXAdapter.getAmountOut(addresses, _swapDataDebtForCollateral, issueInfo.debtAmount); collateralOwed = collateralOwed.sub(borrowSaleProceeds); return DEXAdapter.getAmountIn(addresses, _swapDataInputToken, collateralOwed); } /** * Gets the proceeds of a redemption of a given amount of a set token. This * function is not marked view, but should be static called from frontends. * This constraint is due to the need to interact with the Uniswap V3 quoter * contract and call sync on AaveLeverageModule. Note: If the two SwapData * paths contain the same tokens, there will be a slight error introduced * in the result. * * @param _setToken the set token to issue * @param _setAmount amount of set tokens * @param _swapDataCollateralForDebt swap data for the collateral to debt swap * @param _swapDataOutputToken swap data for the collateral token to the output token * * @return amount of _outputToken that would be obtained from the redemption */ function getRedeemExactSet( ISetToken _setToken, uint256 _setAmount, DEXAdapter.SwapData memory _swapDataCollateralForDebt, DEXAdapter.SwapData memory _swapDataOutputToken ) external returns (uint256) { aaveLeverageModule.sync(_setToken); LeveragedTokenData memory redeemInfo = _getLeveragedTokenData(_setToken, _setAmount, false); uint256 debtOwed = redeemInfo.debtAmount.preciseMul(1.0009 ether); uint256 debtPurchaseCost = DEXAdapter.getAmountIn(addresses, _swapDataCollateralForDebt, debtOwed); uint256 extraCollateral = redeemInfo.collateralAmount.sub(debtPurchaseCost); return DEXAdapter.getAmountOut(addresses, _swapDataOutputToken, extraCollateral); } /** * Trigger redemption of set token to pay the user with Eth * * @param _setToken Set token to redeem * @param _setAmount Amount to redeem * @param _minAmountOutputToken Minimum amount of ETH to send to the user * @param _swapDataCollateralForDebt Data (token path and fee levels) describing the swap from Collateral Token to Debt Token * @param _swapDataOutputToken Data (token path and fee levels) describing the swap from Collateral Token to Eth */ function redeemExactSetForETH( ISetToken _setToken, uint256 _setAmount, uint256 _minAmountOutputToken, DEXAdapter.SwapData memory _swapDataCollateralForDebt, DEXAdapter.SwapData memory _swapDataOutputToken ) external nonReentrant { _initiateRedemption( _setToken, _setAmount, DEXAdapter.ETH_ADDRESS, _minAmountOutputToken, _swapDataCollateralForDebt, _swapDataOutputToken ); } /** * Trigger redemption of set token to pay the user with an arbitrary ERC20 * * @param _setToken Set token to redeem * @param _setAmount Amount to redeem * @param _outputToken Address of the ERC20 token to send to the user * @param _minAmountOutputToken Minimum amount of output token to send to the user * @param _swapDataCollateralForDebt Data (token path and fee levels) describing the swap from Collateral Token to Debt Token * @param _swapDataOutputToken Data (token path and fee levels) describing the swap from Collateral Token to Output token */ function redeemExactSetForERC20( ISetToken _setToken, uint256 _setAmount, address _outputToken, uint256 _minAmountOutputToken, DEXAdapter.SwapData memory _swapDataCollateralForDebt, DEXAdapter.SwapData memory _swapDataOutputToken ) external nonReentrant { _initiateRedemption( _setToken, _setAmount, _outputToken, _minAmountOutputToken, _swapDataCollateralForDebt, _swapDataOutputToken ); } /** * Trigger issuance of set token paying with any arbitrary ERC20 token * * @param _setToken Set token to issue * @param _setAmount Amount to issue * @param _inputToken Input token to pay with * @param _maxAmountInputToken Maximum amount of input token to spend * @param _swapDataDebtForCollateral Data (token addresses and fee levels) to describe the swap path from Debt to collateral token * @param _swapDataInputToken Data (token addresses and fee levels) to describe the swap path from input to collateral token */ function issueExactSetFromERC20( ISetToken _setToken, uint256 _setAmount, address _inputToken, uint256 _maxAmountInputToken, DEXAdapter.SwapData memory _swapDataDebtForCollateral, DEXAdapter.SwapData memory _swapDataInputToken ) external nonReentrant { _initiateIssuance( _setToken, _setAmount, _inputToken, _maxAmountInputToken, _swapDataDebtForCollateral, _swapDataInputToken ); } /** * Trigger issuance of set token paying with Eth * * @param _setToken Set token to issue * @param _setAmount Amount to issue * @param _swapDataDebtForCollateral Data (token addresses and fee levels) to describe the swap path from Debt to collateral token * @param _swapDataInputToken Data (token addresses and fee levels) to describe the swap path from eth to collateral token */ function issueExactSetFromETH( ISetToken _setToken, uint256 _setAmount, DEXAdapter.SwapData memory _swapDataDebtForCollateral, DEXAdapter.SwapData memory _swapDataInputToken ) external payable nonReentrant { _initiateIssuance( _setToken, _setAmount, DEXAdapter.ETH_ADDRESS, msg.value, _swapDataDebtForCollateral, _swapDataInputToken ); } /** * This is the callback function that will be called by the AaveLending Pool after flashloaned tokens have been sent * to this contract. * After exiting this function the Lending Pool will attempt to transfer back the loaned tokens + interest. If it fails to do so * the whole transaction gets reverted * * @param assets Addresses of all assets that were borrowed * @param amounts Amounts that were borrowed * @param premiums Interest to be paid on top of borrowed amount * @param initiator Address that initiated the flashloan * @param params Encoded bytestring of other parameters from the original contract call to be used downstream * * @return Boolean indicating success of the operation (fixed to true otherwise the whole transaction would be reverted by lending pool) */ function executeOperation( address[] memory assets, uint256[] memory amounts, uint256[] memory premiums, address initiator, bytes memory params ) external override onlyLendingPool returns (bool) { require(initiator == address(this), "ExchangeIssuance: INVALID FLASHLOAN INITIATOR"); require(assets.length == 1, "ExchangeIssuance: TOO MANY ASSETS"); require(amounts.length == 1, "ExchangeIssuance: TOO MANY AMOUNTS"); require(premiums.length == 1, "ExchangeIssuance: TOO MANY PREMIUMS"); DecodedParams memory decodedParams = abi.decode(params, (DecodedParams)); if(decodedParams.isIssuance){ _performIssuance(assets[0], amounts[0], premiums[0], decodedParams); } else { _performRedemption(assets[0], amounts[0], premiums[0], decodedParams); } return true; } /** * Runs all the necessary approval functions required for a list of ERC20 tokens. * * @param _tokens Addresses of the tokens which need approval */ function approveTokens(IERC20[] memory _tokens) external { for (uint256 i = 0; i < _tokens.length; i++) { _approveToken(_tokens[i]); } } /** * Runs all the necessary approval functions required before issuing * or redeeming a SetToken. This function need to be called only once before the first time * this smart contract is used on any particular SetToken. * * @param _setToken Address of the SetToken being initialized */ function approveSetToken(ISetToken _setToken) external { LeveragedTokenData memory leveragedTokenData = _getLeveragedTokenData(_setToken, 1 ether, true); _approveToken(IERC20(leveragedTokenData.collateralAToken)); _approveTokenToLendingPool(IERC20(leveragedTokenData.collateralToken)); _approveToken(IERC20(leveragedTokenData.debtToken)); _approveTokenToLendingPool(IERC20(leveragedTokenData.debtToken)); } /* ============ Internal Functions ============ */ /** * Performs all the necessary steps for issuance using the collateral tokens obtained in the flashloan * * @param _collateralToken Address of the underlying collateral token that was loaned * @param _collateralTokenAmountNet Amount of collateral token that was received as flashloan * @param _premium Premium / Interest that has to be returned to the lending pool on top of the loaned amount * @param _decodedParams Struct containing token addresses / amounts to perform issuance */ function _performIssuance( address _collateralToken, uint256 _collateralTokenAmountNet, uint256 _premium, DecodedParams memory _decodedParams ) internal { // Deposit collateral token obtained from flashloan to get the respective aToken position required for issuance _depositCollateralToken(_collateralToken, _collateralTokenAmountNet); // Issue set using the aToken returned by deposit step _issueSet(_decodedParams.setToken, _decodedParams.setAmount, _decodedParams.originalSender); // Obtain necessary collateral tokens to repay flashloan uint amountInputTokenSpent = _obtainCollateralTokens( _collateralToken, _collateralTokenAmountNet + _premium, _decodedParams ); require(amountInputTokenSpent <= _decodedParams.limitAmount, "ExchangeIssuance: INSUFFICIENT INPUT AMOUNT"); } /** * Performs all the necessary steps for redemption using the debt tokens obtained in the flashloan * * @param _debtToken Address of the debt token that was loaned * @param _debtTokenAmountNet Amount of debt token that was received as flashloan * @param _premium Premium / Interest that has to be returned to the lending pool on top of the loaned amount * @param _decodedParams Struct containing token addresses / amounts to perform redemption */ function _performRedemption( address _debtToken, uint256 _debtTokenAmountNet, uint256 _premium, DecodedParams memory _decodedParams ) internal { // Redeem set using debt tokens obtained from flashloan _redeemSet( _decodedParams.setToken, _decodedParams.setAmount, _decodedParams.originalSender ); // Withdraw underlying collateral token from the aToken position returned by redeem step _withdrawCollateralToken( _decodedParams.leveragedTokenData.collateralToken, _decodedParams.leveragedTokenData.collateralAmount - ROUNDING_ERROR_MARGIN ); // Obtain debt tokens required to repay flashloan by swapping the underlying collateral tokens obtained in withdraw step uint256 collateralTokenSpent = _swapCollateralForDebtToken( _debtTokenAmountNet + _premium, _debtToken, _decodedParams.leveragedTokenData.collateralAmount, _decodedParams.leveragedTokenData.collateralToken, _decodedParams.collateralAndDebtSwapData ); // Liquidate remaining collateral tokens for the payment token specified by user uint256 amountOutputToken = _liquidateCollateralTokens( collateralTokenSpent, _decodedParams.setToken, _decodedParams.setAmount, _decodedParams.originalSender, _decodedParams.paymentToken, _decodedParams.limitAmount, _decodedParams.leveragedTokenData.collateralToken, _decodedParams.leveragedTokenData.collateralAmount - 2*ROUNDING_ERROR_MARGIN, _decodedParams.paymentTokenSwapData ); require(amountOutputToken >= _decodedParams.limitAmount, "ExchangeIssuance: INSUFFICIENT OUTPUT AMOUNT"); } /** * Returns the collateral / debt token addresses and amounts for a leveraged index * * @param _setToken Address of the SetToken to be issued / redeemed * @param _setAmount Amount of SetTokens to issue / redeem * @param _isIssuance Boolean indicating if the SetToken is to be issued or redeemed * * @return Struct containing the collateral / debt token addresses and amounts */ function _getLeveragedTokenData( ISetToken _setToken, uint256 _setAmount, bool _isIssuance ) internal view returns (LeveragedTokenData memory) { address[] memory components; uint256[] memory equityPositions; uint256[] memory debtPositions; if(_isIssuance){ (components, equityPositions, debtPositions) = debtIssuanceModule.getRequiredComponentIssuanceUnits(_setToken, _setAmount); } else { (components, equityPositions, debtPositions) = debtIssuanceModule.getRequiredComponentRedemptionUnits(_setToken, _setAmount); } require(components.length == 2, "ExchangeIssuance: TOO MANY COMPONENTS"); require(equityPositions[0] == 0 || equityPositions[1] == 0, "ExchangeIssuance: TOO MANY EQUITY POSITIONS"); require(debtPositions[0] == 0 || debtPositions[1] == 0, "ExchangeIssuance: TOO MANY DEBT POSITIONS"); if(equityPositions[0] > 0){ return LeveragedTokenData( components[0], IAToken(components[0]).UNDERLYING_ASSET_ADDRESS(), equityPositions[0] + ROUNDING_ERROR_MARGIN, components[1], debtPositions[1] ); } else { return LeveragedTokenData( components[1], IAToken(components[1]).UNDERLYING_ASSET_ADDRESS(), equityPositions[1] + ROUNDING_ERROR_MARGIN, components[0], debtPositions[0] ); } } /** * Approves max amount of given token to all exchange routers and the debt issuance module * * @param _token Address of the token to be approved */ function _approveToken(IERC20 _token) internal { _safeApprove(_token, address(debtIssuanceModule), MAX_UINT256); } /** * Initiates a flashloan call with the correct parameters for issuing set tokens in the callback * Borrows correct amount of collateral token and and forwards encoded memory to controll issuance in the callback. * * @param _setToken Address of the SetToken being initialized * @param _setAmount Amount of the SetToken being initialized * @param _inputToken Address of the input token to pay with * @param _maxAmountInputToken Maximum amount of input token to pay * @param _swapDataDebtForCollateral Data (token addresses and fee levels) to describe the swap path from Debt to collateral token * @param _swapDataInputToken Data (token addresses and fee levels) to describe the swap path from input to collateral token */ function _initiateIssuance( ISetToken _setToken, uint256 _setAmount, address _inputToken, uint256 _maxAmountInputToken, DEXAdapter.SwapData memory _swapDataDebtForCollateral, DEXAdapter.SwapData memory _swapDataInputToken ) internal { aaveLeverageModule.sync(_setToken); LeveragedTokenData memory leveragedTokenData = _getLeveragedTokenData(_setToken, _setAmount, true); address[] memory assets = new address[](1); assets[0] = leveragedTokenData.collateralToken; uint[] memory amounts = new uint[](1); amounts[0] = leveragedTokenData.collateralAmount; bytes memory params = abi.encode( DecodedParams( _setToken, _setAmount, msg.sender, true, _inputToken, _maxAmountInputToken, leveragedTokenData, _swapDataDebtForCollateral, _swapDataInputToken ) ); _flashloan(assets, amounts, params); } /** * Initiates a flashloan call with the correct parameters for redeeming set tokens in the callback * * @param _setToken Address of the SetToken to redeem * @param _setAmount Amount of the SetToken to redeem * @param _outputToken Address of token to return to the user * @param _minAmountOutputToken Minimum amount of output token to receive * @param _swapDataCollateralForDebt Data (token path and fee levels) describing the swap from Collateral Token to Debt Token * @param _swapDataOutputToken Data (token path and fee levels) describing the swap from Collateral Token to Output token */ function _initiateRedemption( ISetToken _setToken, uint256 _setAmount, address _outputToken, uint256 _minAmountOutputToken, DEXAdapter.SwapData memory _swapDataCollateralForDebt, DEXAdapter.SwapData memory _swapDataOutputToken ) internal { aaveLeverageModule.sync(_setToken); LeveragedTokenData memory leveragedTokenData = _getLeveragedTokenData(_setToken, _setAmount, false); address[] memory assets = new address[](1); assets[0] = leveragedTokenData.debtToken; uint[] memory amounts = new uint[](1); amounts[0] = leveragedTokenData.debtAmount; bytes memory params = abi.encode( DecodedParams( _setToken, _setAmount, msg.sender, false, _outputToken, _minAmountOutputToken, leveragedTokenData, _swapDataCollateralForDebt, _swapDataOutputToken ) ); _flashloan(assets, amounts, params); } /** * Gets rid of the obtained collateral tokens from redemption by either sending them to the user * directly or converting them to the payment token and sending those out. * * @param _collateralTokenSpent Amount of collateral token spent to obtain the debt token required for redemption * @param _setToken Address of the SetToken to be issued * @param _setAmount Amount of SetTokens to issue * @param _originalSender Address of the user who initiated the redemption * @param _outputToken Address of token to return to the user * @param _collateralToken Address of the collateral token to sell * @param _collateralAmount Amount of collateral token to sell * @param _minAmountOutputToken Minimum amount of output token to return to the user * @param _swapData Struct containing path and fee data for swap * * @return Amount of output token returned to the user */ function _liquidateCollateralTokens( uint256 _collateralTokenSpent, ISetToken _setToken, uint256 _setAmount, address _originalSender, address _outputToken, uint256 _minAmountOutputToken, address _collateralToken, uint256 _collateralAmount, DEXAdapter.SwapData memory _swapData ) internal returns (uint256) { require(_collateralAmount >= _collateralTokenSpent, "ExchangeIssuance: OVERSPENT COLLATERAL TOKEN"); uint256 amountToReturn = _collateralAmount.sub(_collateralTokenSpent); uint256 outputAmount; if(_outputToken == DEXAdapter.ETH_ADDRESS){ outputAmount = _liquidateCollateralTokensForETH( _collateralToken, amountToReturn, _originalSender, _minAmountOutputToken, _swapData ); } else { outputAmount = _liquidateCollateralTokensForERC20( _collateralToken, amountToReturn, _originalSender, IERC20(_outputToken), _minAmountOutputToken, _swapData ); } emit ExchangeRedeem(_originalSender, _setToken, _outputToken, _setAmount, outputAmount); return outputAmount; } /** * Returns the collateralToken directly to the user * * @param _collateralToken Address of the the collateral token * @param _collateralRemaining Amount of the collateral token remaining after buying required debt tokens * @param _originalSender Address of the original sender to return the tokens to */ function _returnCollateralTokensToSender( address _collateralToken, uint256 _collateralRemaining, address _originalSender ) internal { IERC20(_collateralToken).transfer(_originalSender, _collateralRemaining); } /** * Sells the collateral tokens for the selected output ERC20 and returns that to the user * * @param _collateralToken Address of the collateral token * @param _collateralRemaining Amount of the collateral token remaining after buying required debt tokens * @param _originalSender Address of the original sender to return the tokens to * @param _outputToken Address of token to return to the user * @param _minAmountOutputToken Minimum amount of output token to return to the user * @param _swapData Data (token path and fee levels) describing the swap path from Collateral Token to Output token * * @return Amount of output token returned to the user */ function _liquidateCollateralTokensForERC20( address _collateralToken, uint256 _collateralRemaining, address _originalSender, IERC20 _outputToken, uint256 _minAmountOutputToken, DEXAdapter.SwapData memory _swapData ) internal returns (uint256) { if(address(_outputToken) == _collateralToken){ _returnCollateralTokensToSender(_collateralToken, _collateralRemaining, _originalSender); return _collateralRemaining; } uint256 outputTokenAmount = _swapCollateralForOutputToken( _collateralToken, _collateralRemaining, address(_outputToken), _minAmountOutputToken, _swapData ); _outputToken.transfer(_originalSender, outputTokenAmount); return outputTokenAmount; } /** * Sells the remaining collateral tokens for weth, withdraws that and returns native eth to the user * * @param _collateralToken Address of the collateral token * @param _collateralRemaining Amount of the collateral token remaining after buying required debt tokens * @param _originalSender Address of the original sender to return the eth to * @param _minAmountOutputToken Minimum amount of output token to return to user * @param _swapData Data (token path and fee levels) describing the swap path from Collateral Token to eth * * @return Amount of eth returned to the user */ function _liquidateCollateralTokensForETH( address _collateralToken, uint256 _collateralRemaining, address _originalSender, uint256 _minAmountOutputToken, DEXAdapter.SwapData memory _swapData ) internal isValidPath(_swapData.path, _collateralToken, addresses.weth) returns(uint256) { uint256 ethAmount = _swapCollateralForOutputToken( _collateralToken, _collateralRemaining, addresses.weth, _minAmountOutputToken, _swapData ); if (ethAmount > 0) { IWETH(addresses.weth).withdraw(ethAmount); (payable(_originalSender)).sendValue(ethAmount); } return ethAmount; } /** * Obtains the tokens necessary to return the flashloan by swapping the debt tokens obtained * from issuance and making up the shortfall using the users funds. * * @param _collateralToken collateral token to obtain * @param _amountRequired Amount of collateralToken required to repay the flashloan * @param _decodedParams Struct containing decoded data from original call passed through via flashloan * * @return Amount of input token spent */ function _obtainCollateralTokens( address _collateralToken, uint256 _amountRequired, DecodedParams memory _decodedParams ) internal returns (uint256) { uint collateralTokenObtained = _swapDebtForCollateralToken( _collateralToken, _decodedParams.leveragedTokenData.debtToken, _decodedParams.leveragedTokenData.debtAmount, _decodedParams.collateralAndDebtSwapData ); uint collateralTokenShortfall = _amountRequired.sub(collateralTokenObtained) + ROUNDING_ERROR_MARGIN; uint amountInputToken; if(_decodedParams.paymentToken == DEXAdapter.ETH_ADDRESS){ amountInputToken = _makeUpShortfallWithETH( _collateralToken, collateralTokenShortfall, _decodedParams.originalSender, _decodedParams.limitAmount, _decodedParams.paymentTokenSwapData ); } else { amountInputToken = _makeUpShortfallWithERC20( _collateralToken, collateralTokenShortfall, _decodedParams.originalSender, IERC20(_decodedParams.paymentToken), _decodedParams.limitAmount, _decodedParams.paymentTokenSwapData ); } emit ExchangeIssue( _decodedParams.originalSender, _decodedParams.setToken, _decodedParams.paymentToken, amountInputToken, _decodedParams.setAmount ); return amountInputToken; } /** * Issues set token using the previously obtained collateral token * Results in debt token being returned to the contract * * @param _setToken Address of the SetToken to be issued * @param _setAmount Amount of SetTokens to issue * @param _originalSender Adress that initiated the token issuance, which will receive the set tokens */ function _issueSet(ISetToken _setToken, uint256 _setAmount, address _originalSender) internal { debtIssuanceModule.issue(_setToken, _setAmount, _originalSender); } /** * Redeems set token using the previously obtained debt token * Results in collateral token being returned to the contract * * @param _setToken Address of the SetToken to be redeemed * @param _setAmount Amount of SetTokens to redeem * @param _originalSender Adress that initiated the token redemption which is the source of the set tokens to be redeemed */ function _redeemSet(ISetToken _setToken, uint256 _setAmount, address _originalSender) internal { _setToken.safeTransferFrom(_originalSender, address(this), _setAmount); debtIssuanceModule.redeem(_setToken, _setAmount, address(this)); } /** * Transfers the shortfall between the amount of tokens required to return flashloan and what was obtained * from swapping the debt tokens from the users address * * @param _token Address of the token to transfer from user * @param _shortfall Collateral token shortfall required to return the flashloan * @param _originalSender Adress that initiated the token issuance, which is the adresss form which to transfer the tokens */ function _transferShortfallFromSender( address _token, uint256 _shortfall, address _originalSender ) internal { if(_shortfall>0){ IERC20(_token).safeTransferFrom(_originalSender, address(this), _shortfall); } } /** * Makes up the collateral token shortfall with user specified ERC20 token * * @param _collateralToken Address of the collateral token * @param _collateralTokenShortfall Shortfall of collateral token that was not covered by selling the debt tokens * @param _originalSender Address of the original sender to return the tokens to * @param _inputToken Input token to pay with * @param _maxAmountInputToken Maximum amount of input token to spend * * @return Amount of input token spent */ function _makeUpShortfallWithERC20( address _collateralToken, uint256 _collateralTokenShortfall, address _originalSender, IERC20 _inputToken, uint256 _maxAmountInputToken, DEXAdapter.SwapData memory _swapData ) internal returns (uint256) { if(address(_inputToken) == _collateralToken){ _transferShortfallFromSender(_collateralToken, _collateralTokenShortfall, _originalSender); return _collateralTokenShortfall; } else { _inputToken.transferFrom(_originalSender, address(this), _maxAmountInputToken); uint256 amountInputToken = _swapInputForCollateralToken( _collateralToken, _collateralTokenShortfall, address(_inputToken), _maxAmountInputToken, _swapData ); if(amountInputToken < _maxAmountInputToken){ _inputToken.transfer(_originalSender, _maxAmountInputToken.sub(amountInputToken)); } return amountInputToken; } } /** * Makes up the collateral token shortfall with native eth * * @param _collateralToken Address of the collateral token * @param _collateralTokenShortfall Shortfall of collateral token that was not covered by selling the debt tokens * @param _originalSender Address of the original sender to return the tokens to * @param _maxAmountEth Maximum amount of eth to pay * * @return Amount of eth spent */ function _makeUpShortfallWithETH( address _collateralToken, uint256 _collateralTokenShortfall, address _originalSender, uint256 _maxAmountEth, DEXAdapter.SwapData memory _swapData ) internal returns(uint256) { IWETH(addresses.weth).deposit{value: _maxAmountEth}(); uint256 amountEth = _swapInputForCollateralToken( _collateralToken, _collateralTokenShortfall, addresses.weth, _maxAmountEth, _swapData ); if(_maxAmountEth > amountEth){ uint256 amountEthReturn = _maxAmountEth.sub(amountEth); IWETH(addresses.weth).withdraw(amountEthReturn); (payable(_originalSender)).sendValue(amountEthReturn); } return amountEth; } /** * Swaps the debt tokens obtained from issuance for the collateral * * @param _collateralToken Address of the collateral token buy * @param _debtToken Address of the debt token to sell * @param _debtAmount Amount of debt token to sell * @param _swapData Struct containing path and fee data for swap * * @return Amount of collateral token obtained */ function _swapDebtForCollateralToken( address _collateralToken, address _debtToken, uint256 _debtAmount, DEXAdapter.SwapData memory _swapData ) internal isValidPath(_swapData.path, _debtToken, _collateralToken) returns (uint256) { return addresses.swapExactTokensForTokens( _debtAmount, // minAmountOut is 0 here since we are going to make up the shortfall with the input token. // Sandwich protection is provided by the check at the end against _maxAmountInputToken parameter specified by the user 0, _swapData ); } /** * Acquires debt tokens needed for flashloan repayment by swapping a portion of the collateral tokens obtained from redemption * * @param _debtAmount Amount of debt token to buy * @param _debtToken Address of debt token * @param _collateralAmount Amount of collateral token available to spend / used as maxAmountIn parameter * @param _collateralToken Address of collateral token * @param _swapData Struct containing path and fee data for swap * * @return Amount of collateral token spent */ function _swapCollateralForDebtToken( uint256 _debtAmount, address _debtToken, uint256 _collateralAmount, address _collateralToken, DEXAdapter.SwapData memory _swapData ) internal isValidPath(_swapData.path, _collateralToken, _debtToken) returns (uint256) { return addresses.swapTokensForExactTokens( _debtAmount, _collateralAmount, _swapData ); } /** * Acquires the required amount of collateral tokens by swapping the input tokens * Does nothing if collateral and input token are indentical * * @param _collateralToken Address of collateral token * @param _amountRequired Remaining amount of collateral token required to repay flashloan, after having swapped debt tokens for collateral * @param _inputToken Address of input token to swap * @param _maxAmountInputToken Maximum amount of input token to spend * @param _swapData Data (token addresses and fee levels) describing the swap path * * @return Amount of input token spent */ function _swapInputForCollateralToken( address _collateralToken, uint256 _amountRequired, address _inputToken, uint256 _maxAmountInputToken, DEXAdapter.SwapData memory _swapData ) internal isValidPath( _swapData.path, _inputToken, _collateralToken ) returns (uint256) { if(_collateralToken == _inputToken) return _amountRequired; return addresses.swapTokensForExactTokens( _amountRequired, _maxAmountInputToken, _swapData ); } /** * Swaps the collateral tokens obtained from redemption for the selected output token * If both tokens are the same, does nothing * * @param _collateralToken Address of collateral token * @param _collateralTokenAmount Amount of colalteral token to swap * @param _outputToken Address of the ERC20 token to swap into * @param _minAmountOutputToken Minimum amount of output token to return to the user * @param _swapData Data (token addresses and fee levels) describing the swap path * * @return Amount of output token obtained */ function _swapCollateralForOutputToken( address _collateralToken, uint256 _collateralTokenAmount, address _outputToken, uint256 _minAmountOutputToken, DEXAdapter.SwapData memory _swapData ) internal isValidPath(_swapData.path, _collateralToken, _outputToken) returns (uint256) { return addresses.swapExactTokensForTokens( _collateralTokenAmount, _minAmountOutputToken, _swapData ); } /** * Deposit collateral to aave to obtain collateralAToken for issuance * * @param _collateralToken Address of collateral token * @param _depositAmount Amount to deposit */ function _depositCollateralToken( address _collateralToken, uint256 _depositAmount ) internal { LENDING_POOL.deposit(_collateralToken, _depositAmount, address(this), 0); } /** * Convert collateralAToken from set redemption to collateralToken by withdrawing underlying from Aave * * @param _collateralToken Address of the collateralToken to withdraw from Aave lending pool * @param _collateralAmount Amount of collateralToken to withdraw */ function _withdrawCollateralToken( address _collateralToken, uint256 _collateralAmount ) internal { LENDING_POOL.withdraw(_collateralToken, _collateralAmount, address(this)); } /** * Sets a max approval limit for an ERC20 token, provided the current allowance * is less than the required allownce. * * @param _token Token to approve * @param _spender Spender address to approve * @param _requiredAllowance Target allowance to set */ function _safeApprove( IERC20 _token, address _spender, uint256 _requiredAllowance ) internal { uint256 allowance = _token.allowance(address(this), _spender); if (allowance < _requiredAllowance) { _token.safeIncreaseAllowance(_spender, MAX_UINT256 - allowance); } } /** * Approves max amount of token to lending pool * * @param _token Address of the token to approve */ function _approveTokenToLendingPool( IERC20 _token ) internal { uint256 allowance = _token.allowance(address(this), address(LENDING_POOL)); if (allowance > 0) { _token.approve(address(LENDING_POOL), 0); } _token.approve(address(LENDING_POOL), MAX_UINT256); } /** * Triggers the flashloan from the Lending Pool * * @param assets Addresses of tokens to loan * @param amounts Amounts to loan * @param params Encoded memory to forward to the executeOperation method */ function _flashloan( address[] memory assets, uint256[] memory amounts, bytes memory params ) internal { address receiverAddress = address(this); address onBehalfOf = address(this); uint16 referralCode = 0; uint256[] memory modes = new uint256[](assets.length); // 0 = no debt (flash), 1 = stable, 2 = variable for (uint256 i = 0; i < assets.length; i++) { modes[i] = 0; } LENDING_POOL.flashLoan( receiverAddress, assets, amounts, modes, onBehalfOf, params, referralCode ); } /** * Redeems a given amount of SetToken. * * @param _setToken Address of the SetToken to be redeemed * @param _amount Amount of SetToken to be redeemed */ function _redeemExactSet(ISetToken _setToken, uint256 _amount) internal returns (uint256) { _setToken.safeTransferFrom(msg.sender, address(this), _amount); debtIssuanceModule.redeem(_setToken, _amount, address(this)); } }
/* Copyright 2020 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; interface IController { function addSet(address _setToken) external; function feeRecipient() external view returns(address); function getModuleFee(address _module, uint256 _feeType) external view returns(uint256); function isModule(address _module) external view returns(bool); function isSet(address _setToken) external view returns(bool); function isSystemContract(address _contractAddress) external view returns (bool); function resourceId(uint256 _id) external view returns(address); function owner() external view returns(address); function addFactory(address _factory) external; function addModule(address _module) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.10; interface IAToken { /** * @dev Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH) **/ function UNDERLYING_ASSET_ADDRESS() external view returns (address); }
/* Copyright 2021 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; import { ISetToken } from "./ISetToken.sol"; interface IAaveLeverageModule { function sync(ISetToken _setToken) external virtual; }
/* Copyright 2020 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity >=0.6.10; import { ISetToken } from "./ISetToken.sol"; import { IManagerIssuanceHook } from "./IManagerIssuanceHook.sol"; interface IDebtIssuanceModule { function getRequiredComponentIssuanceUnits( ISetToken _setToken, uint256 _quantity ) external view returns (address[] memory, uint256[] memory, uint256[] memory); function getRequiredComponentRedemptionUnits( ISetToken _setToken, uint256 _quantity ) external view returns (address[] memory, uint256[] memory, uint256[] memory); function issue(ISetToken _setToken, uint256 _quantity, address _to) external; function redeem(ISetToken _token, uint256 _quantity, address _to) external; function initialize( ISetToken _setToken, uint256 _maxManagerFee, uint256 _managerIssueFee, uint256 _managerRedeemFee, address _feeRecipient, IManagerIssuanceHook _managerIssuanceHook ) external; }
// SPDX-License-Identifier: Apache License, Version 2.0 pragma solidity 0.6.10; pragma experimental "ABIEncoderV2"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title ISetToken * @author Set Protocol * * Interface for operating with SetTokens. */ interface ISetToken is IERC20 { /* ============ Enums ============ */ enum ModuleState { NONE, PENDING, INITIALIZED } /* ============ Structs ============ */ /** * The base definition of a SetToken Position * * @param component Address of token in the Position * @param module If not in default state, the address of associated module * @param unit Each unit is the # of components per 10^18 of a SetToken * @param positionState Position ENUM. Default is 0; External is 1 * @param data Arbitrary data */ struct Position { address component; address module; int256 unit; uint8 positionState; bytes data; } /** * A struct that stores a component's cash position details and external positions * This data structure allows O(1) access to a component's cash position units and * virtual units. * * @param virtualUnit Virtual value of a component's DEFAULT position. Stored as virtual for efficiency * updating all units at once via the position multiplier. Virtual units are achieved * by dividing a "real" value by the "positionMultiplier" * @param componentIndex * @param externalPositionModules List of external modules attached to each external position. Each module * maps to an external position * @param externalPositions Mapping of module => ExternalPosition struct for a given component */ struct ComponentPosition { int256 virtualUnit; address[] externalPositionModules; mapping(address => ExternalPosition) externalPositions; } /** * A struct that stores a component's external position details including virtual unit and any * auxiliary data. * * @param virtualUnit Virtual value of a component's EXTERNAL position. * @param data Arbitrary data */ struct ExternalPosition { int256 virtualUnit; bytes data; } /* ============ Functions ============ */ function addComponent(address _component) external; function removeComponent(address _component) external; function editDefaultPositionUnit(address _component, int256 _realUnit) external; function addExternalPositionModule(address _component, address _positionModule) external; function removeExternalPositionModule(address _component, address _positionModule) external; function editExternalPositionUnit(address _component, address _positionModule, int256 _realUnit) external; function editExternalPositionData(address _component, address _positionModule, bytes calldata _data) external; function invoke(address _target, uint256 _value, bytes calldata _data) external returns(bytes memory); function editPositionMultiplier(int256 _newMultiplier) external; function mint(address _account, uint256 _quantity) external; function burn(address _account, uint256 _quantity) external; function lock() external; function unlock() external; function addModule(address _module) external; function removeModule(address _module) external; function initializeModule() external; function setManager(address _manager) external; function manager() external view returns (address); function moduleStates(address _module) external view returns (ModuleState); function getModules() external view returns (address[] memory); function getDefaultPositionRealUnit(address _component) external view returns(int256); function getExternalPositionRealUnit(address _component, address _positionModule) external view returns(int256); function getComponents() external view returns(address[] memory); function getExternalPositionModules(address _component) external view returns(address[] memory); function getExternalPositionData(address _component, address _positionModule) external view returns(bytes memory); function isExternalPositionModule(address _component, address _module) external view returns(bool); function isComponent(address _component) external view returns(bool); function positionMultiplier() external view returns (int256); function getPositions() external view returns (Position[] memory); function getTotalComponentRealUnits(address _component) external view returns(int256); function isInitializedModule(address _module) external view returns(bool); function isPendingModule(address _module) external view returns(bool); function isLocked() external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol'; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; library UniSushiV2Library { using SafeMath for uint; // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } // fetches and sorts the reserves for a pair function getReserves(address pair, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) { (address token0,) = sortTokens(tokenA, tokenB); (uint reserve0, uint reserve1,) = IUniswapV2Pair(pair).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) { require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); amountB = amountA.mul(reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) { require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) { require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } } // performs chained getAmountIn calculations on any number of pairs function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[amounts.length - 1] = amountOut; for (uint i = path.length - 1; i > 0; i--) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } }
/* Copyright 2022 Index Cooperative Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import { IUniswapV2Router02 } from "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; import { ICurveCalculator } from "../interfaces/external/ICurveCalculator.sol"; import { ICurveAddressProvider } from "../interfaces/external/ICurveAddressProvider.sol"; import { ICurvePoolRegistry } from "../interfaces/external/ICurvePoolRegistry.sol"; import { ICurvePool } from "../interfaces/external/ICurvePool.sol"; import { ISwapRouter} from "../interfaces/external/ISwapRouter.sol"; import { IQuoter } from "../interfaces/IQuoter.sol"; import { IWETH } from "../interfaces/IWETH.sol"; import { PreciseUnitMath } from "../lib/PreciseUnitMath.sol"; /** * @title DEXAdapter * @author Index Coop * * Adapter to execute swaps on different DEXes */ library DEXAdapter { using SafeERC20 for IERC20; using PreciseUnitMath for uint256; using SafeMath for uint256; /* ============ Constants ============= */ uint256 constant private MAX_UINT256 = type(uint256).max; address public constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; uint256 public constant ROUNDING_ERROR_MARGIN = 2; /* ============ Enums ============ */ enum Exchange { None, Quickswap, Sushiswap, UniV3, Curve } /* ============ Structs ============ */ struct Addresses { address quickRouter; address sushiRouter; address uniV3Router; address uniV3Quoter; address curveAddressProvider; address curveCalculator; // Wrapped native token (WMATIC on polygon) address weth; } struct SwapData { address[] path; uint24[] fees; address pool; Exchange exchange; } struct CurvePoolData { int128 nCoins; uint256[8] balances; uint256 A; uint256 fee; uint256[8] rates; uint256[8] decimals; } /** * Swap exact tokens for another token on a given DEX. * * @param _addresses Struct containing relevant smart contract addresses. * @param _amountIn The amount of input token to be spent * @param _minAmountOut Minimum amount of output token to receive * @param _swapData Swap data containing the path and fee levels (latter only used for uniV3) * * @return amountOut The amount of output tokens */ function swapExactTokensForTokens( Addresses memory _addresses, uint256 _amountIn, uint256 _minAmountOut, SwapData memory _swapData ) external returns (uint256) { if (_swapData.path[0] == _swapData.path[_swapData.path.length -1]) { return _amountIn; } if(_swapData.exchange == Exchange.Curve){ return _swapExactTokensForTokensCurve( _swapData.path, _swapData.pool, _amountIn, _minAmountOut, _addresses ); } if(_swapData.exchange== Exchange.UniV3){ return _swapExactTokensForTokensUniV3( _swapData.path, _swapData.fees, _amountIn, _minAmountOut, ISwapRouter(_addresses.uniV3Router) ); } else { return _swapExactTokensForTokensUniV2( _swapData.path, _amountIn, _minAmountOut, _getRouter(_swapData.exchange, _addresses) ); } } /** * Swap tokens for exact amount of output tokens on a given DEX. * * @param _addresses Struct containing relevant smart contract addresses. * @param _amountOut The amount of output token required * @param _maxAmountIn Maximum amount of input token to be spent * @param _swapData Swap data containing the path and fee levels (latter only used for uniV3) * * @return amountIn The amount of input tokens spent */ function swapTokensForExactTokens( Addresses memory _addresses, uint256 _amountOut, uint256 _maxAmountIn, SwapData memory _swapData ) external returns (uint256 amountIn) { if (_swapData.path[0] == _swapData.path[_swapData.path.length -1]) { return _amountOut; } if(_swapData.exchange == Exchange.Curve){ return _swapTokensForExactTokensCurve( _swapData.path, _swapData.pool, _amountOut, _maxAmountIn, _addresses ); } if(_swapData.exchange == Exchange.UniV3){ return _swapTokensForExactTokensUniV3( _swapData.path, _swapData.fees, _amountOut, _maxAmountIn, ISwapRouter(_addresses.uniV3Router) ); } else { return _swapTokensForExactTokensUniV2( _swapData.path, _amountOut, _maxAmountIn, _getRouter(_swapData.exchange, _addresses) ); } } /** * Gets the output amount of a token swap. * * @param _swapData the swap parameters * @param _addresses Struct containing relevant smart contract addresses. * @param _amountIn the input amount of the trade * * @return the output amount of the swap */ function getAmountOut( Addresses memory _addresses, SwapData memory _swapData, uint256 _amountIn ) external returns (uint256) { if (_swapData.path.length == 0 || _swapData.path[0] == _swapData.path[_swapData.path.length-1]) { return _amountIn; } if (_swapData.exchange == Exchange.UniV3) { return _getAmountOutUniV3(_swapData, _addresses.uniV3Quoter, _amountIn); } else if (_swapData.exchange == Exchange.Curve) { (int128 i, int128 j) = _getCoinIndices( _swapData.pool, _swapData.path[0], _swapData.path[1], ICurveAddressProvider(_addresses.curveAddressProvider) ); return _getAmountOutCurve(_swapData.pool, i, j, _amountIn, _addresses); } else { return _getAmountOutUniV2( _swapData, _getRouter(_swapData.exchange, _addresses), _amountIn ); } } /** * Gets the input amount of a fixed output swap. * * @param _swapData the swap parameters * @param _addresses Struct containing relevant smart contract addresses. * @param _amountOut the output amount of the swap * * @return the input amount of the swap */ function getAmountIn( Addresses memory _addresses, SwapData memory _swapData, uint256 _amountOut ) external returns (uint256) { if (_swapData.path.length == 0 || _swapData.path[0] == _swapData.path[_swapData.path.length-1]) { return _amountOut; } if (_swapData.exchange == Exchange.UniV3) { return _getAmountInUniV3(_swapData, _addresses.uniV3Quoter, _amountOut); } else if (_swapData.exchange == Exchange.Curve) { (int128 i, int128 j) = _getCoinIndices( _swapData.pool, _swapData.path[0], _swapData.path[1], ICurveAddressProvider(_addresses.curveAddressProvider) ); return _getAmountInCurve(_swapData.pool, i, j, _amountOut, _addresses); } else { return _getAmountInUniV2( _swapData, _getRouter(_swapData.exchange, _addresses), _amountOut ); } } /** * Sets a max approval limit for an ERC20 token, provided the current allowance * is less than the required allownce. * * @param _token Token to approve * @param _spender Spender address to approve * @param _requiredAllowance Target allowance to set */ function _safeApprove( IERC20 _token, address _spender, uint256 _requiredAllowance ) internal { uint256 allowance = _token.allowance(address(this), _spender); if (allowance < _requiredAllowance) { _token.safeIncreaseAllowance(_spender, MAX_UINT256 - allowance); } } /* ============ Private Methods ============ */ /** * Execute exact output swap via a UniV2 based DEX. (such as sushiswap); * * @param _path List of token address to swap via. * @param _amountOut The amount of output token required * @param _maxAmountIn Maximum amount of input token to be spent * @param _router Address of the uniV2 router to use * * @return amountIn The amount of input tokens spent */ function _swapTokensForExactTokensUniV2( address[] memory _path, uint256 _amountOut, uint256 _maxAmountIn, IUniswapV2Router02 _router ) private returns (uint256) { _safeApprove(IERC20(_path[0]), address(_router), _maxAmountIn); return _router.swapTokensForExactTokens(_amountOut, _maxAmountIn, _path, address(this), block.timestamp)[0]; } /** * Execute exact output swap via UniswapV3 * * @param _path List of token address to swap via. (In the order as * expected by uniV2, the first element being the input toen) * @param _fees List of fee levels identifying the pools to swap via. * (_fees[0] refers to pool between _path[0] and _path[1]) * @param _amountOut The amount of output token required * @param _maxAmountIn Maximum amount of input token to be spent * @param _uniV3Router Address of the uniswapV3 router * * @return amountIn The amount of input tokens spent */ function _swapTokensForExactTokensUniV3( address[] memory _path, uint24[] memory _fees, uint256 _amountOut, uint256 _maxAmountIn, ISwapRouter _uniV3Router ) private returns(uint256) { require(_path.length == _fees.length + 1, "ExchangeIssuance: PATHS_FEES_MISMATCH"); _safeApprove(IERC20(_path[0]), address(_uniV3Router), _maxAmountIn); if(_path.length == 2){ ISwapRouter.ExactOutputSingleParams memory params = ISwapRouter.ExactOutputSingleParams({ tokenIn: _path[0], tokenOut: _path[1], fee: _fees[0], recipient: address(this), deadline: block.timestamp, amountOut: _amountOut, amountInMaximum: _maxAmountIn, sqrtPriceLimitX96: 0 }); return _uniV3Router.exactOutputSingle(params); } else { bytes memory pathV3 = _encodePathV3(_path, _fees, true); ISwapRouter.ExactOutputParams memory params = ISwapRouter.ExactOutputParams({ path: pathV3, recipient: address(this), deadline: block.timestamp, amountOut: _amountOut, amountInMaximum: _maxAmountIn }); return _uniV3Router.exactOutput(params); } } /** * Execute exact input swap via Curve * * @param _path Path (has to be of length 2) * @param _pool Address of curve pool to use * @param _amountIn The amount of input token to be spent * @param _minAmountOut Minimum amount of output token to receive * @param _addresses Struct containing relevant smart contract addresses. * * @return amountOut The amount of output token obtained */ function _swapExactTokensForTokensCurve( address[] memory _path, address _pool, uint256 _amountIn, uint256 _minAmountOut, Addresses memory _addresses ) private returns (uint256 amountOut) { require(_path.length == 2, "ExchangeIssuance: CURVE_WRONG_PATH_LENGTH"); (int128 i, int128 j) = _getCoinIndices(_pool, _path[0], _path[1], ICurveAddressProvider(_addresses.curveAddressProvider)); if(_path[0] == ETH_ADDRESS){ IWETH(_addresses.weth).withdraw(_amountIn); } amountOut = _exchangeCurve(i, j, _pool, _amountIn, _minAmountOut, _path[0]); if(_path[_path.length-1] == ETH_ADDRESS){ IWETH(_addresses.weth).deposit{value: amountOut}(); } } /** * Execute exact output swap via Curve * * @param _path Path (has to be of length 2) * @param _pool Address of curve pool to use * @param _amountOut The amount of output token required * @param _maxAmountIn Maximum amount of input token to be spent * * @return amountOut The amount of output token obtained */ function _swapTokensForExactTokensCurve( address[] memory _path, address _pool, uint256 _amountOut, uint256 _maxAmountIn, Addresses memory _addresses ) private returns (uint256) { require(_path.length == 2, "ExchangeIssuance: CURVE_WRONG_PATH_LENGTH"); (int128 i, int128 j) = _getCoinIndices(_pool, _path[0], _path[1], ICurveAddressProvider(_addresses.curveAddressProvider)); if(_path[0] == ETH_ADDRESS){ IWETH(_addresses.weth).withdraw(_maxAmountIn); } uint256 returnedAmountOut = _exchangeCurve(i, j, _pool, _maxAmountIn, _amountOut, _path[0]); require(_amountOut <= returnedAmountOut, "ExchangeIssuance: CURVE_UNDERBOUGHT"); uint256 swappedBackAmountIn; if(returnedAmountOut > _amountOut){ swappedBackAmountIn = _exchangeCurve(j, i, _pool, returnedAmountOut.sub(_amountOut), 0, _path[1]); if(_path[0] == ETH_ADDRESS){ IWETH(_addresses.weth).deposit{ value: swappedBackAmountIn }(); } } if(_path[_path.length-1] == ETH_ADDRESS){ IWETH(_addresses.weth).deposit{ value: _amountOut }(); } return _maxAmountIn.sub(swappedBackAmountIn); } function _exchangeCurve( int128 _i, int128 _j, address _pool, uint256 _amountIn, uint256 _minAmountOut, address _from ) private returns (uint256 amountOut) { ICurvePool pool = ICurvePool(_pool); if(_from == ETH_ADDRESS){ amountOut = pool.exchange{value: _amountIn}( _i, _j, _amountIn, _minAmountOut ); } else { IERC20(_from).approve(_pool, _amountIn); amountOut = pool.exchange( _i, _j, _amountIn, _minAmountOut ); } } /** * Calculate required input amount to get a given output amount via Curve swap * * @param _i Index of input token as per the ordering of the pools tokens * @param _j Index of output token as per the ordering of the pools tokens * @param _pool Address of curve pool to use * @param _amountOut The amount of output token to be received * @param _addresses Struct containing relevant smart contract addresses. * * @return amountOut The amount of output token obtained */ function _getAmountInCurve( address _pool, int128 _i, int128 _j, uint256 _amountOut, Addresses memory _addresses ) private view returns (uint256) { CurvePoolData memory poolData = _getCurvePoolData(_pool, ICurveAddressProvider(_addresses.curveAddressProvider)); return ICurveCalculator(_addresses.curveCalculator).get_dx( poolData.nCoins, poolData.balances, poolData.A, poolData.fee, poolData.rates, poolData.decimals, false, _i, _j, _amountOut ) + ROUNDING_ERROR_MARGIN; } /** * Calculate output amount of a Curve swap * * @param _i Index of input token as per the ordering of the pools tokens * @param _j Index of output token as per the ordering of the pools tokens * @param _pool Address of curve pool to use * @param _amountIn The amount of output token to be received * @param _addresses Struct containing relevant smart contract addresses. * * @return amountOut The amount of output token obtained */ function _getAmountOutCurve( address _pool, int128 _i, int128 _j, uint256 _amountIn, Addresses memory _addresses ) private view returns (uint256) { return ICurvePool(_pool).get_dy(_i, _j, _amountIn); } /** * Get metadata on curve pool required to calculate input amount from output amount * * @param _pool Address of curve pool to use * @param _curveAddressProvider Address of curve address provider * * @return Struct containing all required data to perform getAmountInCurve calculation */ function _getCurvePoolData( address _pool, ICurveAddressProvider _curveAddressProvider ) private view returns(CurvePoolData memory) { ICurvePoolRegistry registry = ICurvePoolRegistry(_curveAddressProvider.get_registry()); return CurvePoolData( int128(registry.get_n_coins(_pool)[0]), registry.get_balances(_pool), registry.get_A(_pool), registry.get_fees(_pool)[0], registry.get_rates(_pool), registry.get_decimals(_pool) ); } /** * Get token indices for given pool * NOTE: This was necessary sine the get_coin_indices function of the CurvePoolRegistry did not work for StEth/ETH pool * * @param _pool Address of curve pool to use * @param _from Address of input token * @param _to Address of output token * @param _curveAddressProvider Address of curve address provider * * @return i Index of input token * @return j Index of output token */ function _getCoinIndices( address _pool, address _from, address _to, ICurveAddressProvider _curveAddressProvider ) private view returns (int128 i, int128 j) { ICurvePoolRegistry registry = ICurvePoolRegistry(_curveAddressProvider.get_registry()); // Set to out of range index to signal the coin is not found yet i = 9; j = 9; address[8] memory poolCoins = registry.get_coins(_pool); for(uint256 k = 0; k < 8; k++){ if(poolCoins[k] == _from){ i = int128(k); } else if(poolCoins[k] == _to){ j = int128(k); } // ZeroAddress signals end of list if(poolCoins[k] == address(0) || (i != 9 && j != 9)){ break; } } require(i != 9, "ExchangeIssuance: CURVE_FROM_NOT_FOUND"); require(j != 9, "ExchangeIssuance: CURVE_TO_NOT_FOUND"); return (i, j); } /** * Execute exact input swap via UniswapV3 * * @param _path List of token address to swap via. * @param _fees List of fee levels identifying the pools to swap via. * (_fees[0] refers to pool between _path[0] and _path[1]) * @param _amountIn The amount of input token to be spent * @param _minAmountOut Minimum amount of output token to receive * @param _uniV3Router Address of the uniswapV3 router * * @return amountOut The amount of output token obtained */ function _swapExactTokensForTokensUniV3( address[] memory _path, uint24[] memory _fees, uint256 _amountIn, uint256 _minAmountOut, ISwapRouter _uniV3Router ) private returns (uint256) { require(_path.length == _fees.length + 1, "ExchangeIssuance: PATHS_FEES_MISMATCH"); _safeApprove(IERC20(_path[0]), address(_uniV3Router), _amountIn); if(_path.length == 2){ ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({ tokenIn: _path[0], tokenOut: _path[1], fee: _fees[0], recipient: address(this), deadline: block.timestamp, amountIn: _amountIn, amountOutMinimum: _minAmountOut, sqrtPriceLimitX96: 0 }); return _uniV3Router.exactInputSingle(params); } else { bytes memory pathV3 = _encodePathV3(_path, _fees, false); ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({ path: pathV3, recipient: address(this), deadline: block.timestamp, amountIn: _amountIn, amountOutMinimum: _minAmountOut }); uint amountOut = _uniV3Router.exactInput(params); return amountOut; } } /** * Execute exact input swap via UniswapV2 * * @param _path List of token address to swap via. * @param _amountIn The amount of input token to be spent * @param _minAmountOut Minimum amount of output token to receive * @param _router Address of uniV2 router to use * * @return amountOut The amount of output token obtained */ function _swapExactTokensForTokensUniV2( address[] memory _path, uint256 _amountIn, uint256 _minAmountOut, IUniswapV2Router02 _router ) private returns (uint256) { _safeApprove(IERC20(_path[0]), address(_router), _amountIn); // NOTE: The following was changed from always returning result at position [1] to returning the last element of the result array // With this change, the actual output is correctly returned also for multi-hop swaps // See https://github.com/IndexCoop/index-coop-smart-contracts/pull/116 uint256[] memory result = _router.swapExactTokensForTokens(_amountIn, _minAmountOut, _path, address(this), block.timestamp); // result = uint[] memory The input token amount and all subsequent output token amounts. // we are usually only interested in the actual amount of the output token (so result element at the last place) return result[result.length-1]; } /** * Gets the output amount of a token swap on Uniswap V2 * * @param _swapData the swap parameters * @param _router the uniswap v2 router address * @param _amountIn the input amount of the trade * * @return the output amount of the swap */ function _getAmountOutUniV2( SwapData memory _swapData, IUniswapV2Router02 _router, uint256 _amountIn ) private view returns (uint256) { return _router.getAmountsOut(_amountIn, _swapData.path)[_swapData.path.length-1]; } /** * Gets the input amount of a fixed output swap on Uniswap V2. * * @param _swapData the swap parameters * @param _router the uniswap v2 router address * @param _amountOut the output amount of the swap * * @return the input amount of the swap */ function _getAmountInUniV2( SwapData memory _swapData, IUniswapV2Router02 _router, uint256 _amountOut ) private view returns (uint256) { return _router.getAmountsIn(_amountOut, _swapData.path)[0]; } /** * Gets the output amount of a token swap on Uniswap V3. * * @param _swapData the swap parameters * @param _quoter the uniswap v3 quoter * @param _amountIn the input amount of the trade * * @return the output amount of the swap */ function _getAmountOutUniV3( SwapData memory _swapData, address _quoter, uint256 _amountIn ) private returns (uint256) { bytes memory path = _encodePathV3(_swapData.path, _swapData.fees, false); return IQuoter(_quoter).quoteExactInput(path, _amountIn); } /** * Gets the input amount of a fixed output swap on Uniswap V3. * * @param _swapData the swap parameters * @param _quoter uniswap v3 quoter * @param _amountOut the output amount of the swap * * @return the input amount of the swap */ function _getAmountInUniV3( SwapData memory _swapData, address _quoter, uint256 _amountOut ) private returns (uint256) { bytes memory path = _encodePathV3(_swapData.path, _swapData.fees, true); return IQuoter(_quoter).quoteExactOutput(path, _amountOut); } /** * Encode path / fees to bytes in the format expected by UniV3 router * * @param _path List of token address to swap via (starting with input token) * @param _fees List of fee levels identifying the pools to swap via. * (_fees[0] refers to pool between _path[0] and _path[1]) * @param _reverseOrder Boolean indicating if path needs to be reversed to start with output token. * (which is the case for exact output swap) * * @return encodedPath Encoded path to be forwared to uniV3 router */ function _encodePathV3( address[] memory _path, uint24[] memory _fees, bool _reverseOrder ) private pure returns(bytes memory encodedPath) { if(_reverseOrder){ encodedPath = abi.encodePacked(_path[_path.length-1]); for(uint i = 0; i < _fees.length; i++){ uint index = _fees.length - i - 1; encodedPath = abi.encodePacked(encodedPath, _fees[index], _path[index]); } } else { encodedPath = abi.encodePacked(_path[0]); for(uint i = 0; i < _fees.length; i++){ encodedPath = abi.encodePacked(encodedPath, _fees[i], _path[i+1]); } } } function _getRouter( Exchange _exchange, Addresses memory _addresses ) private pure returns (IUniswapV2Router02) { return IUniswapV2Router02( (_exchange == Exchange.Quickswap) ? _addresses.quickRouter : _addresses.sushiRouter ); } }
/* Copyright 2020 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; import { SignedSafeMath } from "@openzeppelin/contracts/math/SignedSafeMath.sol"; /** * @title PreciseUnitMath * @author Set Protocol * * Arithmetic for fixed-point numbers with 18 decimals of precision. Some functions taken from * dYdX's BaseMath library. * * CHANGELOG: * - 9/21/20: Added safePower function */ library PreciseUnitMath { using SafeMath for uint256; using SignedSafeMath for int256; // The number One in precise units. uint256 constant internal PRECISE_UNIT = 10 ** 18; int256 constant internal PRECISE_UNIT_INT = 10 ** 18; // Max unsigned integer value uint256 constant internal MAX_UINT_256 = type(uint256).max; // Max and min signed integer value int256 constant internal MAX_INT_256 = type(int256).max; int256 constant internal MIN_INT_256 = type(int256).min; /** * @dev Getter function since constants can't be read directly from libraries. */ function preciseUnit() internal pure returns (uint256) { return PRECISE_UNIT; } /** * @dev Getter function since constants can't be read directly from libraries. */ function preciseUnitInt() internal pure returns (int256) { return PRECISE_UNIT_INT; } /** * @dev Getter function since constants can't be read directly from libraries. */ function maxUint256() internal pure returns (uint256) { return MAX_UINT_256; } /** * @dev Getter function since constants can't be read directly from libraries. */ function maxInt256() internal pure returns (int256) { return MAX_INT_256; } /** * @dev Getter function since constants can't be read directly from libraries. */ function minInt256() internal pure returns (int256) { return MIN_INT_256; } /** * @dev Multiplies value a by value b (result is rounded down). It's assumed that the value b is the significand * of a number with 18 decimals precision. */ function preciseMul(uint256 a, uint256 b) internal pure returns (uint256) { return a.mul(b).div(PRECISE_UNIT); } /** * @dev Multiplies value a by value b (result is rounded towards zero). It's assumed that the value b is the * significand of a number with 18 decimals precision. */ function preciseMul(int256 a, int256 b) internal pure returns (int256) { return a.mul(b).div(PRECISE_UNIT_INT); } /** * @dev Multiplies value a by value b (result is rounded up). It's assumed that the value b is the significand * of a number with 18 decimals precision. */ function preciseMulCeil(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0 || b == 0) { return 0; } return a.mul(b).sub(1).div(PRECISE_UNIT).add(1); } /** * @dev Divides value a by value b (result is rounded down). */ function preciseDiv(uint256 a, uint256 b) internal pure returns (uint256) { return a.mul(PRECISE_UNIT).div(b); } /** * @dev Divides value a by value b (result is rounded towards 0). */ function preciseDiv(int256 a, int256 b) internal pure returns (int256) { return a.mul(PRECISE_UNIT_INT).div(b); } /** * @dev Divides value a by value b (result is rounded up or away from 0). */ function preciseDivCeil(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "Cant divide by 0"); return a > 0 ? a.mul(PRECISE_UNIT).sub(1).div(b).add(1) : 0; } /** * @dev Divides value a by value b (result is rounded down - positive numbers toward 0 and negative away from 0). */ function divDown(int256 a, int256 b) internal pure returns (int256) { require(b != 0, "Cant divide by 0"); require(a != MIN_INT_256 || b != -1, "Invalid input"); int256 result = a.div(b); if (a ^ b < 0 && a % b != 0) { result -= 1; } return result; } /** * @dev Multiplies value a by value b where rounding is towards the lesser number. * (positive values are rounded towards zero and negative values are rounded away from 0). */ function conservativePreciseMul(int256 a, int256 b) internal pure returns (int256) { return divDown(a.mul(b), PRECISE_UNIT_INT); } /** * @dev Divides value a by value b where rounding is towards the lesser number. * (positive values are rounded towards zero and negative values are rounded away from 0). */ function conservativePreciseDiv(int256 a, int256 b) internal pure returns (int256) { return divDown(a.mul(PRECISE_UNIT_INT), b); } /** * @dev Performs the power on a specified value, reverts on overflow. */ function safePower( uint256 a, uint256 pow ) internal pure returns (uint256) { require(a > 0, "Value must be positive"); uint256 result = 1; for (uint256 i = 0; i < pow; i++){ uint256 previousResult = result; // Using safemath multiplication prevents overflows result = previousResult.mul(a); } return result; } }
// SPDX-License-Identifier: Apache License, Version 2.0 pragma solidity >=0.6.10; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; import { SafeMath } from '@openzeppelin/contracts/math/SafeMath.sol'; import { IERC20 } from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import { SafeERC20 } from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; import { IFlashLoanReceiverV2 } from './../../../contracts/interfaces/IFlashLoanReceiverV2.sol'; import { ILendingPoolAddressesProviderV2 } from './../../../contracts/interfaces/ILendingPoolAddressesProviderV2.sol'; import { ILendingPoolV2 } from './../../../contracts/interfaces/ILendingPoolV2.sol'; import "./utils/Withdrawable.sol"; /** !!! Never keep funds permanently on your FlashLoanReceiverBase contract as they could be exposed to a 'griefing' attack, where the stored funds are used by an attacker. !!! */ abstract contract FlashLoanReceiverBaseV2 is IFlashLoanReceiverV2 { using SafeERC20 for IERC20; using SafeMath for uint256; ILendingPoolAddressesProviderV2 public immutable override ADDRESSES_PROVIDER; ILendingPoolV2 public immutable override LENDING_POOL; constructor(address provider) public { ADDRESSES_PROVIDER = ILendingPoolAddressesProviderV2(provider); LENDING_POOL = ILendingPoolV2(ILendingPoolAddressesProviderV2(provider).getLendingPool()); } receive() payable external {} }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
/* Copyright 2020 Set Labs Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; import { ISetToken } from "./ISetToken.sol"; interface IManagerIssuanceHook { function invokePreIssueHook(ISetToken _setToken, uint256 _issueQuantity, address _sender, address _to) external; function invokePreRedeemHook(ISetToken _setToken, uint256 _redeemQuantity, address _sender, address _to) external; }
pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.6.10; pragma experimental ABIEncoderV2; /// @title Quoter Interface /// @notice Supports quoting the calculated amounts from exact input or exact output swaps /// @dev These functions are not marked view because they rely on calling non-view functions and reverting /// to compute the result. They are also not gas efficient and should not be called on-chain. interface IQuoter { /// @notice Returns the amount out received for a given exact input swap without executing the swap /// @param path The path of the swap, i.e. each token pair and the pool fee /// @param amountIn The amount of the first token to swap /// @return amountOut The amount of the last token that would be received function quoteExactInput(bytes memory path, uint256 amountIn) external returns (uint256 amountOut); /// @notice Returns the amount out received for a given exact input but for a swap of a single pool /// @param tokenIn The token being swapped in /// @param tokenOut The token being swapped out /// @param fee The fee of the token pool to consider for the pair /// @param amountIn The desired input amount /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap /// @return amountOut The amount of `tokenOut` that would be received function quoteExactInputSingle( address tokenIn, address tokenOut, uint24 fee, uint256 amountIn, uint160 sqrtPriceLimitX96 ) external returns (uint256 amountOut); /// @notice Returns the amount in required for a given exact output swap without executing the swap /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order /// @param amountOut The amount of the last token to receive /// @return amountIn The amount of first token required to be paid function quoteExactOutput(bytes memory path, uint256 amountOut) external returns (uint256 amountIn); /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool /// @param tokenIn The token being swapped in /// @param tokenOut The token being swapped out /// @param fee The fee of the token pool to consider for the pair /// @param amountOut The desired output amount /// @param sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap /// @return amountIn The amount required as the input for the swap in order to receive `amountOut` function quoteExactOutputSingle( address tokenIn, address tokenOut, uint24 fee, uint256 amountOut, uint160 sqrtPriceLimitX96 ) external returns (uint256 amountIn); }
/* Copyright 2022 Index Cooperative Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; // Implementation: https://etherscan.io/address/0xc1DB00a8E5Ef7bfa476395cdbcc98235477cDE4E#readContract interface ICurveCalculator { function get_dx( int128 n_coins, uint256[8] memory balances, uint256 amp, uint256 fee, uint256[8] memory rates, uint256[8] memory precisions, bool underlying, int128 i, int128 j, uint256 dy ) external view returns(uint256); function get_dy( int128 n_coins, uint256[8] memory balances, uint256 amp, uint256 fee, uint256[8] memory rates, uint256[8] memory precisions, bool underlying, int128 i, int128 j, uint256 dx ) external view returns(uint256); }
/* Copyright 2022 Index Cooperative Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; // Implementation: https://etherscan.io/address/0x0000000022d53366457f9d5e68ec105046fc4383#readContract interface ICurveAddressProvider { function get_registry() external view returns(address); function get_address(uint256 _id) external view returns(address); }
/* Copyright 2022 Index Cooperative Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; // Implementation: https://etherscan.io/address/0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5#readContract interface ICurvePoolRegistry { // amplification factor function get_A(address _pool) external view returns(uint256); function get_balances(address _pool) external view returns(uint256[8] memory); function get_coins(address _pool) external view returns(address[8] memory); function get_coin_indices(address _pool, address _from, address _to) external view returns(int128, int128, bool); function get_decimals(address _pool) external view returns(uint256[8] memory); function get_n_coins(address _pool) external view returns(uint256[2] memory); function get_fees(address _pool) external view returns(uint256[2] memory); function get_rates(address _pool) external view returns(uint256[8] memory); }
/* Copyright 2022 Index Cooperative Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 */ pragma solidity 0.6.10; pragma experimental ABIEncoderV2; // Implementation: https://etherscan.io/address/0x8e764bE4288B842791989DB5b8ec067279829809#writeContract interface ICurvePool { function exchange( int128 i, int128 j, uint256 dx, uint256 min_dy ) external payable returns (uint256); function get_dy( int128 i, int128 j, uint256 dx ) external view returns (uint256); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.6.10; pragma experimental ABIEncoderV2; /// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3 interface ISwapRouter { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInpuSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @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); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
pragma solidity >=0.6.2; import './IUniswapV2Router01.sol'; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @title SignedSafeMath * @dev Signed math operations with safety checks that revert on error. */ library SignedSafeMath { int256 constant private _INT256_MIN = -2**255; /** * @dev Returns the multiplication of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow"); int256 c = a * b; require(c / a == b, "SignedSafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two signed integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(int256 a, int256 b) internal pure returns (int256) { require(b != 0, "SignedSafeMath: division by zero"); require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow"); int256 c = a / b; return c; } /** * @dev Returns the subtraction of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow"); return c; } /** * @dev Returns the addition of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow"); return c; } }
pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.10; import { ILendingPoolAddressesProviderV2 } from "./ILendingPoolAddressesProviderV2.sol"; import { ILendingPoolV2 } from "./ILendingPoolV2.sol"; /** * @title IFlashLoanReceiverV2 interface * @notice Interface for the Aave fee IFlashLoanReceiver. * @author Aave * @dev implement this interface to develop a flashloan-compatible flashLoanReceiver contract **/ interface IFlashLoanReceiverV2 { function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address initiator, bytes calldata params ) external returns (bool); function ADDRESSES_PROVIDER() external view returns (ILendingPoolAddressesProviderV2); function LENDING_POOL() external view returns (ILendingPoolV2); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.10; /** * @title LendingPoolAddressesProvider contract * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles * - Acting also as factory of proxies and admin of those, so with right to change its implementations * - Owned by the Aave Governance * @author Aave **/ interface ILendingPoolAddressesProviderV2 { event MarketIdSet(string newMarketId); event LendingPoolUpdated(address indexed newAddress); event ConfigurationAdminUpdated(address indexed newAddress); event EmergencyAdminUpdated(address indexed newAddress); event LendingPoolConfiguratorUpdated(address indexed newAddress); event LendingPoolCollateralManagerUpdated(address indexed newAddress); event PriceOracleUpdated(address indexed newAddress); event LendingRateOracleUpdated(address indexed newAddress); event ProxyCreated(bytes32 id, address indexed newAddress); event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy); function getMarketId() external view returns (string memory); function setMarketId(string calldata marketId) external; function setAddress(bytes32 id, address newAddress) external; function setAddressAsProxy(bytes32 id, address impl) external; function getAddress(bytes32 id) external view returns (address); function getLendingPool() external view returns (address); function setLendingPoolImpl(address pool) external; function getLendingPoolConfigurator() external view returns (address); function setLendingPoolConfiguratorImpl(address configurator) external; function getLendingPoolCollateralManager() external view returns (address); function setLendingPoolCollateralManager(address manager) external; function getPoolAdmin() external view returns (address); function setPoolAdmin(address admin) external; function getEmergencyAdmin() external view returns (address); function setEmergencyAdmin(address admin) external; function getPriceOracle() external view returns (address); function setPriceOracle(address priceOracle) external; function getLendingRateOracle() external view returns (address); function setLendingRateOracle(address lendingRateOracle) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.10; pragma experimental ABIEncoderV2; import {ILendingPoolAddressesProviderV2} from "./ILendingPoolAddressesProviderV2.sol"; import {DataTypes} from "../../external/contracts/aaveV2/lib/DataTypes.sol"; interface ILendingPoolV2 { /** * @dev Emitted on deposit() * @param reserve The address of the underlying asset of the reserve * @param user The address initiating the deposit * @param onBehalfOf The beneficiary of the deposit, receiving the aTokens * @param amount The amount deposited * @param referral The referral code used **/ event Deposit( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint16 indexed referral ); /** * @dev Emitted on withdraw() * @param reserve The address of the underlyng asset being withdrawn * @param user The address initiating the withdrawal, owner of aTokens * @param to Address that will receive the underlying * @param amount The amount to be withdrawn **/ event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount); /** * @dev Emitted on borrow() and flashLoan() when debt needs to be opened * @param reserve The address of the underlying asset being borrowed * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just * initiator of the transaction on flashLoan() * @param onBehalfOf The address that will be getting the debt * @param amount The amount borrowed out * @param borrowRateMode The rate mode: 1 for Stable, 2 for Variable * @param borrowRate The numeric rate at which the user has borrowed * @param referral The referral code used **/ event Borrow( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint256 borrowRateMode, uint256 borrowRate, uint16 indexed referral ); /** * @dev Emitted on repay() * @param reserve The address of the underlying asset of the reserve * @param user The beneficiary of the repayment, getting his debt reduced * @param repayer The address of the user initiating the repay(), providing the funds * @param amount The amount repaid **/ event Repay( address indexed reserve, address indexed user, address indexed repayer, uint256 amount ); /** * @dev Emitted on swapBorrowRateMode() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user swapping his rate mode * @param rateMode The rate mode that the user wants to swap to **/ event Swap(address indexed reserve, address indexed user, uint256 rateMode); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral **/ event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral **/ event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); /** * @dev Emitted on rebalanceStableBorrowRate() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user for which the rebalance has been executed **/ event RebalanceStableBorrowRate(address indexed reserve, address indexed user); /** * @dev Emitted on flashLoan() * @param target The address of the flash loan receiver contract * @param initiator The address initiating the flash loan * @param asset The address of the asset being flash borrowed * @param amount The amount flash borrowed * @param premium The fee flash borrowed * @param referralCode The referral code used **/ event FlashLoan( address indexed target, address indexed initiator, address indexed asset, uint256 amount, uint256 premium, uint16 referralCode ); /** * @dev Emitted when the pause is triggered. */ event Paused(); /** * @dev Emitted when the pause is lifted. */ event Unpaused(); /** * @dev Emitted when a borrower is liquidated. This event is emitted by the LendingPool via * LendingPoolCollateral manager using a DELEGATECALL * This allows to have the events in the generated ABI for LendingPool. * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param liquidatedCollateralAmount The amount of collateral received by the liiquidator * @param liquidator The address of the liquidator * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly **/ event LiquidationCall( address indexed collateralAsset, address indexed debtAsset, address indexed user, uint256 debtToCover, uint256 liquidatedCollateralAmount, address liquidator, bool receiveAToken ); /** * @dev Emitted when the state of a reserve is updated. NOTE: This event is actually declared * in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal, * the event will actually be fired by the LendingPool contract. The event is therefore replicated here so it * gets added to the LendingPool ABI * @param reserve The address of the underlying asset of the reserve * @param liquidityRate The new liquidity rate * @param stableBorrowRate The new stable borrow rate * @param variableBorrowRate The new variable borrow rate * @param liquidityIndex The new liquidity index * @param variableBorrowIndex The new variable borrow index **/ event ReserveDataUpdated( address indexed reserve, uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex ); /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function deposit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to ) external returns (uint256); /** * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower * already deposited enough collateral, or he was given enough allowance by a credit delegator on the * corresponding debt token (StableDebtToken or VariableDebtToken) * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet * and 100 stable/variable debt tokens, depending on the `interestRateMode` * @param asset The address of the underlying asset to borrow * @param amount The amount to be borrowed * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man * @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator * if he has been given credit delegation allowance **/ function borrow( address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf ) external; /** * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` * @param rateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed * @return The final amount repaid **/ function repay( address asset, uint256 amount, uint256 rateMode, address onBehalfOf ) external returns (uint256); /** * @dev Allows a borrower to swap his debt between stable and variable mode, or viceversa * @param asset The address of the underlying asset borrowed * @param rateMode The rate mode that the user wants to swap to **/ function swapBorrowRateMode(address asset, uint256 rateMode) external; /** * @dev Rebalances the stable interest rate of a user to the current stable rate defined on the reserve. * - Users can be rebalanced if the following conditions are satisfied: * 1. Usage ratio is above 95% * 2. the current deposit APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too much has been * borrowed at a stable rate and depositors are not earning enough * @param asset The address of the underlying asset borrowed * @param user The address of the user to be rebalanced **/ function rebalanceStableBorrowRate(address asset, address user) external; /** * @dev Allows depositors to enable/disable a specific deposited asset as collateral * @param asset The address of the underlying asset deposited * @param useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise **/ function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external; /** * @dev Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1 * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly **/ function liquidationCall( address collateralAsset, address debtAsset, address user, uint256 debtToCover, bool receiveAToken ) external; /** * @dev Allows smartcontracts to access the liquidity of the pool within one transaction, * as long as the amount taken plus a fee is returned. * IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration. * For further details please visit https://developers.aave.com * @param receiverAddress The address of the contract receiving the funds, implementing the IFlashLoanReceiver interface * @param assets The addresses of the assets being flash-borrowed * @param amounts The amounts amounts being flash-borrowed * @param modes Types of the debt to open if the flash loan is not returned: * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2 * @param params Variadic packed params to pass to the receiver as extra information * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function flashLoan( address receiverAddress, address[] calldata assets, uint256[] calldata amounts, uint256[] calldata modes, address onBehalfOf, bytes calldata params, uint16 referralCode ) external; /** * @dev Returns the user account data across all the reserves * @param user The address of the user * @return totalCollateralETH the total collateral in ETH of the user * @return totalDebtETH the total debt in ETH of the user * @return availableBorrowsETH the borrowing power left of the user * @return currentLiquidationThreshold the liquidation threshold of the user * @return ltv the loan to value of the user * @return healthFactor the current health factor of the user **/ function getUserAccountData(address user) external view returns ( uint256 totalCollateralETH, uint256 totalDebtETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor ); function initReserve( address reserve, address aTokenAddress, address stableDebtAddress, address variableDebtAddress, address interestRateStrategyAddress ) external; function setReserveInterestRateStrategyAddress(address reserve, address rateStrategyAddress) external; function setConfiguration(address reserve, uint256 configuration) external; /** * @dev Returns the configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The configuration of the reserve **/ function getConfiguration(address asset) external view returns (DataTypes.ReserveConfigurationMap memory); /** * @dev Returns the configuration of the user across all the reserves * @param user The user address * @return The configuration of the user **/ function getUserConfiguration(address user) external view returns (DataTypes.UserConfigurationMap memory); /** * @dev Returns the normalized income normalized income of the reserve * @param asset The address of the underlying asset of the reserve * @return The reserve's normalized income */ function getReserveNormalizedIncome(address asset) external view returns (uint256); /** * @dev Returns the normalized variable debt per unit of asset * @param asset The address of the underlying asset of the reserve * @return The reserve normalized variable debt */ function getReserveNormalizedVariableDebt(address asset) external view returns (uint256); /** * @dev Returns the state and configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The state of the reserve **/ function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); function finalizeTransfer( address asset, address from, address to, uint256 amount, uint256 balanceFromAfter, uint256 balanceToBefore ) external; function getReservesList() external view returns (address[] memory); function getAddressesProvider() external view returns (ILendingPoolAddressesProviderV2); function setPause(bool val) external; function paused() external view returns (bool); }
pragma solidity ^0.6.10; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /** Ensures that any contract that inherits from this contract is able to withdraw funds that are accidentally received or stuck. */ contract Withdrawable is Ownable { using SafeERC20 for ERC20; address constant ETHER = address(0); event LogWithdraw( address indexed _from, address indexed _assetAddress, uint amount ); /** * @dev Withdraw asset. * @param _assetAddress Asset to be withdrawn. */ function withdraw(address _assetAddress) public onlyOwner { uint assetBalance; if (_assetAddress == ETHER) { address self = address(this); // workaround for a possible solidity bug assetBalance = self.balance; msg.sender.transfer(assetBalance); } else { assetBalance = ERC20(_assetAddress).balanceOf(address(this)); ERC20(_assetAddress).safeTransfer(msg.sender, assetBalance); } emit LogWithdraw(msg.sender, _assetAddress, assetBalance); } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.10; /** * @dev This is the Aave V2 DataTypes library. */ library DataTypes { // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; } struct ReserveConfigurationMap { //bit 0-15: LTV //bit 16-31: Liq. threshold //bit 32-47: Liq. bonus //bit 48-55: Decimals //bit 56: Reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled //bit 59: stable rate borrowing enabled //bit 60-63: reserved //bit 64-79: reserve factor uint256 data; } struct UserConfigurationMap { uint256 data; } enum InterestRateMode {NONE, STABLE, VARIABLE} }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": { "contracts/exchangeIssuance/DEXAdapter.sol": { "DEXAdapter": "0x4737ed26956cc0a927bbddc860103f559121046c" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
[{"inputs":[{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_quickRouter","type":"address"},{"internalType":"address","name":"_sushiRouter","type":"address"},{"internalType":"address","name":"_uniV3Router","type":"address"},{"internalType":"address","name":"_uniV3Quoter","type":"address"},{"internalType":"contract IController","name":"_setController","type":"address"},{"internalType":"contract IDebtIssuanceModule","name":"_debtIssuanceModule","type":"address"},{"internalType":"contract IAaveLeverageModule","name":"_aaveLeverageModule","type":"address"},{"internalType":"address","name":"_aaveAddressProvider","type":"address"},{"internalType":"address","name":"_curveAddressProvider","type":"address"},{"internalType":"address","name":"_curveCalculator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"indexed":true,"internalType":"address","name":"_inputToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amountInputToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amountSetIssued","type":"uint256"}],"name":"ExchangeIssue","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"indexed":true,"internalType":"address","name":"_outputToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amountSetRedeemed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amountOutputToken","type":"uint256"}],"name":"ExchangeRedeem","type":"event"},{"inputs":[],"name":"ADDRESSES_PROVIDER","outputs":[{"internalType":"contract ILendingPoolAddressesProviderV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LENDING_POOL","outputs":[{"internalType":"contract ILendingPoolV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROUNDING_ERROR_MARGIN","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aaveLeverageModule","outputs":[{"internalType":"contract IAaveLeverageModule","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"addresses","outputs":[{"internalType":"address","name":"quickRouter","type":"address"},{"internalType":"address","name":"sushiRouter","type":"address"},{"internalType":"address","name":"uniV3Router","type":"address"},{"internalType":"address","name":"uniV3Quoter","type":"address"},{"internalType":"address","name":"curveAddressProvider","type":"address"},{"internalType":"address","name":"curveCalculator","type":"address"},{"internalType":"address","name":"weth","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"}],"name":"approveSetToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"}],"name":"approveToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20[]","name":"_tokens","type":"address[]"}],"name":"approveTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"debtIssuanceModule","outputs":[{"internalType":"contract IDebtIssuanceModule","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"premiums","type":"uint256[]"},{"internalType":"address","name":"initiator","type":"address"},{"internalType":"bytes","name":"params","type":"bytes"}],"name":"executeOperation","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"uint256","name":"_setAmount","type":"uint256"},{"components":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"enum DEXAdapter.Exchange","name":"exchange","type":"uint8"}],"internalType":"struct DEXAdapter.SwapData","name":"_swapDataDebtForCollateral","type":"tuple"},{"components":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"enum DEXAdapter.Exchange","name":"exchange","type":"uint8"}],"internalType":"struct DEXAdapter.SwapData","name":"_swapDataInputToken","type":"tuple"}],"name":"getIssueExactSet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"uint256","name":"_setAmount","type":"uint256"},{"internalType":"bool","name":"_isIssuance","type":"bool"}],"name":"getLeveragedTokenData","outputs":[{"components":[{"internalType":"address","name":"collateralAToken","type":"address"},{"internalType":"address","name":"collateralToken","type":"address"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"address","name":"debtToken","type":"address"},{"internalType":"uint256","name":"debtAmount","type":"uint256"}],"internalType":"struct ExchangeIssuanceLeveraged.LeveragedTokenData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"uint256","name":"_setAmount","type":"uint256"},{"components":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"enum DEXAdapter.Exchange","name":"exchange","type":"uint8"}],"internalType":"struct DEXAdapter.SwapData","name":"_swapDataCollateralForDebt","type":"tuple"},{"components":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"enum DEXAdapter.Exchange","name":"exchange","type":"uint8"}],"internalType":"struct DEXAdapter.SwapData","name":"_swapDataOutputToken","type":"tuple"}],"name":"getRedeemExactSet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"uint256","name":"_setAmount","type":"uint256"},{"internalType":"address","name":"_inputToken","type":"address"},{"internalType":"uint256","name":"_maxAmountInputToken","type":"uint256"},{"components":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"enum DEXAdapter.Exchange","name":"exchange","type":"uint8"}],"internalType":"struct DEXAdapter.SwapData","name":"_swapDataDebtForCollateral","type":"tuple"},{"components":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"enum DEXAdapter.Exchange","name":"exchange","type":"uint8"}],"internalType":"struct DEXAdapter.SwapData","name":"_swapDataInputToken","type":"tuple"}],"name":"issueExactSetFromERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"uint256","name":"_setAmount","type":"uint256"},{"components":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"enum DEXAdapter.Exchange","name":"exchange","type":"uint8"}],"internalType":"struct DEXAdapter.SwapData","name":"_swapDataDebtForCollateral","type":"tuple"},{"components":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"enum DEXAdapter.Exchange","name":"exchange","type":"uint8"}],"internalType":"struct DEXAdapter.SwapData","name":"_swapDataInputToken","type":"tuple"}],"name":"issueExactSetFromETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"uint256","name":"_setAmount","type":"uint256"},{"internalType":"address","name":"_outputToken","type":"address"},{"internalType":"uint256","name":"_minAmountOutputToken","type":"uint256"},{"components":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"enum DEXAdapter.Exchange","name":"exchange","type":"uint8"}],"internalType":"struct DEXAdapter.SwapData","name":"_swapDataCollateralForDebt","type":"tuple"},{"components":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"enum DEXAdapter.Exchange","name":"exchange","type":"uint8"}],"internalType":"struct DEXAdapter.SwapData","name":"_swapDataOutputToken","type":"tuple"}],"name":"redeemExactSetForERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"uint256","name":"_setAmount","type":"uint256"},{"internalType":"uint256","name":"_minAmountOutputToken","type":"uint256"},{"components":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"enum DEXAdapter.Exchange","name":"exchange","type":"uint8"}],"internalType":"struct DEXAdapter.SwapData","name":"_swapDataCollateralForDebt","type":"tuple"},{"components":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint24[]","name":"fees","type":"uint24[]"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"enum DEXAdapter.Exchange","name":"exchange","type":"uint8"}],"internalType":"struct DEXAdapter.SwapData","name":"_swapDataOutputToken","type":"tuple"}],"name":"redeemExactSetForETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setController","outputs":[{"internalType":"contract IController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6101206040523480156200001257600080fd5b506040516200493c3803806200493c8339810160408190526200003591620001bc565b826001600081905550806001600160a01b03166080816001600160a01b031660601b81525050806001600160a01b0316630261bf8b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200009557600080fd5b505afa158015620000aa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000d0919062000196565b606090811b6001600160601b031990811660a05297811b881660c05295861b871660e052509290931b90931661010052600780546001600160a01b03199081166001600160a01b039a8b1617909155600180548216988a1698909817909755600280548816968916969096179095556003805487169488169490941790935550600480548516918616919091179055600580548416918516919091179055600680549092169216919091179055620002d3565b80516200019081620002ba565b92915050565b600060208284031215620001a8578081fd5b8151620001b581620002ba565b9392505050565b60008060008060008060008060008060006101608c8e031215620001de578687fd5b8b51620001eb81620002ba565b60208d0151909b50620001fe81620002ba565b60408d0151909a506200021181620002ba565b60608d01519099506200022481620002ba565b60808d01519098506200023781620002ba565b60a08d01519097506200024a81620002ba565b60c08d01519096506200025d81620002ba565b60e08d01519095506200027081620002ba565b6101008d01519094506200028481620002ba565b9250620002968d6101208e0162000183565b9150620002a88d6101408e0162000183565b90509295989b509295989b9093969950565b6001600160a01b0381168114620002d057600080fd5b50565b60805160601c60a05160601c60c05160601c60e05160601c6101005160601c6145ca620003726000398061037752806103ff52806108bd5280610bc152806115a052508061080b5280610d915280610e3f528061124852806119de5280611b9e525080610614525080610643528061082f52806113bf5280611463528061150652806117b2528061195d5280611bee52508061035352506145ca6000f3fe60806040526004361061010d5760003560e01c8063ac43070b11610095578063c4ba5db211610064578063c4ba5db2146102b6578063c58bc7e0146102d6578063d1d719ef146102f6578063da0321cd14610316578063f875572d1461033e57610114565b8063ac43070b1461024c578063af6f220a1461026c578063b4dcfc7714610281578063b7711c631461029657610114565b80637452ed1e116100dc5780637452ed1e146101a857806380b2edd8146101d5578063848af32d146101f55780638b2704ec1461020a578063920f5c841461021f57610114565b80630542975c146101195780631d2d88ca14610144578063590c81c51461015957806364718c1d1461017b57610114565b3661011457005b600080fd5b34801561012557600080fd5b5061012e610351565b60405161013b9190613cd6565b60405180910390f35b34801561015057600080fd5b5061012e610375565b34801561016557600080fd5b506101796101743660046135c9565b610399565b005b34801561018757600080fd5b5061019b6101963660046136a2565b6103e5565b60405161013b919061449d565b3480156101b457600080fd5b506101c86101c3366004613661565b6105e4565b60405161013b919061448f565b3480156101e157600080fd5b506101796101f03660046135ad565b610601565b34801561020157600080fd5b5061019b61060d565b34801561021657600080fd5b5061012e610612565b34801561022b57600080fd5b5061023f61023a3660046133fb565b610636565b60405161013b9190613ccb565b34801561025857600080fd5b50610179610267366004613501565b6107d5565b34801561027857600080fd5b5061012e610809565b34801561028d57600080fd5b5061012e61082d565b3480156102a257600080fd5b506101796102b13660046135ad565b610851565b3480156102c257600080fd5b5061019b6102d13660046136a2565b6108a3565b3480156102e257600080fd5b506101796102f136600461371f565b610a9c565b34801561030257600080fd5b506101796103113660046135c9565b610aec565b34801561032257600080fd5b5061032b610b22565b60405161013b9796959493929190613ba4565b61017961034c3660046136a2565b610b5b565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600260005414156103c55760405162461bcd60e51b81526004016103bc90614213565b60405180910390fd5b60026000556103d8868686868686610baa565b5050600160005550505050565b604051632961046560e21b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a584119490610434908890600401613cd6565b600060405180830381600087803b15801561044e57600080fd5b505af1158015610462573d6000803e3d6000fd5b5050505061046e612e53565b61047a86866000610d67565b9050600061049d670de3e93f3bb0400083608001516111e790919063ffffffff16565b90506000734737ed26956cc0a927bbddc860103f559121046c63f943b31e600188856040518463ffffffff1660e01b81526004016104dd93929190614303565b60206040518083038186803b1580156104f557600080fd5b505af4158015610509573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052d91906138a9565b9050600061054882856040015161121a90919063ffffffff16565b6040516301fae87160e61b8152909150734737ed26956cc0a927bbddc860103f559121046c90637eba1c4090610587906001908a908690600401614303565b60206040518083038186803b15801561059f57600080fd5b505af41580156105b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d791906138a9565b9998505050505050505050565b6105ec612e53565b6105f7848484610d67565b90505b9392505050565b61060a81611242565b50565b600281565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146106805760405162461bcd60e51b81526004016103bc9061410d565b6001600160a01b03831630146106a85760405162461bcd60e51b81526004016103bc90614076565b85516001146106c95760405162461bcd60e51b81526004016103bc90614293565b84516001146106ea5760405162461bcd60e51b81526004016103bc90614187565b835160011461070b5760405162461bcd60e51b81526004016103bc90613d94565b610713612e81565b8280602001905181019061072791906137a6565b90508060600151156107805761077b8760008151811061074357fe5b60200260200101518760008151811061075857fe5b60200260200101518760008151811061076d57fe5b60200260200101518461126f565b6107c8565b6107c88760008151811061079057fe5b6020026020010151876000815181106107a557fe5b6020026020010151876000815181106107ba57fe5b6020026020010151846112cc565b5060019695505050505050565b60005b8151811015610805576107fd8282815181106107f057fe5b6020026020010151611242565b6001016107d8565b5050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b610859612e53565b61086d82670de0b6b3a76400006001610d67565b905061087c8160000151611242565b6108898160200151611396565b6108968160600151611242565b6108058160600151611396565b604051632961046560e21b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a5841194906108f2908890600401613cd6565b600060405180830381600087803b15801561090c57600080fd5b505af1158015610920573d6000803e3d6000fd5b5050505061092c612e53565b61093886866001610d67565b9050600061095b670de3e93f3bb0400083604001516111e790919063ffffffff16565b90506000734737ed26956cc0a927bbddc860103f559121046c637eba1c4060018886608001516040518463ffffffff1660e01b815260040161099f93929190614303565b60206040518083038186803b1580156109b757600080fd5b505af41580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef91906138a9565b9050610a01828263ffffffff61121a16565b604051637ca1d98f60e11b8152909250734737ed26956cc0a927bbddc860103f559121046c9063f943b31e90610a409060019089908790600401614303565b60206040518083038186803b158015610a5857600080fd5b505af4158015610a6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9091906138a9565b98975050505050505050565b60026000541415610abf5760405162461bcd60e51b81526004016103bc90614213565b6002600055610ae08585600080516020614575833981519152868686610baa565b50506001600055505050565b60026000541415610b0f5760405162461bcd60e51b81526004016103bc90614213565b60026000556103d8868686868686611589565b6001546002546003546004546005546006546007546001600160a01b039687169695861695948516949384169392831692918216911687565b60026000541415610b7e5760405162461bcd60e51b81526004016103bc90614213565b6002600055610b9f8484600080516020614575833981519152348686611589565b505060016000555050565b604051632961046560e21b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a584119490610bf6908990600401613cd6565b600060405180830381600087803b158015610c1057600080fd5b505af1158015610c24573d6000803e3d6000fd5b50505050610c30612e53565b610c3c87876000610d67565b6040805160018082528183019092529192506060919060208083019080368337019050509050816060015181600081518110610c7457fe5b6001600160a01b039290921660209283029190910190910152604080516001808252818301909252606091816020016020820280368337019050509050826080015181600081518110610cc357fe5b60200260200101818152505060606040518061012001604052808b6001600160a01b031681526020018a8152602001336001600160a01b03168152602001600015158152602001896001600160a01b0316815260200188815260200185815260200187815260200186815250604051602001610d3f91906143e1565b6040516020818303038152906040529050610d5b83838361171e565b50505050505050505050565b610d6f612e53565b60608060608415610e285760405163131e26b960e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063131e26b990610dc8908a908a90600401613c62565b60006040518083038186803b158015610de057600080fd5b505afa158015610df4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e1c9190810190613377565b91945092509050610ed2565b6040516335c729db60e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636b8e53b690610e76908a908a90600401613c62565b60006040518083038186803b158015610e8e57600080fd5b505afa158015610ea2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610eca9190810190613377565b919450925090505b8251600214610ef35760405162461bcd60e51b81526004016103bc90613fa4565b81600081518110610f0057fe5b602002602001015160001480610f2a575081600181518110610f1e57fe5b60200260200101516000145b610f465760405162461bcd60e51b81526004016103bc90613f22565b80600081518110610f5357fe5b602002602001015160001480610f7d575080600181518110610f7157fe5b60200260200101516000145b610f995760405162461bcd60e51b81526004016103bc9061424a565b600082600081518110610fa857fe5b602002602001015111156110d9576040518060a0016040528084600081518110610fce57fe5b60200260200101516001600160a01b0316815260200184600081518110610ff157fe5b60200260200101516001600160a01b031663b16a19de6040518163ffffffff1660e01b815260040160206040518083038186803b15801561103157600080fd5b505afa158015611045573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611069919061335b565b6001600160a01b0316815260200160028460008151811061108657fe5b6020026020010151018152602001846001815181106110a157fe5b60200260200101516001600160a01b03168152602001826001815181106110c457fe5b602002602001015181525093505050506105fa565b6040518060a00160405280846001815181106110f157fe5b60200260200101516001600160a01b031681526020018460018151811061111457fe5b60200260200101516001600160a01b031663b16a19de6040518163ffffffff1660e01b815260040160206040518083038186803b15801561115457600080fd5b505afa158015611168573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118c919061335b565b6001600160a01b031681526020016002846001815181106111a957fe5b6020026020010151018152602001846000815181106111c457fe5b60200260200101516001600160a01b03168152602001826000815181106110c457fe5b6000611211670de0b6b3a7640000611205858563ffffffff61182e16565b9063ffffffff61186816565b90505b92915050565b60008282111561123c5760405162461bcd60e51b81526004016103bc90613e0e565b50900390565b61060a817f000000000000000000000000000000000000000000000000000000000000000060001961189a565b6112798484611946565b6112908160000151826020015183604001516119c7565b600061129f8584860184611a4e565b90508160a001518111156112c55760405162461bcd60e51b81526004016103bc90613d49565b5050505050565b6112e3816000015182602001518360400151611b6c565b6113008160c001516020015160028360c001516040015103611bd7565b6000611325838501868460c00151604001518560c00151602001518660e00151611c79565b905060006113688284600001518560200151866040015187608001518860a001518960c0015160200151600280028b60c0015160400151038b6101000151611ec7565b90508260a0015181101561138e5760405162461bcd60e51b81526004016103bc90613cfd565b505050505050565b604051636eb1769f60e11b81526000906001600160a01b0383169063dd62ed3e906113e79030907f000000000000000000000000000000000000000000000000000000000000000090600401613b66565b60206040518083038186803b1580156113ff57600080fd5b505afa158015611413573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143791906138a9565b905080156114e25760405163095ea7b360e01b81526001600160a01b0383169063095ea7b39061148e907f000000000000000000000000000000000000000000000000000000000000000090600090600401613c62565b602060405180830381600087803b1580156114a857600080fd5b505af11580156114bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e09190613591565b505b60405163095ea7b360e01b81526001600160a01b0383169063095ea7b390611532907f00000000000000000000000000000000000000000000000000000000000000009060001990600401613c62565b602060405180830381600087803b15801561154c57600080fd5b505af1158015611560573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115849190613591565b505050565b604051632961046560e21b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a5841194906115d5908990600401613cd6565b600060405180830381600087803b1580156115ef57600080fd5b505af1158015611603573d6000803e3d6000fd5b5050505061160f612e53565b61161b87876001610d67565b604080516001808252818301909252919250606091906020808301908036833701905050905081602001518160008151811061165357fe5b6001600160a01b0392909216602092830291909101909101526040805160018082528183019092526060918160200160208202803683370190505090508260400151816000815181106116a257fe5b60200260200101818152505060606040518061012001604052808b6001600160a01b031681526020018a8152602001336001600160a01b03168152602001600115158152602001896001600160a01b0316815260200188815260200185815260200187815260200186815250604051602001610d3f91906143e1565b82513090819060009060609067ffffffffffffffff8111801561174057600080fd5b5060405190808252806020026020018201604052801561176a578160200160208202803683370190505b50905060005b875181101561179a57600082828151811061178757fe5b6020908102919091010152600101611770565b5060405163ab9c4b5d60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063ab9c4b5d906117f39087908b908b9087908a908d908b90600401613be5565b600060405180830381600087803b15801561180d57600080fd5b505af1158015611821573d6000803e3d6000fd5b5050505050505050505050565b60008261183d57506000611214565b8282028284828161184a57fe5b04146112115760405162461bcd60e51b81526004016103bc90614035565b60008082116118895760405162461bcd60e51b81526004016103bc90613f6d565b81838161189257fe5b049392505050565b604051636eb1769f60e11b81526000906001600160a01b0385169063dd62ed3e906118cb9030908790600401613b66565b60206040518083038186803b1580156118e357600080fd5b505afa1580156118f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191b91906138a9565b905081811015611940576119406001600160a01b03851684831963ffffffff611fa916565b50505050565b60405163e8eda9df60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e8eda9df9061199990859085903090600090600401613c9e565b600060405180830381600087803b1580156119b357600080fd5b505af115801561138e573d6000803e3d6000fd5b6040516336bc7a3d60e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636d78f47a90611a1790869086908690600401613c7b565b600060405180830381600087803b158015611a3157600080fd5b505af1158015611a45573d6000803e3d6000fd5b50505050505050565b600080611a71858460c00151606001518560c00151608001518660e00151612091565b905060006002611a87868463ffffffff61121a16565b01905060006000805160206145758339815191526001600160a01b031685608001516001600160a01b03161415611ad957611ad2878387604001518860a00151896101000151612281565b9050611afb565b611af88783876040015188608001518960a001518a610100015161239f565b90505b84608001516001600160a01b031685600001516001600160a01b031686604001516001600160a01b03167f44b3b16472a909f781f712646232271ffd156fff642d4895b700146a40462601848960200151604051611b5a9291906144a6565b60405180910390a49695505050505050565b611b876001600160a01b03841682308563ffffffff61250516565b604051635c833bfd60e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690635c833bfd90611a1790869086903090600401613c7b565b604051631a4ca37b60e21b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906369328dec90611c2790859085903090600401613c7b565b602060405180830381600087803b158015611c4157600080fd5b505af1158015611c55573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158491906138a9565b600081600001518386806001600160a01b0316826001600160a01b031614611dd757816001600160a01b031683600081518110611cb257fe5b60200260200101516001600160a01b03161480611d1a57506007546001600160a01b038381169116148015611d1a57506000805160206145758339815191526001600160a01b031683600081518110611d0757fe5b60200260200101516001600160a01b0316145b611d365760405162461bcd60e51b81526004016103bc90613ea2565b806001600160a01b031683600185510381518110611d5057fe5b60200260200101516001600160a01b03161480611dbb57506007546001600160a01b038281169116148015611dbb57506000805160206145758339815191526001600160a01b031683600185510381518110611da857fe5b60200260200101516001600160a01b0316145b611dd75760405162461bcd60e51b81526004016103bc906140c3565b6040805160e0810182526001546001600160a01b03908116825260025481166020830152600354811682840152600480548216606084015260055482166080840152600654821660a084015260075490911660c08301529151636fd7d45f60e01b8152734737ed26956cc0a927bbddc860103f559121046c92636fd7d45f92611e689290918e918d918c91016142d4565b60206040518083038186803b158015611e8057600080fd5b505af4158015611e94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eb891906138a9565b93505b50505095945050505050565b600089831015611ee95760405162461bcd60e51b81526004016103bc90613fe9565b6000611efb848c63ffffffff61121a16565b905060006001600160a01b0388166000805160206145758339815191521415611f3257611f2b86838b8a88612526565b9050611f43565b611f4086838b8b8b8961271d565b90505b876001600160a01b03168b6001600160a01b03168a6001600160a01b03167f9f8f1a845f52c0a7086f16f355a092a5acf0cca219c831409b9e5b1c39af9f9f8d85604051611f929291906144a6565b60405180910390a49b9a5050505050505050505050565b600061203982856001600160a01b031663dd62ed3e30876040518363ffffffff1660e01b8152600401611fdd929190613b66565b60206040518083038186803b158015611ff557600080fd5b505afa158015612009573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061202d91906138a9565b9063ffffffff61278416565b90506119408463095ea7b360e01b858460405160240161205a929190613c62565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526127a9565b600081600001518486806001600160a01b0316826001600160a01b0316146121ef57816001600160a01b0316836000815181106120ca57fe5b60200260200101516001600160a01b0316148061213257506007546001600160a01b03838116911614801561213257506000805160206145758339815191526001600160a01b03168360008151811061211f57fe5b60200260200101516001600160a01b0316145b61214e5760405162461bcd60e51b81526004016103bc90613ea2565b806001600160a01b03168360018551038151811061216857fe5b60200260200101516001600160a01b031614806121d357506007546001600160a01b0382811691161480156121d357506000805160206145758339815191526001600160a01b0316836001855103815181106121c057fe5b60200260200101516001600160a01b0316145b6121ef5760405162461bcd60e51b81526004016103bc906140c3565b6040805160e0810182526001546001600160a01b03908116825260025481166020830152600354811682840152600480548216606084015260055482166080840152600654821660a084015260075490911660c08301529151630355f53b60e31b8152734737ed26956cc0a927bbddc860103f559121046c92631aafa9d892610a409290918b916000918c91016142d4565b60075460408051630d0e30db60e41b815290516000926001600160a01b03169163d0e30db0918691600480820192879290919082900301818588803b1580156122c957600080fd5b505af11580156122dd573d6000803e3d6000fd5b505060075460009350612300925089915088906001600160a01b03168787612838565b90508084111561239557600061231c858363ffffffff61121a16565b600754604051632e1a7d4d60e01b81529192506001600160a01b031690632e1a7d4d9061234d90849060040161449d565b600060405180830381600087803b15801561236757600080fd5b505af115801561237b573d6000803e3d6000fd5b50612393925050506001600160a01b03871682612a49565b505b9695505050505050565b6000866001600160a01b0316846001600160a01b031614156123cd576123c6878787612ae5565b5084612395565b6040516323b872dd60e01b81526001600160a01b038516906323b872dd906123fd90889030908890600401613b80565b602060405180830381600087803b15801561241757600080fd5b505af115801561242b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061244f9190613591565b50600061245f8888878787612838565b9050838110156124fa576001600160a01b03851663a9059cbb87612489878563ffffffff61121a16565b6040518363ffffffff1660e01b81526004016124a6929190613c62565b602060405180830381600087803b1580156124c057600080fd5b505af11580156124d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124f89190613591565b505b979650505050505050565b611940846323b872dd60e01b85858560405160240161205a93929190613b80565b80516007546000919087906001600160a01b03908116908216811461268157816001600160a01b03168360008151811061255c57fe5b60200260200101516001600160a01b031614806125c457506007546001600160a01b0383811691161480156125c457506000805160206145758339815191526001600160a01b0316836000815181106125b157fe5b60200260200101516001600160a01b0316145b6125e05760405162461bcd60e51b81526004016103bc90613ea2565b806001600160a01b0316836001855103815181106125fa57fe5b60200260200101516001600160a01b0316148061266557506007546001600160a01b03828116911614801561266557506000805160206145758339815191526001600160a01b03168360018551038151811061265257fe5b60200260200101516001600160a01b0316145b6126815760405162461bcd60e51b81526004016103bc906140c3565b60075460009061269f908b908b906001600160a01b03168a8a612b06565b90508015611eb857600754604051632e1a7d4d60e01b81526001600160a01b0390911690632e1a7d4d906126d790849060040161449d565b600060405180830381600087803b1580156126f157600080fd5b505af1158015612705573d6000803e3d6000fd5b50611eb8925050506001600160a01b03891682612a49565b6000866001600160a01b0316846001600160a01b03161415612744576123c6878787612cf5565b60006127538888878787612b06565b60405163a9059cbb60e01b81529091506001600160a01b0386169063a9059cbb906124a69089908590600401613c62565b6000828201838110156112115760405162461bcd60e51b81526004016103bc90613dd7565b60606127fe826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d759092919063ffffffff16565b805190915015611584578080602001905181019061281c9190613591565b6115845760405162461bcd60e51b81526004016103bc906141c9565b600081600001518487806001600160a01b0316826001600160a01b03161461299657816001600160a01b03168360008151811061287157fe5b60200260200101516001600160a01b031614806128d957506007546001600160a01b0383811691161480156128d957506000805160206145758339815191526001600160a01b0316836000815181106128c657fe5b60200260200101516001600160a01b0316145b6128f55760405162461bcd60e51b81526004016103bc90613ea2565b806001600160a01b03168360018551038151811061290f57fe5b60200260200101516001600160a01b0316148061297a57506007546001600160a01b03828116911614801561297a57506000805160206145758339815191526001600160a01b03168360018551038151811061296757fe5b60200260200101516001600160a01b0316145b6129965760405162461bcd60e51b81526004016103bc906140c3565b866001600160a01b0316896001600160a01b031614156129b857879350611ebb565b6040805160e0810182526001546001600160a01b03908116825260025481166020830152600354811682840152600480548216606084015260055482166080840152600654821660a084015260075490911660c08301529151636fd7d45f60e01b8152734737ed26956cc0a927bbddc860103f559121046c92636fd7d45f92611e689290918d918c918c91016142d4565b80471015612a695760405162461bcd60e51b81526004016103bc90613eeb565b6000826001600160a01b031682604051612a8290613b63565b60006040518083038185875af1925050503d8060008114612abf576040519150601f19603f3d011682016040523d82523d6000602084013e612ac4565b606091505b50509050806115845760405162461bcd60e51b81526004016103bc90613e45565b8115611584576115846001600160a01b03841682308563ffffffff61250516565b600081600001518685806001600160a01b0316826001600160a01b031614612c6457816001600160a01b031683600081518110612b3f57fe5b60200260200101516001600160a01b03161480612ba757506007546001600160a01b038381169116148015612ba757506000805160206145758339815191526001600160a01b031683600081518110612b9457fe5b60200260200101516001600160a01b0316145b612bc35760405162461bcd60e51b81526004016103bc90613ea2565b806001600160a01b031683600185510381518110612bdd57fe5b60200260200101516001600160a01b03161480612c4857506007546001600160a01b038281169116148015612c4857506000805160206145758339815191526001600160a01b031683600185510381518110612c3557fe5b60200260200101516001600160a01b0316145b612c645760405162461bcd60e51b81526004016103bc906140c3565b6040805160e0810182526001546001600160a01b03908116825260025481166020830152600354811682840152600480548216606084015260055482166080840152600654821660a084015260075490911660c08301529151630355f53b60e31b8152734737ed26956cc0a927bbddc860103f559121046c92631aafa9d892611e689290918d918c918c91016142d4565b60405163a9059cbb60e01b81526001600160a01b0384169063a9059cbb90612d239084908690600401613c62565b602060405180830381600087803b158015612d3d57600080fd5b505af1158015612d51573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119409190613591565b60606105f7848460008585612d8985612e14565b612da55760405162461bcd60e51b81526004016103bc90614150565b60006060866001600160a01b03168587604051612dc29190613b47565b60006040518083038185875af1925050503d8060008114612dff576040519150601f19603f3d011682016040523d82523d6000602084013e612e04565b606091505b50915091506124fa828286612e1a565b3b151590565b60608315612e295750816105fa565b825115612e395782518084602001fd5b8160405162461bcd60e51b81526004016103bc9190613cea565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b60405180610120016040528060006001600160a01b031681526020016000815260200160006001600160a01b0316815260200160001515815260200160006001600160a01b0316815260200160008152602001612edc612e53565b8152602001612ee9612efb565b8152602001612ef6612efb565b905290565b6040518060800160405280606081526020016060815260200160006001600160a01b0316815260200160006004811115612ef657fe5b803561121481614533565b805161121481614533565b600082601f830112612f57578081fd5b8135612f6a612f65826144db565b6144b4565b818152915060208083019084810181840286018201871015612f8b57600080fd5b60005b84811015612fb3578135612fa181614533565b84529282019290820190600101612f8e565b505050505092915050565b600082601f830112612fce578081fd5b8151612fdc612f65826144db565b818152915060208083019084810181840286018201871015612ffd57600080fd5b60005b84811015612fb357815161301381614533565b84529282019290820190600101613000565b600082601f830112613035578081fd5b8135613043612f65826144db565b81815291506020808301908481018184028601820187101561306457600080fd5b60005b84811015612fb357813584529282019290820190600101613067565b600082601f830112613093578081fd5b81516130a1612f65826144db565b8181529150602080830190848101818402860182018710156130c257600080fd5b60005b84811015612fb3578151845292820192908201906001016130c5565b805161121481614548565b803561121481614556565b805161121481614556565b600060a08284031215613113578081fd5b61311d60a06144b4565b9050815161312a81614533565b8152602082015161313a81614533565b602082015260408281015190820152606082015161315781614533565b806060830152506080820151608082015292915050565b60006080828403121561317f578081fd5b61318960806144b4565b9050813567ffffffffffffffff808211156131a357600080fd5b6131af85838601612f47565b83526020915081840135818111156131c657600080fd5b84019050601f810185136131d957600080fd5b80356131e7612f65826144db565b818152838101908385018584028501860189101561320457600080fd5b600094505b8385101561322f5761321b8982613350565b835260019490940193918501918501613209565b50808587015250505050506132478360408401612f31565b604082015261325983606084016130ec565b606082015292915050565b600060808284031215613275578081fd5b61327f60806144b4565b9050815167ffffffffffffffff8082111561329957600080fd5b6132a585838601612fbe565b83526020915081840151818111156132bc57600080fd5b84019050601f810185136132cf57600080fd5b80516132dd612f65826144db565b81815283810190838501858402850186018910156132fa57600080fd5b600094505b8385101561332657805161331281614563565b8352600194909401939185019185016132ff565b508085870152505050505061333e8360408401612f3c565b604082015261325983606084016130f7565b803561121481614563565b60006020828403121561336c578081fd5b815161121181614533565b60008060006060848603121561338b578182fd5b835167ffffffffffffffff808211156133a2578384fd5b6133ae87838801612fbe565b945060208601519150808211156133c3578384fd5b6133cf87838801613083565b935060408601519150808211156133e4578283fd5b506133f186828701613083565b9150509250925092565b600080600080600060a08688031215613412578283fd5b853567ffffffffffffffff80821115613429578485fd5b61343589838a01612f47565b965060209150818801358181111561344b578586fd5b6134578a828b01613025565b96505060408801358181111561346b578586fd5b6134778a828b01613025565b955050606088013561348881614533565b935060808801358181111561349b578384fd5b8089018a601f8201126134ac578485fd5b80359150828211156134bc578485fd5b6134ce601f8301601f191685016144b4565b92508183528a848383010111156134e3578485fd5b81848201858501375081019091019190915293969295509093509190565b60006020808385031215613513578182fd5b823567ffffffffffffffff811115613529578283fd5b80840185601f82011261353a578384fd5b8035915061354a612f65836144db565b8281528381019082850185850284018601891015613566578687fd5b8693505b848410156124f857803561357d81614533565b83526001939093019291850191850161356a565b6000602082840312156135a2578081fd5b815161121181614548565b6000602082840312156135be578081fd5b813561121181614533565b60008060008060008060c087890312156135e1578384fd5b86356135ec81614533565b955060208701359450604087013561360381614533565b935060608701359250608087013567ffffffffffffffff80821115613626578283fd5b6136328a838b0161316e565b935060a0890135915080821115613647578283fd5b5061365489828a0161316e565b9150509295509295509295565b600080600060608486031215613675578081fd5b833561368081614533565b925060208401359150604084013561369781614548565b809150509250925092565b600080600080608085870312156136b7578182fd5b84356136c281614533565b935060208501359250604085013567ffffffffffffffff808211156136e5578384fd5b6136f18883890161316e565b93506060870135915080821115613706578283fd5b506137138782880161316e565b91505092959194509250565b600080600080600060a08688031215613736578283fd5b853561374181614533565b94506020860135935060408601359250606086013567ffffffffffffffff8082111561376b578283fd5b61377789838a0161316e565b9350608088013591508082111561378c578283fd5b506137998882890161316e565b9150509295509295909350565b6000602082840312156137b7578081fd5b815167ffffffffffffffff808211156137ce578283fd5b8184016101a081870312156137e1578384fd5b6137ec6101206144b4565b92506137f88682612f3c565b8352602081015160208401526138118660408301612f3c565b604084015261382386606083016130e1565b60608401526138358660808301612f3c565b608084015260a081015160a08401526138518660c08301613102565b60c084015261016081015182811115613868578485fd5b61387487828401613264565b60e0850152506101808101518281111561388c578485fd5b61389887828401613264565b610100850152509195945050505050565b6000602082840312156138ba578081fd5b5051919050565b6001600160a01b03169052565b6000815180845260208085019450808401835b838110156139065781516001600160a01b0316875295820195908201906001016138e1565b509495945050505050565b6000815180845260208085019450808401835b8381101561390657815187529582019590820190600101613924565b15159052565b6000815180845261395e816020860160208601614507565b601f01601f19169290920160200192915050565b6005811061397c57fe5b9052565b80516001600160a01b03908116835260208083015182169084015260408083015182169084015260608083015182169084015260808083015182169084015260a08281015182169084015260c09182015116910152565b80516001600160a01b0390811683526020808301518216908401526040808301519084015260608083015190911690830152608090810151910152565b6000815160808452613a2960808501826138ce565b6020848101518683038783015280518084529193508301918491908401905b80831015613a6d57835162ffffff168252928401926001929092019190840190613a48565b506040868101516001600160a01b031690880152606080870151945061239590880185613972565b805160808084528151908401819052600091602091839160a08701919084015b81841015613adc5780516001600160a01b0316835260019390930192918401918401613ab5565b505084830151868203878501528051808352859350908401918401905b80841015613b1e57825162ffffff168252600193909301929184019190840190613af9565b5060408601519350613b3360408801856138c1565b606086015193506123956060880185613972565b60008251613b59818460208701614507565b9190910192915050565b90565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03978816815295871660208701529386166040860152918516606085015284166080840152831660a083015290911660c082015260e00190565b600060018060a01b03808a16835260e06020840152613c0760e084018a6138ce565b8381036040850152613c19818a613911565b8481036060860152613c2b818a613911565b915050818716608085015283810360a0850152613c488187613946565b9250505061ffff831660c083015298975050505050505050565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6001600160a01b03948516815260208101939093529216604082015261ffff909116606082015260800190565b901515815260200190565b6001600160a01b0391909116815260200190565b6000602082526112116020830184613946565b6020808252602c908201527f45786368616e676549737375616e63653a20494e53554646494349454e54204f60408201526b155514155508105353d5539560a21b606082015260800190565b6020808252602b908201527f45786368616e676549737375616e63653a20494e53554646494349454e54204960408201526a1394155508105353d5539560aa1b606082015260800190565b60208082526023908201527f45786368616e676549737375616e63653a20544f4f204d414e59205052454d49604082015262554d5360e81b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252603a908201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260408201527f6563697069656e74206d61792068617665207265766572746564000000000000606082015260800190565b60208082526029908201527f45786368616e676549737375616e63653a20494e5055545f544f4b454e5f4e4f6040820152680a8be929cbea082a8960bb1b606082015260800190565b6020808252601d908201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604082015260600190565b6020808252602b908201527f45786368616e676549737375616e63653a20544f4f204d414e5920455155495460408201526a5920504f534954494f4e5360a81b606082015260800190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526025908201527f45786368616e676549737375616e63653a20544f4f204d414e5920434f4d504f6040820152644e454e545360d81b606082015260800190565b6020808252602c908201527f45786368616e676549737375616e63653a204f5645525350454e5420434f4c4c60408201526b20aa22a920a6102a27a5a2a760a11b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252602d908201527f45786368616e676549737375616e63653a20494e56414c494420464c4153484c60408201526c27a0a71024a724aa24a0aa27a960991b606082015260800190565b6020808252602a908201527f45786368616e676549737375616e63653a204f55545055545f544f4b454e5f4e60408201526909ea8be929cbea082a8960b31b606082015260800190565b60208082526023908201527f45786368616e676549737375616e63653a204c454e44494e4720504f4f4c204f6040820152624e4c5960e81b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526022908201527f45786368616e676549737375616e63653a20544f4f204d414e5920414d4f554e604082015261545360f01b606082015260800190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526029908201527f45786368616e676549737375616e63653a20544f4f204d414e59204445425420604082015268504f534954494f4e5360b81b606082015260800190565b60208082526021908201527f45786368616e676549737375616e63653a20544f4f204d414e592041535345546040820152605360f81b606082015260800190565b60006101406142e38388613980565b8560e084015284610100840152806101208401526124fa81840185613a95565b600061012061431b8361431688546144fb565b6138c1565b61432860018701546144fb565b61433560208501826138c1565b5061434360028701546144fb565b61435060408501826138c1565b5061435e60038701546144fb565b61436b60608501826138c1565b5061437960048701546144fb565b61438660808501826138c1565b5061439460058701546144fb565b6143a160a08501826138c1565b506143af60068701546144fb565b6143bc60c08501826138c1565b508060e08401526143cf81840186613a95565b91505082610100830152949350505050565b6000602082526143f56020830184516138c1565b60208301516040830152604083015161441160608401826138c1565b5060608301516144246080840182613940565b50608083015161443760a08401826138c1565b5060a083015160c083015260c083015161445460e08401826139d7565b5060e08301516101a0806101808501526144726101c0850183613a14565b610100860151858203601f19018387015292506123958184613a14565b60a0810161121482846139d7565b90815260200190565b918252602082015260400190565b60405181810167ffffffffffffffff811182821017156144d357600080fd5b604052919050565b600067ffffffffffffffff8211156144f1578081fd5b5060209081020190565b6001600160a01b031690565b60005b8381101561452257818101518382015260200161450a565b838111156119405750506000910152565b6001600160a01b038116811461060a57600080fd5b801515811461060a57600080fd5b6005811061060a57600080fd5b62ffffff8116811461060a57600080fdfe000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeea26469706673582212209e199d414cb4663c256da699998d658ee12d95ae83bc8d3ae1f7181ab593250564736f6c634300060a0033000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000b27308f9f90d607463bb33ea1bebb41c27ce5ab6000000000000000000000000a4c8d221d8bb851f83aadd0223a8900a6921a34900000000000000000000000069a592d2129415a4a1d1b1e309c17051b7f28d57000000000000000000000000251bd1d42df1f153d86a5ba2305faade4d5f51dc000000000000000000000000b53c1a33016b2dc2ff3653530bff1848a515c8c50000000000000000000000000000000022d53366457f9d5e68ec105046fc4383000000000000000000000000c1db00a8e5ef7bfa476395cdbcc98235477cde4eDeployed Bytecode
0x60806040526004361061010d5760003560e01c8063ac43070b11610095578063c4ba5db211610064578063c4ba5db2146102b6578063c58bc7e0146102d6578063d1d719ef146102f6578063da0321cd14610316578063f875572d1461033e57610114565b8063ac43070b1461024c578063af6f220a1461026c578063b4dcfc7714610281578063b7711c631461029657610114565b80637452ed1e116100dc5780637452ed1e146101a857806380b2edd8146101d5578063848af32d146101f55780638b2704ec1461020a578063920f5c841461021f57610114565b80630542975c146101195780631d2d88ca14610144578063590c81c51461015957806364718c1d1461017b57610114565b3661011457005b600080fd5b34801561012557600080fd5b5061012e610351565b60405161013b9190613cd6565b60405180910390f35b34801561015057600080fd5b5061012e610375565b34801561016557600080fd5b506101796101743660046135c9565b610399565b005b34801561018757600080fd5b5061019b6101963660046136a2565b6103e5565b60405161013b919061449d565b3480156101b457600080fd5b506101c86101c3366004613661565b6105e4565b60405161013b919061448f565b3480156101e157600080fd5b506101796101f03660046135ad565b610601565b34801561020157600080fd5b5061019b61060d565b34801561021657600080fd5b5061012e610612565b34801561022b57600080fd5b5061023f61023a3660046133fb565b610636565b60405161013b9190613ccb565b34801561025857600080fd5b50610179610267366004613501565b6107d5565b34801561027857600080fd5b5061012e610809565b34801561028d57600080fd5b5061012e61082d565b3480156102a257600080fd5b506101796102b13660046135ad565b610851565b3480156102c257600080fd5b5061019b6102d13660046136a2565b6108a3565b3480156102e257600080fd5b506101796102f136600461371f565b610a9c565b34801561030257600080fd5b506101796103113660046135c9565b610aec565b34801561032257600080fd5b5061032b610b22565b60405161013b9796959493929190613ba4565b61017961034c3660046136a2565b610b5b565b7f000000000000000000000000b53c1a33016b2dc2ff3653530bff1848a515c8c581565b7f000000000000000000000000251bd1d42df1f153d86a5ba2305faade4d5f51dc81565b600260005414156103c55760405162461bcd60e51b81526004016103bc90614213565b60405180910390fd5b60026000556103d8868686868686610baa565b5050600160005550505050565b604051632961046560e21b81526000906001600160a01b037f000000000000000000000000251bd1d42df1f153d86a5ba2305faade4d5f51dc169063a584119490610434908890600401613cd6565b600060405180830381600087803b15801561044e57600080fd5b505af1158015610462573d6000803e3d6000fd5b5050505061046e612e53565b61047a86866000610d67565b9050600061049d670de3e93f3bb0400083608001516111e790919063ffffffff16565b90506000734737ed26956cc0a927bbddc860103f559121046c63f943b31e600188856040518463ffffffff1660e01b81526004016104dd93929190614303565b60206040518083038186803b1580156104f557600080fd5b505af4158015610509573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052d91906138a9565b9050600061054882856040015161121a90919063ffffffff16565b6040516301fae87160e61b8152909150734737ed26956cc0a927bbddc860103f559121046c90637eba1c4090610587906001908a908690600401614303565b60206040518083038186803b15801561059f57600080fd5b505af41580156105b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d791906138a9565b9998505050505050505050565b6105ec612e53565b6105f7848484610d67565b90505b9392505050565b61060a81611242565b50565b600281565b7f000000000000000000000000a4c8d221d8bb851f83aadd0223a8900a6921a34981565b6000336001600160a01b037f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a916146106805760405162461bcd60e51b81526004016103bc9061410d565b6001600160a01b03831630146106a85760405162461bcd60e51b81526004016103bc90614076565b85516001146106c95760405162461bcd60e51b81526004016103bc90614293565b84516001146106ea5760405162461bcd60e51b81526004016103bc90614187565b835160011461070b5760405162461bcd60e51b81526004016103bc90613d94565b610713612e81565b8280602001905181019061072791906137a6565b90508060600151156107805761077b8760008151811061074357fe5b60200260200101518760008151811061075857fe5b60200260200101518760008151811061076d57fe5b60200260200101518461126f565b6107c8565b6107c88760008151811061079057fe5b6020026020010151876000815181106107a557fe5b6020026020010151876000815181106107ba57fe5b6020026020010151846112cc565b5060019695505050505050565b60005b8151811015610805576107fd8282815181106107f057fe5b6020026020010151611242565b6001016107d8565b5050565b7f00000000000000000000000069a592d2129415a4a1d1b1e309c17051b7f28d5781565b7f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a981565b610859612e53565b61086d82670de0b6b3a76400006001610d67565b905061087c8160000151611242565b6108898160200151611396565b6108968160600151611242565b6108058160600151611396565b604051632961046560e21b81526000906001600160a01b037f000000000000000000000000251bd1d42df1f153d86a5ba2305faade4d5f51dc169063a5841194906108f2908890600401613cd6565b600060405180830381600087803b15801561090c57600080fd5b505af1158015610920573d6000803e3d6000fd5b5050505061092c612e53565b61093886866001610d67565b9050600061095b670de3e93f3bb0400083604001516111e790919063ffffffff16565b90506000734737ed26956cc0a927bbddc860103f559121046c637eba1c4060018886608001516040518463ffffffff1660e01b815260040161099f93929190614303565b60206040518083038186803b1580156109b757600080fd5b505af41580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef91906138a9565b9050610a01828263ffffffff61121a16565b604051637ca1d98f60e11b8152909250734737ed26956cc0a927bbddc860103f559121046c9063f943b31e90610a409060019089908790600401614303565b60206040518083038186803b158015610a5857600080fd5b505af4158015610a6c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9091906138a9565b98975050505050505050565b60026000541415610abf5760405162461bcd60e51b81526004016103bc90614213565b6002600055610ae08585600080516020614575833981519152868686610baa565b50506001600055505050565b60026000541415610b0f5760405162461bcd60e51b81526004016103bc90614213565b60026000556103d8868686868686611589565b6001546002546003546004546005546006546007546001600160a01b039687169695861695948516949384169392831692918216911687565b60026000541415610b7e5760405162461bcd60e51b81526004016103bc90614213565b6002600055610b9f8484600080516020614575833981519152348686611589565b505060016000555050565b604051632961046560e21b81526001600160a01b037f000000000000000000000000251bd1d42df1f153d86a5ba2305faade4d5f51dc169063a584119490610bf6908990600401613cd6565b600060405180830381600087803b158015610c1057600080fd5b505af1158015610c24573d6000803e3d6000fd5b50505050610c30612e53565b610c3c87876000610d67565b6040805160018082528183019092529192506060919060208083019080368337019050509050816060015181600081518110610c7457fe5b6001600160a01b039290921660209283029190910190910152604080516001808252818301909252606091816020016020820280368337019050509050826080015181600081518110610cc357fe5b60200260200101818152505060606040518061012001604052808b6001600160a01b031681526020018a8152602001336001600160a01b03168152602001600015158152602001896001600160a01b0316815260200188815260200185815260200187815260200186815250604051602001610d3f91906143e1565b6040516020818303038152906040529050610d5b83838361171e565b50505050505050505050565b610d6f612e53565b60608060608415610e285760405163131e26b960e01b81526001600160a01b037f00000000000000000000000069a592d2129415a4a1d1b1e309c17051b7f28d57169063131e26b990610dc8908a908a90600401613c62565b60006040518083038186803b158015610de057600080fd5b505afa158015610df4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e1c9190810190613377565b91945092509050610ed2565b6040516335c729db60e11b81526001600160a01b037f00000000000000000000000069a592d2129415a4a1d1b1e309c17051b7f28d571690636b8e53b690610e76908a908a90600401613c62565b60006040518083038186803b158015610e8e57600080fd5b505afa158015610ea2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610eca9190810190613377565b919450925090505b8251600214610ef35760405162461bcd60e51b81526004016103bc90613fa4565b81600081518110610f0057fe5b602002602001015160001480610f2a575081600181518110610f1e57fe5b60200260200101516000145b610f465760405162461bcd60e51b81526004016103bc90613f22565b80600081518110610f5357fe5b602002602001015160001480610f7d575080600181518110610f7157fe5b60200260200101516000145b610f995760405162461bcd60e51b81526004016103bc9061424a565b600082600081518110610fa857fe5b602002602001015111156110d9576040518060a0016040528084600081518110610fce57fe5b60200260200101516001600160a01b0316815260200184600081518110610ff157fe5b60200260200101516001600160a01b031663b16a19de6040518163ffffffff1660e01b815260040160206040518083038186803b15801561103157600080fd5b505afa158015611045573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611069919061335b565b6001600160a01b0316815260200160028460008151811061108657fe5b6020026020010151018152602001846001815181106110a157fe5b60200260200101516001600160a01b03168152602001826001815181106110c457fe5b602002602001015181525093505050506105fa565b6040518060a00160405280846001815181106110f157fe5b60200260200101516001600160a01b031681526020018460018151811061111457fe5b60200260200101516001600160a01b031663b16a19de6040518163ffffffff1660e01b815260040160206040518083038186803b15801561115457600080fd5b505afa158015611168573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118c919061335b565b6001600160a01b031681526020016002846001815181106111a957fe5b6020026020010151018152602001846000815181106111c457fe5b60200260200101516001600160a01b03168152602001826000815181106110c457fe5b6000611211670de0b6b3a7640000611205858563ffffffff61182e16565b9063ffffffff61186816565b90505b92915050565b60008282111561123c5760405162461bcd60e51b81526004016103bc90613e0e565b50900390565b61060a817f00000000000000000000000069a592d2129415a4a1d1b1e309c17051b7f28d5760001961189a565b6112798484611946565b6112908160000151826020015183604001516119c7565b600061129f8584860184611a4e565b90508160a001518111156112c55760405162461bcd60e51b81526004016103bc90613d49565b5050505050565b6112e3816000015182602001518360400151611b6c565b6113008160c001516020015160028360c001516040015103611bd7565b6000611325838501868460c00151604001518560c00151602001518660e00151611c79565b905060006113688284600001518560200151866040015187608001518860a001518960c0015160200151600280028b60c0015160400151038b6101000151611ec7565b90508260a0015181101561138e5760405162461bcd60e51b81526004016103bc90613cfd565b505050505050565b604051636eb1769f60e11b81526000906001600160a01b0383169063dd62ed3e906113e79030907f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a990600401613b66565b60206040518083038186803b1580156113ff57600080fd5b505afa158015611413573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143791906138a9565b905080156114e25760405163095ea7b360e01b81526001600160a01b0383169063095ea7b39061148e907f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a990600090600401613c62565b602060405180830381600087803b1580156114a857600080fd5b505af11580156114bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114e09190613591565b505b60405163095ea7b360e01b81526001600160a01b0383169063095ea7b390611532907f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a99060001990600401613c62565b602060405180830381600087803b15801561154c57600080fd5b505af1158015611560573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115849190613591565b505050565b604051632961046560e21b81526001600160a01b037f000000000000000000000000251bd1d42df1f153d86a5ba2305faade4d5f51dc169063a5841194906115d5908990600401613cd6565b600060405180830381600087803b1580156115ef57600080fd5b505af1158015611603573d6000803e3d6000fd5b5050505061160f612e53565b61161b87876001610d67565b604080516001808252818301909252919250606091906020808301908036833701905050905081602001518160008151811061165357fe5b6001600160a01b0392909216602092830291909101909101526040805160018082528183019092526060918160200160208202803683370190505090508260400151816000815181106116a257fe5b60200260200101818152505060606040518061012001604052808b6001600160a01b031681526020018a8152602001336001600160a01b03168152602001600115158152602001896001600160a01b0316815260200188815260200185815260200187815260200186815250604051602001610d3f91906143e1565b82513090819060009060609067ffffffffffffffff8111801561174057600080fd5b5060405190808252806020026020018201604052801561176a578160200160208202803683370190505b50905060005b875181101561179a57600082828151811061178757fe5b6020908102919091010152600101611770565b5060405163ab9c4b5d60e01b81526001600160a01b037f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a9169063ab9c4b5d906117f39087908b908b9087908a908d908b90600401613be5565b600060405180830381600087803b15801561180d57600080fd5b505af1158015611821573d6000803e3d6000fd5b5050505050505050505050565b60008261183d57506000611214565b8282028284828161184a57fe5b04146112115760405162461bcd60e51b81526004016103bc90614035565b60008082116118895760405162461bcd60e51b81526004016103bc90613f6d565b81838161189257fe5b049392505050565b604051636eb1769f60e11b81526000906001600160a01b0385169063dd62ed3e906118cb9030908790600401613b66565b60206040518083038186803b1580156118e357600080fd5b505afa1580156118f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061191b91906138a9565b905081811015611940576119406001600160a01b03851684831963ffffffff611fa916565b50505050565b60405163e8eda9df60e01b81526001600160a01b037f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a9169063e8eda9df9061199990859085903090600090600401613c9e565b600060405180830381600087803b1580156119b357600080fd5b505af115801561138e573d6000803e3d6000fd5b6040516336bc7a3d60e11b81526001600160a01b037f00000000000000000000000069a592d2129415a4a1d1b1e309c17051b7f28d571690636d78f47a90611a1790869086908690600401613c7b565b600060405180830381600087803b158015611a3157600080fd5b505af1158015611a45573d6000803e3d6000fd5b50505050505050565b600080611a71858460c00151606001518560c00151608001518660e00151612091565b905060006002611a87868463ffffffff61121a16565b01905060006000805160206145758339815191526001600160a01b031685608001516001600160a01b03161415611ad957611ad2878387604001518860a00151896101000151612281565b9050611afb565b611af88783876040015188608001518960a001518a610100015161239f565b90505b84608001516001600160a01b031685600001516001600160a01b031686604001516001600160a01b03167f44b3b16472a909f781f712646232271ffd156fff642d4895b700146a40462601848960200151604051611b5a9291906144a6565b60405180910390a49695505050505050565b611b876001600160a01b03841682308563ffffffff61250516565b604051635c833bfd60e01b81526001600160a01b037f00000000000000000000000069a592d2129415a4a1d1b1e309c17051b7f28d571690635c833bfd90611a1790869086903090600401613c7b565b604051631a4ca37b60e21b81526001600160a01b037f0000000000000000000000007d2768de32b0b80b7a3454c06bdac94a69ddc7a916906369328dec90611c2790859085903090600401613c7b565b602060405180830381600087803b158015611c4157600080fd5b505af1158015611c55573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061158491906138a9565b600081600001518386806001600160a01b0316826001600160a01b031614611dd757816001600160a01b031683600081518110611cb257fe5b60200260200101516001600160a01b03161480611d1a57506007546001600160a01b038381169116148015611d1a57506000805160206145758339815191526001600160a01b031683600081518110611d0757fe5b60200260200101516001600160a01b0316145b611d365760405162461bcd60e51b81526004016103bc90613ea2565b806001600160a01b031683600185510381518110611d5057fe5b60200260200101516001600160a01b03161480611dbb57506007546001600160a01b038281169116148015611dbb57506000805160206145758339815191526001600160a01b031683600185510381518110611da857fe5b60200260200101516001600160a01b0316145b611dd75760405162461bcd60e51b81526004016103bc906140c3565b6040805160e0810182526001546001600160a01b03908116825260025481166020830152600354811682840152600480548216606084015260055482166080840152600654821660a084015260075490911660c08301529151636fd7d45f60e01b8152734737ed26956cc0a927bbddc860103f559121046c92636fd7d45f92611e689290918e918d918c91016142d4565b60206040518083038186803b158015611e8057600080fd5b505af4158015611e94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eb891906138a9565b93505b50505095945050505050565b600089831015611ee95760405162461bcd60e51b81526004016103bc90613fe9565b6000611efb848c63ffffffff61121a16565b905060006001600160a01b0388166000805160206145758339815191521415611f3257611f2b86838b8a88612526565b9050611f43565b611f4086838b8b8b8961271d565b90505b876001600160a01b03168b6001600160a01b03168a6001600160a01b03167f9f8f1a845f52c0a7086f16f355a092a5acf0cca219c831409b9e5b1c39af9f9f8d85604051611f929291906144a6565b60405180910390a49b9a5050505050505050505050565b600061203982856001600160a01b031663dd62ed3e30876040518363ffffffff1660e01b8152600401611fdd929190613b66565b60206040518083038186803b158015611ff557600080fd5b505afa158015612009573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061202d91906138a9565b9063ffffffff61278416565b90506119408463095ea7b360e01b858460405160240161205a929190613c62565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526127a9565b600081600001518486806001600160a01b0316826001600160a01b0316146121ef57816001600160a01b0316836000815181106120ca57fe5b60200260200101516001600160a01b0316148061213257506007546001600160a01b03838116911614801561213257506000805160206145758339815191526001600160a01b03168360008151811061211f57fe5b60200260200101516001600160a01b0316145b61214e5760405162461bcd60e51b81526004016103bc90613ea2565b806001600160a01b03168360018551038151811061216857fe5b60200260200101516001600160a01b031614806121d357506007546001600160a01b0382811691161480156121d357506000805160206145758339815191526001600160a01b0316836001855103815181106121c057fe5b60200260200101516001600160a01b0316145b6121ef5760405162461bcd60e51b81526004016103bc906140c3565b6040805160e0810182526001546001600160a01b03908116825260025481166020830152600354811682840152600480548216606084015260055482166080840152600654821660a084015260075490911660c08301529151630355f53b60e31b8152734737ed26956cc0a927bbddc860103f559121046c92631aafa9d892610a409290918b916000918c91016142d4565b60075460408051630d0e30db60e41b815290516000926001600160a01b03169163d0e30db0918691600480820192879290919082900301818588803b1580156122c957600080fd5b505af11580156122dd573d6000803e3d6000fd5b505060075460009350612300925089915088906001600160a01b03168787612838565b90508084111561239557600061231c858363ffffffff61121a16565b600754604051632e1a7d4d60e01b81529192506001600160a01b031690632e1a7d4d9061234d90849060040161449d565b600060405180830381600087803b15801561236757600080fd5b505af115801561237b573d6000803e3d6000fd5b50612393925050506001600160a01b03871682612a49565b505b9695505050505050565b6000866001600160a01b0316846001600160a01b031614156123cd576123c6878787612ae5565b5084612395565b6040516323b872dd60e01b81526001600160a01b038516906323b872dd906123fd90889030908890600401613b80565b602060405180830381600087803b15801561241757600080fd5b505af115801561242b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061244f9190613591565b50600061245f8888878787612838565b9050838110156124fa576001600160a01b03851663a9059cbb87612489878563ffffffff61121a16565b6040518363ffffffff1660e01b81526004016124a6929190613c62565b602060405180830381600087803b1580156124c057600080fd5b505af11580156124d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124f89190613591565b505b979650505050505050565b611940846323b872dd60e01b85858560405160240161205a93929190613b80565b80516007546000919087906001600160a01b03908116908216811461268157816001600160a01b03168360008151811061255c57fe5b60200260200101516001600160a01b031614806125c457506007546001600160a01b0383811691161480156125c457506000805160206145758339815191526001600160a01b0316836000815181106125b157fe5b60200260200101516001600160a01b0316145b6125e05760405162461bcd60e51b81526004016103bc90613ea2565b806001600160a01b0316836001855103815181106125fa57fe5b60200260200101516001600160a01b0316148061266557506007546001600160a01b03828116911614801561266557506000805160206145758339815191526001600160a01b03168360018551038151811061265257fe5b60200260200101516001600160a01b0316145b6126815760405162461bcd60e51b81526004016103bc906140c3565b60075460009061269f908b908b906001600160a01b03168a8a612b06565b90508015611eb857600754604051632e1a7d4d60e01b81526001600160a01b0390911690632e1a7d4d906126d790849060040161449d565b600060405180830381600087803b1580156126f157600080fd5b505af1158015612705573d6000803e3d6000fd5b50611eb8925050506001600160a01b03891682612a49565b6000866001600160a01b0316846001600160a01b03161415612744576123c6878787612cf5565b60006127538888878787612b06565b60405163a9059cbb60e01b81529091506001600160a01b0386169063a9059cbb906124a69089908590600401613c62565b6000828201838110156112115760405162461bcd60e51b81526004016103bc90613dd7565b60606127fe826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d759092919063ffffffff16565b805190915015611584578080602001905181019061281c9190613591565b6115845760405162461bcd60e51b81526004016103bc906141c9565b600081600001518487806001600160a01b0316826001600160a01b03161461299657816001600160a01b03168360008151811061287157fe5b60200260200101516001600160a01b031614806128d957506007546001600160a01b0383811691161480156128d957506000805160206145758339815191526001600160a01b0316836000815181106128c657fe5b60200260200101516001600160a01b0316145b6128f55760405162461bcd60e51b81526004016103bc90613ea2565b806001600160a01b03168360018551038151811061290f57fe5b60200260200101516001600160a01b0316148061297a57506007546001600160a01b03828116911614801561297a57506000805160206145758339815191526001600160a01b03168360018551038151811061296757fe5b60200260200101516001600160a01b0316145b6129965760405162461bcd60e51b81526004016103bc906140c3565b866001600160a01b0316896001600160a01b031614156129b857879350611ebb565b6040805160e0810182526001546001600160a01b03908116825260025481166020830152600354811682840152600480548216606084015260055482166080840152600654821660a084015260075490911660c08301529151636fd7d45f60e01b8152734737ed26956cc0a927bbddc860103f559121046c92636fd7d45f92611e689290918d918c918c91016142d4565b80471015612a695760405162461bcd60e51b81526004016103bc90613eeb565b6000826001600160a01b031682604051612a8290613b63565b60006040518083038185875af1925050503d8060008114612abf576040519150601f19603f3d011682016040523d82523d6000602084013e612ac4565b606091505b50509050806115845760405162461bcd60e51b81526004016103bc90613e45565b8115611584576115846001600160a01b03841682308563ffffffff61250516565b600081600001518685806001600160a01b0316826001600160a01b031614612c6457816001600160a01b031683600081518110612b3f57fe5b60200260200101516001600160a01b03161480612ba757506007546001600160a01b038381169116148015612ba757506000805160206145758339815191526001600160a01b031683600081518110612b9457fe5b60200260200101516001600160a01b0316145b612bc35760405162461bcd60e51b81526004016103bc90613ea2565b806001600160a01b031683600185510381518110612bdd57fe5b60200260200101516001600160a01b03161480612c4857506007546001600160a01b038281169116148015612c4857506000805160206145758339815191526001600160a01b031683600185510381518110612c3557fe5b60200260200101516001600160a01b0316145b612c645760405162461bcd60e51b81526004016103bc906140c3565b6040805160e0810182526001546001600160a01b03908116825260025481166020830152600354811682840152600480548216606084015260055482166080840152600654821660a084015260075490911660c08301529151630355f53b60e31b8152734737ed26956cc0a927bbddc860103f559121046c92631aafa9d892611e689290918d918c918c91016142d4565b60405163a9059cbb60e01b81526001600160a01b0384169063a9059cbb90612d239084908690600401613c62565b602060405180830381600087803b158015612d3d57600080fd5b505af1158015612d51573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119409190613591565b60606105f7848460008585612d8985612e14565b612da55760405162461bcd60e51b81526004016103bc90614150565b60006060866001600160a01b03168587604051612dc29190613b47565b60006040518083038185875af1925050503d8060008114612dff576040519150601f19603f3d011682016040523d82523d6000602084013e612e04565b606091505b50915091506124fa828286612e1a565b3b151590565b60608315612e295750816105fa565b825115612e395782518084602001fd5b8160405162461bcd60e51b81526004016103bc9190613cea565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b60405180610120016040528060006001600160a01b031681526020016000815260200160006001600160a01b0316815260200160001515815260200160006001600160a01b0316815260200160008152602001612edc612e53565b8152602001612ee9612efb565b8152602001612ef6612efb565b905290565b6040518060800160405280606081526020016060815260200160006001600160a01b0316815260200160006004811115612ef657fe5b803561121481614533565b805161121481614533565b600082601f830112612f57578081fd5b8135612f6a612f65826144db565b6144b4565b818152915060208083019084810181840286018201871015612f8b57600080fd5b60005b84811015612fb3578135612fa181614533565b84529282019290820190600101612f8e565b505050505092915050565b600082601f830112612fce578081fd5b8151612fdc612f65826144db565b818152915060208083019084810181840286018201871015612ffd57600080fd5b60005b84811015612fb357815161301381614533565b84529282019290820190600101613000565b600082601f830112613035578081fd5b8135613043612f65826144db565b81815291506020808301908481018184028601820187101561306457600080fd5b60005b84811015612fb357813584529282019290820190600101613067565b600082601f830112613093578081fd5b81516130a1612f65826144db565b8181529150602080830190848101818402860182018710156130c257600080fd5b60005b84811015612fb3578151845292820192908201906001016130c5565b805161121481614548565b803561121481614556565b805161121481614556565b600060a08284031215613113578081fd5b61311d60a06144b4565b9050815161312a81614533565b8152602082015161313a81614533565b602082015260408281015190820152606082015161315781614533565b806060830152506080820151608082015292915050565b60006080828403121561317f578081fd5b61318960806144b4565b9050813567ffffffffffffffff808211156131a357600080fd5b6131af85838601612f47565b83526020915081840135818111156131c657600080fd5b84019050601f810185136131d957600080fd5b80356131e7612f65826144db565b818152838101908385018584028501860189101561320457600080fd5b600094505b8385101561322f5761321b8982613350565b835260019490940193918501918501613209565b50808587015250505050506132478360408401612f31565b604082015261325983606084016130ec565b606082015292915050565b600060808284031215613275578081fd5b61327f60806144b4565b9050815167ffffffffffffffff8082111561329957600080fd5b6132a585838601612fbe565b83526020915081840151818111156132bc57600080fd5b84019050601f810185136132cf57600080fd5b80516132dd612f65826144db565b81815283810190838501858402850186018910156132fa57600080fd5b600094505b8385101561332657805161331281614563565b8352600194909401939185019185016132ff565b508085870152505050505061333e8360408401612f3c565b604082015261325983606084016130f7565b803561121481614563565b60006020828403121561336c578081fd5b815161121181614533565b60008060006060848603121561338b578182fd5b835167ffffffffffffffff808211156133a2578384fd5b6133ae87838801612fbe565b945060208601519150808211156133c3578384fd5b6133cf87838801613083565b935060408601519150808211156133e4578283fd5b506133f186828701613083565b9150509250925092565b600080600080600060a08688031215613412578283fd5b853567ffffffffffffffff80821115613429578485fd5b61343589838a01612f47565b965060209150818801358181111561344b578586fd5b6134578a828b01613025565b96505060408801358181111561346b578586fd5b6134778a828b01613025565b955050606088013561348881614533565b935060808801358181111561349b578384fd5b8089018a601f8201126134ac578485fd5b80359150828211156134bc578485fd5b6134ce601f8301601f191685016144b4565b92508183528a848383010111156134e3578485fd5b81848201858501375081019091019190915293969295509093509190565b60006020808385031215613513578182fd5b823567ffffffffffffffff811115613529578283fd5b80840185601f82011261353a578384fd5b8035915061354a612f65836144db565b8281528381019082850185850284018601891015613566578687fd5b8693505b848410156124f857803561357d81614533565b83526001939093019291850191850161356a565b6000602082840312156135a2578081fd5b815161121181614548565b6000602082840312156135be578081fd5b813561121181614533565b60008060008060008060c087890312156135e1578384fd5b86356135ec81614533565b955060208701359450604087013561360381614533565b935060608701359250608087013567ffffffffffffffff80821115613626578283fd5b6136328a838b0161316e565b935060a0890135915080821115613647578283fd5b5061365489828a0161316e565b9150509295509295509295565b600080600060608486031215613675578081fd5b833561368081614533565b925060208401359150604084013561369781614548565b809150509250925092565b600080600080608085870312156136b7578182fd5b84356136c281614533565b935060208501359250604085013567ffffffffffffffff808211156136e5578384fd5b6136f18883890161316e565b93506060870135915080821115613706578283fd5b506137138782880161316e565b91505092959194509250565b600080600080600060a08688031215613736578283fd5b853561374181614533565b94506020860135935060408601359250606086013567ffffffffffffffff8082111561376b578283fd5b61377789838a0161316e565b9350608088013591508082111561378c578283fd5b506137998882890161316e565b9150509295509295909350565b6000602082840312156137b7578081fd5b815167ffffffffffffffff808211156137ce578283fd5b8184016101a081870312156137e1578384fd5b6137ec6101206144b4565b92506137f88682612f3c565b8352602081015160208401526138118660408301612f3c565b604084015261382386606083016130e1565b60608401526138358660808301612f3c565b608084015260a081015160a08401526138518660c08301613102565b60c084015261016081015182811115613868578485fd5b61387487828401613264565b60e0850152506101808101518281111561388c578485fd5b61389887828401613264565b610100850152509195945050505050565b6000602082840312156138ba578081fd5b5051919050565b6001600160a01b03169052565b6000815180845260208085019450808401835b838110156139065781516001600160a01b0316875295820195908201906001016138e1565b509495945050505050565b6000815180845260208085019450808401835b8381101561390657815187529582019590820190600101613924565b15159052565b6000815180845261395e816020860160208601614507565b601f01601f19169290920160200192915050565b6005811061397c57fe5b9052565b80516001600160a01b03908116835260208083015182169084015260408083015182169084015260608083015182169084015260808083015182169084015260a08281015182169084015260c09182015116910152565b80516001600160a01b0390811683526020808301518216908401526040808301519084015260608083015190911690830152608090810151910152565b6000815160808452613a2960808501826138ce565b6020848101518683038783015280518084529193508301918491908401905b80831015613a6d57835162ffffff168252928401926001929092019190840190613a48565b506040868101516001600160a01b031690880152606080870151945061239590880185613972565b805160808084528151908401819052600091602091839160a08701919084015b81841015613adc5780516001600160a01b0316835260019390930192918401918401613ab5565b505084830151868203878501528051808352859350908401918401905b80841015613b1e57825162ffffff168252600193909301929184019190840190613af9565b5060408601519350613b3360408801856138c1565b606086015193506123956060880185613972565b60008251613b59818460208701614507565b9190910192915050565b90565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03978816815295871660208701529386166040860152918516606085015284166080840152831660a083015290911660c082015260e00190565b600060018060a01b03808a16835260e06020840152613c0760e084018a6138ce565b8381036040850152613c19818a613911565b8481036060860152613c2b818a613911565b915050818716608085015283810360a0850152613c488187613946565b9250505061ffff831660c083015298975050505050505050565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6001600160a01b03948516815260208101939093529216604082015261ffff909116606082015260800190565b901515815260200190565b6001600160a01b0391909116815260200190565b6000602082526112116020830184613946565b6020808252602c908201527f45786368616e676549737375616e63653a20494e53554646494349454e54204f60408201526b155514155508105353d5539560a21b606082015260800190565b6020808252602b908201527f45786368616e676549737375616e63653a20494e53554646494349454e54204960408201526a1394155508105353d5539560aa1b606082015260800190565b60208082526023908201527f45786368616e676549737375616e63653a20544f4f204d414e59205052454d49604082015262554d5360e81b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252603a908201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260408201527f6563697069656e74206d61792068617665207265766572746564000000000000606082015260800190565b60208082526029908201527f45786368616e676549737375616e63653a20494e5055545f544f4b454e5f4e4f6040820152680a8be929cbea082a8960bb1b606082015260800190565b6020808252601d908201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604082015260600190565b6020808252602b908201527f45786368616e676549737375616e63653a20544f4f204d414e5920455155495460408201526a5920504f534954494f4e5360a81b606082015260800190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526025908201527f45786368616e676549737375616e63653a20544f4f204d414e5920434f4d504f6040820152644e454e545360d81b606082015260800190565b6020808252602c908201527f45786368616e676549737375616e63653a204f5645525350454e5420434f4c4c60408201526b20aa22a920a6102a27a5a2a760a11b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252602d908201527f45786368616e676549737375616e63653a20494e56414c494420464c4153484c60408201526c27a0a71024a724aa24a0aa27a960991b606082015260800190565b6020808252602a908201527f45786368616e676549737375616e63653a204f55545055545f544f4b454e5f4e60408201526909ea8be929cbea082a8960b31b606082015260800190565b60208082526023908201527f45786368616e676549737375616e63653a204c454e44494e4720504f4f4c204f6040820152624e4c5960e81b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526022908201527f45786368616e676549737375616e63653a20544f4f204d414e5920414d4f554e604082015261545360f01b606082015260800190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526029908201527f45786368616e676549737375616e63653a20544f4f204d414e59204445425420604082015268504f534954494f4e5360b81b606082015260800190565b60208082526021908201527f45786368616e676549737375616e63653a20544f4f204d414e592041535345546040820152605360f81b606082015260800190565b60006101406142e38388613980565b8560e084015284610100840152806101208401526124fa81840185613a95565b600061012061431b8361431688546144fb565b6138c1565b61432860018701546144fb565b61433560208501826138c1565b5061434360028701546144fb565b61435060408501826138c1565b5061435e60038701546144fb565b61436b60608501826138c1565b5061437960048701546144fb565b61438660808501826138c1565b5061439460058701546144fb565b6143a160a08501826138c1565b506143af60068701546144fb565b6143bc60c08501826138c1565b508060e08401526143cf81840186613a95565b91505082610100830152949350505050565b6000602082526143f56020830184516138c1565b60208301516040830152604083015161441160608401826138c1565b5060608301516144246080840182613940565b50608083015161443760a08401826138c1565b5060a083015160c083015260c083015161445460e08401826139d7565b5060e08301516101a0806101808501526144726101c0850183613a14565b610100860151858203601f19018387015292506123958184613a14565b60a0810161121482846139d7565b90815260200190565b918252602082015260400190565b60405181810167ffffffffffffffff811182821017156144d357600080fd5b604052919050565b600067ffffffffffffffff8211156144f1578081fd5b5060209081020190565b6001600160a01b031690565b60005b8381101561452257818101518382015260200161450a565b838111156119405750506000910152565b6001600160a01b038116811461060a57600080fd5b801515811461060a57600080fd5b6005811061060a57600080fd5b62ffffff8116811461060a57600080fdfe000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeea26469706673582212209e199d414cb4663c256da699998d658ee12d95ae83bc8d3ae1f7181ab593250564736f6c634300060a0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000b27308f9f90d607463bb33ea1bebb41c27ce5ab6000000000000000000000000a4c8d221d8bb851f83aadd0223a8900a6921a34900000000000000000000000069a592d2129415a4a1d1b1e309c17051b7f28d57000000000000000000000000251bd1d42df1f153d86a5ba2305faade4d5f51dc000000000000000000000000b53c1a33016b2dc2ff3653530bff1848a515c8c50000000000000000000000000000000022d53366457f9d5e68ec105046fc4383000000000000000000000000c1db00a8e5ef7bfa476395cdbcc98235477cde4e
-----Decoded View---------------
Arg [0] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [1] : _quickRouter (address): 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
Arg [2] : _sushiRouter (address): 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F
Arg [3] : _uniV3Router (address): 0xE592427A0AEce92De3Edee1F18E0157C05861564
Arg [4] : _uniV3Quoter (address): 0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6
Arg [5] : _setController (address): 0xa4c8d221d8BB851f83aadd0223a8900A6921A349
Arg [6] : _debtIssuanceModule (address): 0x69a592D2129415a4A1d1b1E309C17051B7F28d57
Arg [7] : _aaveLeverageModule (address): 0x251Bd1D42Df1f153D86a5BA2305FaADE4D5f51DC
Arg [8] : _aaveAddressProvider (address): 0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5
Arg [9] : _curveAddressProvider (address): 0x0000000022D53366457F9d5E68Ec105046FC4383
Arg [10] : _curveCalculator (address): 0xc1DB00a8E5Ef7bfa476395cdbcc98235477cDE4E
-----Encoded View---------------
11 Constructor Arguments found :
Arg [0] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [1] : 0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d
Arg [2] : 000000000000000000000000d9e1ce17f2641f24ae83637ab66a2cca9c378b9f
Arg [3] : 000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564
Arg [4] : 000000000000000000000000b27308f9f90d607463bb33ea1bebb41c27ce5ab6
Arg [5] : 000000000000000000000000a4c8d221d8bb851f83aadd0223a8900a6921a349
Arg [6] : 00000000000000000000000069a592d2129415a4a1d1b1e309c17051b7f28d57
Arg [7] : 000000000000000000000000251bd1d42df1f153d86a5ba2305faade4d5f51dc
Arg [8] : 000000000000000000000000b53c1a33016b2dc2ff3653530bff1848a515c8c5
Arg [9] : 0000000000000000000000000000000022d53366457f9d5e68ec105046fc4383
Arg [10] : 000000000000000000000000c1db00a8e5ef7bfa476395cdbcc98235477cde4eLoading...LoadingLoading...Loading
Loading...Loading
Loading...LoadingLoading...LoadingLoading...LoadingLoading...LoadingLoading...LoadingLoading...LoadingMultichain Portfolio | 30 Chains
Chain Token Portfolio % Price Amount Value Loading...Loading[ Download: CSV Export ][ Download: CSV Export ]A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.
Address QR Code
My Address - Private Name Tag or Note
My Name Tag:
Private Name Tags (up to 35 characters) can be used for easy identification of addressesPrivate Note:
A private note (up to 500 characters) can be attached to this address.
Please DO NOT store any passwords or private keys here.Compiler specific version warnings:
The compiled contract might be susceptible to FullInlinerNonExpressionSplitArgumentEvaluationOrder (low-severity), MissingSideEffectsOnSelectorAccess (low-severity), AbiReencodingHeadOverflowWithStaticArrayCleanup (medium-severity), DirtyBytesArrayToStorage (low-severity), DataLocationChangeInInternalOverride (very low-severity), NestedCalldataArrayAbiReencodingSizeValidation (very low-severity), SignedImmutables (very low-severity), ABIDecodeTwoDimensionalArrayMemory (very low-severity), KeccakCaching (medium-severity), EmptyByteArrayCopy (medium-severity), DynamicArrayCleanup (medium-severity) Solidity Compiler Bugs.
Connect a Wallet
Connecting wallet for read function is optional, useful if you want to call certain functions or simply use your wallet's node.Connect a Wallet
Connecting wallet for read function is optional, useful if you want to call certain functions or simply use your wallet's node.Connect a Wallet
Connecting wallet for read function is optional, useful if you want to call certain functions or simply use your wallet's node.SignIn
Address Cards
To use this feature, please login to your Etherscan account and return to this page.Before You Copy
Transaction Private Note
This website uses cookies to improve your experience. By continuing to use this website, you agree to its Terms and Privacy Policy.