Overview
APE Balance
0 APE
APE Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
CWrappedNativeDelegate
Compiler Version
v0.5.17+commit.d19bba13
Contract Source Code (Solidity Standard Json-Input format)
pragma solidity ^0.5.16; import "./CWrappedNative.sol"; /** * @title Zeno's CWrappedNativeDelegate Contract * @notice CTokens which wrap an EIP-20 underlying and are delegated to * @author Zeno */ contract CWrappedNativeDelegate is CWrappedNative { /** * @notice Construct an empty delegate */ constructor() public {} /** * @notice Called by the delegator on a delegate to initialize it for duty * @param data The encoded bytes data for any initialization */ function _becomeImplementation(bytes memory data) public { // Shh -- currently unused data; require(msg.sender == admin, "admin only"); // Set CToken version in comptroller and convert native token to wrapped token. ComptrollerInterfaceExtension(address(comptroller)).updateCTokenVersion( address(this), ComptrollerV1Storage.Version.WRAPPEDNATIVE ); uint256 balance = address(this).balance; if (balance > 0) { WrappedNativeInterface(underlying).deposit.value(balance)(); } // Set internal cash when becoming implementation internalCash = getCashOnChain(); } /** * @notice Called by the delegator on a delegate to forfeit its responsibility */ function _resignImplementation() public { // Shh -- we don't ever want this hook to be marked pure if (false) { implementation = address(0); } require(msg.sender == admin, "admin only"); } }
pragma solidity ^0.5.16; import "./ComptrollerInterface.sol"; import "./CTokenInterfaces.sol"; import "./ErrorReporter.sol"; import "./Exponential.sol"; import "./EIP20Interface.sol"; import "./EIP20NonStandardInterface.sol"; import "./InterestRateModel.sol"; /** * @title Compound's CToken Contract * @notice Abstract base for CTokens * @author Compound */ contract CToken is CTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ EIP-20 name of this token * @param symbol_ EIP-20 symbol of this token * @param decimals_ EIP-20 decimal precision of this token */ function initialize( ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint256 initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_ ) public { require(msg.sender == admin, "admin only"); require(accrualBlockNumber == 0 && borrowIndex == 0, "initialized"); // Set initial exchange rate initialExchangeRateMantissa = initialExchangeRateMantissa_; require(initialExchangeRateMantissa > 0, "invalid exchange rate"); // Set the comptroller uint256 err = _setComptroller(comptroller_); require(err == uint256(Error.NO_ERROR), "set comptroller failed"); // Initialize block number and borrow index (block number mocks depend on comptroller being set) accrualBlockNumber = getBlockNumber(); borrowIndex = mantissaOne; // Set the interest rate model (depends on block number / borrow index) err = _setInterestRateModelFresh(interestRateModel_); require(err == uint256(Error.NO_ERROR), "set IRM failed"); name = name_; symbol = symbol_; decimals = decimals_; // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund) _notEntered = true; } /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external nonReentrant returns (bool) { return transferTokens(msg.sender, msg.sender, dst, amount) == uint256(Error.NO_ERROR); } /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom( address src, address dst, uint256 amount ) external nonReentrant returns (bool) { return transferTokens(msg.sender, src, dst, amount) == uint256(Error.NO_ERROR); } /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool) { address src = msg.sender; transferAllowances[src][spender] = amount; emit Approval(src, spender, amount); return true; } /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view returns (uint256) { return transferAllowances[owner][spender]; } /** * @notice Get the token balance of the `owner` * @param owner The address of the account to query * @return The number of tokens owned by `owner` */ function balanceOf(address owner) external view returns (uint256) { return accountTokens[owner]; } /** * @notice Get the underlying balance of the `owner` * @dev This also accrues interest in a transaction * @param owner The address of the account to query * @return The amount of underlying owned by `owner` */ function balanceOfUnderlying(address owner) external returns (uint256) { Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()}); return mul_ScalarTruncate(exchangeRate, accountTokens[owner]); } /** * @notice Get a snapshot of the account's balances, and the cached exchange rate * @dev This is used by comptroller to more efficiently perform liquidity checks. * @param account Address of the account to snapshot * @return (possible error, token balance, borrow balance, exchange rate mantissa) */ function getAccountSnapshot(address account) external view returns ( uint256, uint256, uint256, uint256 ) { uint256 cTokenBalance = getCTokenBalanceInternal(account); uint256 borrowBalance = borrowBalanceStoredInternal(account); uint256 exchangeRateMantissa = exchangeRateStoredInternal(); return (uint256(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa); } /** * @dev Function to simply retrieve block number * This exists mainly for inheriting test contracts to stub this result. */ function getBlockNumber() internal view returns (uint256) { return block.timestamp; } /** * @notice Returns the current per-block borrow interest rate for this cToken * @return The borrow interest rate per block, scaled by 1e18 */ function borrowRatePerBlock() external view returns (uint256) { return interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves); } /** * @notice Returns the current per-block supply interest rate for this cToken * @return The supply interest rate per block, scaled by 1e18 */ function supplyRatePerBlock() external view returns (uint256) { return interestRateModel.getSupplyRate(getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa); } /** * @notice Returns the estimated per-block borrow interest rate for this cToken after some change * @return The borrow interest rate per block, scaled by 1e18 */ function estimateBorrowRatePerBlockAfterChange(uint256 change, bool repay) external view returns (uint256) { uint256 cashPriorNew; uint256 totalBorrowsNew; if (repay) { cashPriorNew = add_(getCashPrior(), change); totalBorrowsNew = sub_(totalBorrows, change); } else { cashPriorNew = sub_(getCashPrior(), change); totalBorrowsNew = add_(totalBorrows, change); } return interestRateModel.getBorrowRate(cashPriorNew, totalBorrowsNew, totalReserves); } /** * @notice Returns the estimated per-block supply interest rate for this cToken after some change * @return The supply interest rate per block, scaled by 1e18 */ function estimateSupplyRatePerBlockAfterChange(uint256 change, bool repay) external view returns (uint256) { uint256 cashPriorNew; uint256 totalBorrowsNew; if (repay) { cashPriorNew = add_(getCashPrior(), change); totalBorrowsNew = sub_(totalBorrows, change); } else { cashPriorNew = sub_(getCashPrior(), change); totalBorrowsNew = add_(totalBorrows, change); } return interestRateModel.getSupplyRate(cashPriorNew, totalBorrowsNew, totalReserves, reserveFactorMantissa); } /** * @notice Returns the current total borrows plus accrued interest * @return The total borrows with interest */ function totalBorrowsCurrent() external nonReentrant returns (uint256) { accrueInterest(); return totalBorrows; } /** * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex * @param account The address whose balance should be calculated after updating borrowIndex * @return The calculated balance */ function borrowBalanceCurrent(address account) external nonReentrant returns (uint256) { accrueInterest(); return borrowBalanceStored(account); } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return The calculated balance */ function borrowBalanceStored(address account) public view returns (uint256) { return borrowBalanceStoredInternal(account); } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return the calculated balance or 0 if error code is non-zero */ function borrowBalanceStoredInternal(address account) internal view returns (uint256) { /* Get borrowBalance and borrowIndex */ BorrowSnapshot storage borrowSnapshot = accountBorrows[account]; /* If borrowBalance = 0 then borrowIndex is likely also 0. * Rather than failing the calculation with a division by 0, we immediately return 0 in this case. */ if (borrowSnapshot.principal == 0) { return 0; } /* Calculate new borrow balance using the interest index: * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex */ uint256 principalTimesIndex = mul_(borrowSnapshot.principal, borrowIndex); uint256 result = div_(principalTimesIndex, borrowSnapshot.interestIndex); return result; } /** * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateCurrent() public nonReentrant returns (uint256) { accrueInterest(); return exchangeRateStored(); } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateStored() public view returns (uint256) { return exchangeRateStoredInternal(); } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return calculated exchange rate scaled by 1e18 */ function exchangeRateStoredInternal() internal view returns (uint256) { uint256 _totalSupply = totalSupply; if (_totalSupply == 0) { /* * If there are no tokens minted: * exchangeRate = initialExchangeRate */ return initialExchangeRateMantissa; } else { /* * Otherwise: * exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply */ uint256 totalCash = getCashPrior(); uint256 cashPlusBorrowsMinusReserves = sub_(add_(totalCash, totalBorrows), totalReserves); uint256 exchangeRate = div_(cashPlusBorrowsMinusReserves, Exp({mantissa: _totalSupply})); return exchangeRate; } } /** * @notice Get cash balance of this cToken in the underlying asset * @return The quantity of underlying asset owned by this contract */ function getCash() external view returns (uint256) { return getCashPrior(); } /** * @notice Applies accrued interest to total borrows and reserves * @dev This calculates interest accrued from the last checkpointed block * up to the current block and writes new checkpoint to storage. */ function accrueInterest() public returns (uint256) { /* Remember the initial block number */ uint256 currentBlockNumber = getBlockNumber(); uint256 accrualBlockNumberPrior = accrualBlockNumber; /* Short-circuit accumulating 0 interest */ if (accrualBlockNumberPrior == currentBlockNumber) { return uint256(Error.NO_ERROR); } /* Read the previous values out of storage */ uint256 cashPrior = getCashPrior(); uint256 borrowsPrior = totalBorrows; uint256 reservesPrior = totalReserves; uint256 borrowIndexPrior = borrowIndex; /* Calculate the current borrow interest rate */ uint256 borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior); require(borrowRateMantissa <= borrowRateMaxMantissa, "borrow rate too high"); /* Calculate the number of blocks elapsed since the last accrual */ uint256 blockDelta = sub_(currentBlockNumber, accrualBlockNumberPrior); /* * Calculate the interest accumulated into borrows and reserves and the new index: * simpleInterestFactor = borrowRate * blockDelta * interestAccumulated = simpleInterestFactor * totalBorrows * totalBorrowsNew = interestAccumulated + totalBorrows * totalReservesNew = interestAccumulated * reserveFactor + totalReserves * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex */ Exp memory simpleInterestFactor = mul_(Exp({mantissa: borrowRateMantissa}), blockDelta); uint256 interestAccumulated = mul_ScalarTruncate(simpleInterestFactor, borrowsPrior); uint256 totalBorrowsNew = add_(interestAccumulated, borrowsPrior); uint256 totalReservesNew = mul_ScalarTruncateAddUInt( Exp({mantissa: reserveFactorMantissa}), interestAccumulated, reservesPrior ); uint256 borrowIndexNew = mul_ScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accrualBlockNumber = currentBlockNumber; borrowIndex = borrowIndexNew; totalBorrows = totalBorrowsNew; totalReserves = totalReservesNew; /* We emit an AccrueInterest event */ emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew); return uint256(Error.NO_ERROR); } /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. */ function mintInternal(uint256 mintAmount, bool isNative) internal nonReentrant returns (uint256, uint256) { accrueInterest(); // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to return mintFresh(msg.sender, mintAmount, isNative); } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @param isNative The amount is in native or not * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemInternal(uint256 redeemTokens, bool isNative) internal nonReentrant returns (uint256) { accrueInterest(); // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(msg.sender, redeemTokens, 0, isNative); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to receive from redeeming cTokens * @param isNative The amount is in native or not * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlyingInternal(uint256 redeemAmount, bool isNative) internal nonReentrant returns (uint256) { accrueInterest(); // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(msg.sender, 0, redeemAmount, isNative); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @param isNative The amount is in native or not * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowInternal(uint256 borrowAmount, bool isNative) internal nonReentrant returns (uint256) { accrueInterest(); // borrowFresh emits borrow-specific logs on errors, so we don't need to return borrowFresh(msg.sender, borrowAmount, isNative); } struct BorrowLocalVars { MathError mathErr; uint256 accountBorrows; uint256 accountBorrowsNew; uint256 totalBorrowsNew; } /** * @notice Users borrow assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @param isNative The amount is in native or not * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowFresh( address payable borrower, uint256 borrowAmount, bool isNative ) internal returns (uint256) { /* Fail if borrow not allowed */ require(comptroller.borrowAllowed(address(this), borrower, borrowAmount) == 0, "rejected"); /* Verify market's block number equals current block number */ require(accrualBlockNumber == getBlockNumber(), "market is stale"); /* Reverts if protocol has insufficient cash */ require(getCashPrior() >= borrowAmount, "insufficient cash"); BorrowLocalVars memory vars; /* * We calculate the new borrower and total borrow balances, failing on overflow: * accountBorrowsNew = accountBorrows + borrowAmount * totalBorrowsNew = totalBorrows + borrowAmount */ vars.accountBorrows = borrowBalanceStoredInternal(borrower); vars.accountBorrowsNew = add_(vars.accountBorrows, borrowAmount); vars.totalBorrowsNew = add_(totalBorrows, borrowAmount); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = vars.accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; /* * We invoke doTransferOut for the borrower and the borrowAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken borrowAmount less of cash. * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. */ doTransferOut(borrower, borrowAmount, isNative); /* We emit a Borrow event */ emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew); /* We call the defense hook */ comptroller.borrowVerify(address(this), borrower, borrowAmount); return uint256(Error.NO_ERROR); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowInternal(uint256 repayAmount, bool isNative) internal nonReentrant returns (uint256, uint256) { accrueInterest(); // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, msg.sender, repayAmount, isNative); } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowBehalfInternal( address borrower, uint256 repayAmount, bool isNative ) internal nonReentrant returns (uint256, uint256) { accrueInterest(); // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, borrower, repayAmount, isNative); } struct RepayBorrowLocalVars { Error err; MathError mathErr; uint256 repayAmount; uint256 borrowerIndex; uint256 accountBorrows; uint256 accountBorrowsNew; uint256 totalBorrowsNew; uint256 actualRepayAmount; } /** * @notice Borrows are repaid by another user (possibly the borrower). * @param payer the account paying off the borrow * @param borrower the account with the debt being payed off * @param repayAmount the amount of underlying tokens being returned * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowFresh( address payer, address borrower, uint256 repayAmount, bool isNative ) internal returns (uint256, uint256) { /* Fail if repayBorrow not allowed */ require(comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount) == 0, "rejected"); /* Verify market's block number equals current block number */ require(accrualBlockNumber == getBlockNumber(), "market is stale"); RepayBorrowLocalVars memory vars; /* We remember the original borrowerIndex for verification purposes */ vars.borrowerIndex = accountBorrows[borrower].interestIndex; /* We fetch the amount the borrower owes, with accumulated interest */ vars.accountBorrows = borrowBalanceStoredInternal(borrower); /* If repayAmount == -1, repayAmount = accountBorrows */ if (repayAmount == uint256(-1)) { vars.repayAmount = vars.accountBorrows; } else { vars.repayAmount = repayAmount; } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the payer and the repayAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional repayAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount, isNative); /* * We calculate the new borrower and total borrow balances, failing on underflow: * accountBorrowsNew = accountBorrows - actualRepayAmount * totalBorrowsNew = totalBorrows - actualRepayAmount */ vars.accountBorrowsNew = sub_(vars.accountBorrows, vars.actualRepayAmount); vars.totalBorrowsNew = sub_(totalBorrows, vars.actualRepayAmount); /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = vars.accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; /* We emit a RepayBorrow event */ emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew); /* We call the defense hook */ comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex); return (uint256(Error.NO_ERROR), vars.actualRepayAmount); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param repayAmount The amount of the underlying borrowed asset to repay * @param cTokenCollateral The market in which to seize collateral from the borrower * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function liquidateBorrowInternal( address borrower, uint256 repayAmount, CTokenInterface cTokenCollateral, bool isNative ) internal nonReentrant returns (uint256, uint256) { accrueInterest(); require(cTokenCollateral.accrueInterest() == uint256(Error.NO_ERROR), "accrue interest failed"); // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral, isNative); } struct LiquidateBorrowLocalVars { uint256 repayBorrowError; uint256 actualRepayAmount; uint256 amountSeizeError; uint256 seizeTokens; } /** * @notice The liquidator liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param liquidator The address repaying the borrow and seizing collateral * @param cTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function liquidateBorrowFresh( address liquidator, address borrower, uint256 repayAmount, CTokenInterface cTokenCollateral, bool isNative ) internal returns (uint256, uint256) { /* Fail if liquidate not allowed */ require( comptroller.liquidateBorrowAllowed( address(this), address(cTokenCollateral), liquidator, borrower, repayAmount ) == 0, "rejected" ); /* Verify market's block number equals current block number */ require(accrualBlockNumber == getBlockNumber(), "market is stale"); /* Verify cTokenCollateral market's block number equals current block number */ require(cTokenCollateral.accrualBlockNumber() == getBlockNumber(), "market is stale"); /* Fail if borrower = liquidator */ require(borrower != liquidator, "invalid account pair"); /* Fail if repayAmount = 0 or repayAmount = -1 */ require(repayAmount > 0 && repayAmount != uint256(-1), "invalid amount"); LiquidateBorrowLocalVars memory vars; /* Fail if repayBorrow fails */ (vars.repayBorrowError, vars.actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount, isNative); require(vars.repayBorrowError == uint256(Error.NO_ERROR), "repay borrow failed"); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We calculate the number of collateral tokens that will be seized */ (vars.amountSeizeError, vars.seizeTokens) = comptroller.liquidateCalculateSeizeTokens( address(this), address(cTokenCollateral), vars.actualRepayAmount ); require(vars.amountSeizeError == uint256(Error.NO_ERROR), "calculate seize amount failed"); /* Revert if borrower collateral token balance < seizeTokens */ require(cTokenCollateral.balanceOf(borrower) >= vars.seizeTokens, "seize too much"); // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call uint256 seizeError; if (address(cTokenCollateral) == address(this)) { seizeError = seizeInternal(address(this), liquidator, borrower, vars.seizeTokens); } else { seizeError = cTokenCollateral.seize(liquidator, borrower, vars.seizeTokens); } /* Revert if seize tokens fails (since we cannot be sure of side effects) */ require(seizeError == uint256(Error.NO_ERROR), "token seizure failed"); /* We emit a LiquidateBorrow event */ emit LiquidateBorrow(liquidator, borrower, vars.actualRepayAmount, address(cTokenCollateral), vars.seizeTokens); /* We call the defense hook */ comptroller.liquidateBorrowVerify( address(this), address(cTokenCollateral), liquidator, borrower, vars.actualRepayAmount, vars.seizeTokens ); return (uint256(Error.NO_ERROR), vars.actualRepayAmount); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Will fail unless called by another cToken during the process of liquidation. * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter. * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of cTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seize( address liquidator, address borrower, uint256 seizeTokens ) external nonReentrant returns (uint256) { return seizeInternal(msg.sender, liquidator, borrower, seizeTokens); } /*** Admin Functions ***/ /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPendingAdmin(address payable newPendingAdmin) external returns (uint256) { // Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint256(Error.NO_ERROR); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() external returns (uint256) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = address(0); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint256(Error.NO_ERROR); } /** * @notice Sets a new comptroller for the market * @dev Admin function to set a new comptroller * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setComptroller(ComptrollerInterface newComptroller) public returns (uint256) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK); } ComptrollerInterface oldComptroller = comptroller; // Ensure invoke comptroller.isComptroller() returns true require(newComptroller.isComptroller(), "not comptroller"); // Set market's comptroller to newComptroller comptroller = newComptroller; // Emit NewComptroller(oldComptroller, newComptroller) emit NewComptroller(oldComptroller, newComptroller); return uint256(Error.NO_ERROR); } /** * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh * @dev Admin function to accrue interest and set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactor(uint256 newReserveFactorMantissa) external nonReentrant returns (uint256) { accrueInterest(); // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to. return _setReserveFactorFresh(newReserveFactorMantissa); } /** * @notice Sets a new reserve factor for the protocol (*requires fresh interest accrual) * @dev Admin function to set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactorFresh(uint256 newReserveFactorMantissa) internal returns (uint256) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK); } // Verify market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK); } // Check newReserveFactor ≤ maxReserveFactor if (newReserveFactorMantissa > reserveFactorMaxMantissa) { return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK); } uint256 oldReserveFactorMantissa = reserveFactorMantissa; reserveFactorMantissa = newReserveFactorMantissa; emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa); return uint256(Error.NO_ERROR); } /** * @notice Accrues interest and reduces reserves by transferring from msg.sender * @param addAmount Amount of addition to reserves * @param isNative The amount is in native or not * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReservesInternal(uint256 addAmount, bool isNative) internal nonReentrant returns (uint256) { accrueInterest(); // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to. (uint256 error, ) = _addReservesFresh(addAmount, isNative); return error; } /** * @notice Add reserves by transferring from caller * @dev Requires fresh interest accrual * @param addAmount Amount of addition to reserves * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees */ function _addReservesFresh(uint256 addAmount, bool isNative) internal returns (uint256, uint256) { // totalReserves + actualAddAmount uint256 totalReservesNew; uint256 actualAddAmount; // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the caller and the addAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional addAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ actualAddAmount = doTransferIn(msg.sender, addAmount, isNative); totalReservesNew = add_(totalReserves, actualAddAmount); // Store reserves[n+1] = reserves[n] + actualAddAmount totalReserves = totalReservesNew; /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */ emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew); /* Return (NO_ERROR, actualAddAmount) */ return (uint256(Error.NO_ERROR), actualAddAmount); } /** * @notice Accrues interest and reduces reserves by transferring to admin * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReserves(uint256 reduceAmount) external nonReentrant returns (uint256) { accrueInterest(); // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to. return _reduceReservesFresh(reduceAmount); } /** * @notice Reduces reserves by transferring to admin * @dev Requires fresh interest accrual * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReservesFresh(uint256 reduceAmount) internal returns (uint256) { // totalReserves - reduceAmount uint256 totalReservesNew; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.REDUCE_RESERVES_ADMIN_CHECK); } // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK); } // Fail gracefully if protocol has insufficient underlying cash if (getCashPrior() < reduceAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE); } // Check reduceAmount ≤ reserves[n] (totalReserves) if (reduceAmount > totalReserves) { return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) totalReservesNew = sub_(totalReserves, reduceAmount); // Store reserves[n+1] = reserves[n] - reduceAmount totalReserves = totalReservesNew; // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. // Restrict reducing reserves in wrapped token. Implementations except `CWrappedNative` won't use parameter `isNative`. doTransferOut(admin, reduceAmount, false); emit ReservesReduced(admin, reduceAmount, totalReservesNew); return uint256(Error.NO_ERROR); } /** * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh * @dev Admin function to accrue interest and update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint256) { accrueInterest(); // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to. return _setInterestRateModelFresh(newInterestRateModel); } /** * @notice updates the interest rate model (*requires fresh interest accrual) * @dev Admin function to update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModelFresh(InterestRateModel newInterestRateModel) internal returns (uint256) { // Used to store old model for use in the event that is emitted on success InterestRateModel oldInterestRateModel; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK); } // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK); } // Track the market's current interest rate model oldInterestRateModel = interestRateModel; // Ensure invoke newInterestRateModel.isInterestRateModel() returns true require(newInterestRateModel.isInterestRateModel(), "invalid IRM"); // Set the interest rate model to newInterestRateModel interestRateModel = newInterestRateModel; // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel) emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel); return uint256(Error.NO_ERROR); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying owned by this contract */ function getCashPrior() internal view returns (uint256); /** * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee. * This may revert due to insufficient balance or insufficient allowance. */ function doTransferIn( address from, uint256 amount, bool isNative ) internal returns (uint256); /** * @dev Performs a transfer out, ideally returning an explanatory error code upon failure rather than reverting. * If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract. * If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions. */ function doTransferOut( address payable to, uint256 amount, bool isNative ) internal; /** * @notice Transfer `tokens` tokens from `src` to `dst` by `spender` * @dev Called by both `transfer` and `transferFrom` internally */ function transferTokens( address spender, address src, address dst, uint256 tokens ) internal returns (uint256); /** * @notice Get the account's cToken balances */ function getCTokenBalanceInternal(address account) internal view returns (uint256); /** * @notice User supplies assets into the market and receives cTokens in exchange * @dev Assumes interest has already been accrued up to the current block */ function mintFresh( address minter, uint256 mintAmount, bool isNative ) internal returns (uint256, uint256); /** * @notice User redeems cTokens in exchange for the underlying asset * @dev Assumes interest has already been accrued up to the current block */ function redeemFresh( address payable redeemer, uint256 redeemTokensIn, uint256 redeemAmountIn, bool isNative ) internal returns (uint256); /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken. * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter. */ function seizeInternal( address seizerToken, address liquidator, address borrower, uint256 seizeTokens ) internal returns (uint256); /*** Reentrancy Guard ***/ /** * @dev Prevents a contract from calling itself, directly or indirectly. */ modifier nonReentrant() { require(_notEntered, "re-entered"); _notEntered = false; _; _notEntered = true; // get a gas-refund post-Istanbul } }
pragma solidity ^0.5.16; import "./ComptrollerInterface.sol"; import "./InterestRateModel.sol"; import "./ERC3156FlashBorrowerInterface.sol"; contract CTokenStorage { /** * @dev Guard variable for re-entrancy checks */ bool internal _notEntered; /** * @notice EIP-20 token name for this token */ string public name; /** * @notice EIP-20 token symbol for this token */ string public symbol; /** * @notice EIP-20 token decimals for this token */ uint8 public decimals; /** * @notice Maximum borrow rate that can ever be applied (.0005% / block) */ uint256 internal constant borrowRateMaxMantissa = 0.0005e16; /** * @notice Maximum fraction of interest that can be set aside for reserves */ uint256 internal constant reserveFactorMaxMantissa = 1e18; /** * @notice Administrator for this contract */ address payable public admin; /** * @notice Pending administrator for this contract */ address payable public pendingAdmin; /** * @notice Contract which oversees inter-cToken operations */ ComptrollerInterface public comptroller; /** * @notice Model which tells what the current interest rate should be */ InterestRateModel public interestRateModel; /** * @notice Initial exchange rate used when minting the first CTokens (used when totalSupply = 0) */ uint256 internal initialExchangeRateMantissa; /** * @notice Fraction of interest currently set aside for reserves */ uint256 public reserveFactorMantissa; /** * @notice Block number that interest was last accrued at */ uint256 public accrualBlockNumber; /** * @notice Accumulator of the total earned interest rate since the opening of the market */ uint256 public borrowIndex; /** * @notice Total amount of outstanding borrows of the underlying in this market */ uint256 public totalBorrows; /** * @notice Total amount of reserves of the underlying held in this market */ uint256 public totalReserves; /** * @notice Total number of tokens in circulation */ uint256 public totalSupply; /** * @notice Official record of token balances for each account */ mapping(address => uint256) internal accountTokens; /** * @notice Approved token transfer amounts on behalf of others */ mapping(address => mapping(address => uint256)) internal transferAllowances; /** * @notice Container for borrow balance information * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action * @member interestIndex Global borrowIndex as of the most recent balance-changing action */ struct BorrowSnapshot { uint256 principal; uint256 interestIndex; } /** * @notice Mapping of account addresses to outstanding borrow balances */ mapping(address => BorrowSnapshot) internal accountBorrows; } contract CErc20Storage { /** * @notice Underlying asset for this CToken */ address public underlying; /** * @notice Implementation address for this contract */ address public implementation; } contract CSupplyCapStorage { /** * @notice Internal cash counter for this CToken. Should equal underlying.balanceOf(address(this)) for CERC20. */ uint256 public internalCash; } contract CCollateralCapStorage { /** * @notice Total number of tokens used as collateral in circulation. */ uint256 public totalCollateralTokens; /** * @notice Record of token balances which could be treated as collateral for each account. * If collateral cap is not set, the value should be equal to accountTokens. */ mapping(address => uint256) public accountCollateralTokens; /** * @notice Check if accountCollateralTokens have been initialized. */ mapping(address => bool) public isCollateralTokenInit; /** * @notice Collateral cap for this CToken, zero for no cap. */ uint256 public collateralCap; } /*** Interface ***/ contract CTokenInterface is CTokenStorage { /** * @notice Indicator that this is a CToken contract (for inspection) */ bool public constant isCToken = true; /*** Market Events ***/ /** * @notice Event emitted when interest is accrued */ event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows); /** * @notice Event emitted when tokens are minted */ event Mint(address minter, uint256 mintAmount, uint256 mintTokens); /** * @notice Event emitted when tokens are redeemed */ event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens); /** * @notice Event emitted when underlying is borrowed */ event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows); /** * @notice Event emitted when a borrow is repaid */ event RepayBorrow( address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows ); /** * @notice Event emitted when a borrow is liquidated */ event LiquidateBorrow( address liquidator, address borrower, uint256 repayAmount, address cTokenCollateral, uint256 seizeTokens ); /*** Admin Events ***/ /** * @notice Event emitted when pendingAdmin is changed */ event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /** * @notice Event emitted when pendingAdmin is accepted, which means admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); /** * @notice Event emitted when comptroller is changed */ event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller); /** * @notice Event emitted when interestRateModel is changed */ event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel); /** * @notice Event emitted when the reserve factor is changed */ event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa); /** * @notice Event emitted when the reserves are added */ event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves); /** * @notice Event emitted when the reserves are reduced */ event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves); /** * @notice EIP20 Transfer event */ event Transfer(address indexed from, address indexed to, uint256 amount); /** * @notice EIP20 Approval event */ event Approval(address indexed owner, address indexed spender, uint256 amount); /** * @notice Failure event */ event Failure(uint256 error, uint256 info, uint256 detail); /*** User Interface ***/ function transfer(address dst, uint256 amount) external returns (bool); function transferFrom( address src, address dst, uint256 amount ) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function balanceOfUnderlying(address owner) external returns (uint256); function getAccountSnapshot(address account) external view returns ( uint256, uint256, uint256, uint256 ); function borrowRatePerBlock() external view returns (uint256); function supplyRatePerBlock() external view returns (uint256); function totalBorrowsCurrent() external returns (uint256); function borrowBalanceCurrent(address account) external returns (uint256); function borrowBalanceStored(address account) public view returns (uint256); function exchangeRateCurrent() public returns (uint256); function exchangeRateStored() public view returns (uint256); function getCash() external view returns (uint256); function accrueInterest() public returns (uint256); function seize( address liquidator, address borrower, uint256 seizeTokens ) external returns (uint256); /*** Admin Functions ***/ function _setPendingAdmin(address payable newPendingAdmin) external returns (uint256); function _acceptAdmin() external returns (uint256); function _setComptroller(ComptrollerInterface newComptroller) public returns (uint256); function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256); function _reduceReserves(uint256 reduceAmount) external returns (uint256); function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint256); } contract CErc20Interface is CErc20Storage { /*** User Interface ***/ function mint(uint256 mintAmount) external returns (uint256); function redeem(uint256 redeemTokens) external returns (uint256); function redeemUnderlying(uint256 redeemAmount) external returns (uint256); function borrow(uint256 borrowAmount) external returns (uint256); function repayBorrow(uint256 repayAmount) external returns (uint256); function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256); function liquidateBorrow( address borrower, uint256 repayAmount, CTokenInterface cTokenCollateral ) external returns (uint256); function _addReserves(uint256 addAmount) external returns (uint256); } contract CCapableErc20Interface is CErc20Interface, CSupplyCapStorage { /** * @notice Flash loan fee ratio */ uint256 public constant flashFeeBips = 9; /*** Market Events ***/ /** * @notice Event emitted when a flashloan occurred */ event Flashloan(address indexed receiver, uint256 amount, uint256 totalFee, uint256 reservesFee); /*** User Interface ***/ function gulp() external; } contract CWrappedNativeInterface is CCapableErc20Interface { /*** User Interface ***/ function mintNative() external payable returns (uint256); function redeemNative(uint256 redeemTokens) external returns (uint256); function redeemUnderlyingNative(uint256 redeemAmount) external returns (uint256); function borrowNative(uint256 borrowAmount) external returns (uint256); function repayBorrowNative() external payable returns (uint256); function repayBorrowBehalfNative(address borrower) external payable returns (uint256); function liquidateBorrowNative(address borrower, CTokenInterface cTokenCollateral) external payable returns (uint256); function flashLoan( ERC3156FlashBorrowerInterface receiver, address initiator, uint256 amount, bytes calldata data ) external returns (bool); function _addReservesNative() external payable returns (uint256); function collateralCap() external view returns (uint256); function totalCollateralTokens() external view returns (uint256); } contract CCollateralCapErc20Interface is CCapableErc20Interface, CCollateralCapStorage { /*** Admin Events ***/ /** * @notice Event emitted when collateral cap is set */ event NewCollateralCap(address token, uint256 newCap); /** * @notice Event emitted when user collateral is changed */ event UserCollateralChanged(address account, uint256 newCollateralTokens); /*** User Interface ***/ function registerCollateral(address account) external returns (uint256); function unregisterCollateral(address account) external; function flashLoan( ERC3156FlashBorrowerInterface receiver, address initiator, uint256 amount, bytes calldata data ) external returns (bool); /*** Admin Functions ***/ function _setCollateralCap(uint256 newCollateralCap) external; } contract CDelegatorInterface { /** * @notice Emitted when implementation is changed */ event NewImplementation(address oldImplementation, address newImplementation); /** * @notice Called by the admin to update the implementation of the delegator * @param implementation_ The address of the new implementation for delegation * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation */ function _setImplementation( address implementation_, bool allowResign, bytes memory becomeImplementationData ) public; } contract CDelegateInterface { /** * @notice Called by the delegator on a delegate to initialize it for duty * @dev Should revert if any issues arise which make it unfit for delegation * @param data The encoded bytes data for any initialization */ function _becomeImplementation(bytes memory data) public; /** * @notice Called by the delegator on a delegate to forfeit its responsibility */ function _resignImplementation() public; } /*** External interface ***/ /** * @title Flash loan receiver interface */ interface IFlashloanReceiver { function executeOperation( address sender, address underlying, uint256 amount, uint256 fee, bytes calldata params ) external; }
pragma solidity ^0.5.16; import "./CToken.sol"; import "./ERC3156FlashBorrowerInterface.sol"; import "./ERC3156FlashLenderInterface.sol"; /** * @title Wrapped native token interface */ interface WrappedNativeInterface { function deposit() external payable; function withdraw(uint256 wad) external; } /** * @title Zeno's CWrappedNative Contract * @notice CTokens which wrap the native token * @author Zeno */ contract CWrappedNative is CToken, CWrappedNativeInterface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ ERC-20 name of this token * @param symbol_ ERC-20 symbol of this token * @param decimals_ ERC-20 decimal precision of this token */ function initialize( address underlying_, ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint256 initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_ ) public { // CToken initialize does the bulk of the work super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_); // Set underlying and sanity check it underlying = underlying_; EIP20Interface(underlying).totalSupply(); WrappedNativeInterface(underlying); } /*** User Interface ***/ /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for backward compatibility * @param mintAmount The amount of the underlying asset to supply * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function mint(uint256 mintAmount) external returns (uint256) { (uint256 err, ) = mintInternal(mintAmount, false); require(err == 0, "mint failed"); } /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for consistency * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function mintNative() external payable returns (uint256) { (uint256 err, ) = mintInternal(msg.value, true); require(err == 0, "mint native failed"); } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for backward compatibility * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeem(uint256 redeemTokens) external returns (uint256) { require(redeemInternal(redeemTokens, false) == 0, "redeem failed"); } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for consistency * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemNative(uint256 redeemTokens) external returns (uint256) { require(redeemInternal(redeemTokens, true) == 0, "redeem native failed"); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for backward compatibility * @param redeemAmount The amount of underlying to redeem * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlying(uint256 redeemAmount) external returns (uint256) { require(redeemUnderlyingInternal(redeemAmount, false) == 0, "redeem underlying failed"); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for consistency * @param redeemAmount The amount of underlying to redeem * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlyingNative(uint256 redeemAmount) external returns (uint256) { require(redeemUnderlyingInternal(redeemAmount, true) == 0, "redeem underlying native failed"); } /** * @notice Sender borrows assets from the protocol to their own address * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for backward compatibility * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrow(uint256 borrowAmount) external returns (uint256) { require(borrowInternal(borrowAmount, false) == 0, "borrow failed"); } /** * @notice Sender borrows assets from the protocol to their own address * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for consistency * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowNative(uint256 borrowAmount) external returns (uint256) { require(borrowInternal(borrowAmount, true) == 0, "borrow native failed"); } /** * @notice Sender repays their own borrow * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for backward compatibility * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrow(uint256 repayAmount) external returns (uint256) { (uint256 err, ) = repayBorrowInternal(repayAmount, false); require(err == 0, "repay failed"); } /** * @notice Sender repays their own borrow * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for consistency * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrowNative() external payable returns (uint256) { (uint256 err, ) = repayBorrowInternal(msg.value, true); require(err == 0, "repay native failed"); } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256) { (uint256 err, ) = repayBorrowBehalfInternal(borrower, repayAmount, false); require(err == 0, "repay behalf failed"); } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrowBehalfNative(address borrower) external payable returns (uint256) { (uint256 err, ) = repayBorrowBehalfInternal(borrower, msg.value, true); require(err == 0, "repay behalf native failed"); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for backward compatibility * @param borrower The borrower of this cToken to be liquidated * @param repayAmount The amount of the underlying borrowed asset to repay * @param cTokenCollateral The market in which to seize collateral from the borrower * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function liquidateBorrow( address borrower, uint256 repayAmount, CTokenInterface cTokenCollateral ) external returns (uint256) { (uint256 err, ) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral, false); require(err == 0, "liquidate borrow failed"); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for consistency * @param borrower The borrower of this cToken to be liquidated * @param cTokenCollateral The market in which to seize collateral from the borrower * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function liquidateBorrowNative(address borrower, CTokenInterface cTokenCollateral) external payable returns (uint256) { (uint256 err, ) = liquidateBorrowInternal(borrower, msg.value, cTokenCollateral, true); require(err == 0, "liquidate borrow native failed"); } /** * @notice Absorb excess cash into reserves. */ function gulp() external nonReentrant { uint256 cashOnChain = getCashOnChain(); uint256 cashPrior = getCashPrior(); uint256 excessCash = sub_(cashOnChain, cashPrior); totalReserves = add_(totalReserves, excessCash); internalCash = cashOnChain; } /** * @dev The amount of currency available to be lent. * @param token The loan currency. * @return The amount of `token` that can be borrowed. */ function maxFlashLoan(address token) external view returns (uint256) { uint256 amount = 0; if ( token == underlying && ComptrollerInterfaceExtension(address(comptroller)).flashloanAllowed(address(this), address(0), amount, "") ) { amount = getCashPrior(); } return amount; } /** * @notice Get the flash loan fees * @param token The loan currency. Must match the address of this contract's underlying. * @param amount amount of token to borrow * @return The amount of `token` to be charged for the loan, on top of the returned principal. */ function flashFee(address token, uint256 amount) external view returns (uint256) { require(token == underlying, "unsupported currency"); require( ComptrollerInterfaceExtension(address(comptroller)).flashloanAllowed(address(this), address(0), amount, ""), "flashloan is paused" ); return _flashFee(token, amount); } /** * @notice Flash loan funds to a given account. * @param receiver The receiver address for the funds * @param token The loan currency. Must match the address of this contract's underlying. * @param amount The amount of the funds to be loaned * @param data The other data * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function flashLoan( ERC3156FlashBorrowerInterface receiver, address token, uint256 amount, bytes calldata data ) external nonReentrant returns (bool) { require(amount > 0, "invalid flashloan amount"); require(token == underlying, "unsupported currency"); accrueInterest(); require( ComptrollerInterfaceExtension(address(comptroller)).flashloanAllowed( address(this), address(receiver), amount, data ), "flashloan is paused" ); uint256 cashOnChainBefore = getCashOnChain(); uint256 cashBefore = getCashPrior(); require(cashBefore >= amount, "insufficient cash"); // 1. calculate fee, 1 bips = 1/10000 uint256 totalFee = _flashFee(token, amount); // 2. transfer fund to receiver doTransferOut(address(uint160(address(receiver))), amount, false); // 3. update totalBorrows totalBorrows = add_(totalBorrows, amount); // 4. execute receiver's callback function require( receiver.onFlashLoan(msg.sender, underlying, amount, totalFee, data) == keccak256("ERC3156FlashBorrowerInterface.onFlashLoan"), "IERC3156: Callback failed" ); // 5. take amount + fee from receiver, then check balance uint256 repaymentAmount = add_(amount, totalFee); doTransferIn(address(receiver), repaymentAmount, false); uint256 cashOnChainAfter = getCashOnChain(); require(cashOnChainAfter == add_(cashOnChainBefore, totalFee), "inconsistent balance"); // 6. update reserves and internal cash and totalBorrows uint256 reservesFee = mul_ScalarTruncate(Exp({mantissa: reserveFactorMantissa}), totalFee); totalReserves = add_(totalReserves, reservesFee); internalCash = add_(cashBefore, totalFee); totalBorrows = sub_(totalBorrows, amount); emit Flashloan(address(receiver), amount, totalFee, reservesFee); return true; } /** * @notice Get the flash loan fees * @param token The loan currency. Must match the address of this contract's underlying. * @param amount amount of token to borrow * @return The amount of `token` to be charged for the loan, on top of the returned principal. */ function _flashFee(address token, uint256 amount) internal view returns (uint256) { return div_(mul_(amount, flashFeeBips), 10000); } /** * @dev CWrappedNative doesn't have the collateral cap functionality. Return the supply cap for * interface consistency. * @return the supply cap of this market */ function collateralCap() external view returns (uint256) { return ComptrollerInterfaceExtension(address(comptroller)).supplyCaps(address(this)); } /** * @dev CWrappedNative doesn't have the collateral cap functionality. Return the total supply for * interface consistency. * @return the total supply of this market */ function totalCollateralTokens() external view returns (uint256) { return totalSupply; } function() external payable { require(msg.sender == underlying, "only wrapped native contract could send native token"); } /** * @notice The sender adds to reserves. * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for backward compatibility * @param addAmount The amount fo underlying token to add as reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReserves(uint256 addAmount) external returns (uint256) { require(_addReservesInternal(addAmount, false) == 0, "add reserves failed"); } /** * @notice The sender adds to reserves. * @dev Accrues interest whether or not the operation succeeds, unless reverted * Keep return in the function signature for consistency * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReservesNative() external payable returns (uint256) { require(_addReservesInternal(msg.value, true) == 0, "add reserves failed"); } /*** Safe Token ***/ /** * @notice Gets internal balance of this contract in terms of the underlying. * It excludes balance from direct transfer. * @dev This excludes the value of the current message, if any * @return The quantity of underlying tokens owned by this contract */ function getCashPrior() internal view returns (uint256) { return internalCash; } /** * @notice Gets total balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying tokens owned by this contract */ function getCashOnChain() internal view returns (uint256) { EIP20Interface token = EIP20Interface(underlying); return token.balanceOf(address(this)); } /** * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case. * This will revert due to insufficient balance or insufficient allowance. * This function returns the actual amount received, * which may be less than `amount` if there is a fee attached to the transfer. * * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ function doTransferIn( address from, uint256 amount, bool isNative ) internal returns (uint256) { if (isNative) { // Sanity checks require(msg.sender == from, "sender mismatch"); require(msg.value == amount, "value mismatch"); // Convert received native token to wrapped token WrappedNativeInterface(underlying).deposit.value(amount)(); internalCash = add_(internalCash, amount); return amount; } else { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); uint256 balanceBefore = EIP20Interface(underlying).balanceOf(address(this)); token.transferFrom(from, address(this), amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) // set success to true } case 32 { // This is a compliant ERC-20 returndatacopy(0, 0, 32) success := mload(0) // Set `success = returndata` of external call } default { // This is an excessively non-compliant ERC-20, revert. revert(0, 0) } } require(success, "transfer failed"); // Calculate the amount that was *actually* transferred uint256 balanceAfter = EIP20Interface(underlying).balanceOf(address(this)); uint256 transferredIn = sub_(balanceAfter, balanceBefore); internalCash = add_(internalCash, transferredIn); return transferredIn; } } /** * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified * it is >= amount, this should not revert in normal conditions. * * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ function doTransferOut( address payable to, uint256 amount, bool isNative ) internal { // Update the internal cash. internalCash = sub_(internalCash, amount); if (isNative) { // Convert wrapped token to native token WrappedNativeInterface(underlying).withdraw(amount); /* Send the Ether, with minimal gas and revert on failure */ to.transfer(amount); } else { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); token.transfer(to, amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) // set success to true } case 32 { // This is a complaint ERC-20 returndatacopy(0, 0, 32) success := mload(0) // Set `success = returndata` of external call } default { // This is an excessively non-compliant ERC-20, revert. revert(0, 0) } } require(success, "transfer failed"); } } /** * @notice Transfer `tokens` tokens from `src` to `dst` by `spender` * @dev Called by both `transfer` and `transferFrom` internally * @param spender The address of the account performing the transfer * @param src The address of the source account * @param dst The address of the destination account * @param tokens The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferTokens( address spender, address src, address dst, uint256 tokens ) internal returns (uint256) { /* Fail if transfer not allowed */ require(comptroller.transferAllowed(address(this), src, dst, tokens) == 0, "rejected"); /* Do not allow self-transfers */ require(src != dst, "bad input"); /* Get the allowance, infinite for the account owner */ uint256 startingAllowance = 0; if (spender == src) { startingAllowance = uint256(-1); } else { startingAllowance = transferAllowances[src][spender]; } /* Do the calculations, checking for {under,over}flow */ accountTokens[src] = sub_(accountTokens[src], tokens); accountTokens[dst] = add_(accountTokens[dst], tokens); /* Eat some of the allowance (if necessary) */ if (startingAllowance != uint256(-1)) { transferAllowances[src][spender] = sub_(startingAllowance, tokens); } /* We emit a Transfer event */ emit Transfer(src, dst, tokens); comptroller.transferVerify(address(this), src, dst, tokens); return uint256(Error.NO_ERROR); } /** * @notice Get the account's cToken balances * @param account The address of the account */ function getCTokenBalanceInternal(address account) internal view returns (uint256) { return accountTokens[account]; } struct MintLocalVars { uint256 exchangeRateMantissa; uint256 mintTokens; uint256 actualMintAmount; } /** * @notice User supplies assets into the market and receives cTokens in exchange * @dev Assumes interest has already been accrued up to the current block * @param minter The address of the account which is supplying the assets * @param mintAmount The amount of the underlying asset to supply * @param isNative The amount is in native or not * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. */ function mintFresh( address minter, uint256 mintAmount, bool isNative ) internal returns (uint256, uint256) { /* Fail if mint not allowed */ require(comptroller.mintAllowed(address(this), minter, mintAmount) == 0, "rejected"); /* * Return if mintAmount is zero. * Put behind `mintAllowed` for accruing potential COMP rewards. */ if (mintAmount == 0) { return (uint256(Error.NO_ERROR), 0); } /* Verify market's block number equals current block number */ require(accrualBlockNumber == getBlockNumber(), "market is stale"); MintLocalVars memory vars; vars.exchangeRateMantissa = exchangeRateStoredInternal(); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call `doTransferIn` for the minter and the mintAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * `doTransferIn` reverts if anything goes wrong, since we can't be sure if * side-effects occurred. The function returns the amount actually transferred, * in case of a fee. On success, the cToken holds an additional `actualMintAmount` * of cash. */ vars.actualMintAmount = doTransferIn(minter, mintAmount, isNative); /* * We get the current exchange rate and calculate the number of cTokens to be minted: * mintTokens = actualMintAmount / exchangeRate */ vars.mintTokens = div_ScalarByExpTruncate(vars.actualMintAmount, Exp({mantissa: vars.exchangeRateMantissa})); /* * We calculate the new total supply of cTokens and minter token balance, checking for overflow: * totalSupply = totalSupply + mintTokens * accountTokens[minter] = accountTokens[minter] + mintTokens */ totalSupply = add_(totalSupply, vars.mintTokens); accountTokens[minter] = add_(accountTokens[minter], vars.mintTokens); /* We emit a Mint event, and a Transfer event */ emit Mint(minter, vars.actualMintAmount, vars.mintTokens); emit Transfer(address(this), minter, vars.mintTokens); /* We call the defense hook */ comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens); return (uint256(Error.NO_ERROR), vars.actualMintAmount); } struct RedeemLocalVars { uint256 exchangeRateMantissa; uint256 redeemTokens; uint256 redeemAmount; uint256 totalSupplyNew; uint256 accountTokensNew; } /** * @notice User redeems cTokens in exchange for the underlying asset * @dev Assumes interest has already been accrued up to the current block. Only one of redeemTokensIn or redeemAmountIn may be non-zero and it would do nothing if both are zero. * @param redeemer The address of the account which is redeeming the tokens * @param redeemTokensIn The number of cTokens to redeem into underlying * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens * @param isNative The amount is in native or not * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemFresh( address payable redeemer, uint256 redeemTokensIn, uint256 redeemAmountIn, bool isNative ) internal returns (uint256) { require(redeemTokensIn == 0 || redeemAmountIn == 0, "bad input"); RedeemLocalVars memory vars; /* exchangeRate = invoke Exchange Rate Stored() */ vars.exchangeRateMantissa = exchangeRateStoredInternal(); /* If redeemTokensIn > 0: */ if (redeemTokensIn > 0) { /* * We calculate the exchange rate and the amount of underlying to be redeemed: * redeemTokens = redeemTokensIn * redeemAmount = redeemTokensIn x exchangeRateCurrent */ vars.redeemTokens = redeemTokensIn; vars.redeemAmount = mul_ScalarTruncate(Exp({mantissa: vars.exchangeRateMantissa}), redeemTokensIn); } else { /* * We get the current exchange rate and calculate the amount to be redeemed: * redeemTokens = redeemAmountIn / exchangeRate * redeemAmount = redeemAmountIn */ vars.redeemTokens = div_ScalarByExpTruncate(redeemAmountIn, Exp({mantissa: vars.exchangeRateMantissa})); vars.redeemAmount = redeemAmountIn; } /* Fail if redeem not allowed */ require(comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens) == 0, "rejected"); /* * Return if redeemTokensIn and redeemAmountIn are zero. * Put behind `redeemAllowed` for accruing potential COMP rewards. */ if (redeemTokensIn == 0 && redeemAmountIn == 0) { return uint256(Error.NO_ERROR); } /* Verify market's block number equals current block number */ require(accrualBlockNumber == getBlockNumber(), "market is stale"); /* * We calculate the new total supply and redeemer balance, checking for underflow: * totalSupplyNew = totalSupply - redeemTokens * accountTokensNew = accountTokens[redeemer] - redeemTokens */ vars.totalSupplyNew = sub_(totalSupply, vars.redeemTokens); vars.accountTokensNew = sub_(accountTokens[redeemer], vars.redeemTokens); /* Reverts if protocol has insufficient cash */ require(getCashPrior() >= vars.redeemAmount, "insufficient cash"); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write previously calculated values into storage */ totalSupply = vars.totalSupplyNew; accountTokens[redeemer] = vars.accountTokensNew; /* * We invoke doTransferOut for the redeemer and the redeemAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken has redeemAmount less of cash. * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. */ doTransferOut(redeemer, vars.redeemAmount, isNative); /* We emit a Transfer event, and a Redeem event */ emit Transfer(redeemer, address(this), vars.redeemTokens); emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens); /* We call the defense hook */ comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens); return uint256(Error.NO_ERROR); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken. * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter. * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken) * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of cTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seizeInternal( address seizerToken, address liquidator, address borrower, uint256 seizeTokens ) internal returns (uint256) { /* Fail if seize not allowed */ require( comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens) == 0, "rejected" ); /* * Return if seizeTokens is zero. * Put behind `seizeAllowed` for accruing potential COMP rewards. */ if (seizeTokens == 0) { return uint256(Error.NO_ERROR); } /* Fail if borrower = liquidator */ require(borrower != liquidator, "invalid account pair"); /* * We calculate the new borrower and liquidator token balances, failing on underflow/overflow: * borrowerTokensNew = accountTokens[borrower] - seizeTokens * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens */ accountTokens[borrower] = sub_(accountTokens[borrower], seizeTokens); accountTokens[liquidator] = add_(accountTokens[liquidator], seizeTokens); /* Emit a Transfer event */ emit Transfer(borrower, liquidator, seizeTokens); /* We call the defense hook */ comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens); return uint256(Error.NO_ERROR); } }
pragma solidity ^0.5.16; /** * @title Careful Math * @author Compound * @notice Derived from OpenZeppelin's SafeMath library * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol */ contract CarefulMath { /** * @dev Possible error codes that we can return */ enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW } /** * @dev Multiplies two numbers, returns an error on overflow. */ function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) { if (a == 0) { return (MathError.NO_ERROR, 0); } uint256 c = a * b; if (c / a != b) { return (MathError.INTEGER_OVERFLOW, 0); } else { return (MathError.NO_ERROR, c); } } /** * @dev Integer division of two numbers, truncating the quotient. */ function divUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) { if (b == 0) { return (MathError.DIVISION_BY_ZERO, 0); } return (MathError.NO_ERROR, a / b); } /** * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend). */ function subUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) { if (b <= a) { return (MathError.NO_ERROR, a - b); } else { return (MathError.INTEGER_UNDERFLOW, 0); } } /** * @dev Adds two numbers, returns an error on overflow. */ function addUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) { uint256 c = a + b; if (c >= a) { return (MathError.NO_ERROR, c); } else { return (MathError.INTEGER_OVERFLOW, 0); } } /** * @dev add a and b and then subtract c */ function addThenSubUInt( uint256 a, uint256 b, uint256 c ) internal pure returns (MathError, uint256) { (MathError err0, uint256 sum) = addUInt(a, b); if (err0 != MathError.NO_ERROR) { return (err0, 0); } return subUInt(sum, c); } }
pragma solidity ^0.5.16; import "./CToken.sol"; import "./ComptrollerStorage.sol"; contract ComptrollerInterface { /// @notice Indicator that this is a Comptroller contract (for inspection) bool public constant isComptroller = true; /*** Assets You Are In ***/ function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory); function exitMarket(address cToken) external returns (uint256); /*** Policy Hooks ***/ function mintAllowed( address cToken, address minter, uint256 mintAmount ) external returns (uint256); function mintVerify( address cToken, address minter, uint256 mintAmount, uint256 mintTokens ) external; function redeemAllowed( address cToken, address redeemer, uint256 redeemTokens ) external returns (uint256); function redeemVerify( address cToken, address redeemer, uint256 redeemAmount, uint256 redeemTokens ) external; function borrowAllowed( address cToken, address borrower, uint256 borrowAmount ) external returns (uint256); function borrowVerify( address cToken, address borrower, uint256 borrowAmount ) external; function repayBorrowAllowed( address cToken, address payer, address borrower, uint256 repayAmount ) external returns (uint256); function repayBorrowVerify( address cToken, address payer, address borrower, uint256 repayAmount, uint256 borrowerIndex ) external; function liquidateBorrowAllowed( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint256 repayAmount ) external returns (uint256); function liquidateBorrowVerify( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint256 repayAmount, uint256 seizeTokens ) external; function seizeAllowed( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint256 seizeTokens ) external returns (uint256); function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint256 seizeTokens ) external; function transferAllowed( address cToken, address src, address dst, uint256 transferTokens ) external returns (uint256); function transferVerify( address cToken, address src, address dst, uint256 transferTokens ) external; /*** Liquidity/Liquidation Calculations ***/ function liquidateCalculateSeizeTokens( address cTokenBorrowed, address cTokenCollateral, uint256 repayAmount ) external view returns (uint256, uint256); } interface ComptrollerInterfaceExtension { function checkMembership(address account, CToken cToken) external view returns (bool); function updateCTokenVersion(address cToken, ComptrollerV1Storage.Version version) external; function flashloanAllowed( address cToken, address receiver, uint256 amount, bytes calldata params ) external view returns (bool); function getAccountLiquidity(address account) external view returns ( uint256, uint256, uint256 ); function supplyCaps(address market) external view returns (uint256); }
pragma solidity ^0.5.16; import "./CToken.sol"; import "./PriceOracle/PriceOracle.sol"; contract UnitrollerAdminStorage { /** * @notice Administrator for this contract */ address public admin; /** * @notice Pending administrator for this contract */ address public pendingAdmin; /** * @notice Active brains of Unitroller */ address public comptrollerImplementation; /** * @notice Pending brains of Unitroller */ address public pendingComptrollerImplementation; } contract ComptrollerV1Storage is UnitrollerAdminStorage { /** * @notice Oracle which gives the price of any given asset */ PriceOracle public oracle; /** * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow */ uint256 public closeFactorMantissa; /** * @notice Multiplier representing the discount on collateral that a liquidator receives */ uint256 public liquidationIncentiveMantissa; /** * @notice Per-account mapping of "assets you are in" */ mapping(address => CToken[]) public accountAssets; enum Version { VANILLA, COLLATERALCAP, WRAPPEDNATIVE } struct Market { /// @notice Whether or not this market is listed bool isListed; /** * @notice Multiplier representing the most one can borrow against their collateral in this market. * For instance, 0.9 to allow borrowing 90% of collateral value. * Must be between 0 and 1, and stored as a mantissa. */ uint256 collateralFactorMantissa; /// @notice Per-market mapping of "accounts in this asset" mapping(address => bool) accountMembership; /// @notice CToken version Version version; } /** * @notice Official mapping of cTokens -> Market metadata * @dev Used e.g. to determine if a market is supported */ mapping(address => Market) public markets; /** * @notice The Guardian can pause certain actions as a safety mechanism. * Actions which allow users to remove their own assets cannot be paused. * Liquidation / seizing / transfer can only be paused globally, not by market. */ address public guardian; bool public _mintGuardianPaused; bool public _borrowGuardianPaused; bool public transferGuardianPaused; bool public seizeGuardianPaused; mapping(address => bool) public mintGuardianPaused; mapping(address => bool) public borrowGuardianPaused; mapping(address => bool) public flashloanGuardianPaused; /// @notice A list of all markets CToken[] public allMarkets; /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market. /// @dev This storage is deprecated. address public borrowCapGuardian; /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing. mapping(address => uint256) public borrowCaps; /// @notice The supplyCapGuardian can set supplyCaps to any number for any market. Lowering the supply cap could disable supplying to the given market. /// @dev This storage is deprecated. address public supplyCapGuardian; /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying. mapping(address => uint256) public supplyCaps; /// @notice creditLimits allowed specific protocols to borrow and repay specific markets without collateral. mapping(address => mapping(address => uint256)) public creditLimits; /// @notice liquidityMining the liquidity mining module that handles the LM rewards distribution. address public liquidityMining; /// @notice isMarketSoftDelisted records the market which has been soft delisted by us. mapping(address => bool) public isMarketSoftDelisted; /// @notice creditLimitManager is the role who is in charge of increasing the credit limit. address public creditLimitManager; /// @notice A list of all soft delisted markets address[] public softDelistedMarkets; }
pragma solidity ^0.5.16; /** * @title ERC 20 Token Standard Interface * https://eips.ethereum.org/EIPS/eip-20 */ interface EIP20Interface { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return The balance */ function balanceOf(address owner) external view returns (uint256 balance); /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external returns (bool success); /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom( address src, address dst, uint256 amount ) external returns (bool success); /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); }
pragma solidity ^0.5.16; /** * @title EIP20NonStandardInterface * @dev Version of ERC20 with no return values for `transfer` and `transferFrom` * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ interface EIP20NonStandardInterface { /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return The balance */ function balanceOf(address owner) external view returns (uint256 balance); /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transfer` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transfer(address dst, uint256 amount) external; /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transferFrom( address src, address dst, uint256 amount ) external; /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); }
pragma solidity ^0.5.16; interface ERC3156FlashBorrowerInterface { /** * @dev Receive a flash loan. * @param initiator The initiator of the loan. * @param token The loan currency. * @param amount The amount of tokens lent. * @param fee The additional amount of tokens to repay. * @param data Arbitrary data structure, intended to contain user-defined parameters. * @return The keccak256 hash of "ERC3156FlashBorrower.onFlashLoan" */ function onFlashLoan( address initiator, address token, uint256 amount, uint256 fee, bytes calldata data ) external returns (bytes32); }
pragma solidity ^0.5.16; import "./ERC3156FlashBorrowerInterface.sol"; interface ERC3156FlashLenderInterface { /** * @dev The amount of currency available to be lent. * @param token The loan currency. * @return The amount of `token` that can be borrowed. */ function maxFlashLoan(address token) external view returns (uint256); /** * @dev The fee to be charged for a given loan. * @param token The loan currency. * @param amount The amount of tokens lent. * @return The amount of `token` to be charged for the loan, on top of the returned principal. */ function flashFee(address token, uint256 amount) external view returns (uint256); /** * @dev Initiate a flash loan. * @param receiver The receiver of the tokens in the loan, and the receiver of the callback. * @param token The loan currency. * @param amount The amount of tokens lent. * @param data Arbitrary data structure, intended to contain user-defined parameters. */ function flashLoan( ERC3156FlashBorrowerInterface receiver, address token, uint256 amount, bytes calldata data ) external returns (bool); }
pragma solidity ^0.5.16; contract ComptrollerErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, COMPTROLLER_MISMATCH, INSUFFICIENT_SHORTFALL, INSUFFICIENT_LIQUIDITY, INVALID_CLOSE_FACTOR, INVALID_COLLATERAL_FACTOR, INVALID_LIQUIDATION_INCENTIVE, MARKET_NOT_ENTERED, // no longer possible MARKET_NOT_LISTED, MARKET_ALREADY_LISTED, MATH_ERROR, NONZERO_BORROW_BALANCE, PRICE_ERROR, REJECTION, SNAPSHOT_ERROR, TOO_MANY_ASSETS, TOO_MUCH_REPAY } enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK, EXIT_MARKET_BALANCE_OWED, EXIT_MARKET_REJECTION, SET_CLOSE_FACTOR_OWNER_CHECK, SET_CLOSE_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_NO_EXISTS, SET_COLLATERAL_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_WITHOUT_PRICE, SET_IMPLEMENTATION_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_VALIDATION, SET_MAX_ASSETS_OWNER_CHECK, SET_PENDING_ADMIN_OWNER_CHECK, SET_PENDING_IMPLEMENTATION_OWNER_CHECK, SET_PRICE_ORACLE_OWNER_CHECK, SUPPORT_MARKET_EXISTS, SUPPORT_MARKET_OWNER_CHECK, SET_PAUSE_GUARDIAN_OWNER_CHECK } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint256 error, uint256 info, uint256 detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint256) { emit Failure(uint256(err), uint256(info), 0); return uint256(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque( Error err, FailureInfo info, uint256 opaqueError ) internal returns (uint256) { emit Failure(uint256(err), uint256(info), opaqueError); return uint256(err); } } contract TokenErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, BAD_INPUT, COMPTROLLER_REJECTION, COMPTROLLER_CALCULATION_ERROR, INTEREST_RATE_MODEL_ERROR, INVALID_ACCOUNT_PAIR, INVALID_CLOSE_AMOUNT_REQUESTED, INVALID_COLLATERAL_FACTOR, MATH_ERROR, MARKET_NOT_FRESH, MARKET_NOT_LISTED, TOKEN_INSUFFICIENT_ALLOWANCE, TOKEN_INSUFFICIENT_BALANCE, TOKEN_INSUFFICIENT_CASH, TOKEN_TRANSFER_IN_FAILED, TOKEN_TRANSFER_OUT_FAILED } /* * Note: FailureInfo (but not Error) is kept in alphabetical order * This is because FailureInfo grows significantly faster, and * the order of Error has some meaning, while the order of FailureInfo * is entirely arbitrary. */ enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED, BORROW_ACCRUE_INTEREST_FAILED, BORROW_CASH_NOT_AVAILABLE, BORROW_FRESHNESS_CHECK, BORROW_MARKET_NOT_LISTED, BORROW_COMPTROLLER_REJECTION, LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED, LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED, LIQUIDATE_COLLATERAL_FRESHNESS_CHECK, LIQUIDATE_COMPTROLLER_REJECTION, LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED, LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX, LIQUIDATE_CLOSE_AMOUNT_IS_ZERO, LIQUIDATE_FRESHNESS_CHECK, LIQUIDATE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_REPAY_BORROW_FRESH_FAILED, LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_SEIZE_TOO_MUCH, MINT_ACCRUE_INTEREST_FAILED, MINT_COMPTROLLER_REJECTION, MINT_FRESHNESS_CHECK, MINT_TRANSFER_IN_FAILED, MINT_TRANSFER_IN_NOT_POSSIBLE, REDEEM_ACCRUE_INTEREST_FAILED, REDEEM_COMPTROLLER_REJECTION, REDEEM_FRESHNESS_CHECK, REDEEM_TRANSFER_OUT_NOT_POSSIBLE, REDUCE_RESERVES_ACCRUE_INTEREST_FAILED, REDUCE_RESERVES_ADMIN_CHECK, REDUCE_RESERVES_CASH_NOT_AVAILABLE, REDUCE_RESERVES_FRESH_CHECK, REDUCE_RESERVES_VALIDATION, REPAY_BEHALF_ACCRUE_INTEREST_FAILED, REPAY_BORROW_ACCRUE_INTEREST_FAILED, REPAY_BORROW_COMPTROLLER_REJECTION, REPAY_BORROW_FRESHNESS_CHECK, REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_VALIDATION, SET_COMPTROLLER_OWNER_CHECK, SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED, SET_INTEREST_RATE_MODEL_FRESH_CHECK, SET_INTEREST_RATE_MODEL_OWNER_CHECK, SET_MAX_ASSETS_OWNER_CHECK, SET_ORACLE_MARKET_NOT_LISTED, SET_PENDING_ADMIN_OWNER_CHECK, SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED, SET_RESERVE_FACTOR_ADMIN_CHECK, SET_RESERVE_FACTOR_FRESH_CHECK, SET_RESERVE_FACTOR_BOUNDS_CHECK, TRANSFER_COMPTROLLER_REJECTION, TRANSFER_NOT_ALLOWED, ADD_RESERVES_ACCRUE_INTEREST_FAILED, ADD_RESERVES_FRESH_CHECK, ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint256 error, uint256 info, uint256 detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint256) { emit Failure(uint256(err), uint256(info), 0); return uint256(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque( Error err, FailureInfo info, uint256 opaqueError ) internal returns (uint256) { emit Failure(uint256(err), uint256(info), opaqueError); return uint256(err); } }
pragma solidity ^0.5.16; import "./CarefulMath.sol"; /** * @title Exponential module for storing fixed-precision decimals * @author Compound * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places. * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is: * `Exp({mantissa: 5100000000000000000})`. */ contract Exponential is CarefulMath { uint256 constant expScale = 1e18; uint256 constant doubleScale = 1e36; uint256 constant halfExpScale = expScale / 2; uint256 constant mantissaOne = expScale; struct Exp { uint256 mantissa; } struct Double { uint256 mantissa; } /** * @dev Creates an exponential from numerator and denominator values. * Note: Returns an error if (`num` * 10e18) > MAX_INT, * or if `denom` is zero. */ function getExp(uint256 num, uint256 denom) internal pure returns (MathError, Exp memory) { (MathError err0, uint256 scaledNumerator) = mulUInt(num, expScale); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } (MathError err1, uint256 rational) = divUInt(scaledNumerator, denom); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: rational})); } /** * @dev Adds two exponentials, returning a new exponential. */ function addExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) { (MathError error, uint256 result) = addUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Subtracts two exponentials, returning a new exponential. */ function subExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) { (MathError error, uint256 result) = subUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Multiply an Exp by a scalar, returning a new Exp. */ function mulScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) { (MathError err0, uint256 scaledMantissa) = mulUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: scaledMantissa})); } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mulScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (MathError, uint256) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(product)); } /** * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. */ function mulScalarTruncateAddUInt( Exp memory a, uint256 scalar, uint256 addend ) internal pure returns (MathError, uint256) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return addUInt(truncate(product), addend); } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mul_ScalarTruncate(Exp memory a, uint256 scalar) internal pure returns (uint256) { Exp memory product = mul_(a, scalar); return truncate(product); } /** * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. */ function mul_ScalarTruncateAddUInt( Exp memory a, uint256 scalar, uint256 addend ) internal pure returns (uint256) { Exp memory product = mul_(a, scalar); return add_(truncate(product), addend); } /** * @dev Divide an Exp by a scalar, returning a new Exp. */ function divScalar(Exp memory a, uint256 scalar) internal pure returns (MathError, Exp memory) { (MathError err0, uint256 descaledMantissa) = divUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: descaledMantissa})); } /** * @dev Divide a scalar by an Exp, returning a new Exp. */ function divScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (MathError, Exp memory) { /* We are doing this as: getExp(mulUInt(expScale, scalar), divisor.mantissa) How it works: Exp = a / b; Scalar = s; `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale` */ (MathError err0, uint256 numerator) = mulUInt(expScale, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return getExp(numerator, divisor.mantissa); } /** * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer. */ function divScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (MathError, uint256) { (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(fraction)); } /** * @dev Divide a scalar by an Exp, returning a new Exp. */ function div_ScalarByExp(uint256 scalar, Exp memory divisor) internal pure returns (Exp memory) { /* We are doing this as: getExp(mulUInt(expScale, scalar), divisor.mantissa) How it works: Exp = a / b; Scalar = s; `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale` */ uint256 numerator = mul_(expScale, scalar); return Exp({mantissa: div_(numerator, divisor)}); } /** * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer. */ function div_ScalarByExpTruncate(uint256 scalar, Exp memory divisor) internal pure returns (uint256) { Exp memory fraction = div_ScalarByExp(scalar, divisor); return truncate(fraction); } /** * @dev Multiplies two exponentials, returning a new exponential. */ function mulExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) { (MathError err0, uint256 doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } // We add half the scale before dividing so that we get rounding instead of truncation. // See "Listing 6" and text above it at https://accu.org/index.php/journals/1717 // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18. (MathError err1, uint256 doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } (MathError err2, uint256 product) = divUInt(doubleScaledProductWithHalfScale, expScale); // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero. assert(err2 == MathError.NO_ERROR); return (MathError.NO_ERROR, Exp({mantissa: product})); } /** * @dev Multiplies two exponentials given their mantissas, returning a new exponential. */ function mulExp(uint256 a, uint256 b) internal pure returns (MathError, Exp memory) { return mulExp(Exp({mantissa: a}), Exp({mantissa: b})); } /** * @dev Multiplies three exponentials, returning a new exponential. */ function mulExp3( Exp memory a, Exp memory b, Exp memory c ) internal pure returns (MathError, Exp memory) { (MathError err, Exp memory ab) = mulExp(a, b); if (err != MathError.NO_ERROR) { return (err, ab); } return mulExp(ab, c); } /** * @dev Divides two exponentials, returning a new exponential. * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b, * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa) */ function divExp(Exp memory a, Exp memory b) internal pure returns (MathError, Exp memory) { return getExp(a.mantissa, b.mantissa); } /** * @dev Truncates the given exp to a whole number value. * For example, truncate(Exp{mantissa: 15 * expScale}) = 15 */ function truncate(Exp memory exp) internal pure returns (uint256) { // Note: We are not using careful math here as we're performing a division that cannot fail return exp.mantissa / expScale; } /** * @dev Checks if first Exp is less than second Exp. */ function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) { return left.mantissa < right.mantissa; } /** * @dev Checks if left Exp <= right Exp. */ function lessThanOrEqualExp(Exp memory left, Exp memory right) internal pure returns (bool) { return left.mantissa <= right.mantissa; } /** * @dev returns true if Exp is exactly zero */ function isZeroExp(Exp memory value) internal pure returns (bool) { return value.mantissa == 0; } function safe224(uint256 n, string memory errorMessage) internal pure returns (uint224) { require(n < 2**224, errorMessage); return uint224(n); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function add_(Exp memory a, Exp memory b) internal pure returns (Exp memory) { return Exp({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(Double memory a, Double memory b) internal pure returns (Double memory) { return Double({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(uint256 a, uint256 b) internal pure returns (uint256) { return add_(a, b, "addition overflow"); } function add_( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, errorMessage); return c; } function sub_(Exp memory a, Exp memory b) internal pure returns (Exp memory) { return Exp({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(Double memory a, Double memory b) internal pure returns (Double memory) { return Double({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(uint256 a, uint256 b) internal pure returns (uint256) { return sub_(a, b, "subtraction underflow"); } function sub_( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } function mul_(Exp memory a, Exp memory b) internal pure returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b.mantissa) / expScale}); } function mul_(Exp memory a, uint256 b) internal pure returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b)}); } function mul_(uint256 a, Exp memory b) internal pure returns (uint256) { return mul_(a, b.mantissa) / expScale; } function mul_(Double memory a, Double memory b) internal pure returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b.mantissa) / doubleScale}); } function mul_(Double memory a, uint256 b) internal pure returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b)}); } function mul_(uint256 a, Double memory b) internal pure returns (uint256) { return mul_(a, b.mantissa) / doubleScale; } function mul_(uint256 a, uint256 b) internal pure returns (uint256) { return mul_(a, b, "multiplication overflow"); } function mul_( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { if (a == 0 || b == 0) { return 0; } uint256 c = a * b; require(c / a == b, errorMessage); return c; } function div_(Exp memory a, Exp memory b) internal pure returns (Exp memory) { return Exp({mantissa: div_(mul_(a.mantissa, expScale), b.mantissa)}); } function div_(Exp memory a, uint256 b) internal pure returns (Exp memory) { return Exp({mantissa: div_(a.mantissa, b)}); } function div_(uint256 a, Exp memory b) internal pure returns (uint256) { return div_(mul_(a, expScale), b.mantissa); } function div_(Double memory a, Double memory b) internal pure returns (Double memory) { return Double({mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa)}); } function div_(Double memory a, uint256 b) internal pure returns (Double memory) { return Double({mantissa: div_(a.mantissa, b)}); } function div_(uint256 a, Double memory b) internal pure returns (uint256) { return div_(mul_(a, doubleScale), b.mantissa); } function div_(uint256 a, uint256 b) internal pure returns (uint256) { return div_(a, b, "divide by zero"); } function div_( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } function fraction(uint256 a, uint256 b) internal pure returns (Double memory) { return Double({mantissa: div_(mul_(a, doubleScale), b)}); } // implementation from https://github.com/Uniswap/uniswap-lib/commit/99f3f28770640ba1bb1ff460ac7c5292fb8291a0 // original implementation: https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687 function sqrt(uint256 x) internal pure returns (uint256) { if (x == 0) return 0; uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return (r < r1 ? r : r1); } }
pragma solidity ^0.5.16; /** * @title Compound's InterestRateModel Interface * @author Compound */ contract InterestRateModel { /// @notice Indicator that this is an InterestRateModel contract (for inspection) bool public constant isInterestRateModel = true; /** * @notice Calculates the current borrow interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amount of reserves the market has * @return The borrow rate per block (as a percentage, and scaled by 1e18) */ function getBorrowRate( uint256 cash, uint256 borrows, uint256 reserves ) external view returns (uint256); /** * @notice Calculates the current supply interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amount of reserves the market has * @param reserveFactorMantissa The current reserve factor the market has * @return The supply rate per block (as a percentage, and scaled by 1e18) */ function getSupplyRate( uint256 cash, uint256 borrows, uint256 reserves, uint256 reserveFactorMantissa ) external view returns (uint256); }
pragma solidity ^0.5.16; import "../CToken.sol"; contract PriceOracle { /** * @notice Get the underlying price of a cToken asset * @param cToken The cToken to get the underlying price of * @return The underlying asset price mantissa (scaled by 1e18). * Zero means the price is unavailable. */ function getUnderlyingPrice(CToken cToken) external view returns (uint256); }
{ "evmVersion": "istanbul", "libraries": {}, "metadata": { "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"cashPrior","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"interestAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"borrowIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"AccrueInterest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accountBorrows","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"Borrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"error","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"info","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"detail","type":"uint256"}],"name":"Failure","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reservesFee","type":"uint256"}],"name":"Flashloan","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"liquidator","type":"address"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"repayAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"cTokenCollateral","type":"address"},{"indexed":false,"internalType":"uint256","name":"seizeTokens","type":"uint256"}],"name":"LiquidateBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"mintAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mintTokens","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"NewAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ComptrollerInterface","name":"oldComptroller","type":"address"},{"indexed":false,"internalType":"contract ComptrollerInterface","name":"newComptroller","type":"address"}],"name":"NewComptroller","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract InterestRateModel","name":"oldInterestRateModel","type":"address"},{"indexed":false,"internalType":"contract InterestRateModel","name":"newInterestRateModel","type":"address"}],"name":"NewMarketInterestRateModel","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingAdmin","type":"address"}],"name":"NewPendingAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldReserveFactorMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newReserveFactorMantissa","type":"uint256"}],"name":"NewReserveFactor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"redeemer","type":"address"},{"indexed":false,"internalType":"uint256","name":"redeemAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"payer","type":"address"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"repayAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accountBorrows","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"RepayBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"benefactor","type":"address"},{"indexed":false,"internalType":"uint256","name":"addAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalReserves","type":"uint256"}],"name":"ReservesAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"admin","type":"address"},{"indexed":false,"internalType":"uint256","name":"reduceAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalReserves","type":"uint256"}],"name":"ReservesReduced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[],"name":"_acceptAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"addAmount","type":"uint256"}],"name":"_addReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"_addReservesNative","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"_becomeImplementation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"reduceAmount","type":"uint256"}],"name":"_reduceReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"_resignImplementation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract ComptrollerInterface","name":"newComptroller","type":"address"}],"name":"_setComptroller","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract InterestRateModel","name":"newInterestRateModel","type":"address"}],"name":"_setInterestRateModel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address payable","name":"newPendingAdmin","type":"address"}],"name":"_setPendingAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"newReserveFactorMantissa","type":"uint256"}],"name":"_setReserveFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"accrualBlockNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"accrueInterest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"admin","outputs":[{"internalType":"address payable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOfUnderlying","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"name":"borrow","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"borrowBalanceCurrent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"borrowBalanceStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"borrowIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"name":"borrowNative","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"borrowRatePerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"collateralCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"comptroller","outputs":[{"internalType":"contract ComptrollerInterface","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"change","type":"uint256"},{"internalType":"bool","name":"repay","type":"bool"}],"name":"estimateBorrowRatePerBlockAfterChange","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"change","type":"uint256"},{"internalType":"bool","name":"repay","type":"bool"}],"name":"estimateSupplyRatePerBlockAfterChange","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"exchangeRateCurrent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"exchangeRateStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"flashFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"flashFeeBips","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"contract ERC3156FlashBorrowerInterface","name":"receiver","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"flashLoan","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAccountSnapshot","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getCash","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"gulp","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"underlying_","type":"address"},{"internalType":"contract ComptrollerInterface","name":"comptroller_","type":"address"},{"internalType":"contract InterestRateModel","name":"interestRateModel_","type":"address"},{"internalType":"uint256","name":"initialExchangeRateMantissa_","type":"uint256"},{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract ComptrollerInterface","name":"comptroller_","type":"address"},{"internalType":"contract InterestRateModel","name":"interestRateModel_","type":"address"},{"internalType":"uint256","name":"initialExchangeRateMantissa_","type":"uint256"},{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"interestRateModel","outputs":[{"internalType":"contract InterestRateModel","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"internalCash","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isCToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"repayAmount","type":"uint256"},{"internalType":"contract CTokenInterface","name":"cTokenCollateral","type":"address"}],"name":"liquidateBorrow","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"contract CTokenInterface","name":"cTokenCollateral","type":"address"}],"name":"liquidateBorrowNative","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"maxFlashLoan","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"mintNative","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pendingAdmin","outputs":[{"internalType":"address payable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"redeemNative","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemUnderlying","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemUnderlyingNative","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"repayAmount","type":"uint256"}],"name":"repayBorrow","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"repayAmount","type":"uint256"}],"name":"repayBorrowBehalf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"borrower","type":"address"}],"name":"repayBorrowBehalfNative","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"repayBorrowNative","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"reserveFactorMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"liquidator","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"seizeTokens","type":"uint256"}],"name":"seize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"supplyRatePerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalBorrows","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"totalBorrowsCurrent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalCollateralTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50615e5080620000216000396000f3fe6080604052600436106103fa5760003560e01c806373acee9811610213578063c37f68e211610123578063e9c714f2116100ab578063f5e3c4621161007a578063f5e3c4621461115d578063f851a440146111a0578063f8f9da28146111b5578063fca7820b146111ca578063fe9c44ae146111f4576103fa565b8063e9c714f2146110eb578063ea11eea414611100578063f2b3abbd14611115578063f3fdb15a14611148576103fa565b8063d9d98ce4116100f2578063d9d98ce414610ffd578063db006a7514611036578063dbf7692914611060578063dd62ed3e14611086578063dff76484146110c1576103fa565b8063c37f68e214610f5d578063c5ebeaec14610fb6578063d2bb18e914610fe0578063d3c5715114610ff5576103fa565b806399d8c1b4116101a6578063aa5af0fd11610175578063aa5af0fd14610ea8578063ae9d70b014610ebd578063b2a02ff114610ed2578063b71d1a0c14610f15578063bd6d894d14610f48576103fa565b806399d8c1b414610cd5578063a0712d6814610e30578063a6afed9514610e5a578063a9059cbb14610e6f576103fa565b80638f840ddd116101e25780638f840ddd14610c6357806394909e6214610c7857806395d89b4114610c8d57806395dd919314610ca2576103fa565b806373acee9814610bf2578063852a12e314610c07578063884b934314610c315780638d3f9c6214610c5b576103fa565b8063291727a41161030e57806356e67728116102a1578063601a0bf111610270578063601a0bf114610b38578063613255ab14610b625780636c540baf14610b955780636f307dc314610baa57806370a0823114610bbf576103fa565b806356e67728146109c25780635c60da1b14610a735780635cffe9de14610a885780635fe3b56714610b23576103fa565b80633e941010116102dd5780633e941010146109265780634576b5db1461095057806347bd3718146109835780634bf03edf14610998576103fa565b8063291727a414610885578063313ce567146108b35780633af9e669146108de5780633b1d21a214610911576103fa565b806318160ddd11610391578063219f2fe711610360578063219f2fe7146107bb57806322abdbf5146107c357806323b872dd146107d85780632608f8181461081b5780632678224714610854576103fa565b806318160ddd14610619578063182df0f51461062e57806319a4dd3c146106435780631a31d46514610658576103fa565b80630f226888116103cd5780630f2268881461058a578063153ab505146105bc578063173b9904146105d157806317bfdfbc146105e6576103fa565b806305dd00b81461044557806306fdde0314610489578063095ea7b3146105135780630e75270214610560575b6011546001600160a01b031633146104435760405162461bcd60e51b8152600401808060200182810382526034815260200180615d9f6034913960400191505060405180910390fd5b005b34801561045157600080fd5b506104776004803603604081101561046857600080fd5b50803590602001351515611209565b60408051918252519081900360200190f35b34801561049557600080fd5b5061049e6112ee565b6040805160208082528351818301528351919283929083019185019080838360005b838110156104d85781810151838201526020016104c0565b50505050905090810190601f1680156105055780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561051f57600080fd5b5061054c6004803603604081101561053657600080fd5b506001600160a01b03813516906020013561137b565b604080519115158252519081900360200190f35b34801561056c57600080fd5b506104776004803603602081101561058357600080fd5b50356113e6565b34801561059657600080fd5b50610477600480360360408110156105ad57600080fd5b5080359060200135151561143f565b3480156105c857600080fd5b506104436114ee565b3480156105dd57600080fd5b50610477611541565b3480156105f257600080fd5b506104776004803603602081101561060957600080fd5b50356001600160a01b0316611547565b34801561062557600080fd5b506104776115bc565b34801561063a57600080fd5b506104776115c2565b34801561064f57600080fd5b506104776115d2565b34801561066457600080fd5b50610443600480360360e081101561067b57600080fd5b6001600160a01b03823581169260208101358216926040820135909216916060820135919081019060a081016080820135600160201b8111156106bd57600080fd5b8201836020820111156106cf57600080fd5b803590602001918460018302840111600160201b831117156106f057600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561074257600080fd5b82018360208201111561075457600080fd5b803590602001918460018302840111600160201b8311171561077557600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050903560ff1691506115d89050565b610477611677565b3480156107cf57600080fd5b506104776116d4565b3480156107e457600080fd5b5061054c600480360360608110156107fb57600080fd5b506001600160a01b038135811691602081013590911690604001356116da565b34801561082757600080fd5b506104776004803603604081101561083e57600080fd5b506001600160a01b03813516906020013561174c565b34801561086057600080fd5b506108696117ae565b604080516001600160a01b039092168252519081900360200190f35b6104776004803603604081101561089b57600080fd5b506001600160a01b03813581169160200135166117bd565b3480156108bf57600080fd5b506108c8611823565b6040805160ff9092168252519081900360200190f35b3480156108ea57600080fd5b506104776004803603602081101561090157600080fd5b50356001600160a01b031661182c565b34801561091d57600080fd5b5061047761187b565b34801561093257600080fd5b506104776004803603602081101561094957600080fd5b5035611885565b34801561095c57600080fd5b506104776004803603602081101561097357600080fd5b50356001600160a01b03166118da565b34801561098f57600080fd5b50610477611a1e565b3480156109a457600080fd5b50610477600480360360208110156109bb57600080fd5b5035611a24565b3480156109ce57600080fd5b50610443600480360360208110156109e557600080fd5b810190602081018135600160201b8111156109ff57600080fd5b820183602082011115610a1157600080fd5b803590602001918460018302840111600160201b83111715610a3257600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611a7a945050505050565b348015610a7f57600080fd5b50610869611bb8565b348015610a9457600080fd5b5061054c60048036036080811015610aab57600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b811115610ae557600080fd5b820183602082011115610af757600080fd5b803590602001918460018302840111600160201b83111715610b1857600080fd5b509092509050611bc7565b348015610b2f57600080fd5b506108696120c0565b348015610b4457600080fd5b5061047760048036036020811015610b5b57600080fd5b50356120cf565b348015610b6e57600080fd5b5061047760048036036020811015610b8557600080fd5b50356001600160a01b0316612130565b348015610ba157600080fd5b506104776121f7565b348015610bb657600080fd5b506108696121fd565b348015610bcb57600080fd5b5061047760048036036020811015610be257600080fd5b50356001600160a01b031661220c565b348015610bfe57600080fd5b50610477612227565b348015610c1357600080fd5b5061047760048036036020811015610c2a57600080fd5b5035612293565b348015610c3d57600080fd5b5061047760048036036020811015610c5457600080fd5b50356122f2565b610477612348565b348015610c6f57600080fd5b506104776123a2565b348015610c8457600080fd5b506104436123a8565b348015610c9957600080fd5b5061049e61243d565b348015610cae57600080fd5b5061047760048036036020811015610cc557600080fd5b50356001600160a01b0316612495565b348015610ce157600080fd5b50610443600480360360c0811015610cf857600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b811115610d3257600080fd5b820183602082011115610d4457600080fd5b803590602001918460018302840111600160201b83111715610d6557600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b811115610db757600080fd5b820183602082011115610dc957600080fd5b803590602001918460018302840111600160201b83111715610dea57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050903560ff1691506124a09050565b348015610e3c57600080fd5b5061047760048036036020811015610e5357600080fd5b503561269c565b348015610e6657600080fd5b506104776126ee565b348015610e7b57600080fd5b5061054c60048036036040811015610e9257600080fd5b506001600160a01b0381351690602001356128f5565b348015610eb457600080fd5b50610477612966565b348015610ec957600080fd5b5061047761296c565b348015610ede57600080fd5b5061047760048036036060811015610ef557600080fd5b506001600160a01b03813581169160208101359091169060400135612a0b565b348015610f2157600080fd5b5061047760048036036020811015610f3857600080fd5b50356001600160a01b0316612a7c565b348015610f5457600080fd5b50610477612b08565b348015610f6957600080fd5b50610f9060048036036020811015610f8057600080fd5b50356001600160a01b0316612b7a565b604080519485526020850193909352838301919091526060830152519081900360800190f35b348015610fc257600080fd5b5061047760048036036020811015610fd957600080fd5b5035612bb6565b348015610fec57600080fd5b50610477612c05565b610477612c50565b34801561100957600080fd5b506104776004803603604081101561102057600080fd5b506001600160a01b038135169060200135612ca5565b34801561104257600080fd5b506104776004803603602081101561105957600080fd5b5035612dec565b6104776004803603602081101561107657600080fd5b50356001600160a01b0316612e3b565b34801561109257600080fd5b50610477600480360360408110156110a957600080fd5b506001600160a01b0381358116916020013516612ea0565b3480156110cd57600080fd5b50610477600480360360208110156110e457600080fd5b5035612ecb565b3480156110f757600080fd5b50610477612f2a565b34801561110c57600080fd5b5061047761302d565b34801561112157600080fd5b506104776004803603602081101561113857600080fd5b50356001600160a01b0316613032565b34801561115457600080fd5b50610869613046565b34801561116957600080fd5b506104776004803603606081101561118057600080fd5b506001600160a01b03813581169160208101359160409091013516613055565b3480156111ac57600080fd5b506108696130c3565b3480156111c157600080fd5b506104776130d7565b3480156111d657600080fd5b50610477600480360360208110156111ed57600080fd5b503561313b565b34801561120057600080fd5b5061054c61319c565b6000806000831561123a5761122561121f6131a1565b866131a7565b9150611233600b54866131dd565b905061125c565b61124b6112456131a1565b866131dd565b9150611259600b54866131a7565b90505b600654600c54604080516315f2405360e01b815260048101869052602481018590526044810192909252516001600160a01b03909216916315f2405391606480820192602092909190829003018186803b1580156112b957600080fd5b505afa1580156112cd573d6000803e3d6000fd5b505050506040513d60208110156112e357600080fd5b505195945050505050565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156113735780601f1061134857610100808354040283529160200191611373565b820191906000526020600020905b81548152906001019060200180831161135657829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855290835281842086905581518681529151939493909284927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a35060019392505050565b6000806113f4836000613217565b5090508015611439576040805162461bcd60e51b815260206004820152600c60248201526b1c995c185e4819985a5b195960a21b604482015290519081900360640190fd5b50919050565b6000806000831561146a5761145561121f6131a1565b9150611463600b54866131dd565b9050611486565b6114756112456131a1565b9150611483600b54866131a7565b90505b600654600c5460085460408051635c0b440b60e11b8152600481018790526024810186905260448101939093526064830191909152516001600160a01b039092169163b816881691608480820192602092909190829003018186803b1580156112b957600080fd5b60035461010090046001600160a01b0316331461153f576040805162461bcd60e51b815260206004820152600a60248201526961646d696e206f6e6c7960b01b604482015290519081900360640190fd5b565b60085481565b6000805460ff1661158c576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905561159e6126ee565b506115a882612495565b90506000805460ff19166001179055919050565b600d5481565b60006115cc613297565b90505b90565b600d5490565b6115e68686868686866124a0565b601180546001600160a01b0319166001600160a01b038981169190911791829055604080516318160ddd60e01b8152905192909116916318160ddd91600480820192602092909190829003018186803b15801561164257600080fd5b505afa158015611656573d6000803e3d6000fd5b505050506040513d602081101561166c57600080fd5b505050505050505050565b6000806116853460016132f9565b50905080156116d0576040805162461bcd60e51b81526020600482015260126024820152711b5a5b9d081b985d1a5d994819985a5b195960721b604482015290519081900360640190fd5b5090565b60135481565b6000805460ff1661171f576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556117353386868661335e565b1490506000805460ff191660011790559392505050565b60008061175b84846000613636565b50905080156117a7576040805162461bcd60e51b81526020600482015260136024820152721c995c185e4818995a185b198819985a5b1959606a1b604482015290519081900360640190fd5b5092915050565b6004546001600160a01b031681565b6000806117cd84348560016136b7565b50905080156117a7576040805162461bcd60e51b815260206004820152601e60248201527f6c697175696461746520626f72726f77206e6174697665206661696c65640000604482015290519081900360640190fd5b60035460ff1681565b6000611836615c10565b6040518060200160405280611849612b08565b90526001600160a01b0384166000908152600e60205260409020549091506118729082906137ee565b9150505b919050565b60006115cc6131a1565b600061189282600061380d565b15611876576040805162461bcd60e51b8152602060048201526013602482015272185919081c995cd95c9d995cc819985a5b1959606a1b604482015290519081900360640190fd5b60035460009061010090046001600160a01b031633146119075761190060016029613888565b9050611876565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b15801561194c57600080fd5b505afa158015611960573d6000803e3d6000fd5b505050506040513d602081101561197657600080fd5b50516119bb576040805162461bcd60e51b815260206004820152600f60248201526e3737ba1031b7b6b83a3937b63632b960891b604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d9281900390910190a16000611872565b600b5481565b6000611a318260016138ee565b15611876576040805162461bcd60e51b81526020600482015260146024820152731c995919595b481b985d1a5d994819985a5b195960621b604482015290519081900360640190fd5b60035461010090046001600160a01b03163314611acb576040805162461bcd60e51b815260206004820152600a60248201526961646d696e206f6e6c7960b01b604482015290519081900360640190fd5b600554604080516344e3de7360e01b81523060048201526002602482015290516001600160a01b03909216916344e3de739160448082019260009290919082900301818387803b158015611b1e57600080fd5b505af1158015611b32573d6000803e3d6000fd5b504792505081159050611ba957601160009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015611b8f57600080fd5b505af1158015611ba3573d6000803e3d6000fd5b50505050505b611bb1613968565b6013555050565b6012546001600160a01b031681565b6000805460ff16611c0c576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905583611c68576040805162461bcd60e51b815260206004820152601860248201527f696e76616c696420666c6173686c6f616e20616d6f756e740000000000000000604482015290519081900360640190fd5b6011546001600160a01b03868116911614611cc1576040805162461bcd60e51b8152602060048201526014602482015273756e737570706f727465642063757272656e637960601b604482015290519081900360640190fd5b611cc96126ee565b506005546040516358d5bc7360e11b815230600482018181526001600160a01b038a81166024850152604484018990526080606485019081526084850188905294169363b1ab78e6938b928a928a928a92919060a401848480828437600081840152601f19601f820116905080830192505050965050505050505060206040518083038186803b158015611d5c57600080fd5b505afa158015611d70573d6000803e3d6000fd5b505050506040513d6020811015611d8657600080fd5b5051611dcf576040805162461bcd60e51b8152602060048201526013602482015272199b185cda1b1bd85b881a5cc81c185d5cd959606a1b604482015290519081900360640190fd5b6000611dd9613968565b90506000611de56131a1565b905085811015611e30576040805162461bcd60e51b81526020600482015260116024820152700d2dce6eaccccd2c6d2cadce840c6c2e6d607b1b604482015290519081900360640190fd5b6000611e3c88886139e8565b9050611e4a89886000613a00565b611e56600b54886131a7565b600b55604051806029615dd382396040519081900360290181206011546323e30c8b60e01b835233600484018181526001600160a01b0392831660248601819052604486018e90526064860188905260a06084870190815260a487018d9052949650928f16946323e30c8b949293928e9289928f928f929160c401848480828437600081840152601f19601f820116905080830192505050975050505050505050602060405180830381600087803b158015611f1157600080fd5b505af1158015611f25573d6000803e3d6000fd5b505050506040513d6020811015611f3b57600080fd5b505114611f8f576040805162461bcd60e51b815260206004820152601960248201527f49455243333135363a2043616c6c6261636b206661696c656400000000000000604482015290519081900360640190fd5b6000611f9b88836131a7565b9050611fa98a826000613ba1565b506000611fb4613968565b9050611fc085846131a7565b811461200a576040805162461bcd60e51b8152602060048201526014602482015273696e636f6e73697374656e742062616c616e636560601b604482015290519081900360640190fd5b60006120266040518060200160405280600854815250856137ee565b9050612034600c54826131a7565b600c5561204185856131a7565b601355600b54612051908b6131dd565b600b55604080518b81526020810186905280820183905290516001600160a01b038e16917f33c8e097c526683cbdb29adf782fac95e9d0fbe0ed635c13d8c75fdf726557d9919081900360600190a2600196505050505050506000805460ff1916600117905595945050505050565b6005546001600160a01b031681565b6000805460ff16612114576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556121266126ee565b506115a882613ec0565b60115460009081906001600160a01b0384811691161480156121e15750600554604080516358d5bc7360e11b81523060048201526000602482018190526044820185905260806064830152608482015290516001600160a01b039092169163b1ab78e69160c480820192602092909190829003018186803b1580156121b457600080fd5b505afa1580156121c8573d6000803e3d6000fd5b505050506040513d60208110156121de57600080fd5b50515b156121f1576121ee6131a1565b90505b92915050565b60095481565b6011546001600160a01b031681565b6001600160a01b03166000908152600e602052604090205490565b6000805460ff1661226c576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905561227e6126ee565b5050600b546000805460ff1916600117905590565b60006122a0826000613fc6565b15611876576040805162461bcd60e51b815260206004820152601860248201527f72656465656d20756e6465726c79696e67206661696c65640000000000000000604482015290519081900360640190fd5b60006122ff82600161402b565b15611876576040805162461bcd60e51b8152602060048201526014602482015273189bdc9c9bddc81b985d1a5d994819985a5b195960621b604482015290519081900360640190fd5b600080612356346001613217565b50905080156116d0576040805162461bcd60e51b81526020600482015260136024820152721c995c185e481b985d1a5d994819985a5b1959606a1b604482015290519081900360640190fd5b600c5481565b60005460ff166123ec576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556123fe613968565b9050600061240a6131a1565b9050600061241883836131dd565b9050612426600c54826131a7565b600c5550506013556000805460ff19166001179055565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156113735780601f1061134857610100808354040283529160200191611373565b60006121f18261408e565b60035461010090046001600160a01b031633146124f1576040805162461bcd60e51b815260206004820152600a60248201526961646d696e206f6e6c7960b01b604482015290519081900360640190fd5b6009541580156125015750600a54155b612540576040805162461bcd60e51b815260206004820152600b60248201526a1a5b9a5d1a585b1a5e995960aa1b604482015290519081900360640190fd5b60078490558361258f576040805162461bcd60e51b8152602060048201526015602482015274696e76616c69642065786368616e6765207261746560581b604482015290519081900360640190fd5b600061259a876118da565b905080156125e8576040805162461bcd60e51b81526020600482015260166024820152751cd95d0818dbdb5c1d1c9bdb1b195c8819985a5b195960521b604482015290519081900360640190fd5b6125f06140e3565b600955670de0b6b3a7640000600a55612608866140e7565b9050801561264e576040805162461bcd60e51b815260206004820152600e60248201526d1cd95d081254934819985a5b195960921b604482015290519081900360640190fd5b8351612661906001906020870190615c23565b508251612675906002906020860190615c23565b50506003805460ff90921660ff199283161790556000805490911660011790555050505050565b6000806126aa8360006132f9565b5090508015611439576040805162461bcd60e51b815260206004820152600b60248201526a1b5a5b9d0819985a5b195960aa1b604482015290519081900360640190fd5b6000806126f96140e3565b60095490915080821415612712576000925050506115cf565b600061271c6131a1565b600b54600c54600a54600654604080516315f2405360e01b815260048101879052602481018690526044810185905290519596509394929391926000926001600160a01b03909216916315f24053916064808301926020929190829003018186803b15801561278a57600080fd5b505afa15801561279e573d6000803e3d6000fd5b505050506040513d60208110156127b457600080fd5b5051905065048c2739500081111561280a576040805162461bcd60e51b81526020600482015260146024820152730c4dee4e4deee40e4c2e8ca40e8dede40d0d2ced60631b604482015290519081900360640190fd5b600061281688886131dd565b9050612820615c10565b6128386040518060200160405280858152508361424a565b9050600061284682886137ee565b9050600061285482896131a7565b905060006128736040518060200160405280600854815250848a614274565b9050600061288285898a614274565b60098e9055600a819055600b849055600c839055604080518d8152602081018790528082018390526060810186905290519192507f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc04919081900360800190a160009d505050505050505050505050505090565b6000805460ff1661293a576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556129503333868661335e565b1490506000805460ff1916600117905592915050565b600a5481565b6006546000906001600160a01b031663b81688166129886131a1565b600b54600c546008546040518563ffffffff1660e01b81526004018085815260200184815260200183815260200182815260200194505050505060206040518083038186803b1580156129da57600080fd5b505afa1580156129ee573d6000803e3d6000fd5b505050506040513d6020811015612a0457600080fd5b5051905090565b6000805460ff16612a50576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19169055612a663385858561429c565b90506000805460ff191660011790559392505050565b60035460009061010090046001600160a01b03163314612aa2576119006001602f613888565b600480546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a16000611872565b6000805460ff16612b4d576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19169055612b5f6126ee565b50612b686115c2565b90506000805460ff1916600117905590565b6000806000806000612b8b8661220c565b90506000612b988761408e565b90506000612ba4613297565b90506000989297509095509350915050565b6000612bc382600061402b565b15611876576040805162461bcd60e51b815260206004820152600d60248201526c189bdc9c9bddc819985a5b1959609a1b604482015290519081900360640190fd5b600554604080516302c3bcbb60e01b815230600482015290516000926001600160a01b0316916302c3bcbb916024808301926020929190829003018186803b1580156129da57600080fd5b6000612c5d34600161380d565b156115cf576040805162461bcd60e51b8152602060048201526013602482015272185919081c995cd95c9d995cc819985a5b1959606a1b604482015290519081900360640190fd5b6011546000906001600160a01b03848116911614612d01576040805162461bcd60e51b8152602060048201526014602482015273756e737570706f727465642063757272656e637960601b604482015290519081900360640190fd5b600554604080516358d5bc7360e11b81523060048201526000602482018190526044820186905260806064830152608482015290516001600160a01b039092169163b1ab78e69160c480820192602092909190829003018186803b158015612d6857600080fd5b505afa158015612d7c573d6000803e3d6000fd5b505050506040513d6020811015612d9257600080fd5b5051612ddb576040805162461bcd60e51b8152602060048201526013602482015272199b185cda1b1bd85b881a5cc81c185d5cd959606a1b604482015290519081900360640190fd5b612de583836139e8565b9392505050565b6000612df98260006138ee565b15611876576040805162461bcd60e51b815260206004820152600d60248201526c1c995919595b4819985a5b1959609a1b604482015290519081900360640190fd5b600080612e4a83346001613636565b5090508015611439576040805162461bcd60e51b815260206004820152601a60248201527f726570617920626568616c66206e6174697665206661696c6564000000000000604482015290519081900360640190fd5b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6000612ed8826001613fc6565b15611876576040805162461bcd60e51b815260206004820152601f60248201527f72656465656d20756e6465726c79696e67206e6174697665206661696c656400604482015290519081900360640190fd5b6004546000906001600160a01b031633141580612f45575033155b15612f5d57612f5660016000613888565b90506115cf565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b031990931690935560408051948390048216808652929095041660208401528351909391927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600454604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a160009250505090565b600981565b600061303c6126ee565b506121f1826140e7565b6006546001600160a01b031681565b60008061306585858560006136b7565b50905080156130bb576040805162461bcd60e51b815260206004820152601760248201527f6c697175696461746520626f72726f77206661696c6564000000000000000000604482015290519081900360640190fd5b509392505050565b60035461010090046001600160a01b031681565b6006546000906001600160a01b03166315f240536130f36131a1565b600b54600c546040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b1580156129da57600080fd5b6000805460ff16613180576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556131926126ee565b506115a882614502565b600181565b60135490565b6000612de58383604051806040016040528060118152602001706164646974696f6e206f766572666c6f7760781b8152506145aa565b6000612de58383604051806040016040528060158152602001747375627472616374696f6e20756e646572666c6f7760581b815250614645565b60008054819060ff1661325e576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556132706126ee565b5061327d3333868661469f565b915091506000805460ff1916600117905590939092509050565b600d54600090806132ac5750506007546115cf565b60006132b66131a1565b905060006132d16132c983600b546131a7565b600c546131dd565b905060006132ed82604051806020016040528087815250614991565b94506115cf9350505050565b60008054819060ff16613340576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556133526126ee565b5061327d3385856149af565b600554604080516317b9b84b60e31b81523060048201526001600160a01b0386811660248301528581166044830152606482018590529151600093929092169163bdcdc2589160848082019260209290919082900301818787803b1580156133c557600080fd5b505af11580156133d9573d6000803e3d6000fd5b505050506040513d60208110156133ef57600080fd5b50511561342e576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b826001600160a01b0316846001600160a01b03161415613481576040805162461bcd60e51b8152602060048201526009602482015268189859081a5b9c1d5d60ba1b604482015290519081900360640190fd5b60006001600160a01b0386811690861614156134a057506000196134c8565b506001600160a01b038085166000908152600f60209081526040808320938916835292905220545b6001600160a01b0385166000908152600e60205260409020546134eb90846131dd565b6001600160a01b038087166000908152600e6020526040808220939093559086168152205461351a90846131a7565b6001600160a01b0385166000908152600e6020526040902055600019811461356d5761354681846131dd565b6001600160a01b038087166000908152600f60209081526040808320938b16835292905220555b836001600160a01b0316856001600160a01b0316600080516020615dfc833981519152856040518082815260200191505060405180910390a36005546040805163352b4a3f60e11b81523060048201526001600160a01b03888116602483015287811660448301526064820187905291519190921691636a56947e91608480830192600092919082900301818387803b15801561360957600080fd5b505af115801561361d573d6000803e3d6000fd5b506000925061362a915050565b9150505b949350505050565b60008054819060ff1661367d576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905561368f6126ee565b5061369c3386868661469f565b915091506000805460ff191660011790559094909350915050565b60008054819060ff166136fe576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556137106126ee565b506000846001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561374e57600080fd5b505af1158015613762573d6000803e3d6000fd5b505050506040513d602081101561377857600080fd5b5051146137c5576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b6137d23387878787614c91565b915091506000805460ff19166001179055909590945092505050565b60006137f8615c10565b613802848461424a565b905061362e81615381565b6000805460ff16613852576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556138646126ee565b5060006138718484615390565b509150506000805460ff1916600117905592915050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08360108111156138b757fe5b8360388111156138c357fe5b604080519283526020830191909152600082820152519081900360600190a1826010811115612de557fe5b6000805460ff16613933576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556139456126ee565b50613953338460008561542e565b90506000805460ff1916600117905592915050565b601154604080516370a0823160e01b815230600482015290516000926001600160a01b03169182916370a0823191602480820192602092909190829003018186803b1580156139b657600080fd5b505afa1580156139ca573d6000803e3d6000fd5b505050506040513d60208110156139e057600080fd5b505191505090565b6000612de56139f88360096157e4565b612710615826565b613a0c601354836131dd565b6013558015613ab65760115460408051632e1a7d4d60e01b81526004810185905290516001600160a01b0390921691632e1a7d4d9160248082019260009290919082900301818387803b158015613a6257600080fd5b505af1158015613a76573d6000803e3d6000fd5b50506040516001600160a01b038616925084156108fc02915084906000818181858888f19350505050158015613ab0573d6000803e3d6000fd5b50613b9c565b6011546040805163a9059cbb60e01b81526001600160a01b0386811660048301526024820186905291519190921691829163a9059cbb9160448082019260009290919082900301818387803b158015613b0e57600080fd5b505af1158015613b22573d6000803e3d6000fd5b5050505060003d60008114613b3e5760208114613b4857600080fd5b6000199150613b54565b60206000803e60005191505b5080613b99576040805162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b50505b505050565b60008115613cbc57336001600160a01b03851614613bf8576040805162461bcd60e51b815260206004820152600f60248201526e0e6cadcc8cae440dad2e6dac2e8c6d608b1b604482015290519081900360640190fd5b823414613c3d576040805162461bcd60e51b815260206004820152600e60248201526d0ecc2d8eaca40dad2e6dac2e8c6d60931b604482015290519081900360640190fd5b601160009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b158015613c8d57600080fd5b505af1158015613ca1573d6000803e3d6000fd5b5050505050613cb2601354846131a7565b6013555081612de5565b601154604080516370a0823160e01b815230600482015290516001600160a01b039092169160009183916370a0823191602480820192602092909190829003018186803b158015613d0c57600080fd5b505afa158015613d20573d6000803e3d6000fd5b505050506040513d6020811015613d3657600080fd5b5051604080516323b872dd60e01b81526001600160a01b038981166004830152306024830152604482018990529151929350908416916323b872dd9160648082019260009290919082900301818387803b158015613d9357600080fd5b505af1158015613da7573d6000803e3d6000fd5b5050505060003d60008114613dc35760208114613dcd57600080fd5b6000199150613dd9565b60206000803e60005191505b5080613e1e576040805162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b601154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015613e6957600080fd5b505afa158015613e7d573d6000803e3d6000fd5b505050506040513d6020811015613e9357600080fd5b505190506000613ea382856131dd565b9050613eb1601354826131a7565b6013559450612de59350505050565b600354600090819061010090046001600160a01b03163314613ef057613ee86001601e613888565b915050611876565b613ef86140e3565b60095414613f0c57613ee8600a6020613888565b82613f156131a1565b1015613f2757613ee8600e601f613888565b600c54831115613f3d57613ee860026021613888565b613f49600c54846131dd565b600c819055600354909150613f6e9061010090046001600160a01b0316846000613a00565b600354604080516101009092046001600160a01b0316825260208201859052818101839052517f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e916060908290030190a16000611872565b6000805460ff1661400b576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905561401d6126ee565b50613953336000858561542e565b6000805460ff16614070576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556140826126ee565b50613953338484615859565b6001600160a01b038116600090815260106020526040812080546140b6576000915050611876565b60006140c88260000154600a546157e4565b905060006140da828460010154615826565b95945050505050565b4290565b600354600090819061010090046001600160a01b0316331461410f57613ee86001602c613888565b6141176140e3565b6009541461412b57613ee8600a602b613888565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561417c57600080fd5b505afa158015614190573d6000803e3d6000fd5b505050506040513d60208110156141a657600080fd5b50516141e7576040805162461bcd60e51b815260206004820152600b60248201526a696e76616c69642049524d60a81b604482015290519081900360640190fd5b600680546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f9269281900390910190a16000611872565b614252615c10565b604051806020016040528061426b8560000151856157e4565b90529392505050565b600061427e615c10565b614288858561424a565b90506140da61429682615381565b846131a7565b6005546040805163d02f735160e01b81523060048201526001600160a01b03878116602483015286811660448301528581166064830152608482018590529151600093929092169163d02f73519160a48082019260209290919082900301818787803b15801561430b57600080fd5b505af115801561431f573d6000803e3d6000fd5b505050506040513d602081101561433557600080fd5b505115614374576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b816143815750600061362e565b836001600160a01b0316836001600160a01b031614156143df576040805162461bcd60e51b815260206004820152601460248201527334b73b30b634b21030b1b1b7bab73a103830b4b960611b604482015290519081900360640190fd5b6001600160a01b0383166000908152600e602052604090205461440290836131dd565b6001600160a01b038085166000908152600e6020526040808220939093559086168152205461443190836131a7565b6001600160a01b038086166000818152600e60209081526040918290209490945580518681529051919392871692600080516020615dfc83398151915292918290030190a360055460408051636d35bf9160e01b81523060048201526001600160a01b038881166024830152878116604483015286811660648301526084820186905291519190921691636d35bf919160a480830192600092919082900301818387803b1580156144e157600080fd5b505af11580156144f5573d6000803e3d6000fd5b50600092506140da915050565b60035460009061010090046001600160a01b031633146145285761190060016031613888565b6145306140e3565b6009541461454457611900600a6032613888565b670de0b6b3a76400008211156145605761190060026033613888565b6008805490839055604080518281526020810185905281517faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f821460929181900390910190a16000611872565b6000838301828582101561463c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156146015781810151838201526020016145e9565b50505050905090810190601f16801561462e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50949350505050565b600081848411156146975760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156146015781810151838201526020016145e9565b505050900390565b60055460408051631200453160e11b81523060048201526001600160a01b0387811660248301528681166044830152606482018690529151600093849316916324008a6291608480830192602092919082900301818787803b15801561470457600080fd5b505af1158015614718573d6000803e3d6000fd5b505050506040513d602081101561472e57600080fd5b50511561476d576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b6147756140e3565b600954146147bc576040805162461bcd60e51b815260206004820152600f60248201526e6d61726b6574206973207374616c6560881b604482015290519081900360640190fd5b6147c4615c9d565b6001600160a01b03861660009081526010602052604090206001015460608201526147ee8661408e565b608082015260001985141561480c5760808101516040820152614814565b604081018590525b61482387826040015186613ba1565b60e082018190526080820151614838916131dd565b60a0820152600b5460e082015161484f91906131dd565b60c0820190815260a080830180516001600160a01b03808b16600081815260106020908152604091829020948555600a546001909501949094559551600b81905560e088015194518751938f16845293830191909152818601939093526060810191909152608081019190915291517f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a19281900390910190a160055460e0820151606083015160408051631ededc9160e01b81523060048201526001600160a01b038c811660248301528b8116604483015260648201949094526084810192909252519190921691631ededc919160a480830192600092919082900301818387803b15801561495d57600080fd5b505af1158015614971573d6000803e3d6000fd5b506000925061497e915050565b8160e00151925092505094509492505050565b6000612de56149a884670de0b6b3a76400006157e4565b8351615826565b60055460408051634ef4c3e160e01b81523060048201526001600160a01b03868116602483015260448201869052915160009384931691634ef4c3e191606480830192602092919082900301818787803b158015614a0c57600080fd5b505af1158015614a20573d6000803e3d6000fd5b505050506040513d6020811015614a3657600080fd5b505115614a75576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b83614a8557506000905080614c89565b614a8d6140e3565b60095414614ad4576040805162461bcd60e51b815260206004820152600f60248201526e6d61726b6574206973207374616c6560881b604482015290519081900360640190fd5b614adc615ce3565b614ae4613297565b8152614af1868686613ba1565b604080830182905280516020810190915282518152614b109190615ae7565b60208201819052600d54614b23916131a7565b600d556001600160a01b0386166000908152600e602090815260409091205490820151614b5091906131a7565b6001600160a01b0387166000818152600e60209081526040918290209390935583810151848401518251938452938301528181019290925290517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f9181900360600190a1856001600160a01b0316306001600160a01b0316600080516020615dfc83398151915283602001516040518082815260200191505060405180910390a3600554604080830151602084015182516341c728b960e01b81523060048201526001600160a01b038b811660248301526044820193909352606481019190915291519216916341c728b99160848082019260009290919082900301818387803b158015614c5d57600080fd5b505af1158015614c71573d6000803e3d6000fd5b5060009250614c7e915050565b816040015192509250505b935093915050565b60055460408051632fe3f38f60e11b81523060048201526001600160a01b0385811660248301528881166044830152878116606483015260848201879052915160009384931691635fc7e71e9160a480830192602092919082900301818787803b158015614cfe57600080fd5b505af1158015614d12573d6000803e3d6000fd5b505050506040513d6020811015614d2857600080fd5b505115614d67576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b614d6f6140e3565b60095414614db6576040805162461bcd60e51b815260206004820152600f60248201526e6d61726b6574206973207374616c6560881b604482015290519081900360640190fd5b614dbe6140e3565b846001600160a01b0316636c540baf6040518163ffffffff1660e01b815260040160206040518083038186803b158015614df757600080fd5b505afa158015614e0b573d6000803e3d6000fd5b505050506040513d6020811015614e2157600080fd5b505114614e67576040805162461bcd60e51b815260206004820152600f60248201526e6d61726b6574206973207374616c6560881b604482015290519081900360640190fd5b866001600160a01b0316866001600160a01b03161415614ec5576040805162461bcd60e51b815260206004820152601460248201527334b73b30b634b21030b1b1b7bab73a103830b4b960611b604482015290519081900360640190fd5b600085118015614ed757506000198514155b614f19576040805162461bcd60e51b815260206004820152600e60248201526d1a5b9d985b1a5908185b5bdd5b9d60921b604482015290519081900360640190fd5b614f21615d04565b614f2d8888888761469f565b602083015280825215614f7d576040805162461bcd60e51b81526020600482015260136024820152721c995c185e48189bdc9c9bddc819985a5b1959606a1b604482015290519081900360640190fd5b60055460208201516040805163c488847b60e01b81523060048201526001600160a01b03898116602483015260448201939093528151929093169263c488847b9260648083019392829003018186803b158015614fd957600080fd5b505afa158015614fed573d6000803e3d6000fd5b505050506040513d604081101561500357600080fd5b5080516020909101516060830152604082018190521561506a576040805162461bcd60e51b815260206004820152601d60248201527f63616c63756c617465207365697a6520616d6f756e74206661696c6564000000604482015290519081900360640190fd5b8060600151856001600160a01b03166370a08231896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156150c557600080fd5b505afa1580156150d9573d6000803e3d6000fd5b505050506040513d60208110156150ef57600080fd5b50511015615135576040805162461bcd60e51b815260206004820152600e60248201526d0e6cad2f4ca40e8dede40daeac6d60931b604482015290519081900360640190fd5b60006001600160a01b03861630141561515f57615158308a8a856060015161429c565b90506151ef565b60608201516040805163b2a02ff160e01b81526001600160a01b038c811660048301528b81166024830152604482019390935290519188169163b2a02ff1916064808201926020929091908290030181600087803b1580156151c057600080fd5b505af11580156151d4573d6000803e3d6000fd5b505050506040513d60208110156151ea57600080fd5b505190505b8015615239576040805162461bcd60e51b81526020600482015260146024820152731d1bdad95b881cd95a5e9d5c994819985a5b195960621b604482015290519081900360640190fd5b7f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb528989846020015189866060015160405180866001600160a01b03166001600160a01b03168152602001856001600160a01b03166001600160a01b03168152602001848152602001836001600160a01b03166001600160a01b031681526020018281526020019550505050505060405180910390a160055460208301516060840151604080516347ef3b3b60e01b81523060048201526001600160a01b038b811660248301528e811660448301528d81166064830152608482019490945260a48101929092525191909216916347ef3b3b9160c480830192600092919082900301818387803b15801561534b57600080fd5b505af115801561535f573d6000803e3d6000fd5b506000925061536c915050565b82602001519350935050509550959350505050565b51670de0b6b3a7640000900490565b60008060008061539e6140e3565b600954146153bd576153b2600a6037613888565b935091506154279050565b6153c8338787613ba1565b90506153d6600c54826131a7565b600c819055604080513381526020810184905280820183905290519193507fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc5919081900360600190a1600093509150505b9250929050565b600083158061543b575082155b615478576040805162461bcd60e51b8152602060048201526009602482015268189859081a5b9c1d5d60ba1b604482015290519081900360640190fd5b615480615d2c565b615488613297565b815284156154b9576020808201869052604080519182019052815181526154af90866137ee565b60408201526154e2565b6154d58460405180602001604052808460000151815250615ae7565b6020820152604081018490525b6005546020808301516040805163eabe7d9160e01b81523060048201526001600160a01b038b8116602483015260448201939093529051919093169263eabe7d919260648083019391928290030181600087803b15801561554257600080fd5b505af1158015615556573d6000803e3d6000fd5b505050506040513d602081101561556c57600080fd5b5051156155ab576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b841580156155b7575083155b156155c657600091505061362e565b6155ce6140e3565b60095414615615576040805162461bcd60e51b815260206004820152600f60248201526e6d61726b6574206973207374616c6560881b604482015290519081900360640190fd5b615625600d5482602001516131dd565b60608201526001600160a01b0386166000908152600e60209081526040909120549082015161565491906131dd565b608082015260408101516156666131a1565b10156156ad576040805162461bcd60e51b81526020600482015260116024820152700d2dce6eaccccd2c6d2cadce840c6c2e6d607b1b604482015290519081900360640190fd5b6060810151600d5560808101516001600160a01b0387166000908152600e602052604090819020919091558101516156e790879085613a00565b306001600160a01b0316866001600160a01b0316600080516020615dfc83398151915283602001516040518082815260200191505060405180910390a360408082015160208084015183516001600160a01b038b168152918201929092528083019190915290517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a9299181900360600190a1600554604080830151602084015182516351dff98960e01b81523060048201526001600160a01b038b811660248301526044820193909352606481019190915291519216916351dff9899160848082019260009290919082900301818387803b15801561360957600080fd5b6000612de583836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250615afb565b6000612de583836040518060400160405280600e81526020016d646976696465206279207a65726f60901b815250615b71565b6005546040805163368f515360e21b81523060048201526001600160a01b038681166024830152604482018690529151600093929092169163da3d454c9160648082019260209290919082900301818787803b1580156158b857600080fd5b505af11580156158cc573d6000803e3d6000fd5b505050506040513d60208110156158e257600080fd5b505115615921576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b6159296140e3565b60095414615970576040805162461bcd60e51b815260206004820152600f60248201526e6d61726b6574206973207374616c6560881b604482015290519081900360640190fd5b826159796131a1565b10156159c0576040805162461bcd60e51b81526020600482015260116024820152700d2dce6eaccccd2c6d2cadce840c6c2e6d607b1b604482015290519081900360640190fd5b6159c8615d5b565b6159d18561408e565b602082018190526159e290856131a7565b6040820152600b546159f490856131a7565b606082019081526040808301516001600160a01b0388166000908152601060205291909120908155600a5460019091015551600b55615a34858585613a00565b60408082015160608084015183516001600160a01b038a16815260208101899052808501939093529082015290517f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809181900360800190a160055460408051635c77860560e01b81523060048201526001600160a01b0388811660248301526044820188905291519190921691635c77860591606480830192600092919082900301818387803b1580156144e157600080fd5b6000615af1615c10565b6138028484615bd3565b6000831580615b08575082155b15615b1557506000612de5565b83830283858281615b2257fe5b0414839061463c5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156146015781810151838201526020016145e9565b60008183615bc05760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156146015781810151838201526020016145e9565b50828481615bca57fe5b04949350505050565b615bdb615c10565b6000615bef670de0b6b3a7640000856157e4565b90506040518060200160405280615c068386614991565b9052949350505050565b6040518060200160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10615c6457805160ff1916838001178555615c91565b82800160010185558215615c91579182015b82811115615c91578251825591602001919060010190615c76565b506116d0929150615d84565b6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180606001604052806000815260200160008152602001600081525090565b6040518060800160405280600081526020016000815260200160008152602001600081525090565b6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b604080516080810190915280600081526020016000815260200160008152602001600081525090565b6115cf91905b808211156116d05760008155600101615d8a56fe6f6e6c792077726170706564206e617469766520636f6e747261637420636f756c642073656e64206e617469766520746f6b656e45524333313536466c617368426f72726f776572496e746572666163652e6f6e466c6173684c6f616eddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa265627a7a723158204593c282a4845fd52871313025786a2034cfd4d5dfbb8cfb3ad8d290f0788f6b64736f6c63430005110032
Deployed Bytecode
0x6080604052600436106103fa5760003560e01c806373acee9811610213578063c37f68e211610123578063e9c714f2116100ab578063f5e3c4621161007a578063f5e3c4621461115d578063f851a440146111a0578063f8f9da28146111b5578063fca7820b146111ca578063fe9c44ae146111f4576103fa565b8063e9c714f2146110eb578063ea11eea414611100578063f2b3abbd14611115578063f3fdb15a14611148576103fa565b8063d9d98ce4116100f2578063d9d98ce414610ffd578063db006a7514611036578063dbf7692914611060578063dd62ed3e14611086578063dff76484146110c1576103fa565b8063c37f68e214610f5d578063c5ebeaec14610fb6578063d2bb18e914610fe0578063d3c5715114610ff5576103fa565b806399d8c1b4116101a6578063aa5af0fd11610175578063aa5af0fd14610ea8578063ae9d70b014610ebd578063b2a02ff114610ed2578063b71d1a0c14610f15578063bd6d894d14610f48576103fa565b806399d8c1b414610cd5578063a0712d6814610e30578063a6afed9514610e5a578063a9059cbb14610e6f576103fa565b80638f840ddd116101e25780638f840ddd14610c6357806394909e6214610c7857806395d89b4114610c8d57806395dd919314610ca2576103fa565b806373acee9814610bf2578063852a12e314610c07578063884b934314610c315780638d3f9c6214610c5b576103fa565b8063291727a41161030e57806356e67728116102a1578063601a0bf111610270578063601a0bf114610b38578063613255ab14610b625780636c540baf14610b955780636f307dc314610baa57806370a0823114610bbf576103fa565b806356e67728146109c25780635c60da1b14610a735780635cffe9de14610a885780635fe3b56714610b23576103fa565b80633e941010116102dd5780633e941010146109265780634576b5db1461095057806347bd3718146109835780634bf03edf14610998576103fa565b8063291727a414610885578063313ce567146108b35780633af9e669146108de5780633b1d21a214610911576103fa565b806318160ddd11610391578063219f2fe711610360578063219f2fe7146107bb57806322abdbf5146107c357806323b872dd146107d85780632608f8181461081b5780632678224714610854576103fa565b806318160ddd14610619578063182df0f51461062e57806319a4dd3c146106435780631a31d46514610658576103fa565b80630f226888116103cd5780630f2268881461058a578063153ab505146105bc578063173b9904146105d157806317bfdfbc146105e6576103fa565b806305dd00b81461044557806306fdde0314610489578063095ea7b3146105135780630e75270214610560575b6011546001600160a01b031633146104435760405162461bcd60e51b8152600401808060200182810382526034815260200180615d9f6034913960400191505060405180910390fd5b005b34801561045157600080fd5b506104776004803603604081101561046857600080fd5b50803590602001351515611209565b60408051918252519081900360200190f35b34801561049557600080fd5b5061049e6112ee565b6040805160208082528351818301528351919283929083019185019080838360005b838110156104d85781810151838201526020016104c0565b50505050905090810190601f1680156105055780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561051f57600080fd5b5061054c6004803603604081101561053657600080fd5b506001600160a01b03813516906020013561137b565b604080519115158252519081900360200190f35b34801561056c57600080fd5b506104776004803603602081101561058357600080fd5b50356113e6565b34801561059657600080fd5b50610477600480360360408110156105ad57600080fd5b5080359060200135151561143f565b3480156105c857600080fd5b506104436114ee565b3480156105dd57600080fd5b50610477611541565b3480156105f257600080fd5b506104776004803603602081101561060957600080fd5b50356001600160a01b0316611547565b34801561062557600080fd5b506104776115bc565b34801561063a57600080fd5b506104776115c2565b34801561064f57600080fd5b506104776115d2565b34801561066457600080fd5b50610443600480360360e081101561067b57600080fd5b6001600160a01b03823581169260208101358216926040820135909216916060820135919081019060a081016080820135600160201b8111156106bd57600080fd5b8201836020820111156106cf57600080fd5b803590602001918460018302840111600160201b831117156106f057600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561074257600080fd5b82018360208201111561075457600080fd5b803590602001918460018302840111600160201b8311171561077557600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050903560ff1691506115d89050565b610477611677565b3480156107cf57600080fd5b506104776116d4565b3480156107e457600080fd5b5061054c600480360360608110156107fb57600080fd5b506001600160a01b038135811691602081013590911690604001356116da565b34801561082757600080fd5b506104776004803603604081101561083e57600080fd5b506001600160a01b03813516906020013561174c565b34801561086057600080fd5b506108696117ae565b604080516001600160a01b039092168252519081900360200190f35b6104776004803603604081101561089b57600080fd5b506001600160a01b03813581169160200135166117bd565b3480156108bf57600080fd5b506108c8611823565b6040805160ff9092168252519081900360200190f35b3480156108ea57600080fd5b506104776004803603602081101561090157600080fd5b50356001600160a01b031661182c565b34801561091d57600080fd5b5061047761187b565b34801561093257600080fd5b506104776004803603602081101561094957600080fd5b5035611885565b34801561095c57600080fd5b506104776004803603602081101561097357600080fd5b50356001600160a01b03166118da565b34801561098f57600080fd5b50610477611a1e565b3480156109a457600080fd5b50610477600480360360208110156109bb57600080fd5b5035611a24565b3480156109ce57600080fd5b50610443600480360360208110156109e557600080fd5b810190602081018135600160201b8111156109ff57600080fd5b820183602082011115610a1157600080fd5b803590602001918460018302840111600160201b83111715610a3257600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611a7a945050505050565b348015610a7f57600080fd5b50610869611bb8565b348015610a9457600080fd5b5061054c60048036036080811015610aab57600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b811115610ae557600080fd5b820183602082011115610af757600080fd5b803590602001918460018302840111600160201b83111715610b1857600080fd5b509092509050611bc7565b348015610b2f57600080fd5b506108696120c0565b348015610b4457600080fd5b5061047760048036036020811015610b5b57600080fd5b50356120cf565b348015610b6e57600080fd5b5061047760048036036020811015610b8557600080fd5b50356001600160a01b0316612130565b348015610ba157600080fd5b506104776121f7565b348015610bb657600080fd5b506108696121fd565b348015610bcb57600080fd5b5061047760048036036020811015610be257600080fd5b50356001600160a01b031661220c565b348015610bfe57600080fd5b50610477612227565b348015610c1357600080fd5b5061047760048036036020811015610c2a57600080fd5b5035612293565b348015610c3d57600080fd5b5061047760048036036020811015610c5457600080fd5b50356122f2565b610477612348565b348015610c6f57600080fd5b506104776123a2565b348015610c8457600080fd5b506104436123a8565b348015610c9957600080fd5b5061049e61243d565b348015610cae57600080fd5b5061047760048036036020811015610cc557600080fd5b50356001600160a01b0316612495565b348015610ce157600080fd5b50610443600480360360c0811015610cf857600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b811115610d3257600080fd5b820183602082011115610d4457600080fd5b803590602001918460018302840111600160201b83111715610d6557600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b811115610db757600080fd5b820183602082011115610dc957600080fd5b803590602001918460018302840111600160201b83111715610dea57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050903560ff1691506124a09050565b348015610e3c57600080fd5b5061047760048036036020811015610e5357600080fd5b503561269c565b348015610e6657600080fd5b506104776126ee565b348015610e7b57600080fd5b5061054c60048036036040811015610e9257600080fd5b506001600160a01b0381351690602001356128f5565b348015610eb457600080fd5b50610477612966565b348015610ec957600080fd5b5061047761296c565b348015610ede57600080fd5b5061047760048036036060811015610ef557600080fd5b506001600160a01b03813581169160208101359091169060400135612a0b565b348015610f2157600080fd5b5061047760048036036020811015610f3857600080fd5b50356001600160a01b0316612a7c565b348015610f5457600080fd5b50610477612b08565b348015610f6957600080fd5b50610f9060048036036020811015610f8057600080fd5b50356001600160a01b0316612b7a565b604080519485526020850193909352838301919091526060830152519081900360800190f35b348015610fc257600080fd5b5061047760048036036020811015610fd957600080fd5b5035612bb6565b348015610fec57600080fd5b50610477612c05565b610477612c50565b34801561100957600080fd5b506104776004803603604081101561102057600080fd5b506001600160a01b038135169060200135612ca5565b34801561104257600080fd5b506104776004803603602081101561105957600080fd5b5035612dec565b6104776004803603602081101561107657600080fd5b50356001600160a01b0316612e3b565b34801561109257600080fd5b50610477600480360360408110156110a957600080fd5b506001600160a01b0381358116916020013516612ea0565b3480156110cd57600080fd5b50610477600480360360208110156110e457600080fd5b5035612ecb565b3480156110f757600080fd5b50610477612f2a565b34801561110c57600080fd5b5061047761302d565b34801561112157600080fd5b506104776004803603602081101561113857600080fd5b50356001600160a01b0316613032565b34801561115457600080fd5b50610869613046565b34801561116957600080fd5b506104776004803603606081101561118057600080fd5b506001600160a01b03813581169160208101359160409091013516613055565b3480156111ac57600080fd5b506108696130c3565b3480156111c157600080fd5b506104776130d7565b3480156111d657600080fd5b50610477600480360360208110156111ed57600080fd5b503561313b565b34801561120057600080fd5b5061054c61319c565b6000806000831561123a5761122561121f6131a1565b866131a7565b9150611233600b54866131dd565b905061125c565b61124b6112456131a1565b866131dd565b9150611259600b54866131a7565b90505b600654600c54604080516315f2405360e01b815260048101869052602481018590526044810192909252516001600160a01b03909216916315f2405391606480820192602092909190829003018186803b1580156112b957600080fd5b505afa1580156112cd573d6000803e3d6000fd5b505050506040513d60208110156112e357600080fd5b505195945050505050565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156113735780601f1061134857610100808354040283529160200191611373565b820191906000526020600020905b81548152906001019060200180831161135657829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855290835281842086905581518681529151939493909284927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a35060019392505050565b6000806113f4836000613217565b5090508015611439576040805162461bcd60e51b815260206004820152600c60248201526b1c995c185e4819985a5b195960a21b604482015290519081900360640190fd5b50919050565b6000806000831561146a5761145561121f6131a1565b9150611463600b54866131dd565b9050611486565b6114756112456131a1565b9150611483600b54866131a7565b90505b600654600c5460085460408051635c0b440b60e11b8152600481018790526024810186905260448101939093526064830191909152516001600160a01b039092169163b816881691608480820192602092909190829003018186803b1580156112b957600080fd5b60035461010090046001600160a01b0316331461153f576040805162461bcd60e51b815260206004820152600a60248201526961646d696e206f6e6c7960b01b604482015290519081900360640190fd5b565b60085481565b6000805460ff1661158c576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905561159e6126ee565b506115a882612495565b90506000805460ff19166001179055919050565b600d5481565b60006115cc613297565b90505b90565b600d5490565b6115e68686868686866124a0565b601180546001600160a01b0319166001600160a01b038981169190911791829055604080516318160ddd60e01b8152905192909116916318160ddd91600480820192602092909190829003018186803b15801561164257600080fd5b505afa158015611656573d6000803e3d6000fd5b505050506040513d602081101561166c57600080fd5b505050505050505050565b6000806116853460016132f9565b50905080156116d0576040805162461bcd60e51b81526020600482015260126024820152711b5a5b9d081b985d1a5d994819985a5b195960721b604482015290519081900360640190fd5b5090565b60135481565b6000805460ff1661171f576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556117353386868661335e565b1490506000805460ff191660011790559392505050565b60008061175b84846000613636565b50905080156117a7576040805162461bcd60e51b81526020600482015260136024820152721c995c185e4818995a185b198819985a5b1959606a1b604482015290519081900360640190fd5b5092915050565b6004546001600160a01b031681565b6000806117cd84348560016136b7565b50905080156117a7576040805162461bcd60e51b815260206004820152601e60248201527f6c697175696461746520626f72726f77206e6174697665206661696c65640000604482015290519081900360640190fd5b60035460ff1681565b6000611836615c10565b6040518060200160405280611849612b08565b90526001600160a01b0384166000908152600e60205260409020549091506118729082906137ee565b9150505b919050565b60006115cc6131a1565b600061189282600061380d565b15611876576040805162461bcd60e51b8152602060048201526013602482015272185919081c995cd95c9d995cc819985a5b1959606a1b604482015290519081900360640190fd5b60035460009061010090046001600160a01b031633146119075761190060016029613888565b9050611876565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b15801561194c57600080fd5b505afa158015611960573d6000803e3d6000fd5b505050506040513d602081101561197657600080fd5b50516119bb576040805162461bcd60e51b815260206004820152600f60248201526e3737ba1031b7b6b83a3937b63632b960891b604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d9281900390910190a16000611872565b600b5481565b6000611a318260016138ee565b15611876576040805162461bcd60e51b81526020600482015260146024820152731c995919595b481b985d1a5d994819985a5b195960621b604482015290519081900360640190fd5b60035461010090046001600160a01b03163314611acb576040805162461bcd60e51b815260206004820152600a60248201526961646d696e206f6e6c7960b01b604482015290519081900360640190fd5b600554604080516344e3de7360e01b81523060048201526002602482015290516001600160a01b03909216916344e3de739160448082019260009290919082900301818387803b158015611b1e57600080fd5b505af1158015611b32573d6000803e3d6000fd5b504792505081159050611ba957601160009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015611b8f57600080fd5b505af1158015611ba3573d6000803e3d6000fd5b50505050505b611bb1613968565b6013555050565b6012546001600160a01b031681565b6000805460ff16611c0c576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905583611c68576040805162461bcd60e51b815260206004820152601860248201527f696e76616c696420666c6173686c6f616e20616d6f756e740000000000000000604482015290519081900360640190fd5b6011546001600160a01b03868116911614611cc1576040805162461bcd60e51b8152602060048201526014602482015273756e737570706f727465642063757272656e637960601b604482015290519081900360640190fd5b611cc96126ee565b506005546040516358d5bc7360e11b815230600482018181526001600160a01b038a81166024850152604484018990526080606485019081526084850188905294169363b1ab78e6938b928a928a928a92919060a401848480828437600081840152601f19601f820116905080830192505050965050505050505060206040518083038186803b158015611d5c57600080fd5b505afa158015611d70573d6000803e3d6000fd5b505050506040513d6020811015611d8657600080fd5b5051611dcf576040805162461bcd60e51b8152602060048201526013602482015272199b185cda1b1bd85b881a5cc81c185d5cd959606a1b604482015290519081900360640190fd5b6000611dd9613968565b90506000611de56131a1565b905085811015611e30576040805162461bcd60e51b81526020600482015260116024820152700d2dce6eaccccd2c6d2cadce840c6c2e6d607b1b604482015290519081900360640190fd5b6000611e3c88886139e8565b9050611e4a89886000613a00565b611e56600b54886131a7565b600b55604051806029615dd382396040519081900360290181206011546323e30c8b60e01b835233600484018181526001600160a01b0392831660248601819052604486018e90526064860188905260a06084870190815260a487018d9052949650928f16946323e30c8b949293928e9289928f928f929160c401848480828437600081840152601f19601f820116905080830192505050975050505050505050602060405180830381600087803b158015611f1157600080fd5b505af1158015611f25573d6000803e3d6000fd5b505050506040513d6020811015611f3b57600080fd5b505114611f8f576040805162461bcd60e51b815260206004820152601960248201527f49455243333135363a2043616c6c6261636b206661696c656400000000000000604482015290519081900360640190fd5b6000611f9b88836131a7565b9050611fa98a826000613ba1565b506000611fb4613968565b9050611fc085846131a7565b811461200a576040805162461bcd60e51b8152602060048201526014602482015273696e636f6e73697374656e742062616c616e636560601b604482015290519081900360640190fd5b60006120266040518060200160405280600854815250856137ee565b9050612034600c54826131a7565b600c5561204185856131a7565b601355600b54612051908b6131dd565b600b55604080518b81526020810186905280820183905290516001600160a01b038e16917f33c8e097c526683cbdb29adf782fac95e9d0fbe0ed635c13d8c75fdf726557d9919081900360600190a2600196505050505050506000805460ff1916600117905595945050505050565b6005546001600160a01b031681565b6000805460ff16612114576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556121266126ee565b506115a882613ec0565b60115460009081906001600160a01b0384811691161480156121e15750600554604080516358d5bc7360e11b81523060048201526000602482018190526044820185905260806064830152608482015290516001600160a01b039092169163b1ab78e69160c480820192602092909190829003018186803b1580156121b457600080fd5b505afa1580156121c8573d6000803e3d6000fd5b505050506040513d60208110156121de57600080fd5b50515b156121f1576121ee6131a1565b90505b92915050565b60095481565b6011546001600160a01b031681565b6001600160a01b03166000908152600e602052604090205490565b6000805460ff1661226c576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905561227e6126ee565b5050600b546000805460ff1916600117905590565b60006122a0826000613fc6565b15611876576040805162461bcd60e51b815260206004820152601860248201527f72656465656d20756e6465726c79696e67206661696c65640000000000000000604482015290519081900360640190fd5b60006122ff82600161402b565b15611876576040805162461bcd60e51b8152602060048201526014602482015273189bdc9c9bddc81b985d1a5d994819985a5b195960621b604482015290519081900360640190fd5b600080612356346001613217565b50905080156116d0576040805162461bcd60e51b81526020600482015260136024820152721c995c185e481b985d1a5d994819985a5b1959606a1b604482015290519081900360640190fd5b600c5481565b60005460ff166123ec576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556123fe613968565b9050600061240a6131a1565b9050600061241883836131dd565b9050612426600c54826131a7565b600c5550506013556000805460ff19166001179055565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156113735780601f1061134857610100808354040283529160200191611373565b60006121f18261408e565b60035461010090046001600160a01b031633146124f1576040805162461bcd60e51b815260206004820152600a60248201526961646d696e206f6e6c7960b01b604482015290519081900360640190fd5b6009541580156125015750600a54155b612540576040805162461bcd60e51b815260206004820152600b60248201526a1a5b9a5d1a585b1a5e995960aa1b604482015290519081900360640190fd5b60078490558361258f576040805162461bcd60e51b8152602060048201526015602482015274696e76616c69642065786368616e6765207261746560581b604482015290519081900360640190fd5b600061259a876118da565b905080156125e8576040805162461bcd60e51b81526020600482015260166024820152751cd95d0818dbdb5c1d1c9bdb1b195c8819985a5b195960521b604482015290519081900360640190fd5b6125f06140e3565b600955670de0b6b3a7640000600a55612608866140e7565b9050801561264e576040805162461bcd60e51b815260206004820152600e60248201526d1cd95d081254934819985a5b195960921b604482015290519081900360640190fd5b8351612661906001906020870190615c23565b508251612675906002906020860190615c23565b50506003805460ff90921660ff199283161790556000805490911660011790555050505050565b6000806126aa8360006132f9565b5090508015611439576040805162461bcd60e51b815260206004820152600b60248201526a1b5a5b9d0819985a5b195960aa1b604482015290519081900360640190fd5b6000806126f96140e3565b60095490915080821415612712576000925050506115cf565b600061271c6131a1565b600b54600c54600a54600654604080516315f2405360e01b815260048101879052602481018690526044810185905290519596509394929391926000926001600160a01b03909216916315f24053916064808301926020929190829003018186803b15801561278a57600080fd5b505afa15801561279e573d6000803e3d6000fd5b505050506040513d60208110156127b457600080fd5b5051905065048c2739500081111561280a576040805162461bcd60e51b81526020600482015260146024820152730c4dee4e4deee40e4c2e8ca40e8dede40d0d2ced60631b604482015290519081900360640190fd5b600061281688886131dd565b9050612820615c10565b6128386040518060200160405280858152508361424a565b9050600061284682886137ee565b9050600061285482896131a7565b905060006128736040518060200160405280600854815250848a614274565b9050600061288285898a614274565b60098e9055600a819055600b849055600c839055604080518d8152602081018790528082018390526060810186905290519192507f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc04919081900360800190a160009d505050505050505050505050505090565b6000805460ff1661293a576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556129503333868661335e565b1490506000805460ff1916600117905592915050565b600a5481565b6006546000906001600160a01b031663b81688166129886131a1565b600b54600c546008546040518563ffffffff1660e01b81526004018085815260200184815260200183815260200182815260200194505050505060206040518083038186803b1580156129da57600080fd5b505afa1580156129ee573d6000803e3d6000fd5b505050506040513d6020811015612a0457600080fd5b5051905090565b6000805460ff16612a50576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19169055612a663385858561429c565b90506000805460ff191660011790559392505050565b60035460009061010090046001600160a01b03163314612aa2576119006001602f613888565b600480546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a16000611872565b6000805460ff16612b4d576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19169055612b5f6126ee565b50612b686115c2565b90506000805460ff1916600117905590565b6000806000806000612b8b8661220c565b90506000612b988761408e565b90506000612ba4613297565b90506000989297509095509350915050565b6000612bc382600061402b565b15611876576040805162461bcd60e51b815260206004820152600d60248201526c189bdc9c9bddc819985a5b1959609a1b604482015290519081900360640190fd5b600554604080516302c3bcbb60e01b815230600482015290516000926001600160a01b0316916302c3bcbb916024808301926020929190829003018186803b1580156129da57600080fd5b6000612c5d34600161380d565b156115cf576040805162461bcd60e51b8152602060048201526013602482015272185919081c995cd95c9d995cc819985a5b1959606a1b604482015290519081900360640190fd5b6011546000906001600160a01b03848116911614612d01576040805162461bcd60e51b8152602060048201526014602482015273756e737570706f727465642063757272656e637960601b604482015290519081900360640190fd5b600554604080516358d5bc7360e11b81523060048201526000602482018190526044820186905260806064830152608482015290516001600160a01b039092169163b1ab78e69160c480820192602092909190829003018186803b158015612d6857600080fd5b505afa158015612d7c573d6000803e3d6000fd5b505050506040513d6020811015612d9257600080fd5b5051612ddb576040805162461bcd60e51b8152602060048201526013602482015272199b185cda1b1bd85b881a5cc81c185d5cd959606a1b604482015290519081900360640190fd5b612de583836139e8565b9392505050565b6000612df98260006138ee565b15611876576040805162461bcd60e51b815260206004820152600d60248201526c1c995919595b4819985a5b1959609a1b604482015290519081900360640190fd5b600080612e4a83346001613636565b5090508015611439576040805162461bcd60e51b815260206004820152601a60248201527f726570617920626568616c66206e6174697665206661696c6564000000000000604482015290519081900360640190fd5b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6000612ed8826001613fc6565b15611876576040805162461bcd60e51b815260206004820152601f60248201527f72656465656d20756e6465726c79696e67206e6174697665206661696c656400604482015290519081900360640190fd5b6004546000906001600160a01b031633141580612f45575033155b15612f5d57612f5660016000613888565b90506115cf565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b031990931690935560408051948390048216808652929095041660208401528351909391927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600454604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a160009250505090565b600981565b600061303c6126ee565b506121f1826140e7565b6006546001600160a01b031681565b60008061306585858560006136b7565b50905080156130bb576040805162461bcd60e51b815260206004820152601760248201527f6c697175696461746520626f72726f77206661696c6564000000000000000000604482015290519081900360640190fd5b509392505050565b60035461010090046001600160a01b031681565b6006546000906001600160a01b03166315f240536130f36131a1565b600b54600c546040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b1580156129da57600080fd5b6000805460ff16613180576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556131926126ee565b506115a882614502565b600181565b60135490565b6000612de58383604051806040016040528060118152602001706164646974696f6e206f766572666c6f7760781b8152506145aa565b6000612de58383604051806040016040528060158152602001747375627472616374696f6e20756e646572666c6f7760581b815250614645565b60008054819060ff1661325e576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556132706126ee565b5061327d3333868661469f565b915091506000805460ff1916600117905590939092509050565b600d54600090806132ac5750506007546115cf565b60006132b66131a1565b905060006132d16132c983600b546131a7565b600c546131dd565b905060006132ed82604051806020016040528087815250614991565b94506115cf9350505050565b60008054819060ff16613340576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556133526126ee565b5061327d3385856149af565b600554604080516317b9b84b60e31b81523060048201526001600160a01b0386811660248301528581166044830152606482018590529151600093929092169163bdcdc2589160848082019260209290919082900301818787803b1580156133c557600080fd5b505af11580156133d9573d6000803e3d6000fd5b505050506040513d60208110156133ef57600080fd5b50511561342e576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b826001600160a01b0316846001600160a01b03161415613481576040805162461bcd60e51b8152602060048201526009602482015268189859081a5b9c1d5d60ba1b604482015290519081900360640190fd5b60006001600160a01b0386811690861614156134a057506000196134c8565b506001600160a01b038085166000908152600f60209081526040808320938916835292905220545b6001600160a01b0385166000908152600e60205260409020546134eb90846131dd565b6001600160a01b038087166000908152600e6020526040808220939093559086168152205461351a90846131a7565b6001600160a01b0385166000908152600e6020526040902055600019811461356d5761354681846131dd565b6001600160a01b038087166000908152600f60209081526040808320938b16835292905220555b836001600160a01b0316856001600160a01b0316600080516020615dfc833981519152856040518082815260200191505060405180910390a36005546040805163352b4a3f60e11b81523060048201526001600160a01b03888116602483015287811660448301526064820187905291519190921691636a56947e91608480830192600092919082900301818387803b15801561360957600080fd5b505af115801561361d573d6000803e3d6000fd5b506000925061362a915050565b9150505b949350505050565b60008054819060ff1661367d576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905561368f6126ee565b5061369c3386868661469f565b915091506000805460ff191660011790559094909350915050565b60008054819060ff166136fe576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556137106126ee565b506000846001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561374e57600080fd5b505af1158015613762573d6000803e3d6000fd5b505050506040513d602081101561377857600080fd5b5051146137c5576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b6137d23387878787614c91565b915091506000805460ff19166001179055909590945092505050565b60006137f8615c10565b613802848461424a565b905061362e81615381565b6000805460ff16613852576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556138646126ee565b5060006138718484615390565b509150506000805460ff1916600117905592915050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08360108111156138b757fe5b8360388111156138c357fe5b604080519283526020830191909152600082820152519081900360600190a1826010811115612de557fe5b6000805460ff16613933576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556139456126ee565b50613953338460008561542e565b90506000805460ff1916600117905592915050565b601154604080516370a0823160e01b815230600482015290516000926001600160a01b03169182916370a0823191602480820192602092909190829003018186803b1580156139b657600080fd5b505afa1580156139ca573d6000803e3d6000fd5b505050506040513d60208110156139e057600080fd5b505191505090565b6000612de56139f88360096157e4565b612710615826565b613a0c601354836131dd565b6013558015613ab65760115460408051632e1a7d4d60e01b81526004810185905290516001600160a01b0390921691632e1a7d4d9160248082019260009290919082900301818387803b158015613a6257600080fd5b505af1158015613a76573d6000803e3d6000fd5b50506040516001600160a01b038616925084156108fc02915084906000818181858888f19350505050158015613ab0573d6000803e3d6000fd5b50613b9c565b6011546040805163a9059cbb60e01b81526001600160a01b0386811660048301526024820186905291519190921691829163a9059cbb9160448082019260009290919082900301818387803b158015613b0e57600080fd5b505af1158015613b22573d6000803e3d6000fd5b5050505060003d60008114613b3e5760208114613b4857600080fd5b6000199150613b54565b60206000803e60005191505b5080613b99576040805162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b50505b505050565b60008115613cbc57336001600160a01b03851614613bf8576040805162461bcd60e51b815260206004820152600f60248201526e0e6cadcc8cae440dad2e6dac2e8c6d608b1b604482015290519081900360640190fd5b823414613c3d576040805162461bcd60e51b815260206004820152600e60248201526d0ecc2d8eaca40dad2e6dac2e8c6d60931b604482015290519081900360640190fd5b601160009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b158015613c8d57600080fd5b505af1158015613ca1573d6000803e3d6000fd5b5050505050613cb2601354846131a7565b6013555081612de5565b601154604080516370a0823160e01b815230600482015290516001600160a01b039092169160009183916370a0823191602480820192602092909190829003018186803b158015613d0c57600080fd5b505afa158015613d20573d6000803e3d6000fd5b505050506040513d6020811015613d3657600080fd5b5051604080516323b872dd60e01b81526001600160a01b038981166004830152306024830152604482018990529151929350908416916323b872dd9160648082019260009290919082900301818387803b158015613d9357600080fd5b505af1158015613da7573d6000803e3d6000fd5b5050505060003d60008114613dc35760208114613dcd57600080fd5b6000199150613dd9565b60206000803e60005191505b5080613e1e576040805162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b601154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015613e6957600080fd5b505afa158015613e7d573d6000803e3d6000fd5b505050506040513d6020811015613e9357600080fd5b505190506000613ea382856131dd565b9050613eb1601354826131a7565b6013559450612de59350505050565b600354600090819061010090046001600160a01b03163314613ef057613ee86001601e613888565b915050611876565b613ef86140e3565b60095414613f0c57613ee8600a6020613888565b82613f156131a1565b1015613f2757613ee8600e601f613888565b600c54831115613f3d57613ee860026021613888565b613f49600c54846131dd565b600c819055600354909150613f6e9061010090046001600160a01b0316846000613a00565b600354604080516101009092046001600160a01b0316825260208201859052818101839052517f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e916060908290030190a16000611872565b6000805460ff1661400b576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916905561401d6126ee565b50613953336000858561542e565b6000805460ff16614070576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191690556140826126ee565b50613953338484615859565b6001600160a01b038116600090815260106020526040812080546140b6576000915050611876565b60006140c88260000154600a546157e4565b905060006140da828460010154615826565b95945050505050565b4290565b600354600090819061010090046001600160a01b0316331461410f57613ee86001602c613888565b6141176140e3565b6009541461412b57613ee8600a602b613888565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561417c57600080fd5b505afa158015614190573d6000803e3d6000fd5b505050506040513d60208110156141a657600080fd5b50516141e7576040805162461bcd60e51b815260206004820152600b60248201526a696e76616c69642049524d60a81b604482015290519081900360640190fd5b600680546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f9269281900390910190a16000611872565b614252615c10565b604051806020016040528061426b8560000151856157e4565b90529392505050565b600061427e615c10565b614288858561424a565b90506140da61429682615381565b846131a7565b6005546040805163d02f735160e01b81523060048201526001600160a01b03878116602483015286811660448301528581166064830152608482018590529151600093929092169163d02f73519160a48082019260209290919082900301818787803b15801561430b57600080fd5b505af115801561431f573d6000803e3d6000fd5b505050506040513d602081101561433557600080fd5b505115614374576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b816143815750600061362e565b836001600160a01b0316836001600160a01b031614156143df576040805162461bcd60e51b815260206004820152601460248201527334b73b30b634b21030b1b1b7bab73a103830b4b960611b604482015290519081900360640190fd5b6001600160a01b0383166000908152600e602052604090205461440290836131dd565b6001600160a01b038085166000908152600e6020526040808220939093559086168152205461443190836131a7565b6001600160a01b038086166000818152600e60209081526040918290209490945580518681529051919392871692600080516020615dfc83398151915292918290030190a360055460408051636d35bf9160e01b81523060048201526001600160a01b038881166024830152878116604483015286811660648301526084820186905291519190921691636d35bf919160a480830192600092919082900301818387803b1580156144e157600080fd5b505af11580156144f5573d6000803e3d6000fd5b50600092506140da915050565b60035460009061010090046001600160a01b031633146145285761190060016031613888565b6145306140e3565b6009541461454457611900600a6032613888565b670de0b6b3a76400008211156145605761190060026033613888565b6008805490839055604080518281526020810185905281517faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f821460929181900390910190a16000611872565b6000838301828582101561463c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156146015781810151838201526020016145e9565b50505050905090810190601f16801561462e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50949350505050565b600081848411156146975760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156146015781810151838201526020016145e9565b505050900390565b60055460408051631200453160e11b81523060048201526001600160a01b0387811660248301528681166044830152606482018690529151600093849316916324008a6291608480830192602092919082900301818787803b15801561470457600080fd5b505af1158015614718573d6000803e3d6000fd5b505050506040513d602081101561472e57600080fd5b50511561476d576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b6147756140e3565b600954146147bc576040805162461bcd60e51b815260206004820152600f60248201526e6d61726b6574206973207374616c6560881b604482015290519081900360640190fd5b6147c4615c9d565b6001600160a01b03861660009081526010602052604090206001015460608201526147ee8661408e565b608082015260001985141561480c5760808101516040820152614814565b604081018590525b61482387826040015186613ba1565b60e082018190526080820151614838916131dd565b60a0820152600b5460e082015161484f91906131dd565b60c0820190815260a080830180516001600160a01b03808b16600081815260106020908152604091829020948555600a546001909501949094559551600b81905560e088015194518751938f16845293830191909152818601939093526060810191909152608081019190915291517f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a19281900390910190a160055460e0820151606083015160408051631ededc9160e01b81523060048201526001600160a01b038c811660248301528b8116604483015260648201949094526084810192909252519190921691631ededc919160a480830192600092919082900301818387803b15801561495d57600080fd5b505af1158015614971573d6000803e3d6000fd5b506000925061497e915050565b8160e00151925092505094509492505050565b6000612de56149a884670de0b6b3a76400006157e4565b8351615826565b60055460408051634ef4c3e160e01b81523060048201526001600160a01b03868116602483015260448201869052915160009384931691634ef4c3e191606480830192602092919082900301818787803b158015614a0c57600080fd5b505af1158015614a20573d6000803e3d6000fd5b505050506040513d6020811015614a3657600080fd5b505115614a75576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b83614a8557506000905080614c89565b614a8d6140e3565b60095414614ad4576040805162461bcd60e51b815260206004820152600f60248201526e6d61726b6574206973207374616c6560881b604482015290519081900360640190fd5b614adc615ce3565b614ae4613297565b8152614af1868686613ba1565b604080830182905280516020810190915282518152614b109190615ae7565b60208201819052600d54614b23916131a7565b600d556001600160a01b0386166000908152600e602090815260409091205490820151614b5091906131a7565b6001600160a01b0387166000818152600e60209081526040918290209390935583810151848401518251938452938301528181019290925290517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f9181900360600190a1856001600160a01b0316306001600160a01b0316600080516020615dfc83398151915283602001516040518082815260200191505060405180910390a3600554604080830151602084015182516341c728b960e01b81523060048201526001600160a01b038b811660248301526044820193909352606481019190915291519216916341c728b99160848082019260009290919082900301818387803b158015614c5d57600080fd5b505af1158015614c71573d6000803e3d6000fd5b5060009250614c7e915050565b816040015192509250505b935093915050565b60055460408051632fe3f38f60e11b81523060048201526001600160a01b0385811660248301528881166044830152878116606483015260848201879052915160009384931691635fc7e71e9160a480830192602092919082900301818787803b158015614cfe57600080fd5b505af1158015614d12573d6000803e3d6000fd5b505050506040513d6020811015614d2857600080fd5b505115614d67576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b614d6f6140e3565b60095414614db6576040805162461bcd60e51b815260206004820152600f60248201526e6d61726b6574206973207374616c6560881b604482015290519081900360640190fd5b614dbe6140e3565b846001600160a01b0316636c540baf6040518163ffffffff1660e01b815260040160206040518083038186803b158015614df757600080fd5b505afa158015614e0b573d6000803e3d6000fd5b505050506040513d6020811015614e2157600080fd5b505114614e67576040805162461bcd60e51b815260206004820152600f60248201526e6d61726b6574206973207374616c6560881b604482015290519081900360640190fd5b866001600160a01b0316866001600160a01b03161415614ec5576040805162461bcd60e51b815260206004820152601460248201527334b73b30b634b21030b1b1b7bab73a103830b4b960611b604482015290519081900360640190fd5b600085118015614ed757506000198514155b614f19576040805162461bcd60e51b815260206004820152600e60248201526d1a5b9d985b1a5908185b5bdd5b9d60921b604482015290519081900360640190fd5b614f21615d04565b614f2d8888888761469f565b602083015280825215614f7d576040805162461bcd60e51b81526020600482015260136024820152721c995c185e48189bdc9c9bddc819985a5b1959606a1b604482015290519081900360640190fd5b60055460208201516040805163c488847b60e01b81523060048201526001600160a01b03898116602483015260448201939093528151929093169263c488847b9260648083019392829003018186803b158015614fd957600080fd5b505afa158015614fed573d6000803e3d6000fd5b505050506040513d604081101561500357600080fd5b5080516020909101516060830152604082018190521561506a576040805162461bcd60e51b815260206004820152601d60248201527f63616c63756c617465207365697a6520616d6f756e74206661696c6564000000604482015290519081900360640190fd5b8060600151856001600160a01b03166370a08231896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156150c557600080fd5b505afa1580156150d9573d6000803e3d6000fd5b505050506040513d60208110156150ef57600080fd5b50511015615135576040805162461bcd60e51b815260206004820152600e60248201526d0e6cad2f4ca40e8dede40daeac6d60931b604482015290519081900360640190fd5b60006001600160a01b03861630141561515f57615158308a8a856060015161429c565b90506151ef565b60608201516040805163b2a02ff160e01b81526001600160a01b038c811660048301528b81166024830152604482019390935290519188169163b2a02ff1916064808201926020929091908290030181600087803b1580156151c057600080fd5b505af11580156151d4573d6000803e3d6000fd5b505050506040513d60208110156151ea57600080fd5b505190505b8015615239576040805162461bcd60e51b81526020600482015260146024820152731d1bdad95b881cd95a5e9d5c994819985a5b195960621b604482015290519081900360640190fd5b7f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb528989846020015189866060015160405180866001600160a01b03166001600160a01b03168152602001856001600160a01b03166001600160a01b03168152602001848152602001836001600160a01b03166001600160a01b031681526020018281526020019550505050505060405180910390a160055460208301516060840151604080516347ef3b3b60e01b81523060048201526001600160a01b038b811660248301528e811660448301528d81166064830152608482019490945260a48101929092525191909216916347ef3b3b9160c480830192600092919082900301818387803b15801561534b57600080fd5b505af115801561535f573d6000803e3d6000fd5b506000925061536c915050565b82602001519350935050509550959350505050565b51670de0b6b3a7640000900490565b60008060008061539e6140e3565b600954146153bd576153b2600a6037613888565b935091506154279050565b6153c8338787613ba1565b90506153d6600c54826131a7565b600c819055604080513381526020810184905280820183905290519193507fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc5919081900360600190a1600093509150505b9250929050565b600083158061543b575082155b615478576040805162461bcd60e51b8152602060048201526009602482015268189859081a5b9c1d5d60ba1b604482015290519081900360640190fd5b615480615d2c565b615488613297565b815284156154b9576020808201869052604080519182019052815181526154af90866137ee565b60408201526154e2565b6154d58460405180602001604052808460000151815250615ae7565b6020820152604081018490525b6005546020808301516040805163eabe7d9160e01b81523060048201526001600160a01b038b8116602483015260448201939093529051919093169263eabe7d919260648083019391928290030181600087803b15801561554257600080fd5b505af1158015615556573d6000803e3d6000fd5b505050506040513d602081101561556c57600080fd5b5051156155ab576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b841580156155b7575083155b156155c657600091505061362e565b6155ce6140e3565b60095414615615576040805162461bcd60e51b815260206004820152600f60248201526e6d61726b6574206973207374616c6560881b604482015290519081900360640190fd5b615625600d5482602001516131dd565b60608201526001600160a01b0386166000908152600e60209081526040909120549082015161565491906131dd565b608082015260408101516156666131a1565b10156156ad576040805162461bcd60e51b81526020600482015260116024820152700d2dce6eaccccd2c6d2cadce840c6c2e6d607b1b604482015290519081900360640190fd5b6060810151600d5560808101516001600160a01b0387166000908152600e602052604090819020919091558101516156e790879085613a00565b306001600160a01b0316866001600160a01b0316600080516020615dfc83398151915283602001516040518082815260200191505060405180910390a360408082015160208084015183516001600160a01b038b168152918201929092528083019190915290517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a9299181900360600190a1600554604080830151602084015182516351dff98960e01b81523060048201526001600160a01b038b811660248301526044820193909352606481019190915291519216916351dff9899160848082019260009290919082900301818387803b15801561360957600080fd5b6000612de583836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250615afb565b6000612de583836040518060400160405280600e81526020016d646976696465206279207a65726f60901b815250615b71565b6005546040805163368f515360e21b81523060048201526001600160a01b038681166024830152604482018690529151600093929092169163da3d454c9160648082019260209290919082900301818787803b1580156158b857600080fd5b505af11580156158cc573d6000803e3d6000fd5b505050506040513d60208110156158e257600080fd5b505115615921576040805162461bcd60e51b81526020600482015260086024820152671c995a9958dd195960c21b604482015290519081900360640190fd5b6159296140e3565b60095414615970576040805162461bcd60e51b815260206004820152600f60248201526e6d61726b6574206973207374616c6560881b604482015290519081900360640190fd5b826159796131a1565b10156159c0576040805162461bcd60e51b81526020600482015260116024820152700d2dce6eaccccd2c6d2cadce840c6c2e6d607b1b604482015290519081900360640190fd5b6159c8615d5b565b6159d18561408e565b602082018190526159e290856131a7565b6040820152600b546159f490856131a7565b606082019081526040808301516001600160a01b0388166000908152601060205291909120908155600a5460019091015551600b55615a34858585613a00565b60408082015160608084015183516001600160a01b038a16815260208101899052808501939093529082015290517f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809181900360800190a160055460408051635c77860560e01b81523060048201526001600160a01b0388811660248301526044820188905291519190921691635c77860591606480830192600092919082900301818387803b1580156144e157600080fd5b6000615af1615c10565b6138028484615bd3565b6000831580615b08575082155b15615b1557506000612de5565b83830283858281615b2257fe5b0414839061463c5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156146015781810151838201526020016145e9565b60008183615bc05760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156146015781810151838201526020016145e9565b50828481615bca57fe5b04949350505050565b615bdb615c10565b6000615bef670de0b6b3a7640000856157e4565b90506040518060200160405280615c068386614991565b9052949350505050565b6040518060200160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10615c6457805160ff1916838001178555615c91565b82800160010185558215615c91579182015b82811115615c91578251825591602001919060010190615c76565b506116d0929150615d84565b6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180606001604052806000815260200160008152602001600081525090565b6040518060800160405280600081526020016000815260200160008152602001600081525090565b6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b604080516080810190915280600081526020016000815260200160008152602001600081525090565b6115cf91905b808211156116d05760008155600101615d8a56fe6f6e6c792077726170706564206e617469766520636f6e747261637420636f756c642073656e64206e617469766520746f6b656e45524333313536466c617368426f72726f776572496e746572666163652e6f6e466c6173684c6f616eddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa265627a7a723158204593c282a4845fd52871313025786a2034cfd4d5dfbb8cfb3ad8d290f0788f6b64736f6c63430005110032
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.