Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
OErc20
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 10 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "./abstract/OToken.sol"; import "./abstract/OErc20Storage.sol"; /** * @title 0VIX's OErc20 Contract * @notice OTokens which wrap an EIP-20 underlying * @author 0VIX */ contract OErc20 is OToken, OErc20Storage { bool public isInit = true; /** * @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 init( address underlying_, IComptroller comptroller_, IInterestRateModel interestRateModel_, uint256 initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_ ) public { // OToken initialize does the bulk of the work require(!isInit, "contract already initialized"); isInit = true; admin = payable(msg.sender); super.initialize( comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_ ); // Set underlying and sanity check it underlying = underlying_; IEIP20(underlying).totalSupply(); } /*** User Interface ***/ /** * @notice Sender supplies assets into the market and receives oTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @dev Reverts upon any failure */ function mint(uint256 mintAmount) external override { (uint256 err, ) = mintInternal(mintAmount); requireNoError(err, "mint failed"); } /** * @notice Sender redeems oTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of oTokens to redeem into underlying */ function redeem(uint256 redeemTokens) external override { redeemInternal(redeemTokens); } /** * @notice Sender redeems oTokens 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 redeem */ function redeemUnderlying(uint256 redeemAmount) external override{ redeemUnderlyingInternal(redeemAmount); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow */ function borrow(uint256 borrowAmount) external override { borrowInternal(borrowAmount); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @dev Reverts upon any failure */ function repayBorrow(uint256 repayAmount) external override { (uint256 err, ) = repayBorrowInternal(repayAmount); requireNoError(err, "repayBorrow 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 * @dev Reverts upon any failure */ function repayBorrowBehalf(address borrower, uint256 repayAmount) external override { (uint256 err, ) = repayBorrowBehalfInternal(borrower, repayAmount); requireNoError(err, "repayBorrowBehalf failed"); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this oToken to be liquidated * @param repayAmount The amount of the underlying borrowed asset to repay * @param oTokenCollateral The market in which to seize collateral from the borrower * @dev Reverts upon any failure */ function liquidateBorrow( address borrower, uint256 repayAmount, IOToken oTokenCollateral ) external override { (uint256 err, ) = liquidateBorrowInternal( borrower, repayAmount, oTokenCollateral ); requireNoError(err, "liquidateBorrow failed"); } /** * @notice A public function to sweep accidental ERC-20 transfers to this contract. Tokens are sent to admin (timelock) * @param token The address of the ERC-20 token to sweep */ function sweepToken(IEIP20NonStandard token) external override { require( address(token) != underlying, "OErc20::sweepToken: can not sweep underlying token" ); uint256 underlyingBalanceBefore = IEIP20(underlying).balanceOf(address(this)); uint256 balance = token.balanceOf(address(this)); token.transfer(admin, balance); require(underlyingBalanceBefore == IEIP20(underlying).balanceOf(address(this)), "underlying balance changed"); } /** * @notice The sender adds to reserves. * @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 override returns (uint256) { return _addReservesInternal(addAmount); } /*** 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 tokens owned by this contract */ function getCashPrior() internal override view returns (uint256) { IEIP20 token = IEIP20(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) internal override returns (uint256) { IEIP20NonStandard token = IEIP20NonStandard(underlying); uint256 balanceBefore = IEIP20(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, "TOKEN_TRANSFER_IN_FAILED"); // Calculate the amount that was *actually* transferred uint256 balanceAfter = IEIP20(underlying).balanceOf( address(this) ); require(balanceAfter >= balanceBefore, "TOKEN_TRANSFER_IN_OVERFLOW"); return balanceAfter - balanceBefore; // underflow already checked above, just subtract } /** * @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) internal override virtual { IEIP20NonStandard token = IEIP20NonStandard(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, "TOKEN_TRANSFER_OUT_FAILED"); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; /** * @title 0VIX's IInterestRateModel Interface * @author 0VIX */ interface IInterestRateModel { /// @notice Indicator that this is an InterestRateModel contract (for inspection) function isInterestRateModel() external view returns(bool); /** * @notice Calculates the current borrow interest rate per timestmp * @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 timestmp (as a percentage, and scaled by 1e18) */ function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint); /** * @notice Calculates the current supply interest rate per timestmp * @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 timestmp (as a percentage, and scaled by 1e18) */ function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) external view returns (uint); }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "../otokens/interfaces/IOToken.sol"; import "../PriceOracle.sol"; interface IComptroller { /// @notice Indicator that this is a Comptroller contract (for inspection) function isComptroller() external view returns(bool); /*** Assets You Are In ***/ function enterMarkets(address[] calldata oTokens) external returns (uint[] memory); function exitMarket(address oToken) external returns (uint); /*** Policy Hooks ***/ function mintAllowed(address oToken, address minter, uint mintAmount) external returns (uint); function mintVerify(address oToken, address minter, uint mintAmount, uint mintTokens) external; function redeemAllowed(address oToken, address redeemer, uint redeemTokens) external returns (uint); function redeemVerify(address oToken, address redeemer, uint redeemAmount, uint redeemTokens) external; function borrowAllowed(address oToken, address borrower, uint borrowAmount) external returns (uint); function borrowVerify(address oToken, address borrower, uint borrowAmount) external; function repayBorrowAllowed( address oToken, address payer, address borrower, uint repayAmount) external returns (uint); function liquidateBorrowAllowed( address oTokenBorrowed, address oTokenCollateral, address liquidator, address borrower, uint repayAmount) external returns (uint); function seizeAllowed( address oTokenCollateral, address oTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external returns (uint); function seizeVerify( address oTokenCollateral, address oTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external; function transferAllowed(address oToken, address src, address dst, uint transferTokens) external returns (uint); function transferVerify(address oToken, address src, address dst, uint transferTokens) external; /*** Liquidity/Liquidation Calculations ***/ function liquidateCalculateSeizeTokens( address oTokenBorrowed, address oTokenCollateral, uint repayAmount) external view returns (uint, uint); function isMarket(address market) external view returns(bool); function getBoostManager() external view returns(address); function getAllMarkets() external view returns(IOToken[] memory); function oracle() external view returns(PriceOracle); function updateAndDistributeSupplierRewardsForToken( address oToken, address account ) external; function updateAndDistributeBorrowerRewardsForToken( address oToken, address borrower ) external; function _setRewardSpeeds( address[] memory oTokens, uint256[] memory supplySpeeds, uint256[] memory borrowSpeeds ) external; }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; /** * @title Careful Math * @author 0VIX * @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(uint a, uint b) internal pure returns (MathError, uint) { unchecked { if (a == 0) { return (MathError.NO_ERROR, 0); } uint 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(uint a, uint b) internal pure returns (MathError, uint) { unchecked { 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(uint a, uint b) internal pure returns (MathError, uint) { unchecked { 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(uint a, uint b) internal pure returns (MathError, uint) { unchecked { uint 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(uint a, uint b, uint c) internal pure returns (MathError, uint) { (MathError err0, uint sum) = addUInt(a, b); if (err0 != MathError.NO_ERROR) { return (err0, 0); } return subUInt(sum, c); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; 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(uint error, uint info, uint 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 (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(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_ACCUMULATED_INTEREST_CALCULATION_FAILED, ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED, ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED, BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, BORROW_ACCRUE_INTEREST_FAILED, BORROW_CASH_NOT_AVAILABLE, BORROW_FRESHNESS_CHECK, BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, 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_BALANCE_INCREMENT_FAILED, LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_SEIZE_TOO_MUCH, MINT_ACCRUE_INTEREST_FAILED, MINT_COMPTROLLER_REJECTION, MINT_EXCHANGE_CALCULATION_FAILED, MINT_EXCHANGE_RATE_READ_FAILED, MINT_FRESHNESS_CHECK, MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, MINT_TRANSFER_IN_FAILED, MINT_TRANSFER_IN_NOT_POSSIBLE, REDEEM_ACCRUE_INTEREST_FAILED, REDEEM_COMPTROLLER_REJECTION, REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, REDEEM_EXCHANGE_RATE_READ_FAILED, REDEEM_FRESHNESS_CHECK, REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, 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_ACCUMULATED_BALANCE_CALCULATION_FAILED, REPAY_BORROW_COMPTROLLER_REJECTION, REPAY_BORROW_FRESHNESS_CHECK, REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, 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, TRANSFER_NOT_ENOUGH, TRANSFER_TOO_MUCH, ADD_RESERVES_ACCRUE_INTEREST_FAILED, ADD_RESERVES_FRESH_CHECK, ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE, SET_PROTOCOL_SEIZE_SHARE_ACCRUE_INTEREST_FAILED, SET_PROTOCOL_SEIZE_SHARE_OWNER_CHECK, SET_PROTOCOL_SEIZE_SHARE_FRESH_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(uint error, uint info, uint 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 (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(err); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "./CarefulMath.sol"; import "./ExponentialNoError.sol"; /** * @title Exponential module for storing fixed-precision decimals * @author 0VIX * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError * @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, ExponentialNoError { /** * @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(uint num, uint denom) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledNumerator) = mulUInt(num, expScale); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } (MathError err1, uint 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) pure internal returns (MathError, Exp memory) { (MathError error, uint 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) pure internal returns (MathError, Exp memory) { (MathError error, uint 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, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint 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, uint scalar) pure internal returns (MathError, uint) { (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, uint scalar, uint addend) pure internal returns (MathError, uint) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return addUInt(truncate(product), addend); } /** * @dev Divide an Exp by a scalar, returning a new Exp. */ function divScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint 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(uint scalar, Exp memory divisor) pure internal 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, uint 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(uint scalar, Exp memory divisor) pure internal returns (MathError, uint) { (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(fraction)); } /** * @dev Multiplies two exponentials, returning a new exponential. */ function mulExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError err0, uint 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, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } (MathError err2, uint 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(uint a, uint b) pure internal 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) pure internal 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) pure internal returns (MathError, Exp memory) { return getExp(a.mantissa, b.mantissa); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; /** * @title Exponential module for storing fixed-precision decimals * @author 0VIX * @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 ExponentialNoError { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Truncates the given exp to a whole number value. * For example, truncate(Exp{mantissa: 15 * expScale}) = 15 */ function truncate(Exp memory exp) pure internal returns (uint) { // Note: We are not using careful math here as we're performing a division that cannot fail return exp.mantissa / expScale; } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mul_ScalarTruncate(Exp memory a, uint scalar) pure internal returns (uint) { return truncate(mul_(a, scalar)); } /** * @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, uint scalar, uint addend) pure internal returns (uint) { return truncate(mul_(a, scalar)) + addend; } /** * @dev Checks if first Exp is less than second Exp. */ function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa < right.mantissa; } /** * @dev Checks if left Exp <= right Exp. */ function lessThanOrEqualExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa <= right.mantissa; } /** * @dev Checks if left Exp > right Exp. */ function greaterThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa > right.mantissa; } /** * @dev returns true if Exp is exactly zero */ function isZeroExp(Exp memory value) pure internal returns (bool) { return value.mantissa == 0; } function safe224(uint n) pure internal returns (uint224) { require(n <= type(uint224).max, "safe224 overflow"); return uint224(n); } function safe32(uint n) pure internal returns (uint32) { require(n <= type(uint32).max, "safe32 overflow"); return uint32(n); } function add_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: a.mantissa + b.mantissa}); } function add_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: a.mantissa + b.mantissa}); } function add_(uint a, uint b, string memory errorMessage) pure internal returns (uint c) { unchecked { require((c = a + b ) >= a, errorMessage); } } function sub_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: a.mantissa - b.mantissa}); } function sub_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: a.mantissa - b.mantissa}); } function sub_(uint a, uint b, string memory errorMessage) pure internal returns (uint c) { unchecked { require((c = a - b) <= a, errorMessage); } } function mul_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: (a.mantissa * b.mantissa) / expScale}); } function mul_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: a.mantissa * b}); } function mul_(uint a, Exp memory b) pure internal returns (uint) { return (a * b.mantissa) / expScale; } function mul_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: (a.mantissa * b.mantissa) / doubleScale}); } function mul_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: a.mantissa * b}); } function mul_(uint a, Double memory b) pure internal returns (uint) { return (a * b.mantissa) / doubleScale; } function mul_(uint a, uint b, string memory errorMessage) pure internal returns (uint c) { unchecked { require(a == 0 || (c = a * b) / a == b, errorMessage); } } function div_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: (a.mantissa * expScale) / b.mantissa}); } function div_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: a.mantissa / b}); } function div_(uint a, Exp memory b) pure internal returns (uint) { return (a * expScale) / b.mantissa; } function div_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: (a.mantissa * doubleScale) / b.mantissa}); } function div_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: a.mantissa / b}); } function div_(uint a, Double memory b) pure internal returns (uint) { return (a * doubleScale) / b.mantissa; } function div_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { unchecked { require(b > 0, errorMessage); return a / b; } } function fraction(uint a, uint b) pure internal returns (Double memory) { return Double({mantissa: (a * doubleScale) / b}); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "../interfaces/IOErc20.sol"; abstract contract OErc20Storage is IOErc20 { /** * @notice Underlying asset for this OToken */ address public override underlying; }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "./OTokenStorage.sol"; import "../../interfaces/IComptroller.sol"; import "../../libraries/ErrorReporter.sol"; import "../../libraries/Exponential.sol"; import "../interfaces/IEIP20.sol"; import "../../interest-rate-models/interfaces/IInterestRateModel.sol"; import "../../vote-escrow/interfaces/IBoostManager.sol"; /** * @title 0VIX's OToken Contract * @notice Abstract base for OTokens * @author 0VIX */ abstract contract OToken is OTokenStorage, 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( IComptroller comptroller_, IInterestRateModel interestRateModel_, uint256 initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_ ) internal { require(msg.sender == admin, "only admin may initialize"); require( accrualBlockTimestamp == 0 && borrowIndex == 0, "already initialized" ); // Set initial exchange rate initialExchangeRateMantissa = initialExchangeRateMantissa_; require( initialExchangeRateMantissa > 0, "init exchange rate must be > 0" ); // Set the comptroller require( _setComptroller(comptroller_) == uint256(Error.NO_ERROR), "set comptroller failed" ); // Initialize block timestamp and borrow index (block timestamp mocks depend on comptroller being set) accrualBlockTimestamp = getBlockTimestamp(); borrowIndex = mantissaOne; // Set the interest rate model (depends on block timestamp / borrow index) require( _setInterestRateModelFresh(interestRateModel_) == uint256(Error.NO_ERROR), "set interest rate model 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; } function _updateBoostSupplyBalances( address user, uint256 oldBalance, uint256 newBalance ) internal { address boostManager = comptroller.getBoostManager(); if ( boostManager != address(0) && IBoostManager(boostManager).isAuthorized(address(this)) ) { IBoostManager(boostManager).updateBoostSupplyBalances( address(this), user, oldBalance, newBalance ); } } function _updateBoostBorrowBalances( address user, uint256 oldBalance, uint256 newBalance ) internal { address boostManager = comptroller.getBoostManager(); if ( boostManager != address(0) && IBoostManager(boostManager).isAuthorized(address(this)) ) { IBoostManager(boostManager).updateBoostBorrowBalances( address(this), user, oldBalance, newBalance ); } } /** * @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 */ uint256 allowed = comptroller.transferAllowed( address(this), src, dst, tokens ); require(allowed == 0, "ERC20: transfer not allowed"); /* Do not allow self-transfers */ require(src != dst, "ERC20: self-transfer not allowed"); /* Get the allowance, infinite for the account owner */ uint256 startingAllowance = 0; if (spender == src) { startingAllowance = type(uint256).max; } else { startingAllowance = transferAllowances[src][spender]; } /* Do the calculations, checking for {under,over}flow */ MathError mathErr; uint256 allowanceNew; uint256 srcTokensNew; uint256 dstTokensNew; (mathErr, allowanceNew) = subUInt(startingAllowance, tokens); require( mathErr == MathError.NO_ERROR, "ERC20: decreased allowance below zero" ); (mathErr, srcTokensNew) = subUInt(accountTokens[src], tokens); require( mathErr == MathError.NO_ERROR, "ERC20: transfer amount exceeds balance" ); (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens); require( mathErr == MathError.NO_ERROR, "ERC20: maximum destination balance reached" ); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) _updateBoostSupplyBalances(src, accountTokens[src], srcTokensNew); _updateBoostSupplyBalances(dst, accountTokens[dst], dstTokensNew); accountTokens[src] = srcTokensNew; accountTokens[dst] = dstTokensNew; /* Eat some of the allowance (if necessary) */ if (startingAllowance != type(uint256).max) { transferAllowances[src][spender] = allowanceNew; } /* We emit a Transfer event */ emit Transfer(src, dst, tokens); // unused function // comptroller.transferVerify(address(this), src, dst, tokens); return uint256(Error.NO_ERROR); } /** * @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 override 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 override 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 override 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 override 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 override 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 override returns (uint256) { Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()}); (MathError mErr, uint256 balance) = mulScalarTruncate( exchangeRate, accountTokens[owner] ); require(mErr == MathError.NO_ERROR, "balance could not be calculated"); return balance; } /** * @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 override returns ( uint256, uint256, uint256, uint256 ) { uint256 oTokenBalance = accountTokens[account]; uint256 borrowBalance; uint256 exchangeRateMantissa; MathError mErr; (mErr, borrowBalance) = borrowBalanceStoredInternal(account); if (mErr != MathError.NO_ERROR) { return (uint256(Error.MATH_ERROR), 0, 0, 0); } (mErr, exchangeRateMantissa) = exchangeRateStoredInternal(); if (mErr != MathError.NO_ERROR) { return (uint256(Error.MATH_ERROR), 0, 0, 0); } return ( uint256(Error.NO_ERROR), oTokenBalance, borrowBalance, exchangeRateMantissa ); } /** * @dev Function to simply retrieve block timestamp * This exists mainly for inheriting test contracts to stub this result. */ function getBlockTimestamp() internal view virtual returns (uint256) { return block.timestamp; } /** * @notice Returns the current per-timestamp borrow interest rate for this oToken * @return The borrow interest rate per timestmp, scaled by 1e18 */ function borrowRatePerTimestamp() external view override returns (uint256) { return interestRateModel.getBorrowRate( getCashPrior(), totalBorrows, totalReserves ); } /** * @notice Returns the current per-timestamp supply interest rate for this oToken * @return The supply interest rate per timestmp, scaled by 1e18 */ function supplyRatePerTimestamp() external view override returns (uint256) { return interestRateModel.getSupplyRate( getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa ); } /** * @notice Returns the current total borrows plus accrued interest * @return The total borrows with interest */ function totalBorrowsCurrent() external override nonReentrant returns (uint256) { require( accrueInterest() == uint256(Error.NO_ERROR), "accrue interest failed" ); 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 override nonReentrant returns (uint256) { require( accrueInterest() == uint256(Error.NO_ERROR), "accrue interest failed" ); 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 override returns (uint256) { (MathError err, uint256 result) = borrowBalanceStoredInternal(account); require(err == MathError.NO_ERROR, "borrowBalanceStored failed"); return result; } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return (error code, the calculated balance or 0 if error code is non-zero) */ function borrowBalanceStoredInternal(address account) internal view returns (MathError, uint256) { /* Note: we do not assert that the market is up to date */ MathError mathErr; uint256 principalTimesIndex; uint256 result; /* 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 (MathError.NO_ERROR, 0); } /* Calculate new borrow balance using the interest index: * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex */ (mathErr, principalTimesIndex) = mulUInt( borrowSnapshot.principal, borrowIndex ); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } (mathErr, result) = divUInt( principalTimesIndex, borrowSnapshot.interestIndex ); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } return (MathError.NO_ERROR, result); } /** * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateCurrent() public override nonReentrant returns (uint256) { require( accrueInterest() == uint256(Error.NO_ERROR), "accrue interest failed" ); return exchangeRateStored(); } /** * @notice Calculates the exchange rate from the underlying to the OToken * @dev This function does not accrue interest before calculating the exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateStored() public view override returns (uint256) { (MathError err, uint256 result) = exchangeRateStoredInternal(); require(err == MathError.NO_ERROR, "exchangeRateStored failed"); return result; } /** * @notice Calculates the exchange rate from the underlying to the OToken * @dev This function does not accrue interest before calculating the exchange rate * @return (error code, calculated exchange rate scaled by 1e18) */ function exchangeRateStoredInternal() internal view virtual returns (MathError, uint256) { uint256 _totalSupply = totalSupply; if (_totalSupply == 0) { /* * If there are no tokens minted: * exchangeRate = initialExchangeRate */ return (MathError.NO_ERROR, initialExchangeRateMantissa); } else { /* * Otherwise: * exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply */ uint256 totalCash = getCashPrior(); uint256 cashPlusBorrowsMinusReserves; Exp memory exchangeRate; MathError mathErr; (mathErr, cashPlusBorrowsMinusReserves) = addThenSubUInt( totalCash, totalBorrows, totalReserves ); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } (mathErr, exchangeRate) = getExp( cashPlusBorrowsMinusReserves, _totalSupply ); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } return (MathError.NO_ERROR, exchangeRate.mantissa); } } /** * @notice Get cash balance of this oToken in the underlying asset * @return The quantity of underlying asset owned by this contract */ function getCash() external view override 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 override returns (uint256) { /* Remember the initial block timestamp */ uint256 currentBlockTimestamp = getBlockTimestamp(); uint256 accrualBlockTimestampPrior = accrualBlockTimestamp; /* Short-circuit accumulating 0 interest */ if (accrualBlockTimestampPrior == currentBlockTimestamp) { 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 is absurdly high" ); /* Calculate the number of blocks elapsed since the last accrual */ (MathError mathErr, uint256 blockDelta) = subUInt( currentBlockTimestamp, accrualBlockTimestampPrior ); require( mathErr == MathError.NO_ERROR, "could not calculate block delta" ); /* * 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; uint256 interestAccumulated; uint256 totalBorrowsNew; uint256 totalReservesNew; uint256 borrowIndexNew; (mathErr, simpleInterestFactor) = mulScalar( Exp({mantissa: borrowRateMantissa}), blockDelta ); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED, uint256(mathErr) ); } (mathErr, interestAccumulated) = mulScalarTruncate( simpleInterestFactor, borrowsPrior ); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED, uint256(mathErr) ); } (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED, uint256(mathErr) ); } (mathErr, totalReservesNew) = mulScalarTruncateAddUInt( Exp({mantissa: reserveFactorMantissa}), interestAccumulated, reservesPrior ); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED, uint256(mathErr) ); } (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt( simpleInterestFactor, borrowIndexPrior, borrowIndexPrior ); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED, uint256(mathErr) ); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accrualBlockTimestamp = currentBlockTimestamp; 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 oTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. */ function mintInternal(uint256 mintAmount) internal nonReentrant returns (uint256, uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return ( fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0 ); } // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to return mintFresh(msg.sender, mintAmount); } struct MintLocalVars { Error err; MathError mathErr; } /** * @notice User supplies assets into the market and receives oTokens 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 * @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) internal returns (uint256, uint256) { /* Fail if mint not allowed */ { uint256 allowed = comptroller.mintAllowed( address(this), minter, mintAmount ); if (allowed != 0) { return ( failOpaque( Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed ), 0 ); } } /* Verify market's block timestamp equals current block timestamp */ if (accrualBlockTimestamp != getBlockTimestamp()) { return ( fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0 ); } MintLocalVars memory vars; uint256 exchangeRateMantissa; (vars.mathErr, exchangeRateMantissa) = exchangeRateStoredInternal(); if (vars.mathErr != MathError.NO_ERROR) { return ( failOpaque( Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint256(vars.mathErr) ), 0 ); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call `doTransferIn` for the minter and the mintAmount. * Note: The oToken must handle variations between ERC-20 and NATIVE 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 oToken holds an additional `actualMintAmount` * of cash. */ uint256 actualMintAmount = doTransferIn(minter, mintAmount); /* * We get the current exchange rate and calculate the number of oTokens to be minted: * mintTokens = actualMintAmount / exchangeRate */ uint256 mintTokens; (vars.mathErr, mintTokens) = divScalarByExpTruncate( actualMintAmount, Exp({mantissa: exchangeRateMantissa}) ); require( vars.mathErr == MathError.NO_ERROR, "MINT_EXCHANGE_CALCULATION_FAILED" ); /* * We calculate the new total supply of oTokens and minter token balance, checking for overflow: * totalSupplyNew = totalSupply + mintTokens * accountTokensNew = accountTokens[minter] + mintTokens */ uint256 totalSupplyNew; (vars.mathErr, totalSupplyNew) = addUInt(totalSupply, mintTokens); require( vars.mathErr == MathError.NO_ERROR, "MINT_NEW_TOTAL_SUPPLY_FAILED" ); uint256 accountTokensNew; (vars.mathErr, accountTokensNew) = addUInt( accountTokens[minter], mintTokens ); require( vars.mathErr == MathError.NO_ERROR, "MINT_NEW_ACCOUNT_BALANCE_FAILED" ); _updateBoostSupplyBalances( minter, accountTokens[minter], accountTokensNew ); /* We write previously calculated values into storage */ totalSupply = totalSupplyNew; accountTokens[minter] = accountTokensNew; /* We emit a Mint event, and a Transfer event */ emit Mint(minter, actualMintAmount, mintTokens); emit Transfer(address(0), minter, mintTokens); /* We call the defense hook */ // unused function // comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens); return (uint256(Error.NO_ERROR), actualMintAmount); } /** * @notice Sender redeems oTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of oTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemInternal(uint256 redeemTokens) internal nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(payable(msg.sender), redeemTokens, 0); } /** * @notice Sender redeems oTokens 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 oTokens * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlyingInternal(uint256 redeemAmount) internal nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(payable(msg.sender), 0, redeemAmount); } struct RedeemLocalVars { Error err; MathError mathErr; uint256 exchangeRateMantissa; uint256 redeemTokens; uint256 redeemAmount; uint256 totalSupplyNew; uint256 accountTokensNew; } /** * @notice User redeems oTokens in exchange for the underlying asset * @dev Assumes interest has already been accrued up to the current block * @param redeemer The address of the account which is redeeming the tokens * @param redeemTokensIn The number of oTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero) * @param redeemAmountIn The number of underlying tokens to receive from redeeming oTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero) * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemFresh( address payable redeemer, uint256 redeemTokensIn, uint256 redeemAmountIn ) internal returns (uint256) { require( redeemTokensIn == 0 || redeemAmountIn == 0, "tokensIn or amountIn must be 0" ); RedeemLocalVars memory vars; /* exchangeRate = invoke Exchange Rate Stored() */ ( vars.mathErr, vars.exchangeRateMantissa ) = exchangeRateStoredInternal(); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_RATE_READ_FAILED, uint256(vars.mathErr) ); } /* 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 */ if (redeemTokensIn >= accountTokens[redeemer]) { vars.redeemTokens = accountTokens[redeemer]; } else { vars.redeemTokens = redeemTokensIn; } (vars.mathErr, vars.redeemAmount) = mulScalarTruncate( Exp({mantissa: vars.exchangeRateMantissa}), vars.redeemTokens ); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint256(vars.mathErr) ); } } else { /* * We get the current exchange rate and calculate the amount to be redeemed: * redeemTokens = redeemAmountIn / exchangeRate * redeemAmount = redeemAmountIn */ if (redeemAmountIn == type(uint256).max) { vars.redeemTokens = accountTokens[redeemer]; (vars.mathErr, vars.redeemAmount) = mulScalarTruncate( Exp({mantissa: vars.exchangeRateMantissa}), vars.redeemTokens ); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint256(vars.mathErr) ); } } else { vars.redeemAmount = redeemAmountIn; (vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate( redeemAmountIn, Exp({mantissa: vars.exchangeRateMantissa}) ); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, uint256(vars.mathErr) ); } } } /* Fail if redeem not allowed */ uint256 allowed = comptroller.redeemAllowed( address(this), redeemer, vars.redeemTokens ); if (allowed != 0) { return failOpaque( Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed ); } /* Verify market's block timestamp equals current block timestamp */ if (accrualBlockTimestamp != getBlockTimestamp()) { return fail( Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK ); } /* * We calculate the new total supply and redeemer balance, checking for underflow: * totalSupplyNew = totalSupply - redeemTokens * accountTokensNew = accountTokens[redeemer] - redeemTokens */ (vars.mathErr, vars.totalSupplyNew) = subUInt( totalSupply, vars.redeemTokens ); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint256(vars.mathErr) ); } if (vars.redeemTokens > accountTokens[redeemer]) vars.redeemTokens = accountTokens[redeemer]; (vars.mathErr, vars.accountTokensNew) = subUInt( accountTokens[redeemer], vars.redeemTokens ); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr) ); } /* Fail gracefully if protocol has insufficient cash */ if (getCashPrior() < vars.redeemAmount) { return fail( Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE ); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) _updateBoostSupplyBalances( redeemer, accountTokens[redeemer], vars.accountTokensNew ); /* We write previously calculated values into storage */ totalSupply = vars.totalSupplyNew; accountTokens[redeemer] = vars.accountTokensNew; /* 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 ); /* * We invoke doTransferOut for the redeemer and the redeemAmount. * Note: The oToken must handle variations between ERC-20 and NATIVE underlying. * On success, the oToken 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); return uint256(Error.NO_ERROR); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowInternal(uint256 borrowAmount) internal nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED); } // borrowFresh emits borrow-specific logs on errors, so we don't need to return borrowFresh(payable(msg.sender), borrowAmount); } /** * @notice Users borrow assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowFresh(address payable borrower, uint256 borrowAmount) internal returns (uint256) { /* Fail if borrow not allowed */ { uint256 allowed = comptroller.borrowAllowed( address(this), borrower, borrowAmount ); if (allowed != 0) { return failOpaque( Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed ); } } /* Verify market's block timestamp equals current block timestamp */ if (accrualBlockTimestamp != getBlockTimestamp()) { return fail( Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK ); } /* Fail gracefully if protocol has insufficient underlying cash */ if (getCashPrior() < borrowAmount) { return fail( Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE ); } MathError mathErr; /* * We calculate the new borrower and total borrow balances, failing on overflow: * accountBorrowsNew = accountBorrows + borrowAmount * totalBorrowsNew = totalBorrows + borrowAmount */ uint256 _accountBorrows; (mathErr, _accountBorrows) = borrowBalanceStoredInternal(borrower); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo.BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, uint256(mathErr) ); } uint256 oldBorrowedBalance = _accountBorrows; uint256 accountBorrowsNew; (mathErr, accountBorrowsNew) = addUInt(_accountBorrows, borrowAmount); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, uint256(mathErr) ); } uint256 totalBorrowsNew; (mathErr, totalBorrowsNew) = addUInt(totalBorrows, borrowAmount); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo.BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, uint256(mathErr) ); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = totalBorrowsNew; /* We emit a Borrow event */ emit Borrow(borrower, borrowAmount, accountBorrowsNew, totalBorrowsNew); _updateBoostBorrowBalances( borrower, oldBorrowedBalance, accountBorrowsNew ); /* We call the defense hook */ // unused function // comptroller.borrowVerify(address(this), borrower, borrowAmount); /* * We invoke doTransferOut for the borrower and the borrowAmount. * Note: The oToken must handle variations between ERC-20 and NATIVE underlying. * On success, the oToken borrowAmount less of cash. * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. */ doTransferOut(borrower, borrowAmount); return uint256(Error.NO_ERROR); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowInternal(uint256 repayAmount) internal nonReentrant returns (uint256, uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return ( fail( Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED ), 0 ); } // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, msg.sender, repayAmount); } /** * @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, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowBehalfInternal(address borrower, uint256 repayAmount) internal nonReentrant returns (uint256, uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return ( fail( Error(error), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED ), 0 ); } // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, borrower, repayAmount); } 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 undelrying tokens being returned * @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 ) internal returns (uint256, uint256) { /* Fail if repayBorrow not allowed */ uint256 allowed = comptroller.repayBorrowAllowed( address(this), payer, borrower, repayAmount ); if (allowed != 0) { return ( failOpaque( Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed ), 0 ); } /* Verify market's block timestamp equals current block timestamp */ if (accrualBlockTimestamp != getBlockTimestamp()) { return ( fail( Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK ), 0 ); } RepayBorrowLocalVars memory vars; uint256 oldBorrowedBalance = borrowBalanceStored(borrower); /* We remember the original borrowerIndex for verification purposes */ vars.borrowerIndex = accountBorrows[borrower].interestIndex; /* We fetch the amount the borrower owes, with accumulated interest */ (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal( borrower ); if (vars.mathErr != MathError.NO_ERROR) { return ( failOpaque( Error.MATH_ERROR, FailureInfo .REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr) ), 0 ); } /* If repayAmount >= accountBorrows, repayAmount = accountBorrows */ if (repayAmount >= vars.accountBorrows) { 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 oToken must handle variations between ERC-20 and NATIVE underlying. * On success, the oToken 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); /* * We calculate the new borrower and total borrow balances, failing on underflow: * accountBorrowsNew = accountBorrows - actualRepayAmount * totalBorrowsNew = totalBorrows - actualRepayAmount */ (vars.mathErr, vars.accountBorrowsNew) = subUInt( vars.accountBorrows, vars.actualRepayAmount ); require( vars.mathErr == MathError.NO_ERROR, "REPAY_NEW_ACCOUNT_BALANCE_FAILED" ); (vars.mathErr, vars.totalBorrowsNew) = subUInt( totalBorrows, vars.actualRepayAmount ); require( vars.mathErr == MathError.NO_ERROR, "REPAY_NEW_TOTAL_BALANCE_FAILED" ); /* 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 ); _updateBoostBorrowBalances( borrower, oldBorrowedBalance, vars.accountBorrowsNew ); /* We call the defense hook */ // unused function // 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 oToken to be liquidated * @param oTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @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, IOToken oTokenCollateral ) internal nonReentrant returns (uint256, uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return ( fail( Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED ), 0 ); } error = oTokenCollateral.accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return ( fail( Error(error), FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED ), 0 ); } // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to return liquidateBorrowFresh( msg.sender, borrower, repayAmount, oTokenCollateral ); } /** * @notice The liquidator liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this oToken to be liquidated * @param liquidator The address repaying the borrow and seizing collateral * @param oTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @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, IOToken oTokenCollateral ) internal returns (uint256, uint256) { /* Fail if liquidate not allowed */ uint256 allowed = comptroller.liquidateBorrowAllowed( address(this), address(oTokenCollateral), liquidator, borrower, repayAmount ); if (allowed != 0) { return ( failOpaque( Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed ), 0 ); } /* Verify market's block timestamp equals current block timestamp */ if (accrualBlockTimestamp != getBlockTimestamp()) { return ( fail( Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK ), 0 ); } /* Verify oTokenCollateral market's block timestamp equals current block timestamp */ if (oTokenCollateral.accrualBlockTimestamp() != getBlockTimestamp()) { return ( fail( Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK ), 0 ); } /* Fail if borrower = liquidator */ if (borrower == liquidator) { return ( fail( Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER ), 0 ); } /* Fail if repayAmount = 0 */ if (repayAmount == 0) { return ( fail( Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO ), 0 ); } /* Fail if repayAmount = -1 */ if (repayAmount == type(uint256).max) { return ( fail( Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX ), 0 ); } /* Fail if repayBorrow fails */ ( uint256 repayBorrowError, uint256 actualRepayAmount ) = repayBorrowFresh(liquidator, borrower, repayAmount); if (repayBorrowError != uint256(Error.NO_ERROR)) { return ( fail( Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED ), 0 ); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We calculate the number of collateral tokens that will be seized */ (uint256 amountSeizeError, uint256 seizeTokens) = comptroller .liquidateCalculateSeizeTokens( address(this), address(oTokenCollateral), actualRepayAmount ); require( amountSeizeError == uint256(Error.NO_ERROR), "LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED" ); /* Revert if borrower collateral token balance < seizeTokens */ require( oTokenCollateral.balanceOf(borrower) >= seizeTokens, "LIQUIDATE_SEIZE_TOO_MUCH" ); // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call uint256 seizeError; if (address(oTokenCollateral) == address(this)) { seizeError = seizeInternal( address(this), liquidator, borrower, seizeTokens ); } else { seizeError = oTokenCollateral.seize( liquidator, borrower, 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, actualRepayAmount, address(oTokenCollateral), seizeTokens ); /* We call the defense hook */ // unused function // comptroller.liquidateBorrowVerify(address(this), address(oTokenCollateral), liquidator, borrower, actualRepayAmount, seizeTokens); return (uint256(Error.NO_ERROR), actualRepayAmount); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Will fail unless called by another oToken during the process of liquidation. * Its absolutely critical to use msg.sender as the borrowed oToken and not a parameter. * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of oTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seize( address liquidator, address borrower, uint256 seizeTokens ) external override nonReentrant returns (uint256) { return seizeInternal(msg.sender, liquidator, borrower, seizeTokens); } struct SeizeInternalLocalVars { MathError mathErr; uint256 borrowerTokensNew; uint256 liquidatorTokensNew; uint256 liquidatorSeizeTokens; uint256 protocolSeizeTokens; uint256 protocolSeizeAmount; uint256 exchangeRateMantissa; uint256 totalReservesNew; uint256 totalSupplyNew; } /** * @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 OToken. * Its absolutely critical to use msg.sender as the seizer oToken and not a parameter. * @param seizerToken The contract seizing the collateral (i.e. borrowed oToken) * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of oTokens 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 */ uint256 allowed = comptroller.seizeAllowed( address(this), seizerToken, liquidator, borrower, seizeTokens ); if (allowed != 0) { return failOpaque( Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed ); } /* Fail if borrower = liquidator */ if (borrower == liquidator) { return fail( Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER ); } SeizeInternalLocalVars memory vars; /* * We calculate the new borrower and liquidator token balances, failing on underflow/overflow: * borrowerTokensNew = accountTokens[borrower] - seizeTokens * liquidatorTokensNew = accountTokens[liquidator] + seizeTokens */ (vars.mathErr, vars.borrowerTokensNew) = subUInt( accountTokens[borrower], seizeTokens ); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, uint256(vars.mathErr) ); } vars.protocolSeizeTokens = mul_( seizeTokens, Exp({mantissa: protocolSeizeShareMantissa}) ); vars.liquidatorSeizeTokens = seizeTokens - vars.protocolSeizeTokens; ( vars.mathErr, vars.exchangeRateMantissa ) = exchangeRateStoredInternal(); require(vars.mathErr == MathError.NO_ERROR, "exchange rate math error"); vars.protocolSeizeAmount = mul_ScalarTruncate( Exp({mantissa: vars.exchangeRateMantissa}), vars.protocolSeizeTokens ); vars.totalReservesNew = totalReserves + vars.protocolSeizeAmount; vars.totalSupplyNew = totalSupply - vars.protocolSeizeTokens; (vars.mathErr, vars.liquidatorTokensNew) = addUInt( accountTokens[liquidator], vars.liquidatorSeizeTokens ); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo.LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, uint256(vars.mathErr) ); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ _updateBoostSupplyBalances( borrower, accountTokens[borrower], vars.borrowerTokensNew ); _updateBoostSupplyBalances( liquidator, accountTokens[liquidator], vars.liquidatorTokensNew ); totalReserves = vars.totalReservesNew; totalSupply = vars.totalSupplyNew; accountTokens[borrower] = vars.borrowerTokensNew; accountTokens[liquidator] = vars.liquidatorTokensNew; /* Emit a Transfer event */ emit Transfer(borrower, liquidator, vars.liquidatorSeizeTokens); emit Transfer(borrower, address(this), vars.protocolSeizeTokens); emit ReservesAdded( address(this), vars.protocolSeizeAmount, vars.totalReservesNew ); /* We call the defense hook */ // unused function // comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens); return uint256(Error.NO_ERROR); } /*** Admin Functions ***/ function unauthorized(FailureInfo info) internal returns (uint) { return fail(Error.UNAUTHORIZED, info); } function setAdmin(address payable _admin) public { require(msg.sender == admin, "Unauthorized"); address oldAdmin = admin; admin = _admin; emit NewAdmin(oldAdmin, admin); } /** * @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 override returns (uint256) { // Check caller = admin if (msg.sender != admin) { return unauthorized(FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(pendingAdmin, newPendingAdmin); // Store pendingAdmin with value newPendingAdmin pendingAdmin = 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 override returns (uint256) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return 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 = payable(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(IComptroller newComptroller) public override returns (uint256) { // Check caller is admin if (msg.sender != admin) { return unauthorized(FailureInfo.SET_COMPTROLLER_OWNER_CHECK); } IComptroller oldComptroller = comptroller; // Ensure invoke comptroller.isComptroller() returns true require(newComptroller.isComptroller(), "marker method returned false"); // 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 override nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed. return fail( Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED ); } // _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 unauthorized(FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK); } // Verify market's block timestamp equals current block timestamp if (accrualBlockTimestamp != getBlockTimestamp()) { 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 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReservesInternal(uint256 addAmount) internal nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail( Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED ); } // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to. (error, ) = _addReservesFresh(addAmount); return error; } /** * @notice Add reserves by transferring from caller * @dev Requires fresh interest accrual * @param addAmount Amount of addition to reserves * @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) internal returns (uint256, uint256) { // totalReserves + actualAddAmount uint256 totalReservesNew; uint256 actualAddAmount; // We fail gracefully unless market's block timestamp equals current block timestamp if (accrualBlockTimestamp != getBlockTimestamp()) { 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 oToken must handle variations between ERC-20 and NATIVE underlying. * On success, the oToken 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); /* Reverts on overflow */ totalReservesNew = 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 override nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail( Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED ); } // _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 unauthorized(FailureInfo.REDUCE_RESERVES_ADMIN_CHECK); } // We fail gracefully unless market's block timestamp equals current block timestamp if (accrualBlockTimestamp != getBlockTimestamp()) { 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) // We checked reduceAmount <= totalReserves above, so this should never revert. totalReservesNew = 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. doTransferOut(admin, reduceAmount); 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(IInterestRateModel newInterestRateModel) public override returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed return fail( Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED ); } // _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(IInterestRateModel newInterestRateModel) internal returns (uint256) { // Used to store old model for use in the event that is emitted on success IInterestRateModel oldInterestRateModel; // Check caller is admin if (msg.sender != admin) { return unauthorized(FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK); } // We fail gracefully unless market's block timestamp equals current block timestamp if (accrualBlockTimestamp != getBlockTimestamp()) { 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(), "marker method returned false" ); // Set the interest rate model to newInterestRateModel interestRateModel = newInterestRateModel; // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel) emit NewMarketInterestRateModel( oldInterestRateModel, newInterestRateModel ); return uint256(Error.NO_ERROR); } /** * @notice accrues interest and updates the protocol seize share using _setProtocolSeizeShareFresh * @dev Admin function to accrue interest and update the protocol seize share * @param newProtocolSeizeShareMantissa the new protocol seize share to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setProtocolSeizeShare(uint256 newProtocolSeizeShareMantissa) external override nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of protocol seize share failed return fail( Error(error), FailureInfo.SET_PROTOCOL_SEIZE_SHARE_ACCRUE_INTEREST_FAILED ); } // _setProtocolSeizeShareFresh emits protocol-seize-share-update-specific logs on errors, so we don't need to. return _setProtocolSeizeShareFresh(newProtocolSeizeShareMantissa); } /** * @notice updates the protocol seize share (*requires fresh interest accrual) * @dev Admin function to update the protocol seize share * @param newProtocolSeizeShareMantissa the new protocol seize share to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setProtocolSeizeShareFresh(uint256 newProtocolSeizeShareMantissa) internal returns (uint256) { // Check caller is admin if (msg.sender != admin) { return unauthorized(FailureInfo.SET_PROTOCOL_SEIZE_SHARE_OWNER_CHECK); } // We fail gracefully unless market's block timestamp equals current block timestamp if (accrualBlockTimestamp != getBlockTimestamp()) { return fail( Error.MARKET_NOT_FRESH, FailureInfo.SET_PROTOCOL_SEIZE_SHARE_FRESH_CHECK ); } // Emit NewProtocolSeizeShareMantissa(oldProtocolSeizeShareMantissa, newProtocolSeizeShareMantissa) emit NewProtocolSeizeShare( protocolSeizeShareMantissa, newProtocolSeizeShareMantissa ); // Set the protocol seize share to newProtocolSeizeShareMantissa protocolSeizeShareMantissa = newProtocolSeizeShareMantissa; 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 virtual 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) internal virtual returns (uint256); /** * @dev Performs a transfer out, ideally returning an explanatory error code upon failure tather 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) internal virtual; /*** 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 } function requireNoError(uint256 errCode, string memory message) internal pure { unchecked { if (errCode == uint256(Error.NO_ERROR)) { return; } bytes memory fullMessage = new bytes(bytes(message).length + 5); uint256 i; for (i = 0; i < bytes(message).length; i++) { fullMessage[i] = bytes(message)[i]; } fullMessage[i + 0] = bytes1(uint8(32)); fullMessage[i + 1] = bytes1(uint8(40)); fullMessage[i + 2] = bytes1(uint8(48 + (errCode / 10))); fullMessage[i + 3] = bytes1(uint8(48 + (errCode % 10))); fullMessage[i + 4] = bytes1(uint8(41)); require(errCode == uint256(Error.NO_ERROR), string(fullMessage)); } } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "../interfaces/IEIP20NonStandard.sol"; import "../interfaces/IOToken.sol"; import "../interfaces/IOErc20.sol"; import "../../interfaces/IComptroller.sol"; import "../../interest-rate-models/interfaces/IInterestRateModel.sol"; abstract contract OTokenStorage is IOToken { bool public constant override isOToken = true; /** * @dev Guard variable for re-entrancy checks */ bool internal _notEntered; /** * @notice EIP-20 token name for this token */ string public override name; /** * @notice EIP-20 token symbol for this token */ string public override symbol; /** * @notice EIP-20 token decimals for this token */ uint8 public override decimals; /** * @notice Maximum borrow rate that can ever be applied (.0005% / block) */ uint internal constant borrowRateMaxMantissa = 0.0005e16; /** * @notice Maximum fraction of interest that can be set aside for reserves */ uint 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-oToken operations */ IComptroller public override comptroller; /** * @notice Model which tells what the current interest rate should be */ IInterestRateModel public interestRateModel; /** * @notice Initial exchange rate used when minting the first OTokens (used when totalSupply = 0) */ uint internal initialExchangeRateMantissa; /** * @notice Fraction of interest currently set aside for reserves */ uint public override reserveFactorMantissa; /** * @notice Block number that interest was last accrued at */ uint public override accrualBlockTimestamp; /** * @notice Accumulator of the total earned interest rate since the opening of the market */ uint public override borrowIndex; /** * @notice Total amount of outstanding borrows of the underlying in this market */ uint public override totalBorrows; /** * @notice Total amount of reserves of the underlying held in this market */ uint public totalReserves; /** * @notice Total number of tokens in circulation */ uint public override totalSupply; /** * @notice Official record of token balances for each account */ mapping (address => uint) internal accountTokens; /** * @notice Approved token transfer amounts on behalf of others */ mapping (address => mapping (address => uint)) 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 { uint principal; uint interestIndex; } /** * @notice Mapping of account addresses to outstanding borrow balances */ mapping(address => BorrowSnapshot) internal accountBorrows; /** * @notice Share of seized collateral that is added to reserves */ uint public protocolSeizeShareMantissa; }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; /** * @title ERC 20 Token Standard Interface * https://eips.ethereum.org/EIPS/eip-20 */ interface IEIP20 { 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 balance 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 success 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 success 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 success 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 remaining 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); }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; /** * @title IEIP20NonStandard * @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 IEIP20NonStandard { /** * @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 balance 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 success 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 remaining 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); }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "./IEIP20NonStandard.sol"; import "./IOToken.sol"; interface IOErc20 { /*** User Interface ***/ function mint(uint mintAmount) external; function redeem(uint redeemTokens) external; function redeemUnderlying(uint redeemAmount) external; function borrow(uint borrowAmount) external; function repayBorrow(uint repayAmount) external; function repayBorrowBehalf(address borrower, uint repayAmount) external; function liquidateBorrow(address borrower, uint repayAmount, IOToken oTokenCollateral) external; function sweepToken(IEIP20NonStandard token) external; function underlying() external view returns(address); /*** Admin Functions ***/ function _addReserves(uint addAmount) external returns (uint); }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "../../interfaces/IComptroller.sol"; import "../../interest-rate-models/interfaces/IInterestRateModel.sol"; import "./IEIP20NonStandard.sol"; import "./IEIP20.sol"; interface IOToken is IEIP20{ /** * @notice Indicator that this is a OToken contract (for inspection) */ function isOToken() external view returns(bool); /*** Market Events ***/ /** * @notice Event emitted when interest is accrued */ event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows); /** * @notice Event emitted when tokens are minted */ event Mint(address minter, uint mintAmount, uint mintTokens); /** * @notice Event emitted when tokens are redeemed */ event Redeem(address redeemer, uint redeemAmount, uint redeemTokens); /** * @notice Event emitted when underlying is borrowed */ event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is repaid */ event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is liquidated */ event LiquidateBorrow(address liquidator, address borrower, uint repayAmount, address oTokenCollateral, uint 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(IComptroller oldComptroller, IComptroller newComptroller); /** * @notice Event emitted when interestRateModel is changed */ event NewMarketInterestRateModel(IInterestRateModel oldInterestRateModel, IInterestRateModel newInterestRateModel); /** * @notice Event emitted when the reserve factor is changed */ event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa); /** * @notice Event emitted when the protocol seize share is changed */ event NewProtocolSeizeShare(uint oldProtocolSeizeShareMantissa, uint newProtocolSeizeShareMantissa); /** * @notice Event emitted when the reserves are added */ event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves); /** * @notice Event emitted when the reserves are reduced */ event ReservesReduced(address admin, uint reduceAmount, uint newTotalReserves); function accrualBlockTimestamp() external returns(uint256); /*** User Interface ***/ function balanceOfUnderlying(address owner) external returns (uint); function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint); function borrowRatePerTimestamp() external view returns (uint); function supplyRatePerTimestamp() external view returns (uint); function totalBorrowsCurrent() external returns (uint); function borrowBalanceCurrent(address account) external returns (uint); function borrowBalanceStored(address account) external view returns (uint); function exchangeRateCurrent() external returns (uint); function exchangeRateStored() external view returns (uint); function getCash() external view returns (uint); function accrueInterest() external returns (uint); function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint); function totalBorrows() external view returns(uint); function comptroller() external view returns(IComptroller); function borrowIndex() external view returns(uint); function reserveFactorMantissa() external view returns(uint); /*** Admin Functions ***/ function _setPendingAdmin(address payable newPendingAdmin) external returns (uint); function _acceptAdmin() external returns (uint); function _setComptroller(IComptroller newComptroller) external returns (uint); function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint); function _reduceReserves(uint reduceAmount) external returns (uint); function _setInterestRateModel(IInterestRateModel newInterestRateModel) external returns (uint); function _setProtocolSeizeShare(uint newProtocolSeizeShareMantissa) external returns (uint); }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "./otokens/interfaces/IOToken.sol"; abstract contract PriceOracle { /// @notice Indicator that this is a PriceOracle contract (for inspection) bool public constant isPriceOracle = true; /** * @notice Get the underlying price of a oToken asset * @param oToken The oToken to get the underlying price of * @return The underlying asset price mantissa (scaled by 1e18). * Zero means the price is unavailable. */ function getUnderlyingPrice(IOToken oToken) external virtual view returns (uint); }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IBoostManager { function updateBoostBasis(address user) external returns (bool); function updateBoostSupplyBalances( address market, address user, uint256 oldBalance, uint256 newBalance ) external; function updateBoostBorrowBalances( address market, address user, uint256 oldBalance, uint256 newBalance ) external; function boostedSupplyBalanceOf(address market, address user) external view returns (uint256); function boostedBorrowBalanceOf(address market, address user) external view returns (uint256); function boostedTotalSupply(address market) external view returns (uint256); function boostedTotalBorrows(address market) external view returns (uint256); function setAuthorized(address addr, bool flag) external; function setVeOVIX(IERC20 ve) external; function isAuthorized(address addr) external view returns (bool); }
{ "optimizer": { "enabled": true, "runs": 10 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"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":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":"oTokenCollateral","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 IComptroller","name":"oldComptroller","type":"address"},{"indexed":false,"internalType":"contract IComptroller","name":"newComptroller","type":"address"}],"name":"NewComptroller","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IInterestRateModel","name":"oldInterestRateModel","type":"address"},{"indexed":false,"internalType":"contract IInterestRateModel","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":"oldProtocolSeizeShareMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newProtocolSeizeShareMantissa","type":"uint256"}],"name":"NewProtocolSeizeShare","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"},{"inputs":[],"name":"_acceptAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"addAmount","type":"uint256"}],"name":"_addReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reduceAmount","type":"uint256"}],"name":"_reduceReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IComptroller","name":"newComptroller","type":"address"}],"name":"_setComptroller","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IInterestRateModel","name":"newInterestRateModel","type":"address"}],"name":"_setInterestRateModel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newPendingAdmin","type":"address"}],"name":"_setPendingAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newProtocolSeizeShareMantissa","type":"uint256"}],"name":"_setProtocolSeizeShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newReserveFactorMantissa","type":"uint256"}],"name":"_setReserveFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accrualBlockTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accrueInterest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOfUnderlying","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"borrowBalanceCurrent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"borrowBalanceStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowRatePerTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"comptroller","outputs":[{"internalType":"contract IComptroller","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exchangeRateCurrent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"exchangeRateStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"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"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCash","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"underlying_","type":"address"},{"internalType":"contract IComptroller","name":"comptroller_","type":"address"},{"internalType":"contract IInterestRateModel","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":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"interestRateModel","outputs":[{"internalType":"contract IInterestRateModel","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isInit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isOToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"repayAmount","type":"uint256"},{"internalType":"contract IOToken","name":"oTokenCollateral","type":"address"}],"name":"liquidateBorrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingAdmin","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolSeizeShareMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemUnderlying","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"repayAmount","type":"uint256"}],"name":"repayBorrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"repayAmount","type":"uint256"}],"name":"repayBorrowBehalf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reserveFactorMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"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"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_admin","type":"address"}],"name":"setAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"supplyRatePerTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IEIP20NonStandard","name":"token","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBorrows","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBorrowsCurrent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"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"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60806040526012805460ff60a01b1916600160a01b17905534801561002357600080fd5b50615e4a80620000346000396000f3fe608060405234801561001057600080fd5b506004361061025c5760003560e01c806306fdde0314610261578063095ea7b31461027f5780630e752702146102a2578063173b9904146102b757806317bfdfbc146102ce57806318160ddd146102e1578063182df0f5146102ea5780631be19560146102f257806323b872dd146103055780632608f81814610318578063267822471461032b578063313ce5671461034b5780633af9e6691461036a5780633b1d21a21461037d5780633e941010146103855780634576b5db1461039857806347bd3718146103ab5780635fe3b567146103b4578063601a0bf1146103c75780636752e702146103da5780636f307dc3146103e3578063704b6c02146103f657806370a082311461040957806373acee9814610432578063830308461461043a578063852a12e31461044d5780638f840ddd1461046057806395d89b411461046957806395dd91931461047157806397de9d1114610484578063a0712d681461048c578063a6afed951461049f578063a9059cbb146104a7578063aa5af0fd146104ba578063afe65468146104c3578063b145a5b8146104d6578063b2a02ff1146104ea578063b71d1a0c146104fd578063bd6d894d14610510578063c37f68e214610518578063c5ebeaec1461053b578063cd91801c1461054e578063cfa9920114610556578063d3bd2c721461055f578063db006a7514610567578063dd62ed3e1461057a578063e9c714f2146105b3578063f2b3abbd146105bb578063f3fdb15a146105ce578063f5e3c462146105e1578063f851a440146105f4578063fca7820b1461060c575b600080fd5b61026961061f565b6040516102769190615b79565b60405180910390f35b61029261028d366004615988565b6106ad565b6040519015158152602001610276565b6102b56102b0366004615a14565b61071d565b005b6102c060085481565b604051908152602001610276565b6102c06102dc36600461581d565b610763565b6102c0600d5481565b6102c06107dc565b6102b561030036600461581d565b610859565b61029261031336600461588d565b610b10565b6102b5610326366004615988565b610b60565b60045461033e906001600160a01b031681565b6040516102769190615a67565b6003546103589060ff1681565b60405160ff9091168152602001610276565b6102c061037836600461581d565b610ba9565b6102c0610c67565b6102c0610393366004615a14565b610c76565b6102c06103a636600461581d565b610c81565b6102c0600b5481565b60055461033e906001600160a01b031681565b6102c06103d5366004615a14565b610d9d565b6102c060115481565b60125461033e906001600160a01b031681565b6102b561040436600461581d565b610e2a565b6102c061041736600461581d565b6001600160a01b03166000908152600e602052604090205490565b6102c0610ed6565b6102c0610448366004615a14565b610f3c565b6102b561045b366004615a14565b610fac565b6102c0600c5481565b610269610fb5565b6102c061047f36600461581d565b610fc2565b610292600181565b6102b561049a366004615a14565b611041565b6102c061107c565b6102926104b5366004615988565b61147f565b6102c0600a5481565b6102b56104d13660046158cd565b6114ce565b60125461029290600160a01b900460ff1681565b6102c06104f836600461588d565b6115f7565b6102c061050b36600461581d565b611646565b6102c06116c1565b61052b61052636600461581d565b61172d565b6040516102769493929190615c6c565b6102b5610549366004615a14565b6117ea565b6102c06117f3565b6102c060095481565b6102c0611883565b6102b5610575366004615a14565b6118c7565b6102c0610588366004615855565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6102c06118d0565b6102c06105c936600461581d565b6119a0565b60065461033e906001600160a01b031681565b6102b56105ef3660046159b3565b6119e6565b60035461033e9061010090046001600160a01b031681565b6102c061061a366004615a14565b611a34565b6001805461062c90615cf5565b80601f016020809104026020016040519081016040528092919081815260200182805461065890615cf5565b80156106a55780601f1061067a576101008083540402835291602001916106a5565b820191906000526020600020905b81548152906001019060200180831161068857829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855292528083208590555191929182907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906107099087815260200190565b60405180910390a360019150505b92915050565b600061072882611aa4565b50905061075f81604051806040016040528060128152602001711c995c185e509bdc9c9bddc819985a5b195960721b815250611b3e565b5050565b6000805460ff1661078f5760405162461bcd60e51b815260040161078690615c32565b60405180910390fd5b6000805460ff191681556107a161107c565b146107be5760405162461bcd60e51b815260040161078690615bcc565b6107c782610fc2565b90505b6000805460ff19166001179055919050565b60008060006107e9611d82565b9092509050600082600381111561081057634e487b7160e01b600052602160045260246000fd5b146107175760405162461bcd60e51b8152602060048201526019602482015278195e18da185b99d954985d1954dd1bdc99590819985a5b1959603a1b6044820152606401610786565b6012546001600160a01b03828116911614156108d25760405162461bcd60e51b815260206004820152603260248201527f4f45726332303a3a7377656570546f6b656e3a2063616e206e6f74207377656560448201527138103ab73232b9363cb4b733903a37b5b2b760711b6064820152608401610786565b6012546040516370a0823160e01b81526000916001600160a01b0316906370a0823190610903903090600401615a67565b60206040518083038186803b15801561091b57600080fd5b505afa15801561092f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109539190615a2c565b90506000826001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016109839190615a67565b60206040518083038186803b15801561099b57600080fd5b505afa1580156109af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d39190615a2c565b60035460405163a9059cbb60e01b81529192506001600160a01b038086169263a9059cbb92610a0e9261010090910416908590600401615a95565b600060405180830381600087803b158015610a2857600080fd5b505af1158015610a3c573d6000803e3d6000fd5b50506012546040516370a0823160e01b81526001600160a01b0390911692506370a082319150610a70903090600401615a67565b60206040518083038186803b158015610a8857600080fd5b505afa158015610a9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac09190615a2c565b8214610b0b5760405162461bcd60e51b815260206004820152601a6024820152791d5b99195c9b1e5a5b99c818985b185b98d94818da185b99d95960321b6044820152606401610786565b505050565b6000805460ff16610b335760405162461bcd60e51b815260040161078690615c32565b6000805460ff19168155610b4933868686611e4c565b1490506000805460ff191660011790559392505050565b6000610b6c83836122a6565b509050610b0b81604051806040016040528060188152602001771c995c185e509bdc9c9bddd0995a185b198819985a5b195960421b815250611b3e565b6000806040518060200160405280610bbf6116c1565b90526001600160a01b0384166000908152600e6020526040812054919250908190610beb908490612342565b90925090506000826003811115610c1257634e487b7160e01b600052602160045260246000fd5b14610c5f5760405162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c61746564006044820152606401610786565b949350505050565b6000610c716123a3565b905090565b60006107178261242c565b60035460009061010090046001600160a01b03163314610ca557610717603f6124b2565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b158015610cea57600080fd5b505afa158015610cfe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d2291906159f4565b610d3e5760405162461bcd60e51b815260040161078690615bfc565b600580546001600160a01b0319166001600160a01b0385161790556040517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d90610d8b9083908690615a7b565b60405180910390a160005b9392505050565b6000805460ff16610dc05760405162461bcd60e51b815260040161078690615c32565b6000805460ff19168155610dd261107c565b90508015610e0c57610e04816010811115610dfd57634e487b7160e01b600052602160045260246000fd5b60306124bb565b9150506107ca565b610e1583612545565b9150506000805460ff19166001179055919050565b60035461010090046001600160a01b03163314610e785760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610786565b600380546001600160a01b03838116610100908102610100600160a81b03198416179384905560405192819004821693600080516020615df583398151915293610eca93869390920490911690615a7b565b60405180910390a15050565b6000805460ff16610ef95760405162461bcd60e51b815260040161078690615c32565b6000805460ff19168155610f0b61107c565b14610f285760405162461bcd60e51b815260040161078690615bcc565b50600b546000805460ff1916600117905590565b6000805460ff16610f5f5760405162461bcd60e51b815260040161078690615c32565b6000805460ff19168155610f7161107c565b90508015610fa357610e04816010811115610f9c57634e487b7160e01b600052602160045260246000fd5b60516124bb565b610e158361262a565b61075f816126ab565b6002805461062c90615cf5565b6000806000610fd08461271e565b90925090506000826003811115610ff757634e487b7160e01b600052602160045260246000fd5b14610d965760405162461bcd60e51b815260206004820152601a602482015279189bdc9c9bddd0985b185b98d954dd1bdc99590819985a5b195960321b6044820152606401610786565b600061104c826127f3565b50905061075f816040518060400160405280600b81526020016a1b5a5b9d0819985a5b195960aa1b815250611b3e565b6009546000904290808214156110965760005b9250505090565b60006110a06123a3565b600b54600c54600a546006546040516315f2405360e01b81529495509293919290916000916001600160a01b0316906315f24053906110e790889088908890600401615c56565b60206040518083038186803b1580156110ff57600080fd5b505afa158015611113573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111379190615a2c565b905065048c2739500081111561118e5760405162461bcd60e51b815260206004820152601c60248201527b0c4dee4e4deee40e4c2e8ca40d2e640c2c4e6eae4c8d8f240d0d2ced60231b6044820152606401610786565b60008061119b8989612866565b909250905060008260038111156111c257634e487b7160e01b600052602160045260246000fd5b1461120f5760405162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c7461006044820152606401610786565b6112176156eb565b60008060008061123560405180602001604052808a81525087612889565b9097509450600087600381111561125c57634e487b7160e01b600052602160045260246000fd5b146112a05761128d6009600689600381111561128857634e487b7160e01b600052602160045260246000fd5b612905565b9e50505050505050505050505050505090565b6112aa858c612342565b909750935060008760038111156112d157634e487b7160e01b600052602160045260246000fd5b146112fd5761128d6009600189600381111561128857634e487b7160e01b600052602160045260246000fd5b611307848c61298e565b9097509250600087600381111561132e57634e487b7160e01b600052602160045260246000fd5b1461135a5761128d6009600489600381111561128857634e487b7160e01b600052602160045260246000fd5b6113756040518060200160405280600854815250858c6129b4565b9097509150600087600381111561139c57634e487b7160e01b600052602160045260246000fd5b146113c85761128d6009600589600381111561128857634e487b7160e01b600052602160045260246000fd5b6113d3858a8b6129b4565b909750905060008760038111156113fa57634e487b7160e01b600052602160045260246000fd5b146114265761128d6009600389600381111561128857634e487b7160e01b600052602160045260246000fd5b60098e9055600a819055600b839055600c8290556040517f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc0490611470908e90879085908890615c6c565b60405180910390a1600061128d565b6000805460ff166114a25760405162461bcd60e51b815260040161078690615c32565b6000805460ff191681556114b833338686611e4c565b1490506000805460ff1916600117905592915050565b601254600160a01b900460ff16156115275760405162461bcd60e51b815260206004820152601c60248201527b18dbdb9d1c9858dd08185b1c9958591e481a5b9a5d1a585b1a5e995960221b6044820152606401610786565b6012805460ff60a01b1916600160a01b179055600380543361010002610100600160a81b0319909116179055611561868686868686612a1d565b601280546001600160a01b0319166001600160a01b038916908117909155604080516318160ddd60e01b815290516318160ddd91600480820192602092909190829003018186803b1580156115b557600080fd5b505afa1580156115c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ed9190615a2c565b5050505050505050565b6000805460ff1661161a5760405162461bcd60e51b815260040161078690615c32565b6000805460ff1916905561163033858585612c22565b90506000805460ff191660011790559392505050565b60035460009061010090046001600160a01b0316331461166a5761071760456124b2565b600454604051600080516020615db583398151915291611697916001600160a01b03909116908590615a7b565b60405180910390a1600480546001600160a01b0319166001600160a01b0384161790556000610717565b6000805460ff166116e45760405162461bcd60e51b815260040161078690615c32565b6000805460ff191681556116f661107c565b146117135760405162461bcd60e51b815260040161078690615bcc565b61171b6107dc565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600e60205260408120548190819081908180806117588961271e565b93509050600081600381111561177e57634e487b7160e01b600052602160045260246000fd5b1461179c5760095b60008060009750975097509750505050506117e3565b6117a4611d82565b9250905060008160038111156117ca57634e487b7160e01b600052602160045260246000fd5b146117d6576009611786565b5060009650919450925090505b9193509193565b61075f8161315d565b6006546000906001600160a01b03166315f2405361180f6123a3565b600b54600c546040518463ffffffff1660e01b815260040161183393929190615c56565b60206040518083038186803b15801561184b57600080fd5b505afa15801561185f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c719190615a2c565b6006546000906001600160a01b031663b816881661189f6123a3565b600b54600c546008546040518563ffffffff1660e01b81526004016118339493929190615c6c565b61075f816131ce565b6004546000906001600160a01b0316331415806118eb575033155b156118fa57610c7160006124b2565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b0319909316909355604051938290048116949293600080516020615df58339815191529361195e93879391041690615a7b565b60405180910390a1600454604051600080516020615db5833981519152916119919184916001600160a01b031690615a7b565b60405180910390a1600061108f565b6000806119ab61107c565b905080156119dd57610d968160108111156119d657634e487b7160e01b600052602160045260246000fd5b60406124bb565b610d968361323a565b60006119f3848484613367565b509050611a2e81604051806040016040528060168152602001751b1a5c5d5a59185d19509bdc9c9bddc819985a5b195960521b815250611b3e565b50505050565b6000805460ff16611a575760405162461bcd60e51b815260040161078690615c32565b6000805460ff19168155611a6961107c565b90508015611a9b57610e04816010811115611a9457634e487b7160e01b600052602160045260246000fd5b60466124bb565b610e15836134aa565b60008054819060ff16611ac95760405162461bcd60e51b815260040161078690615c32565b6000805460ff19168155611adb61107c565b90508015611b1957611b0d816010811115611b0657634e487b7160e01b600052602160045260246000fd5b60366124bb565b60009250925050611b2a565b611b2433338661353d565b92509250505b6000805460ff191660011790559092909150565b81611b47575050565b600081516005016001600160401b03811115611b7357634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611b9d576020820181803683370190505b50905060005b8251811015611c1657828181518110611bcc57634e487b7160e01b600052603260045260246000fd5b602001015160f81c60f81b828281518110611bf757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600101611ba3565b8151600160fd1b90839083908110611c3e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602860f81b828260010181518110611c7d57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840460300160f81b828260020181518110611cc157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840660300160f81b828260030181518110611d0557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602960f81b828260040181518110611d4457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350818415611d7b5760405162461bcd60e51b81526004016107869190615b79565b5050505050565b600d54600090819080611d9c575050600754600092909150565b6000611da66123a3565b90506000611db26156eb565b6000611dc384600b54600c546139d3565b935090506000816003811115611de957634e487b7160e01b600052602160045260246000fd5b14611dfb579660009650945050505050565b611e058386613a25565b925090506000816003811115611e2b57634e487b7160e01b600052602160045260246000fd5b14611e3d579660009650945050505050565b50516000969095509350505050565b6005546040516317b9b84b60e31b815260009182916001600160a01b039091169063bdcdc25890611e87903090899089908990600401615b4f565b602060405180830381600087803b158015611ea157600080fd5b505af1158015611eb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed99190615a2c565b90508015611f275760405162461bcd60e51b815260206004820152601b60248201527a115490cc8c0e881d1c985b9cd9995c881b9bdd08185b1b1bddd959602a1b6044820152606401610786565b836001600160a01b0316856001600160a01b03161415611f895760405162461bcd60e51b815260206004820181905260248201527f45524332303a2073656c662d7472616e73666572206e6f7420616c6c6f7765646044820152606401610786565b6000856001600160a01b0316876001600160a01b03161415611fae5750600019611fd6565b506001600160a01b038086166000908152600f60209081526040808320938a16835292905220545b600080600080611fe68589612866565b9094509250600084600381111561200d57634e487b7160e01b600052602160045260246000fd5b146120685760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610786565b6001600160a01b038a166000908152600e602052604090205461208b9089612866565b909450915060008460038111156120b257634e487b7160e01b600052602160045260246000fd5b1461210e5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610786565b6001600160a01b0389166000908152600e6020526040902054612131908961298e565b9094509050600084600381111561215857634e487b7160e01b600052602160045260246000fd5b146121b85760405162461bcd60e51b815260206004820152602a60248201527f45524332303a206d6178696d756d2064657374696e6174696f6e2062616c616e60448201526918d9481c995858da195960b21b6064820152608401610786565b6001600160a01b038a166000908152600e60205260409020546121dd908b9084613afe565b6001600160a01b0389166000908152600e6020526040902054612202908a9083613afe565b6001600160a01b03808b166000908152600e6020526040808220859055918b16815220819055600019851461225a576001600160a01b03808b166000908152600f60209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b0316600080516020615dd58339815191528a60405161228d91815260200190565b60405180910390a35060009a9950505050505050505050565b60008054819060ff166122cb5760405162461bcd60e51b815260040161078690615c32565b6000805460ff191681556122dd61107c565b9050801561231b5761230f81601081111561230857634e487b7160e01b600052602160045260246000fd5b60356124bb565b6000925092505061232c565b61232633868661353d565b92509250505b6000805460ff1916600117905590939092509050565b6000806000806123528686612889565b9092509050600082600381111561237957634e487b7160e01b600052602160045260246000fd5b1461238a575091506000905061239c565b600061239582613c71565b9350935050505b9250929050565b6012546040516370a0823160e01b81526000916001600160a01b03169081906370a08231906123d6903090600401615a67565b60206040518083038186803b1580156123ee57600080fd5b505afa158015612402573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124269190615a2c565b91505090565b6000805460ff1661244f5760405162461bcd60e51b815260040161078690615c32565b6000805460ff1916815561246161107c565b9050801561249357610e0481601081111561248c57634e487b7160e01b600052602160045260246000fd5b604e6124bb565b61249c83613c89565b509150506000805460ff19166001179055919050565b60006107176001835b6000600080516020615d958339815191528360108111156124ec57634e487b7160e01b600052602160045260246000fd5b83605381111561250c57634e487b7160e01b600052602160045260246000fd5b600060405161251d93929190615c56565b60405180910390a1826010811115610d9657634e487b7160e01b600052602160045260246000fd5b600354600090819061010090046001600160a01b0316331461256b57610d9660316124b2565b426009541461258057610d96600a60336124bb565b826125896123a3565b101561259b57610d96600e60326124bb565b600c548311156125b157610d96600260346124bb565b82600c546125bf9190615cde565b600c8190556003549091506125e29061010090046001600160a01b031684613d00565b7f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e600360019054906101000a90046001600160a01b03168483604051610d8b93929190615aae565b60035460009061010090046001600160a01b0316331461264e5761071760526124b2565b426009541461266357610717600a60536124bb565b60115460408051918252602082018490527ff5815f353a60e815cce7553e4f60c533a59d26b1b5504ea4b6db8d60da3e4da2910160405180910390a160118290556000610717565b6000805460ff166126ce5760405162461bcd60e51b815260040161078690615c32565b6000805460ff191681556126e061107c565b9050801561271257610e0481601081111561270b57634e487b7160e01b600052602160045260246000fd5b60276124bb565b610e1533600085613dde565b6001600160a01b0381166000908152601060205260408120805482918291829182916127535750600096879650945050505050565b6127638160000154600a54614544565b9094509250600084600381111561278a57634e487b7160e01b600052602160045260246000fd5b1461279d57509195600095509350505050565b6127ab838260010154614597565b909450915060008460038111156127d257634e487b7160e01b600052602160045260246000fd5b146127e557509195600095509350505050565b506000969095509350505050565b60008054819060ff166128185760405162461bcd60e51b815260040161078690615c32565b6000805460ff1916815561282a61107c565b9050801561285c57611b0d81601081111561285557634e487b7160e01b600052602160045260246000fd5b601e6124bb565b611b2433856145d6565b60008083831161287d57506000905081830361239c565b5060039050600061239c565b60006128936156eb565b6000806128a4866000015186614544565b909250905060008260038111156128cb57634e487b7160e01b600052602160045260246000fd5b146128ea5750604080516020810190915260008152909250905061239c565b60408051602081019091529081526000969095509350505050565b6000600080516020615d9583398151915284601081111561293657634e487b7160e01b600052602160045260246000fd5b84605381111561295657634e487b7160e01b600052602160045260246000fd5b8460405161296693929190615c56565b60405180910390a1836010811115610c5f57634e487b7160e01b600052602160045260246000fd5b6000808383018481106129a65760009250905061239c565b60026000925092505061239c565b6000806000806129c48787612889565b909250905060008260038111156129eb57634e487b7160e01b600052602160045260246000fd5b146129fc5750915060009050612a15565b612a0e612a0882613c71565b8661298e565b9350935050505b935093915050565b60035461010090046001600160a01b03163314612a785760405162461bcd60e51b81526020600482015260196024820152786f6e6c792061646d696e206d617920696e697469616c697a6560381b6044820152606401610786565b600954158015612a885750600a54155b612aca5760405162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610786565b600784905583612b1c5760405162461bcd60e51b815260206004820152601e60248201527f696e69742065786368616e67652072617465206d757374206265203e203000006044820152606401610786565b6000612b2787610c81565b14612b6d5760405162461bcd60e51b81526020600482015260166024820152751cd95d0818dbdb5c1d1c9bdb1b195c8819985a5b195960521b6044820152606401610786565b42600955670de0b6b3a7640000600a556000612b888661323a565b14612bd55760405162461bcd60e51b815260206004820152601e60248201527f73657420696e7465726573742072617465206d6f64656c206661696c656400006044820152606401610786565b8251612be89060019060208601906156fe565b508151612bfc9060029060208501906156fe565b506003805460ff90921660ff199283161790556000805490911660011790555050505050565b60055460405163d02f735160e01b815260009182916001600160a01b039091169063d02f735190612c5f9030908a908a908a908a90600401615b1c565b602060405180830381600087803b158015612c7957600080fd5b505af1158015612c8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb19190615a2c565b90508015612cce57612cc66003601b83612905565b915050610c5f565b846001600160a01b0316846001600160a01b03161415612cf457612cc66006601c6124bb565b612d44604080516101208101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0385166000908152600e6020526040902054612d679085612866565b6020830181905282826003811115612d8f57634e487b7160e01b600052602160045260246000fd5b6003811115612dae57634e487b7160e01b600052602160045260246000fd5b9052506000905081516003811115612dd657634e487b7160e01b600052602160045260246000fd5b14612e0f57612e066009601a8360000151600381111561128857634e487b7160e01b600052602160045260246000fd5b92505050610c5f565b612e29846040518060200160405280601154815250614ac3565b60808201819052612e3a9085615cde565b6060820152612e47611d82565b60c0830181905282826003811115612e6f57634e487b7160e01b600052602160045260246000fd5b6003811115612e8e57634e487b7160e01b600052602160045260246000fd5b9052506000905081516003811115612eb657634e487b7160e01b600052602160045260246000fd5b14612efe5760405162461bcd60e51b815260206004820152601860248201527732bc31b430b733b2903930ba329036b0ba341032b93937b960411b6044820152606401610786565b612f1e60405180602001604052808360c001518152508260800151614ae6565b60a08201819052600c54612f329190615c87565b60e08201526080810151600d54612f499190615cde565b6101008201526001600160a01b0386166000908152600e60205260409020546060820151612f77919061298e565b6040830181905282826003811115612f9f57634e487b7160e01b600052602160045260246000fd5b6003811115612fbe57634e487b7160e01b600052602160045260246000fd5b9052506000905081516003811115612fe657634e487b7160e01b600052602160045260246000fd5b1461301657612e06600960198360000151600381111561128857634e487b7160e01b600052602160045260246000fd5b61304a85600e6000886001600160a01b03166001600160a01b03168152602001908152602001600020548360200151613afe565b6001600160a01b0386166000908152600e6020526040908190205490820151613074918891613afe565b60e0810151600c55610100810151600d556020808201516001600160a01b038781166000818152600e855260408082209490945583860151928b1680825290849020929092556060850151925192835290929091600080516020615dd5833981519152910160405180910390a3306001600160a01b0316856001600160a01b0316600080516020615dd5833981519152836080015160405161311891815260200190565b60405180910390a360a081015160e0820151604051600080516020615d7583398151915292613148923092615aae565b60405180910390a16000979650505050505050565b6000805460ff166131805760405162461bcd60e51b815260040161078690615c32565b6000805460ff1916815561319261107c565b905080156131c457610e048160108111156131bd57634e487b7160e01b600052602160045260246000fd5b60086124bb565b610e153384614afa565b6000805460ff166131f15760405162461bcd60e51b815260040161078690615c32565b6000805460ff1916815561320361107c565b9050801561322e57610e0481601081111561270b57634e487b7160e01b600052602160045260246000fd5b610e1533846000613dde565b600354600090819061010090046001600160a01b0316331461326057610d9660426124b2565b426009541461327557610d96600a60416124bb565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156132c657600080fd5b505afa1580156132da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132fe91906159f4565b61331a5760405162461bcd60e51b815260040161078690615bfc565b600680546001600160a01b0319166001600160a01b0385161790556040517fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f92690610d8b9083908690615a7b565b60008054819060ff1661338c5760405162461bcd60e51b815260040161078690615c32565b6000805460ff1916815561339e61107c565b905080156133dc576133d08160108111156133c957634e487b7160e01b600052602160045260246000fd5b600f6124bb565b60009250925050613493565b836001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561341757600080fd5b505af115801561342b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061344f9190615a2c565b90508015613481576133d081601081111561347a57634e487b7160e01b600052602160045260246000fd5b60106124bb565b61348d33878787614dac565b92509250505b6000805460ff191660011790559094909350915050565b60035460009061010090046001600160a01b031633146134ce5761071760476124b2565b42600954146134e357610717600a60486124bb565b670de0b6b3a76400008211156134ff57610717600260496124bb565b600880549083905560408051828152602081018590527faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f8214609101610d8b565b600554604051631200453160e11b8152600091829182916001600160a01b0316906324008a62906135789030908a908a908a90600401615b4f565b602060405180830381600087803b15801561359257600080fd5b505af11580156135a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135ca9190615a2c565b905080156135eb576135df6003603883612905565b60009250925050612a15565b4260095414613600576135df600a60396124bb565b6136496040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b600061365487610fc2565b6001600160a01b038816600090815260106020526040902060010154606084015290506136808761271e565b60808401819052602084018260038111156136ab57634e487b7160e01b600052602160045260246000fd5b60038111156136ca57634e487b7160e01b600052602160045260246000fd5b90525060009050826020015160038111156136f557634e487b7160e01b600052602160045260246000fd5b1461373357613725600960378460200151600381111561128857634e487b7160e01b600052602160045260246000fd5b600094509450505050612a15565b8160800151861061374d5760808201516040830152613755565b604082018690525b6137638883604001516152b1565b60e08301819052608083015161377891612866565b60a08401819052602084018260038111156137a357634e487b7160e01b600052602160045260246000fd5b60038111156137c257634e487b7160e01b600052602160045260246000fd5b90525060009050826020015160038111156137ed57634e487b7160e01b600052602160045260246000fd5b1461383a5760405162461bcd60e51b815260206004820181905260248201527f52455041595f4e45575f4143434f554e545f42414c414e43455f4641494c45446044820152606401610786565b61384a600b548360e00151612866565b60c084018190526020840182600381111561387557634e487b7160e01b600052602160045260246000fd5b600381111561389457634e487b7160e01b600052602160045260246000fd5b90525060009050826020015160038111156138bf57634e487b7160e01b600052602160045260246000fd5b1461390c5760405162461bcd60e51b815260206004820152601e60248201527f52455041595f4e45575f544f54414c5f42414c414e43455f4641494c454400006044820152606401610786565b60a0820180516001600160a01b03891660009081526010602052604090819020918255600a5460019092019190915560c0840151600b81905560e0850151925191517f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1936139a9938d938d936001600160a01b03958616815293909416602084015260408301919091526060820152608081019190915260a00190565b60405180910390a16139c087828460a001516154f7565b5060e00151600097909650945050505050565b6000806000806139e3878761298e565b90925090506000826003811115613a0a57634e487b7160e01b600052602160045260246000fd5b14613a1b5750915060009050612a15565b612a0e8186612866565b6000613a2f6156eb565b600080613a4486670de0b6b3a7640000614544565b90925090506000826003811115613a6b57634e487b7160e01b600052602160045260246000fd5b14613a8a5750604080516020810190915260008152909250905061239c565b600080613a978388614597565b90925090506000826003811115613abe57634e487b7160e01b600052602160045260246000fd5b14613ae1578160405180602001604052806000815250955095505050505061239c565b604080516020810190915290815260009890975095505050505050565b600554604080516312ab2eaf60e21b815290516000926001600160a01b031691634aacbabc916004808301926020929190829003018186803b158015613b4357600080fd5b505afa158015613b57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b7b9190615839565b90506001600160a01b03811615801590613c0c57506040516301fd3f7760e71b81526001600160a01b0382169063fe9fbb8090613bbc903090600401615a67565b60206040518083038186803b158015613bd457600080fd5b505afa158015613be8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c0c91906159f4565b15611a2e57604051639eba1f6760e01b81526001600160a01b03821690639eba1f6790613c43903090889088908890600401615af3565b600060405180830381600087803b158015613c5d57600080fd5b505af11580156115ed573d6000803e3d6000fd5b805160009061071790670de0b6b3a764000090615c9f565b60008080804260095414613cad57613ca3600a604f6124bb565b9590945092505050565b613cb733866152b1565b905080600c54613cc79190615c87565b915081600c81905550600080516020615d75833981519152338284604051613cf193929190615aae565b60405180910390a16000613ca3565b60125460405163a9059cbb60e01b81526001600160a01b0390911690819063a9059cbb90613d349086908690600401615a95565b600060405180830381600087803b158015613d4e57600080fd5b505af1158015613d62573d6000803e3d6000fd5b5050505060003d60008114613d7e5760208114613d8857600080fd5b6000199150613d94565b60206000803e60005191505b5080611a2e5760405162461bcd60e51b81526020600482015260196024820152781513d2d15397d514905394d1915497d3d55517d19052531151603a1b6044820152606401610786565b6000821580613deb575081155b613e375760405162461bcd60e51b815260206004820152601e60248201527f746f6b656e73496e206f7220616d6f756e74496e206d757374206265203000006044820152606401610786565b613e786040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b613e80611d82565b6040830181905260208301826003811115613eab57634e487b7160e01b600052602160045260246000fd5b6003811115613eca57634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613ef557634e487b7160e01b600052602160045260246000fd5b14613f2d57613f256009602b8360200151600381111561128857634e487b7160e01b600052602160045260246000fd5b915050610d96565b8315614047576001600160a01b0385166000908152600e60205260409020548410613f75576001600160a01b0385166000908152600e60205260409020546060820152613f7d565b606081018490525b613f9d604051806020016040528083604001518152508260600151612342565b6080830181905260208301826003811115613fc857634e487b7160e01b600052602160045260246000fd5b6003811115613fe757634e487b7160e01b600052602160045260246000fd5b905250600090508160200151600381111561401257634e487b7160e01b600052602160045260246000fd5b1461404257613f25600960298360200151600381111561128857634e487b7160e01b600052602160045260246000fd5b614155565b60001983141561408e576001600160a01b0385166000908152600e60209081526040918290205460608401908152825191820183529183015181529051613f9d9190612342565b60808101839052604080516020810182529082015181526140b090849061563c565b60608301819052602083018260038111156140db57634e487b7160e01b600052602160045260246000fd5b60038111156140fa57634e487b7160e01b600052602160045260246000fd5b905250600090508160200151600381111561412557634e487b7160e01b600052602160045260246000fd5b1461415557613f256009602a8360200151600381111561128857634e487b7160e01b600052602160045260246000fd5b600554606082015160405163eabe7d9160e01b81526000926001600160a01b03169163eabe7d919161418e9130918b9190600401615acf565b602060405180830381600087803b1580156141a857600080fd5b505af11580156141bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141e09190615a2c565b905080156141fe576141f56003602883612905565b92505050610d96565b4260095414614213576141f5600a602c6124bb565b614223600d548360600151612866565b60a084018190526020840182600381111561424e57634e487b7160e01b600052602160045260246000fd5b600381111561426d57634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561429857634e487b7160e01b600052602160045260246000fd5b146142c8576141f56009602e8460200151600381111561128857634e487b7160e01b600052602160045260246000fd5b6001600160a01b0386166000908152600e60205260409020546060830151111561430b576001600160a01b0386166000908152600e602052604090205460608301525b6001600160a01b0386166000908152600e602052604090205460608301516143339190612866565b60c084018190526020840182600381111561435e57634e487b7160e01b600052602160045260246000fd5b600381111561437d57634e487b7160e01b600052602160045260246000fd5b90525060009050826020015160038111156143a857634e487b7160e01b600052602160045260246000fd5b146143d8576141f56009602d8460200151600381111561128857634e487b7160e01b600052602160045260246000fd5b81608001516143e56123a3565b10156143f7576141f5600e602f6124bb565b6001600160a01b0386166000908152600e602052604090205460c0830151614420918891613afe565b60a0820151600d5560c08201516001600160a01b0387166000818152600e60205260409081902092909255606084015191513092600080516020615dd58339815191529161447091815260200190565b60405180910390a3608082015160608301516040517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929926144b2928a92615aae565b60405180910390a1600554608083015160608401516040516351dff98960e01b81526001600160a01b03909316926351dff989926144f89230928c929190600401615af3565b600060405180830381600087803b15801561451257600080fd5b505af1158015614526573d6000803e3d6000fd5b50505050614538868360800151613d00565b60009695505050505050565b600080836145575750600090508061239c565b8383028385828161457857634e487b7160e01b600052601260045260246000fd5b041461458c5760026000925092505061239c565b60009250905061239c565b600080826145ab575060019050600061239c565b60008385816145ca57634e487b7160e01b600052601260045260246000fd5b04915091509250929050565b600554604051634ef4c3e160e01b8152600091829182916001600160a01b031690634ef4c3e19061460f90309089908990600401615acf565b602060405180830381600087803b15801561462957600080fd5b505af115801561463d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146619190615a2c565b90508015614682576146766003601f83612905565b6000925092505061239c565b5042600954146146a357614698600a60226124bb565b60009150915061239c565b604080518082019091526000808252602082015260006146c1611d82565b836020018193508260038111156146e857634e487b7160e01b600052602160045260246000fd5b600381111561470757634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561473257634e487b7160e01b600052602160045260246000fd5b1461476f57614762600960218460200151600381111561128857634e487b7160e01b600052602160045260246000fd5b600093509350505061239c565b600061477b87876152b1565b905060006147978260405180602001604052808681525061563c565b856020018193508260038111156147be57634e487b7160e01b600052602160045260246000fd5b60038111156147dd57634e487b7160e01b600052602160045260246000fd5b905250600090508460200151600381111561480857634e487b7160e01b600052602160045260246000fd5b146148555760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c45446044820152606401610786565b6000614863600d548361298e565b8660200181935082600381111561488a57634e487b7160e01b600052602160045260246000fd5b60038111156148a957634e487b7160e01b600052602160045260246000fd5b90525060009050856020015160038111156148d457634e487b7160e01b600052602160045260246000fd5b146149205760405162461bcd60e51b815260206004820152601c60248201527b1352539517d39155d7d513d5105317d4d55414131657d1905253115160221b6044820152606401610786565b6001600160a01b0389166000908152600e6020526040812054614943908461298e565b8760200181935082600381111561496a57634e487b7160e01b600052602160045260246000fd5b600381111561498957634e487b7160e01b600052602160045260246000fd5b90525060009050866020015160038111156149b457634e487b7160e01b600052602160045260246000fd5b14614a015760405162461bcd60e51b815260206004820152601f60248201527f4d494e545f4e45575f4143434f554e545f42414c414e43455f4641494c4544006044820152606401610786565b6001600160a01b038a166000908152600e6020526040902054614a26908b9083613afe565b600d8290556001600160a01b038a166000908152600e602052604090819020829055517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f90614a7a908c9087908790615aae565b60405180910390a16040518381526001600160a01b038b1690600090600080516020615dd58339815191529060200160405180910390a360009a93995092975050505050505050565b8051600090670de0b6b3a764000090614adc9085615cbf565b610d969190615c9f565b6000610d96614af5848461564c565b613c71565b60055460405163368f515360e21b815260009182916001600160a01b039091169063da3d454c90614b3390309088908890600401615acf565b602060405180830381600087803b158015614b4d57600080fd5b505af1158015614b61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b859190615a2c565b90508015614ba257614b9a6003600e83612905565b915050610717565b504260095414614bbe57614bb7600a806124bb565b9050610717565b81614bc76123a3565b1015614bd957614bb7600e60096124bb565b600080614be58561271e565b90925090506000826003811115614c0c57634e487b7160e01b600052602160045260246000fd5b14614c4157614c386009600784600381111561128857634e487b7160e01b600052602160045260246000fd5b92505050610717565b806000614c4e828761298e565b90945090506000846003811115614c7557634e487b7160e01b600052602160045260246000fd5b14614cac57614ca16009600c86600381111561128857634e487b7160e01b600052602160045260246000fd5b945050505050610717565b6000614cba600b548861298e565b90955090506000856003811115614ce157634e487b7160e01b600052602160045260246000fd5b14614d1957614d0d6009600b87600381111561128857634e487b7160e01b600052602160045260246000fd5b95505050505050610717565b6001600160a01b038816600081815260106020908152604091829020858155600a54600190910155600b849055815192835282018990528101839052606081018290527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a1614d948884846154f7565b614d9e8888613d00565b600098975050505050505050565b600554604051632fe3f38f60e11b8152600091829182916001600160a01b031690635fc7e71e90614de990309088908c908c908c90600401615b1c565b602060405180830381600087803b158015614e0357600080fd5b505af1158015614e17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e3b9190615a2c565b90508015614e5c57614e506003601283612905565b600092509250506152a8565b4260095414614e7157614e50600a60166124bb565b42846001600160a01b031663cfa992016040518163ffffffff1660e01b8152600401602060405180830381600087803b158015614ead57600080fd5b505af1158015614ec1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614ee59190615a2c565b14614ef657614e50600a60116124bb565b866001600160a01b0316866001600160a01b03161415614f1c57614e50600660176124bb565b84614f2d57614e50600760156124bb565b600019851415614f4357614e50600760146124bb565b600080614f5189898961353d565b90925090508115614f9457614f86826010811115614f7f57634e487b7160e01b600052602160045260246000fd5b60186124bb565b6000945094505050506152a8565b60055460405163c488847b60e01b815260009182916001600160a01b039091169063c488847b90614fcd9030908c908890600401615acf565b604080518083038186803b158015614fe457600080fd5b505afa158015614ff8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061501c9190615a44565b9092509050811561508b5760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f604482015272105353d5539517d4d152569157d19052531151606a1b6064820152608401610786565b6040516370a0823160e01b815281906001600160a01b038a16906370a08231906150b9908e90600401615a67565b60206040518083038186803b1580156150d157600080fd5b505afa1580156150e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151099190615a2c565b10156151525760405162461bcd60e51b815260206004820152601860248201527709892a2aa928882a88abea68a92b48abea89e9ebe9aaa86960431b6044820152606401610786565b60006001600160a01b03891630141561517857615171308d8d85612c22565b90506151fd565b60405163b2a02ff160e01b81526001600160a01b038a169063b2a02ff1906151a8908f908f908790600401615acf565b602060405180830381600087803b1580156151c257600080fd5b505af11580156151d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151fa9190615a2c565b90505b80156152425760405162461bcd60e51b81526020600482015260146024820152731d1bdad95b881cd95a5e9d5c994819985a5b195960621b6044820152606401610786565b604080516001600160a01b038e811682528d811660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a16000975092955050505050505b94509492505050565b6012546040516370a0823160e01b81526000916001600160a01b031690829082906370a08231906152e6903090600401615a67565b60206040518083038186803b1580156152fe57600080fd5b505afa158015615312573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906153369190615a2c565b6040516323b872dd60e01b81529091506001600160a01b038316906323b872dd9061536990889030908990600401615acf565b600060405180830381600087803b15801561538357600080fd5b505af1158015615397573d6000803e3d6000fd5b5050505060003d600081146153b357602081146153bd57600080fd5b60001991506153c9565b60206000803e60005191505b50806154125760405162461bcd60e51b81526020600482015260186024820152771513d2d15397d514905394d1915497d25397d1905253115160421b6044820152606401610786565b6012546040516370a0823160e01b81526000916001600160a01b0316906370a0823190615443903090600401615a67565b60206040518083038186803b15801561545b57600080fd5b505afa15801561546f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906154939190615a2c565b9050828110156154e25760405162461bcd60e51b815260206004820152601a602482015279544f4b454e5f5452414e534645525f494e5f4f564552464c4f5760301b6044820152606401610786565b6154ec8382615cde565b979650505050505050565b600554604080516312ab2eaf60e21b815290516000926001600160a01b031691634aacbabc916004808301926020929190829003018186803b15801561553c57600080fd5b505afa158015615550573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906155749190615839565b90506001600160a01b0381161580159061560557506040516301fd3f7760e71b81526001600160a01b0382169063fe9fbb80906155b5903090600401615a67565b60206040518083038186803b1580156155cd57600080fd5b505afa1580156155e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061560591906159f4565b15611a2e57604051630578982360e01b81526001600160a01b03821690630578982390613c43903090889088908890600401615af3565b6000806000806123528686615678565b6156546156eb565b604051806020016040528083856000015161566f9190615cbf565b90529392505050565b60006156826156eb565b600080615697670de0b6b3a764000087614544565b909250905060008260038111156156be57634e487b7160e01b600052602160045260246000fd5b146156dd5750604080516020810190915260008152909250905061239c565b612395818660000151613a25565b6040518060200160405280600081525090565b82805461570a90615cf5565b90600052602060002090601f01602090048101928261572c5760008555615772565b82601f1061574557805160ff1916838001178555615772565b82800160010185558215615772579182015b82811115615772578251825591602001919060010190615757565b5061577e929150615782565b5090565b5b8082111561577e5760008155600101615783565b600082601f8301126157a7578081fd5b81356001600160401b03808211156157c1576157c1615d46565b604051601f8301601f19908116603f011681019082821181831017156157e9576157e9615d46565b81604052838152866020858801011115615801578485fd5b8360208701602083013792830160200193909352509392505050565b60006020828403121561582e578081fd5b8135610d9681615d5c565b60006020828403121561584a578081fd5b8151610d9681615d5c565b60008060408385031215615867578081fd5b823561587281615d5c565b9150602083013561588281615d5c565b809150509250929050565b6000806000606084860312156158a1578081fd5b83356158ac81615d5c565b925060208401356158bc81615d5c565b929592945050506040919091013590565b600080600080600080600060e0888a0312156158e7578283fd5b87356158f281615d5c565b9650602088013561590281615d5c565b9550604088013561591281615d5c565b94506060880135935060808801356001600160401b0380821115615934578485fd5b6159408b838c01615797565b945060a08a0135915080821115615955578384fd5b506159628a828b01615797565b92505060c088013560ff81168114615978578182fd5b8091505092959891949750929550565b6000806040838503121561599a578182fd5b82356159a581615d5c565b946020939093013593505050565b6000806000606084860312156159c7578283fd5b83356159d281615d5c565b92506020840135915060408401356159e981615d5c565b809150509250925092565b600060208284031215615a05578081fd5b81518015158114610d96578182fd5b600060208284031215615a25578081fd5b5035919050565b600060208284031215615a3d578081fd5b5051919050565b60008060408385031215615a56578182fd5b505080516020909101519092909150565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b6001600160a01b039586168152938516602085015291841660408401529092166060820152608081019190915260a00190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6000602080835283518082850152825b81811015615ba557858101830151858201604001528201615b89565b81811115615bb65783604083870101525b50601f01601f1916929092016040019392505050565b6020808252601690820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604082015260600190565b6020808252601c908201527b6d61726b6572206d6574686f642072657475726e65642066616c736560201b604082015260600190565b6020808252600a90820152691c994b595b9d195c995960b21b604082015260600190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60008219821115615c9a57615c9a615d30565b500190565b600082615cba57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615615cd957615cd9615d30565b500290565b600082821015615cf057615cf0615d30565b500390565b600181811c90821680615d0957607f821691505b60208210811415615d2a57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114615d7157600080fd5b5056fea91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc545b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0ca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3eff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dca26469706673582212206d679d8c61d76070571935f75f6897481b71e535fe59c966f2d385fb906d6ae664736f6c63430008040033
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061025c5760003560e01c806306fdde0314610261578063095ea7b31461027f5780630e752702146102a2578063173b9904146102b757806317bfdfbc146102ce57806318160ddd146102e1578063182df0f5146102ea5780631be19560146102f257806323b872dd146103055780632608f81814610318578063267822471461032b578063313ce5671461034b5780633af9e6691461036a5780633b1d21a21461037d5780633e941010146103855780634576b5db1461039857806347bd3718146103ab5780635fe3b567146103b4578063601a0bf1146103c75780636752e702146103da5780636f307dc3146103e3578063704b6c02146103f657806370a082311461040957806373acee9814610432578063830308461461043a578063852a12e31461044d5780638f840ddd1461046057806395d89b411461046957806395dd91931461047157806397de9d1114610484578063a0712d681461048c578063a6afed951461049f578063a9059cbb146104a7578063aa5af0fd146104ba578063afe65468146104c3578063b145a5b8146104d6578063b2a02ff1146104ea578063b71d1a0c146104fd578063bd6d894d14610510578063c37f68e214610518578063c5ebeaec1461053b578063cd91801c1461054e578063cfa9920114610556578063d3bd2c721461055f578063db006a7514610567578063dd62ed3e1461057a578063e9c714f2146105b3578063f2b3abbd146105bb578063f3fdb15a146105ce578063f5e3c462146105e1578063f851a440146105f4578063fca7820b1461060c575b600080fd5b61026961061f565b6040516102769190615b79565b60405180910390f35b61029261028d366004615988565b6106ad565b6040519015158152602001610276565b6102b56102b0366004615a14565b61071d565b005b6102c060085481565b604051908152602001610276565b6102c06102dc36600461581d565b610763565b6102c0600d5481565b6102c06107dc565b6102b561030036600461581d565b610859565b61029261031336600461588d565b610b10565b6102b5610326366004615988565b610b60565b60045461033e906001600160a01b031681565b6040516102769190615a67565b6003546103589060ff1681565b60405160ff9091168152602001610276565b6102c061037836600461581d565b610ba9565b6102c0610c67565b6102c0610393366004615a14565b610c76565b6102c06103a636600461581d565b610c81565b6102c0600b5481565b60055461033e906001600160a01b031681565b6102c06103d5366004615a14565b610d9d565b6102c060115481565b60125461033e906001600160a01b031681565b6102b561040436600461581d565b610e2a565b6102c061041736600461581d565b6001600160a01b03166000908152600e602052604090205490565b6102c0610ed6565b6102c0610448366004615a14565b610f3c565b6102b561045b366004615a14565b610fac565b6102c0600c5481565b610269610fb5565b6102c061047f36600461581d565b610fc2565b610292600181565b6102b561049a366004615a14565b611041565b6102c061107c565b6102926104b5366004615988565b61147f565b6102c0600a5481565b6102b56104d13660046158cd565b6114ce565b60125461029290600160a01b900460ff1681565b6102c06104f836600461588d565b6115f7565b6102c061050b36600461581d565b611646565b6102c06116c1565b61052b61052636600461581d565b61172d565b6040516102769493929190615c6c565b6102b5610549366004615a14565b6117ea565b6102c06117f3565b6102c060095481565b6102c0611883565b6102b5610575366004615a14565b6118c7565b6102c0610588366004615855565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6102c06118d0565b6102c06105c936600461581d565b6119a0565b60065461033e906001600160a01b031681565b6102b56105ef3660046159b3565b6119e6565b60035461033e9061010090046001600160a01b031681565b6102c061061a366004615a14565b611a34565b6001805461062c90615cf5565b80601f016020809104026020016040519081016040528092919081815260200182805461065890615cf5565b80156106a55780601f1061067a576101008083540402835291602001916106a5565b820191906000526020600020905b81548152906001019060200180831161068857829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855292528083208590555191929182907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906107099087815260200190565b60405180910390a360019150505b92915050565b600061072882611aa4565b50905061075f81604051806040016040528060128152602001711c995c185e509bdc9c9bddc819985a5b195960721b815250611b3e565b5050565b6000805460ff1661078f5760405162461bcd60e51b815260040161078690615c32565b60405180910390fd5b6000805460ff191681556107a161107c565b146107be5760405162461bcd60e51b815260040161078690615bcc565b6107c782610fc2565b90505b6000805460ff19166001179055919050565b60008060006107e9611d82565b9092509050600082600381111561081057634e487b7160e01b600052602160045260246000fd5b146107175760405162461bcd60e51b8152602060048201526019602482015278195e18da185b99d954985d1954dd1bdc99590819985a5b1959603a1b6044820152606401610786565b6012546001600160a01b03828116911614156108d25760405162461bcd60e51b815260206004820152603260248201527f4f45726332303a3a7377656570546f6b656e3a2063616e206e6f74207377656560448201527138103ab73232b9363cb4b733903a37b5b2b760711b6064820152608401610786565b6012546040516370a0823160e01b81526000916001600160a01b0316906370a0823190610903903090600401615a67565b60206040518083038186803b15801561091b57600080fd5b505afa15801561092f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109539190615a2c565b90506000826001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016109839190615a67565b60206040518083038186803b15801561099b57600080fd5b505afa1580156109af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d39190615a2c565b60035460405163a9059cbb60e01b81529192506001600160a01b038086169263a9059cbb92610a0e9261010090910416908590600401615a95565b600060405180830381600087803b158015610a2857600080fd5b505af1158015610a3c573d6000803e3d6000fd5b50506012546040516370a0823160e01b81526001600160a01b0390911692506370a082319150610a70903090600401615a67565b60206040518083038186803b158015610a8857600080fd5b505afa158015610a9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac09190615a2c565b8214610b0b5760405162461bcd60e51b815260206004820152601a6024820152791d5b99195c9b1e5a5b99c818985b185b98d94818da185b99d95960321b6044820152606401610786565b505050565b6000805460ff16610b335760405162461bcd60e51b815260040161078690615c32565b6000805460ff19168155610b4933868686611e4c565b1490506000805460ff191660011790559392505050565b6000610b6c83836122a6565b509050610b0b81604051806040016040528060188152602001771c995c185e509bdc9c9bddd0995a185b198819985a5b195960421b815250611b3e565b6000806040518060200160405280610bbf6116c1565b90526001600160a01b0384166000908152600e6020526040812054919250908190610beb908490612342565b90925090506000826003811115610c1257634e487b7160e01b600052602160045260246000fd5b14610c5f5760405162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c61746564006044820152606401610786565b949350505050565b6000610c716123a3565b905090565b60006107178261242c565b60035460009061010090046001600160a01b03163314610ca557610717603f6124b2565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b158015610cea57600080fd5b505afa158015610cfe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d2291906159f4565b610d3e5760405162461bcd60e51b815260040161078690615bfc565b600580546001600160a01b0319166001600160a01b0385161790556040517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d90610d8b9083908690615a7b565b60405180910390a160005b9392505050565b6000805460ff16610dc05760405162461bcd60e51b815260040161078690615c32565b6000805460ff19168155610dd261107c565b90508015610e0c57610e04816010811115610dfd57634e487b7160e01b600052602160045260246000fd5b60306124bb565b9150506107ca565b610e1583612545565b9150506000805460ff19166001179055919050565b60035461010090046001600160a01b03163314610e785760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610786565b600380546001600160a01b03838116610100908102610100600160a81b03198416179384905560405192819004821693600080516020615df583398151915293610eca93869390920490911690615a7b565b60405180910390a15050565b6000805460ff16610ef95760405162461bcd60e51b815260040161078690615c32565b6000805460ff19168155610f0b61107c565b14610f285760405162461bcd60e51b815260040161078690615bcc565b50600b546000805460ff1916600117905590565b6000805460ff16610f5f5760405162461bcd60e51b815260040161078690615c32565b6000805460ff19168155610f7161107c565b90508015610fa357610e04816010811115610f9c57634e487b7160e01b600052602160045260246000fd5b60516124bb565b610e158361262a565b61075f816126ab565b6002805461062c90615cf5565b6000806000610fd08461271e565b90925090506000826003811115610ff757634e487b7160e01b600052602160045260246000fd5b14610d965760405162461bcd60e51b815260206004820152601a602482015279189bdc9c9bddd0985b185b98d954dd1bdc99590819985a5b195960321b6044820152606401610786565b600061104c826127f3565b50905061075f816040518060400160405280600b81526020016a1b5a5b9d0819985a5b195960aa1b815250611b3e565b6009546000904290808214156110965760005b9250505090565b60006110a06123a3565b600b54600c54600a546006546040516315f2405360e01b81529495509293919290916000916001600160a01b0316906315f24053906110e790889088908890600401615c56565b60206040518083038186803b1580156110ff57600080fd5b505afa158015611113573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111379190615a2c565b905065048c2739500081111561118e5760405162461bcd60e51b815260206004820152601c60248201527b0c4dee4e4deee40e4c2e8ca40d2e640c2c4e6eae4c8d8f240d0d2ced60231b6044820152606401610786565b60008061119b8989612866565b909250905060008260038111156111c257634e487b7160e01b600052602160045260246000fd5b1461120f5760405162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c7461006044820152606401610786565b6112176156eb565b60008060008061123560405180602001604052808a81525087612889565b9097509450600087600381111561125c57634e487b7160e01b600052602160045260246000fd5b146112a05761128d6009600689600381111561128857634e487b7160e01b600052602160045260246000fd5b612905565b9e50505050505050505050505050505090565b6112aa858c612342565b909750935060008760038111156112d157634e487b7160e01b600052602160045260246000fd5b146112fd5761128d6009600189600381111561128857634e487b7160e01b600052602160045260246000fd5b611307848c61298e565b9097509250600087600381111561132e57634e487b7160e01b600052602160045260246000fd5b1461135a5761128d6009600489600381111561128857634e487b7160e01b600052602160045260246000fd5b6113756040518060200160405280600854815250858c6129b4565b9097509150600087600381111561139c57634e487b7160e01b600052602160045260246000fd5b146113c85761128d6009600589600381111561128857634e487b7160e01b600052602160045260246000fd5b6113d3858a8b6129b4565b909750905060008760038111156113fa57634e487b7160e01b600052602160045260246000fd5b146114265761128d6009600389600381111561128857634e487b7160e01b600052602160045260246000fd5b60098e9055600a819055600b839055600c8290556040517f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc0490611470908e90879085908890615c6c565b60405180910390a1600061128d565b6000805460ff166114a25760405162461bcd60e51b815260040161078690615c32565b6000805460ff191681556114b833338686611e4c565b1490506000805460ff1916600117905592915050565b601254600160a01b900460ff16156115275760405162461bcd60e51b815260206004820152601c60248201527b18dbdb9d1c9858dd08185b1c9958591e481a5b9a5d1a585b1a5e995960221b6044820152606401610786565b6012805460ff60a01b1916600160a01b179055600380543361010002610100600160a81b0319909116179055611561868686868686612a1d565b601280546001600160a01b0319166001600160a01b038916908117909155604080516318160ddd60e01b815290516318160ddd91600480820192602092909190829003018186803b1580156115b557600080fd5b505afa1580156115c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ed9190615a2c565b5050505050505050565b6000805460ff1661161a5760405162461bcd60e51b815260040161078690615c32565b6000805460ff1916905561163033858585612c22565b90506000805460ff191660011790559392505050565b60035460009061010090046001600160a01b0316331461166a5761071760456124b2565b600454604051600080516020615db583398151915291611697916001600160a01b03909116908590615a7b565b60405180910390a1600480546001600160a01b0319166001600160a01b0384161790556000610717565b6000805460ff166116e45760405162461bcd60e51b815260040161078690615c32565b6000805460ff191681556116f661107c565b146117135760405162461bcd60e51b815260040161078690615bcc565b61171b6107dc565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600e60205260408120548190819081908180806117588961271e565b93509050600081600381111561177e57634e487b7160e01b600052602160045260246000fd5b1461179c5760095b60008060009750975097509750505050506117e3565b6117a4611d82565b9250905060008160038111156117ca57634e487b7160e01b600052602160045260246000fd5b146117d6576009611786565b5060009650919450925090505b9193509193565b61075f8161315d565b6006546000906001600160a01b03166315f2405361180f6123a3565b600b54600c546040518463ffffffff1660e01b815260040161183393929190615c56565b60206040518083038186803b15801561184b57600080fd5b505afa15801561185f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c719190615a2c565b6006546000906001600160a01b031663b816881661189f6123a3565b600b54600c546008546040518563ffffffff1660e01b81526004016118339493929190615c6c565b61075f816131ce565b6004546000906001600160a01b0316331415806118eb575033155b156118fa57610c7160006124b2565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b0319909316909355604051938290048116949293600080516020615df58339815191529361195e93879391041690615a7b565b60405180910390a1600454604051600080516020615db5833981519152916119919184916001600160a01b031690615a7b565b60405180910390a1600061108f565b6000806119ab61107c565b905080156119dd57610d968160108111156119d657634e487b7160e01b600052602160045260246000fd5b60406124bb565b610d968361323a565b60006119f3848484613367565b509050611a2e81604051806040016040528060168152602001751b1a5c5d5a59185d19509bdc9c9bddc819985a5b195960521b815250611b3e565b50505050565b6000805460ff16611a575760405162461bcd60e51b815260040161078690615c32565b6000805460ff19168155611a6961107c565b90508015611a9b57610e04816010811115611a9457634e487b7160e01b600052602160045260246000fd5b60466124bb565b610e15836134aa565b60008054819060ff16611ac95760405162461bcd60e51b815260040161078690615c32565b6000805460ff19168155611adb61107c565b90508015611b1957611b0d816010811115611b0657634e487b7160e01b600052602160045260246000fd5b60366124bb565b60009250925050611b2a565b611b2433338661353d565b92509250505b6000805460ff191660011790559092909150565b81611b47575050565b600081516005016001600160401b03811115611b7357634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611b9d576020820181803683370190505b50905060005b8251811015611c1657828181518110611bcc57634e487b7160e01b600052603260045260246000fd5b602001015160f81c60f81b828281518110611bf757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600101611ba3565b8151600160fd1b90839083908110611c3e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602860f81b828260010181518110611c7d57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840460300160f81b828260020181518110611cc157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840660300160f81b828260030181518110611d0557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602960f81b828260040181518110611d4457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350818415611d7b5760405162461bcd60e51b81526004016107869190615b79565b5050505050565b600d54600090819080611d9c575050600754600092909150565b6000611da66123a3565b90506000611db26156eb565b6000611dc384600b54600c546139d3565b935090506000816003811115611de957634e487b7160e01b600052602160045260246000fd5b14611dfb579660009650945050505050565b611e058386613a25565b925090506000816003811115611e2b57634e487b7160e01b600052602160045260246000fd5b14611e3d579660009650945050505050565b50516000969095509350505050565b6005546040516317b9b84b60e31b815260009182916001600160a01b039091169063bdcdc25890611e87903090899089908990600401615b4f565b602060405180830381600087803b158015611ea157600080fd5b505af1158015611eb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed99190615a2c565b90508015611f275760405162461bcd60e51b815260206004820152601b60248201527a115490cc8c0e881d1c985b9cd9995c881b9bdd08185b1b1bddd959602a1b6044820152606401610786565b836001600160a01b0316856001600160a01b03161415611f895760405162461bcd60e51b815260206004820181905260248201527f45524332303a2073656c662d7472616e73666572206e6f7420616c6c6f7765646044820152606401610786565b6000856001600160a01b0316876001600160a01b03161415611fae5750600019611fd6565b506001600160a01b038086166000908152600f60209081526040808320938a16835292905220545b600080600080611fe68589612866565b9094509250600084600381111561200d57634e487b7160e01b600052602160045260246000fd5b146120685760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610786565b6001600160a01b038a166000908152600e602052604090205461208b9089612866565b909450915060008460038111156120b257634e487b7160e01b600052602160045260246000fd5b1461210e5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610786565b6001600160a01b0389166000908152600e6020526040902054612131908961298e565b9094509050600084600381111561215857634e487b7160e01b600052602160045260246000fd5b146121b85760405162461bcd60e51b815260206004820152602a60248201527f45524332303a206d6178696d756d2064657374696e6174696f6e2062616c616e60448201526918d9481c995858da195960b21b6064820152608401610786565b6001600160a01b038a166000908152600e60205260409020546121dd908b9084613afe565b6001600160a01b0389166000908152600e6020526040902054612202908a9083613afe565b6001600160a01b03808b166000908152600e6020526040808220859055918b16815220819055600019851461225a576001600160a01b03808b166000908152600f60209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b0316600080516020615dd58339815191528a60405161228d91815260200190565b60405180910390a35060009a9950505050505050505050565b60008054819060ff166122cb5760405162461bcd60e51b815260040161078690615c32565b6000805460ff191681556122dd61107c565b9050801561231b5761230f81601081111561230857634e487b7160e01b600052602160045260246000fd5b60356124bb565b6000925092505061232c565b61232633868661353d565b92509250505b6000805460ff1916600117905590939092509050565b6000806000806123528686612889565b9092509050600082600381111561237957634e487b7160e01b600052602160045260246000fd5b1461238a575091506000905061239c565b600061239582613c71565b9350935050505b9250929050565b6012546040516370a0823160e01b81526000916001600160a01b03169081906370a08231906123d6903090600401615a67565b60206040518083038186803b1580156123ee57600080fd5b505afa158015612402573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124269190615a2c565b91505090565b6000805460ff1661244f5760405162461bcd60e51b815260040161078690615c32565b6000805460ff1916815561246161107c565b9050801561249357610e0481601081111561248c57634e487b7160e01b600052602160045260246000fd5b604e6124bb565b61249c83613c89565b509150506000805460ff19166001179055919050565b60006107176001835b6000600080516020615d958339815191528360108111156124ec57634e487b7160e01b600052602160045260246000fd5b83605381111561250c57634e487b7160e01b600052602160045260246000fd5b600060405161251d93929190615c56565b60405180910390a1826010811115610d9657634e487b7160e01b600052602160045260246000fd5b600354600090819061010090046001600160a01b0316331461256b57610d9660316124b2565b426009541461258057610d96600a60336124bb565b826125896123a3565b101561259b57610d96600e60326124bb565b600c548311156125b157610d96600260346124bb565b82600c546125bf9190615cde565b600c8190556003549091506125e29061010090046001600160a01b031684613d00565b7f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e600360019054906101000a90046001600160a01b03168483604051610d8b93929190615aae565b60035460009061010090046001600160a01b0316331461264e5761071760526124b2565b426009541461266357610717600a60536124bb565b60115460408051918252602082018490527ff5815f353a60e815cce7553e4f60c533a59d26b1b5504ea4b6db8d60da3e4da2910160405180910390a160118290556000610717565b6000805460ff166126ce5760405162461bcd60e51b815260040161078690615c32565b6000805460ff191681556126e061107c565b9050801561271257610e0481601081111561270b57634e487b7160e01b600052602160045260246000fd5b60276124bb565b610e1533600085613dde565b6001600160a01b0381166000908152601060205260408120805482918291829182916127535750600096879650945050505050565b6127638160000154600a54614544565b9094509250600084600381111561278a57634e487b7160e01b600052602160045260246000fd5b1461279d57509195600095509350505050565b6127ab838260010154614597565b909450915060008460038111156127d257634e487b7160e01b600052602160045260246000fd5b146127e557509195600095509350505050565b506000969095509350505050565b60008054819060ff166128185760405162461bcd60e51b815260040161078690615c32565b6000805460ff1916815561282a61107c565b9050801561285c57611b0d81601081111561285557634e487b7160e01b600052602160045260246000fd5b601e6124bb565b611b2433856145d6565b60008083831161287d57506000905081830361239c565b5060039050600061239c565b60006128936156eb565b6000806128a4866000015186614544565b909250905060008260038111156128cb57634e487b7160e01b600052602160045260246000fd5b146128ea5750604080516020810190915260008152909250905061239c565b60408051602081019091529081526000969095509350505050565b6000600080516020615d9583398151915284601081111561293657634e487b7160e01b600052602160045260246000fd5b84605381111561295657634e487b7160e01b600052602160045260246000fd5b8460405161296693929190615c56565b60405180910390a1836010811115610c5f57634e487b7160e01b600052602160045260246000fd5b6000808383018481106129a65760009250905061239c565b60026000925092505061239c565b6000806000806129c48787612889565b909250905060008260038111156129eb57634e487b7160e01b600052602160045260246000fd5b146129fc5750915060009050612a15565b612a0e612a0882613c71565b8661298e565b9350935050505b935093915050565b60035461010090046001600160a01b03163314612a785760405162461bcd60e51b81526020600482015260196024820152786f6e6c792061646d696e206d617920696e697469616c697a6560381b6044820152606401610786565b600954158015612a885750600a54155b612aca5760405162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610786565b600784905583612b1c5760405162461bcd60e51b815260206004820152601e60248201527f696e69742065786368616e67652072617465206d757374206265203e203000006044820152606401610786565b6000612b2787610c81565b14612b6d5760405162461bcd60e51b81526020600482015260166024820152751cd95d0818dbdb5c1d1c9bdb1b195c8819985a5b195960521b6044820152606401610786565b42600955670de0b6b3a7640000600a556000612b888661323a565b14612bd55760405162461bcd60e51b815260206004820152601e60248201527f73657420696e7465726573742072617465206d6f64656c206661696c656400006044820152606401610786565b8251612be89060019060208601906156fe565b508151612bfc9060029060208501906156fe565b506003805460ff90921660ff199283161790556000805490911660011790555050505050565b60055460405163d02f735160e01b815260009182916001600160a01b039091169063d02f735190612c5f9030908a908a908a908a90600401615b1c565b602060405180830381600087803b158015612c7957600080fd5b505af1158015612c8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb19190615a2c565b90508015612cce57612cc66003601b83612905565b915050610c5f565b846001600160a01b0316846001600160a01b03161415612cf457612cc66006601c6124bb565b612d44604080516101208101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0385166000908152600e6020526040902054612d679085612866565b6020830181905282826003811115612d8f57634e487b7160e01b600052602160045260246000fd5b6003811115612dae57634e487b7160e01b600052602160045260246000fd5b9052506000905081516003811115612dd657634e487b7160e01b600052602160045260246000fd5b14612e0f57612e066009601a8360000151600381111561128857634e487b7160e01b600052602160045260246000fd5b92505050610c5f565b612e29846040518060200160405280601154815250614ac3565b60808201819052612e3a9085615cde565b6060820152612e47611d82565b60c0830181905282826003811115612e6f57634e487b7160e01b600052602160045260246000fd5b6003811115612e8e57634e487b7160e01b600052602160045260246000fd5b9052506000905081516003811115612eb657634e487b7160e01b600052602160045260246000fd5b14612efe5760405162461bcd60e51b815260206004820152601860248201527732bc31b430b733b2903930ba329036b0ba341032b93937b960411b6044820152606401610786565b612f1e60405180602001604052808360c001518152508260800151614ae6565b60a08201819052600c54612f329190615c87565b60e08201526080810151600d54612f499190615cde565b6101008201526001600160a01b0386166000908152600e60205260409020546060820151612f77919061298e565b6040830181905282826003811115612f9f57634e487b7160e01b600052602160045260246000fd5b6003811115612fbe57634e487b7160e01b600052602160045260246000fd5b9052506000905081516003811115612fe657634e487b7160e01b600052602160045260246000fd5b1461301657612e06600960198360000151600381111561128857634e487b7160e01b600052602160045260246000fd5b61304a85600e6000886001600160a01b03166001600160a01b03168152602001908152602001600020548360200151613afe565b6001600160a01b0386166000908152600e6020526040908190205490820151613074918891613afe565b60e0810151600c55610100810151600d556020808201516001600160a01b038781166000818152600e855260408082209490945583860151928b1680825290849020929092556060850151925192835290929091600080516020615dd5833981519152910160405180910390a3306001600160a01b0316856001600160a01b0316600080516020615dd5833981519152836080015160405161311891815260200190565b60405180910390a360a081015160e0820151604051600080516020615d7583398151915292613148923092615aae565b60405180910390a16000979650505050505050565b6000805460ff166131805760405162461bcd60e51b815260040161078690615c32565b6000805460ff1916815561319261107c565b905080156131c457610e048160108111156131bd57634e487b7160e01b600052602160045260246000fd5b60086124bb565b610e153384614afa565b6000805460ff166131f15760405162461bcd60e51b815260040161078690615c32565b6000805460ff1916815561320361107c565b9050801561322e57610e0481601081111561270b57634e487b7160e01b600052602160045260246000fd5b610e1533846000613dde565b600354600090819061010090046001600160a01b0316331461326057610d9660426124b2565b426009541461327557610d96600a60416124bb565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156132c657600080fd5b505afa1580156132da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132fe91906159f4565b61331a5760405162461bcd60e51b815260040161078690615bfc565b600680546001600160a01b0319166001600160a01b0385161790556040517fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f92690610d8b9083908690615a7b565b60008054819060ff1661338c5760405162461bcd60e51b815260040161078690615c32565b6000805460ff1916815561339e61107c565b905080156133dc576133d08160108111156133c957634e487b7160e01b600052602160045260246000fd5b600f6124bb565b60009250925050613493565b836001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561341757600080fd5b505af115801561342b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061344f9190615a2c565b90508015613481576133d081601081111561347a57634e487b7160e01b600052602160045260246000fd5b60106124bb565b61348d33878787614dac565b92509250505b6000805460ff191660011790559094909350915050565b60035460009061010090046001600160a01b031633146134ce5761071760476124b2565b42600954146134e357610717600a60486124bb565b670de0b6b3a76400008211156134ff57610717600260496124bb565b600880549083905560408051828152602081018590527faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f8214609101610d8b565b600554604051631200453160e11b8152600091829182916001600160a01b0316906324008a62906135789030908a908a908a90600401615b4f565b602060405180830381600087803b15801561359257600080fd5b505af11580156135a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135ca9190615a2c565b905080156135eb576135df6003603883612905565b60009250925050612a15565b4260095414613600576135df600a60396124bb565b6136496040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b600061365487610fc2565b6001600160a01b038816600090815260106020526040902060010154606084015290506136808761271e565b60808401819052602084018260038111156136ab57634e487b7160e01b600052602160045260246000fd5b60038111156136ca57634e487b7160e01b600052602160045260246000fd5b90525060009050826020015160038111156136f557634e487b7160e01b600052602160045260246000fd5b1461373357613725600960378460200151600381111561128857634e487b7160e01b600052602160045260246000fd5b600094509450505050612a15565b8160800151861061374d5760808201516040830152613755565b604082018690525b6137638883604001516152b1565b60e08301819052608083015161377891612866565b60a08401819052602084018260038111156137a357634e487b7160e01b600052602160045260246000fd5b60038111156137c257634e487b7160e01b600052602160045260246000fd5b90525060009050826020015160038111156137ed57634e487b7160e01b600052602160045260246000fd5b1461383a5760405162461bcd60e51b815260206004820181905260248201527f52455041595f4e45575f4143434f554e545f42414c414e43455f4641494c45446044820152606401610786565b61384a600b548360e00151612866565b60c084018190526020840182600381111561387557634e487b7160e01b600052602160045260246000fd5b600381111561389457634e487b7160e01b600052602160045260246000fd5b90525060009050826020015160038111156138bf57634e487b7160e01b600052602160045260246000fd5b1461390c5760405162461bcd60e51b815260206004820152601e60248201527f52455041595f4e45575f544f54414c5f42414c414e43455f4641494c454400006044820152606401610786565b60a0820180516001600160a01b03891660009081526010602052604090819020918255600a5460019092019190915560c0840151600b81905560e0850151925191517f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1936139a9938d938d936001600160a01b03958616815293909416602084015260408301919091526060820152608081019190915260a00190565b60405180910390a16139c087828460a001516154f7565b5060e00151600097909650945050505050565b6000806000806139e3878761298e565b90925090506000826003811115613a0a57634e487b7160e01b600052602160045260246000fd5b14613a1b5750915060009050612a15565b612a0e8186612866565b6000613a2f6156eb565b600080613a4486670de0b6b3a7640000614544565b90925090506000826003811115613a6b57634e487b7160e01b600052602160045260246000fd5b14613a8a5750604080516020810190915260008152909250905061239c565b600080613a978388614597565b90925090506000826003811115613abe57634e487b7160e01b600052602160045260246000fd5b14613ae1578160405180602001604052806000815250955095505050505061239c565b604080516020810190915290815260009890975095505050505050565b600554604080516312ab2eaf60e21b815290516000926001600160a01b031691634aacbabc916004808301926020929190829003018186803b158015613b4357600080fd5b505afa158015613b57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b7b9190615839565b90506001600160a01b03811615801590613c0c57506040516301fd3f7760e71b81526001600160a01b0382169063fe9fbb8090613bbc903090600401615a67565b60206040518083038186803b158015613bd457600080fd5b505afa158015613be8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c0c91906159f4565b15611a2e57604051639eba1f6760e01b81526001600160a01b03821690639eba1f6790613c43903090889088908890600401615af3565b600060405180830381600087803b158015613c5d57600080fd5b505af11580156115ed573d6000803e3d6000fd5b805160009061071790670de0b6b3a764000090615c9f565b60008080804260095414613cad57613ca3600a604f6124bb565b9590945092505050565b613cb733866152b1565b905080600c54613cc79190615c87565b915081600c81905550600080516020615d75833981519152338284604051613cf193929190615aae565b60405180910390a16000613ca3565b60125460405163a9059cbb60e01b81526001600160a01b0390911690819063a9059cbb90613d349086908690600401615a95565b600060405180830381600087803b158015613d4e57600080fd5b505af1158015613d62573d6000803e3d6000fd5b5050505060003d60008114613d7e5760208114613d8857600080fd5b6000199150613d94565b60206000803e60005191505b5080611a2e5760405162461bcd60e51b81526020600482015260196024820152781513d2d15397d514905394d1915497d3d55517d19052531151603a1b6044820152606401610786565b6000821580613deb575081155b613e375760405162461bcd60e51b815260206004820152601e60248201527f746f6b656e73496e206f7220616d6f756e74496e206d757374206265203000006044820152606401610786565b613e786040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b613e80611d82565b6040830181905260208301826003811115613eab57634e487b7160e01b600052602160045260246000fd5b6003811115613eca57634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613ef557634e487b7160e01b600052602160045260246000fd5b14613f2d57613f256009602b8360200151600381111561128857634e487b7160e01b600052602160045260246000fd5b915050610d96565b8315614047576001600160a01b0385166000908152600e60205260409020548410613f75576001600160a01b0385166000908152600e60205260409020546060820152613f7d565b606081018490525b613f9d604051806020016040528083604001518152508260600151612342565b6080830181905260208301826003811115613fc857634e487b7160e01b600052602160045260246000fd5b6003811115613fe757634e487b7160e01b600052602160045260246000fd5b905250600090508160200151600381111561401257634e487b7160e01b600052602160045260246000fd5b1461404257613f25600960298360200151600381111561128857634e487b7160e01b600052602160045260246000fd5b614155565b60001983141561408e576001600160a01b0385166000908152600e60209081526040918290205460608401908152825191820183529183015181529051613f9d9190612342565b60808101839052604080516020810182529082015181526140b090849061563c565b60608301819052602083018260038111156140db57634e487b7160e01b600052602160045260246000fd5b60038111156140fa57634e487b7160e01b600052602160045260246000fd5b905250600090508160200151600381111561412557634e487b7160e01b600052602160045260246000fd5b1461415557613f256009602a8360200151600381111561128857634e487b7160e01b600052602160045260246000fd5b600554606082015160405163eabe7d9160e01b81526000926001600160a01b03169163eabe7d919161418e9130918b9190600401615acf565b602060405180830381600087803b1580156141a857600080fd5b505af11580156141bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141e09190615a2c565b905080156141fe576141f56003602883612905565b92505050610d96565b4260095414614213576141f5600a602c6124bb565b614223600d548360600151612866565b60a084018190526020840182600381111561424e57634e487b7160e01b600052602160045260246000fd5b600381111561426d57634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561429857634e487b7160e01b600052602160045260246000fd5b146142c8576141f56009602e8460200151600381111561128857634e487b7160e01b600052602160045260246000fd5b6001600160a01b0386166000908152600e60205260409020546060830151111561430b576001600160a01b0386166000908152600e602052604090205460608301525b6001600160a01b0386166000908152600e602052604090205460608301516143339190612866565b60c084018190526020840182600381111561435e57634e487b7160e01b600052602160045260246000fd5b600381111561437d57634e487b7160e01b600052602160045260246000fd5b90525060009050826020015160038111156143a857634e487b7160e01b600052602160045260246000fd5b146143d8576141f56009602d8460200151600381111561128857634e487b7160e01b600052602160045260246000fd5b81608001516143e56123a3565b10156143f7576141f5600e602f6124bb565b6001600160a01b0386166000908152600e602052604090205460c0830151614420918891613afe565b60a0820151600d5560c08201516001600160a01b0387166000818152600e60205260409081902092909255606084015191513092600080516020615dd58339815191529161447091815260200190565b60405180910390a3608082015160608301516040517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929926144b2928a92615aae565b60405180910390a1600554608083015160608401516040516351dff98960e01b81526001600160a01b03909316926351dff989926144f89230928c929190600401615af3565b600060405180830381600087803b15801561451257600080fd5b505af1158015614526573d6000803e3d6000fd5b50505050614538868360800151613d00565b60009695505050505050565b600080836145575750600090508061239c565b8383028385828161457857634e487b7160e01b600052601260045260246000fd5b041461458c5760026000925092505061239c565b60009250905061239c565b600080826145ab575060019050600061239c565b60008385816145ca57634e487b7160e01b600052601260045260246000fd5b04915091509250929050565b600554604051634ef4c3e160e01b8152600091829182916001600160a01b031690634ef4c3e19061460f90309089908990600401615acf565b602060405180830381600087803b15801561462957600080fd5b505af115801561463d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146619190615a2c565b90508015614682576146766003601f83612905565b6000925092505061239c565b5042600954146146a357614698600a60226124bb565b60009150915061239c565b604080518082019091526000808252602082015260006146c1611d82565b836020018193508260038111156146e857634e487b7160e01b600052602160045260246000fd5b600381111561470757634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561473257634e487b7160e01b600052602160045260246000fd5b1461476f57614762600960218460200151600381111561128857634e487b7160e01b600052602160045260246000fd5b600093509350505061239c565b600061477b87876152b1565b905060006147978260405180602001604052808681525061563c565b856020018193508260038111156147be57634e487b7160e01b600052602160045260246000fd5b60038111156147dd57634e487b7160e01b600052602160045260246000fd5b905250600090508460200151600381111561480857634e487b7160e01b600052602160045260246000fd5b146148555760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c45446044820152606401610786565b6000614863600d548361298e565b8660200181935082600381111561488a57634e487b7160e01b600052602160045260246000fd5b60038111156148a957634e487b7160e01b600052602160045260246000fd5b90525060009050856020015160038111156148d457634e487b7160e01b600052602160045260246000fd5b146149205760405162461bcd60e51b815260206004820152601c60248201527b1352539517d39155d7d513d5105317d4d55414131657d1905253115160221b6044820152606401610786565b6001600160a01b0389166000908152600e6020526040812054614943908461298e565b8760200181935082600381111561496a57634e487b7160e01b600052602160045260246000fd5b600381111561498957634e487b7160e01b600052602160045260246000fd5b90525060009050866020015160038111156149b457634e487b7160e01b600052602160045260246000fd5b14614a015760405162461bcd60e51b815260206004820152601f60248201527f4d494e545f4e45575f4143434f554e545f42414c414e43455f4641494c4544006044820152606401610786565b6001600160a01b038a166000908152600e6020526040902054614a26908b9083613afe565b600d8290556001600160a01b038a166000908152600e602052604090819020829055517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f90614a7a908c9087908790615aae565b60405180910390a16040518381526001600160a01b038b1690600090600080516020615dd58339815191529060200160405180910390a360009a93995092975050505050505050565b8051600090670de0b6b3a764000090614adc9085615cbf565b610d969190615c9f565b6000610d96614af5848461564c565b613c71565b60055460405163368f515360e21b815260009182916001600160a01b039091169063da3d454c90614b3390309088908890600401615acf565b602060405180830381600087803b158015614b4d57600080fd5b505af1158015614b61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b859190615a2c565b90508015614ba257614b9a6003600e83612905565b915050610717565b504260095414614bbe57614bb7600a806124bb565b9050610717565b81614bc76123a3565b1015614bd957614bb7600e60096124bb565b600080614be58561271e565b90925090506000826003811115614c0c57634e487b7160e01b600052602160045260246000fd5b14614c4157614c386009600784600381111561128857634e487b7160e01b600052602160045260246000fd5b92505050610717565b806000614c4e828761298e565b90945090506000846003811115614c7557634e487b7160e01b600052602160045260246000fd5b14614cac57614ca16009600c86600381111561128857634e487b7160e01b600052602160045260246000fd5b945050505050610717565b6000614cba600b548861298e565b90955090506000856003811115614ce157634e487b7160e01b600052602160045260246000fd5b14614d1957614d0d6009600b87600381111561128857634e487b7160e01b600052602160045260246000fd5b95505050505050610717565b6001600160a01b038816600081815260106020908152604091829020858155600a54600190910155600b849055815192835282018990528101839052606081018290527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a1614d948884846154f7565b614d9e8888613d00565b600098975050505050505050565b600554604051632fe3f38f60e11b8152600091829182916001600160a01b031690635fc7e71e90614de990309088908c908c908c90600401615b1c565b602060405180830381600087803b158015614e0357600080fd5b505af1158015614e17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e3b9190615a2c565b90508015614e5c57614e506003601283612905565b600092509250506152a8565b4260095414614e7157614e50600a60166124bb565b42846001600160a01b031663cfa992016040518163ffffffff1660e01b8152600401602060405180830381600087803b158015614ead57600080fd5b505af1158015614ec1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614ee59190615a2c565b14614ef657614e50600a60116124bb565b866001600160a01b0316866001600160a01b03161415614f1c57614e50600660176124bb565b84614f2d57614e50600760156124bb565b600019851415614f4357614e50600760146124bb565b600080614f5189898961353d565b90925090508115614f9457614f86826010811115614f7f57634e487b7160e01b600052602160045260246000fd5b60186124bb565b6000945094505050506152a8565b60055460405163c488847b60e01b815260009182916001600160a01b039091169063c488847b90614fcd9030908c908890600401615acf565b604080518083038186803b158015614fe457600080fd5b505afa158015614ff8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061501c9190615a44565b9092509050811561508b5760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f604482015272105353d5539517d4d152569157d19052531151606a1b6064820152608401610786565b6040516370a0823160e01b815281906001600160a01b038a16906370a08231906150b9908e90600401615a67565b60206040518083038186803b1580156150d157600080fd5b505afa1580156150e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151099190615a2c565b10156151525760405162461bcd60e51b815260206004820152601860248201527709892a2aa928882a88abea68a92b48abea89e9ebe9aaa86960431b6044820152606401610786565b60006001600160a01b03891630141561517857615171308d8d85612c22565b90506151fd565b60405163b2a02ff160e01b81526001600160a01b038a169063b2a02ff1906151a8908f908f908790600401615acf565b602060405180830381600087803b1580156151c257600080fd5b505af11580156151d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151fa9190615a2c565b90505b80156152425760405162461bcd60e51b81526020600482015260146024820152731d1bdad95b881cd95a5e9d5c994819985a5b195960621b6044820152606401610786565b604080516001600160a01b038e811682528d811660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a16000975092955050505050505b94509492505050565b6012546040516370a0823160e01b81526000916001600160a01b031690829082906370a08231906152e6903090600401615a67565b60206040518083038186803b1580156152fe57600080fd5b505afa158015615312573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906153369190615a2c565b6040516323b872dd60e01b81529091506001600160a01b038316906323b872dd9061536990889030908990600401615acf565b600060405180830381600087803b15801561538357600080fd5b505af1158015615397573d6000803e3d6000fd5b5050505060003d600081146153b357602081146153bd57600080fd5b60001991506153c9565b60206000803e60005191505b50806154125760405162461bcd60e51b81526020600482015260186024820152771513d2d15397d514905394d1915497d25397d1905253115160421b6044820152606401610786565b6012546040516370a0823160e01b81526000916001600160a01b0316906370a0823190615443903090600401615a67565b60206040518083038186803b15801561545b57600080fd5b505afa15801561546f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906154939190615a2c565b9050828110156154e25760405162461bcd60e51b815260206004820152601a602482015279544f4b454e5f5452414e534645525f494e5f4f564552464c4f5760301b6044820152606401610786565b6154ec8382615cde565b979650505050505050565b600554604080516312ab2eaf60e21b815290516000926001600160a01b031691634aacbabc916004808301926020929190829003018186803b15801561553c57600080fd5b505afa158015615550573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906155749190615839565b90506001600160a01b0381161580159061560557506040516301fd3f7760e71b81526001600160a01b0382169063fe9fbb80906155b5903090600401615a67565b60206040518083038186803b1580156155cd57600080fd5b505afa1580156155e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061560591906159f4565b15611a2e57604051630578982360e01b81526001600160a01b03821690630578982390613c43903090889088908890600401615af3565b6000806000806123528686615678565b6156546156eb565b604051806020016040528083856000015161566f9190615cbf565b90529392505050565b60006156826156eb565b600080615697670de0b6b3a764000087614544565b909250905060008260038111156156be57634e487b7160e01b600052602160045260246000fd5b146156dd5750604080516020810190915260008152909250905061239c565b612395818660000151613a25565b6040518060200160405280600081525090565b82805461570a90615cf5565b90600052602060002090601f01602090048101928261572c5760008555615772565b82601f1061574557805160ff1916838001178555615772565b82800160010185558215615772579182015b82811115615772578251825591602001919060010190615757565b5061577e929150615782565b5090565b5b8082111561577e5760008155600101615783565b600082601f8301126157a7578081fd5b81356001600160401b03808211156157c1576157c1615d46565b604051601f8301601f19908116603f011681019082821181831017156157e9576157e9615d46565b81604052838152866020858801011115615801578485fd5b8360208701602083013792830160200193909352509392505050565b60006020828403121561582e578081fd5b8135610d9681615d5c565b60006020828403121561584a578081fd5b8151610d9681615d5c565b60008060408385031215615867578081fd5b823561587281615d5c565b9150602083013561588281615d5c565b809150509250929050565b6000806000606084860312156158a1578081fd5b83356158ac81615d5c565b925060208401356158bc81615d5c565b929592945050506040919091013590565b600080600080600080600060e0888a0312156158e7578283fd5b87356158f281615d5c565b9650602088013561590281615d5c565b9550604088013561591281615d5c565b94506060880135935060808801356001600160401b0380821115615934578485fd5b6159408b838c01615797565b945060a08a0135915080821115615955578384fd5b506159628a828b01615797565b92505060c088013560ff81168114615978578182fd5b8091505092959891949750929550565b6000806040838503121561599a578182fd5b82356159a581615d5c565b946020939093013593505050565b6000806000606084860312156159c7578283fd5b83356159d281615d5c565b92506020840135915060408401356159e981615d5c565b809150509250925092565b600060208284031215615a05578081fd5b81518015158114610d96578182fd5b600060208284031215615a25578081fd5b5035919050565b600060208284031215615a3d578081fd5b5051919050565b60008060408385031215615a56578182fd5b505080516020909101519092909150565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b6001600160a01b039586168152938516602085015291841660408401529092166060820152608081019190915260a00190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6000602080835283518082850152825b81811015615ba557858101830151858201604001528201615b89565b81811115615bb65783604083870101525b50601f01601f1916929092016040019392505050565b6020808252601690820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604082015260600190565b6020808252601c908201527b6d61726b6572206d6574686f642072657475726e65642066616c736560201b604082015260600190565b6020808252600a90820152691c994b595b9d195c995960b21b604082015260600190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60008219821115615c9a57615c9a615d30565b500190565b600082615cba57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615615cd957615cd9615d30565b500290565b600082821015615cf057615cf0615d30565b500390565b600181811c90821680615d0957607f821691505b60208210811415615d2a57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114615d7157600080fd5b5056fea91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc545b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0ca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3eff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dca26469706673582212206d679d8c61d76070571935f75f6897481b71e535fe59c966f2d385fb906d6ae664736f6c63430008040033
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.