My Name Tag:
Not Available, login to update
Txn Hash |
Method
|
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x2f340f0326f1623df3a3c3420d413df17d1d3c24034a48e1938f3972e980987c | 0x60806040 | 26312435 | 433 days 20 hrs ago | 0x4b1d76f16d4342799ccfd2dfb3074591faad75f1 | IN | Create: OMatic | 0 MATIC | 0.186909336 |
[ Download CSV Export ]
Contract Name:
OMatic
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 400 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"; /** * @title 0VIX's OMatic Contract * @notice OToken which wraps Matic * @author 0VIX */ contract OMatic is OToken { bool public isInit = true; // init lock, only proxy can run init /** * @notice Construct a new OMatic 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_ ERC-20 name of this token * @param symbol_ ERC-20 symbol of this token * @param decimals_ ERC-20 decimal precision of this token * @param admin_ Address of the administrator of this token */ function init( IComptroller comptroller_, IInterestRateModel interestRateModel_, uint256 initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_, address payable admin_ ) public { require(!isInit,"init not possible"); isInit = true; // Creator of the contract is admin during initialization admin = payable(msg.sender); super.initialize( comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_ ); // Set the proper admin now that initialization is done admin = admin_; } /*** User Interface ***/ /** * @notice Sender supplies assets into the market and receives oTokens in exchange * @dev Reverts upon any failure */ function mint() external payable { (uint256 err, ) = mintInternal(msg.value); 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 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeem(uint256 redeemTokens) external returns (uint256) { return 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 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlying(uint256 redeemAmount) external returns (uint256) { return redeemUnderlyingInternal(redeemAmount); } /** * @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 borrow(uint256 borrowAmount) external returns (uint256) { return borrowInternal(borrowAmount); } /** * @notice Sender repays their own borrow * @dev Reverts upon any failure */ function repayBorrow() external payable { (uint256 err, ) = repayBorrowInternal(msg.value); requireNoError(err, "repayBorrow failed"); } /** * @notice Sender repays a borrow belonging to borrower * @dev Reverts upon any failure * @param borrower the account with the debt being payed off */ function repayBorrowBehalf(address borrower) external payable { (uint256 err, ) = repayBorrowBehalfInternal(borrower, msg.value); requireNoError(err, "repayBorrowBehalf failed"); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @dev Reverts upon any failure * @param borrower The borrower of this oToken to be liquidated * @param oTokenCollateral The market in which to seize collateral from the borrower */ function liquidateBorrow(address borrower, IOToken oTokenCollateral) external payable { (uint256 err, ) = liquidateBorrowInternal( borrower, msg.value, oTokenCollateral ); requireNoError(err, "liquidateBorrow failed"); } /** * @notice The sender adds to reserves. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReserves() external payable returns (uint256) { return _addReservesInternal(msg.value); } /** * @notice Send Matic to OMatic to mint */ receive() external payable { (uint256 err, ) = mintInternal(msg.value); requireNoError(err, "mint failed"); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of Matic, before this message * @dev This excludes the value of the current message, if any * @return The quantity of Matic owned by this contract */ function getCashPrior() internal view override returns (uint256) { (MathError err, uint256 startingBalance) = subUInt( address(this).balance, msg.value ); require(err == MathError.NO_ERROR); return startingBalance; } /** * @notice Perform the actual transfer in, which is a no-op * @param from Address sending the Matic * @param amount Amount of Matic being sent * @return The actual amount of Matic transferred */ function doTransferIn(address from, uint256 amount) internal override returns (uint256) { // Sanity checks require(msg.sender == from, "sender mismatch"); require(msg.value == amount, "value mismatch"); return amount; } function doTransferOut(address payable to, uint256 amount) internal override { /* Send the Matic, with minimal gas and revert on failure */ to.transfer(amount); } 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 "./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 ); if (allowed != 0) { return failOpaque( Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed ); } /* Do not allow self-transfers */ if (src == dst) { return fail(Error.BAD_INPUT, FailureInfo.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); if (mathErr != MathError.NO_ERROR) { return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ALLOWED); } (mathErr, srcTokensNew) = subUInt(accountTokens[src], tokens); if (mathErr != MathError.NO_ERROR) { return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_NOT_ENOUGH); } (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens); if (mathErr != MathError.NO_ERROR) { return fail(Error.MATH_ERROR, FailureInfo.TRANSFER_TOO_MUCH); } ///////////////////////// // 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 override view returns (uint256) { return transferAllowances[owner][spender]; } /** * @notice Get the token balance of the `owner` * @param owner The address of the account to query * @return The number of tokens owned by `owner` */ function balanceOf(address owner) external override view returns (uint256) { return accountTokens[owner]; } /** * @notice Get the underlying balance of the `owner` * @dev This also accrues interest in a transaction * @param owner The address of the account to query * @return The amount of underlying owned by `owner` */ function balanceOfUnderlying(address owner) external 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 override view 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 override view 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 override view 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 override view 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 override view 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 override view returns (uint256) { return getCashPrior(); } /** * @notice Applies accrued interest to total borrows and reserves * @dev This calculates interest accrued from the last checkpointed block * up to the current block and writes new checkpoint to storage. */ function accrueInterest() public 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 MATIC 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(this), 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 == type(uint256).max) { 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) ); } (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 MATIC 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, borrowBalanceStored(borrower) ); /* 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 MATIC 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 == -1, repayAmount = accountBorrows */ if (repayAmount == type(uint256).max) { 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 MATIC 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, borrowBalanceStored(borrower) ); /* 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); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint256(Error.NO_ERROR); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() external 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 MATIC 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) { // Used to store old share for use in the event that is emitted on success uint256 oldProtocolSeizeShareMantissa; // 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 ); } // Track the market's current protocol seize share oldProtocolSeizeShareMantissa = protocolSeizeShareMantissa; // Set the protocol seize share to newProtocolSeizeShareMantissa protocolSeizeShareMantissa = newProtocolSeizeShareMantissa; // Emit NewProtocolSeizeShareMantissa(oldProtocolSeizeShareMantissa, newProtocolSeizeShareMantissa) emit NewProtocolSeizeShare( oldProtocolSeizeShareMantissa, 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 virtual view returns (uint256); /** * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee. * This may revert due to insufficient balance or insufficient allowance. */ function doTransferIn(address from, uint256 amount) 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 } }
//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; 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; 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 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 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 "@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); }
//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 "../../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 "./IEIP20NonStandard.sol"; import "./IOToken.sol"; interface IOErc20 { /*** User Interface ***/ function mint(uint mintAmount) external returns (uint); function redeem(uint redeemTokens) external returns (uint); function redeemUnderlying(uint redeemAmount) external returns (uint); function borrow(uint borrowAmount) external returns (uint); function repayBorrow(uint repayAmount) external returns (uint); function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint); function liquidateBorrow(address borrower, uint repayAmount, IOToken oTokenCollateral) external returns (uint); 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 "./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; /** * @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; /** * @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 < 2**224, "safe224 overflow"); return uint224(n); } function safe32(uint n) pure internal returns (uint32) { require(n < 2**32, "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 // 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); }
{ "optimizer": { "enabled": true, "runs": 400 }, "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":[],"name":"_addReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","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":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"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"},{"internalType":"address payable","name":"admin_","type":"address"}],"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":"contract IOToken","name":"oTokenCollateral","type":"address"}],"name":"liquidateBorrow","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mint","outputs":[],"stateMutability":"payable","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":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemUnderlying","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"repayBorrow","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"}],"name":"repayBorrowBehalf","outputs":[],"stateMutability":"payable","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":[],"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"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60806040526012805460ff1916600117905534801561001d57600080fd5b50615ca1806200002e6000396000f3fe60806040526004361061032d5760003560e01c806395d89b41116101a5578063c5ebeaec116100ec578063e597461911610095578063f3fdb15a1161006f578063f3fdb15a146108dc578063f851a440146108fc578063fca7820b14610921578063fcb641471461094157600080fd5b8063e597461914610894578063e9c714f2146108a7578063f2b3abbd146108bc57600080fd5b8063d3bd2c72116100c6578063d3bd2c7214610819578063db006a751461082e578063dd62ed3e1461084e57600080fd5b8063c5ebeaec146107ce578063cd91801c146107ee578063cfa992011461080357600080fd5b8063aae40a2a1161014e578063b71d1a0c11610128578063b71d1a0c14610759578063bd6d894d14610779578063c37f68e21461078e57600080fd5b8063aae40a2a1461070c578063b145a5b81461071f578063b2a02ff11461073957600080fd5b8063a6afed951161017f578063a6afed95146106c1578063a9059cbb146106d6578063aa5af0fd146106f657600080fd5b806395d89b411461067757806395dd91931461068c57806397de9d11146106ac57600080fd5b80634576b5db116102745780636752e7021161021d57806373acee98116101f757806373acee981461060c5780638303084614610621578063852a12e3146106415780638f840ddd1461066157600080fd5b80636752e702146105a0578063704b6c02146105b657806370a08231146105d657600080fd5b806350a8adf21161024e57806350a8adf2146105405780635fe3b56714610560578063601a0bf11461058057600080fd5b80634576b5db1461050257806347bd3718146105225780634e4d9fea1461053857600080fd5b8063182df0f5116102d6578063313ce567116102b0578063313ce567146104a15780633af9e669146104cd5780633b1d21a2146104ed57600080fd5b8063182df0f51461043457806323b872dd14610449578063267822471461046957600080fd5b8063173b990411610307578063173b9904146103da57806317bfdfbc146103fe57806318160ddd1461041e57600080fd5b806306fdde0314610375578063095ea7b3146103a05780631249c58b146103d057600080fd5b3661037057600061033d34610949565b50905061036d816040518060400160405280600b81526020016a1b5a5b9d0819985a5b195960aa1b815250610a04565b50005b600080fd5b34801561038157600080fd5b5061038a610c49565b6040516103979190615b34565b60405180910390f35b3480156103ac57600080fd5b506103c06103bb3660046159de565b610cd7565b6040519015158152602001610397565b6103d8610d47565b005b3480156103e657600080fd5b506103f060085481565b604051908152602001610397565b34801561040a57600080fd5b506103f061041936600461591c565b610d85565b34801561042a57600080fd5b506103f0600d5481565b34801561044057600080fd5b506103f0610e3b565b34801561045557600080fd5b506103c061046436600461598c565b610ebc565b34801561047557600080fd5b50600454610489906001600160a01b031681565b6040516001600160a01b039091168152602001610397565b3480156104ad57600080fd5b506003546104bb9060ff1681565b60405160ff9091168152602001610397565b3480156104d957600080fd5b506103f06104e836600461591c565b610f29565b3480156104f957600080fd5b506103f0610fe7565b34801561050e57600080fd5b506103f061051d36600461591c565b610ff6565b34801561052e57600080fd5b506103f0600b5481565b6103d8611149565b34801561054c57600080fd5b506103d861055b366004615a29565b611196565b34801561056c57600080fd5b50600554610489906001600160a01b031681565b34801561058c57600080fd5b506103f061059b366004615ae1565b61124b565b3480156105ac57600080fd5b506103f060115481565b3480156105c257600080fd5b506103d86105d136600461591c565b6112f5565b3480156105e257600080fd5b506103f06105f136600461591c565b6001600160a01b03166000908152600e602052604090205490565b34801561061857600080fd5b506103f06113b2565b34801561062d57600080fd5b506103f061063c366004615ae1565b61145e565b34801561064d57600080fd5b506103f061065c366004615ae1565b6114eb565b34801561066d57600080fd5b506103f0600c5481565b34801561068357600080fd5b5061038a6114f6565b34801561069857600080fd5b506103f06106a736600461591c565b611503565b3480156106b857600080fd5b506103c0600181565b3480156106cd57600080fd5b506103f0611585565b3480156106e257600080fd5b506103c06106f13660046159de565b6119a0565b34801561070257600080fd5b506103f0600a5481565b6103d861071a3660046159cc565b611a0c565b34801561072b57600080fd5b506012546103c09060ff1681565b34801561074557600080fd5b506103f061075436600461598c565b611a60565b34801561076557600080fd5b506103f061077436600461591c565b611acc565b34801561078557600080fd5b506103f0611b4a565b34801561079a57600080fd5b506107ae6107a936600461591c565b611bfc565b604080519485526020850193909352918301526060820152608001610397565b3480156107da57600080fd5b506103f06107e9366004615ae1565b611cb9565b3480156107fa57600080fd5b506103f0611cc4565b34801561080f57600080fd5b506103f060095481565b34801561082557600080fd5b506103f0611d63565b34801561083a57600080fd5b506103f0610849366004615ae1565b611dbe565b34801561085a57600080fd5b506103f0610869366004615954565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6103d86108a236600461591c565b611dc9565b3480156108b357600080fd5b506103f0611e1b565b3480156108c857600080fd5b506103f06108d736600461591c565b611f11565b3480156108e857600080fd5b50600654610489906001600160a01b031681565b34801561090857600080fd5b506003546104899061010090046001600160a01b031681565b34801561092d57600080fd5b506103f061093c366004615ae1565b611f57565b6103f0611fe4565b60008054819060ff166109905760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b60448201526064015b60405180910390fd5b6000805460ff191681556109a2611585565b905080156109e0576109d48160108111156109cd57634e487b7160e01b600052602160045260246000fd5b601e611fef565b600092509250506109f0565b6109ea3385612092565b92509250505b6000805460ff191660011790559092909150565b81610a0d575050565b6000815160050167ffffffffffffffff811115610a3a57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015610a64576020820181803683370190505b50905060005b8251811015610add57828181518110610a9357634e487b7160e01b600052603260045260246000fd5b602001015160f81c60f81b828281518110610abe57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600101610a6a565b8151600160fd1b90839083908110610b0557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602860f81b828260010181518110610b4457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840460300160f81b828260020181518110610b8857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840660300160f81b828260030181518110610bcc57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602960f81b828260040181518110610c0b57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350818415610c425760405162461bcd60e51b81526004016109879190615b34565b5050505050565b60018054610c5690615bf5565b80601f0160208091040260200160405190810160405280929190818152602001828054610c8290615bf5565b8015610ccf5780601f10610ca457610100808354040283529160200191610ccf565b820191906000526020600020905b815481529060010190602001808311610cb257829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855292528083208590555191929182907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610d339087815260200190565b60405180910390a360019150505b92915050565b6000610d5234610949565b509050610d82816040518060400160405280600b81526020016a1b5a5b9d0819985a5b195960aa1b815250610a04565b50565b6000805460ff16610dc55760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff19168155610dd7611585565b14610e1d5760405162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b6044820152606401610987565b610e2682611503565b90505b6000805460ff19166001179055919050565b6000806000610e4861259f565b90925090506000826003811115610e6f57634e487b7160e01b600052602160045260246000fd5b14610d415760405162461bcd60e51b815260206004820152601960248201527f65786368616e67655261746553746f726564206661696c6564000000000000006044820152606401610987565b6000805460ff16610efc5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff19168155610f1233868686612677565b1490506000805460ff191660011790559392505050565b6000806040518060200160405280610f3f611b4a565b90526001600160a01b0384166000908152600e6020526040812054919250908190610f6b9084906129aa565b90925090506000826003811115610f9257634e487b7160e01b600052602160045260246000fd5b14610fdf5760405162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c61746564006044820152606401610987565b949350505050565b6000610ff1612a0a565b905090565b60035460009061010090046001600160a01b0316331461101a57610d41603f612a4a565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b15801561105f57600080fd5b505afa158015611073573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110979190615a09565b6110e35760405162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c7365000000006044820152606401610987565b600580546001600160a01b0319166001600160a01b0385811691821790925560408051928416835260208301919091527f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d91015b60405180910390a160005b9392505050565b600061115434612a57565b509050610d82816040518060400160405280601281526020017f7265706179426f72726f77206661696c65640000000000000000000000000000815250610a04565b60125460ff16156111e95760405162461bcd60e51b815260206004820152601160248201527f696e6974206e6f7420706f737369626c650000000000000000000000000000006044820152606401610987565b6012805460ff19166001179055600380543361010002610100600160a81b031990911617905561121d878787878787612ae8565b600380546001600160a01b0390921661010002610100600160a81b0319909216919091179055505050505050565b6000805460ff1661128b5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff1916815561129d611585565b905080156112d7576112cf8160108111156112c857634e487b7160e01b600052602160045260246000fd5b6030611fef565b915050610e29565b6112e083612d02565b9150506000805460ff19166001179055919050565b60035461010090046001600160a01b031633146113435760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610987565b600380546001600160a01b03838116610100908102610100600160a81b03198416179384905560408051938290048316808552919094049091166020830152917ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc910160405180910390a15050565b6000805460ff166113f25760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff19168155611404611585565b1461144a5760405162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b6044820152606401610987565b50600b546000805460ff1916600117905590565b6000805460ff1661149e5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff191681556114b0611585565b905080156114e2576112cf8160108111156114db57634e487b7160e01b600052602160045260246000fd5b6051611fef565b6112e083612ded565b6000610d4182612e67565b60028054610c5690615bf5565b600080600061151184612ef7565b9092509050600082600381111561153857634e487b7160e01b600052602160045260246000fd5b146111425760405162461bcd60e51b815260206004820152601a60248201527f626f72726f7742616c616e636553746f726564206661696c65640000000000006044820152606401610987565b60095460009042908082141561159f5760005b9250505090565b60006115a9612a0a565b600b54600c54600a546006546040516315f2405360e01b81526004810186905260248101859052604481018490529495509293919290916000916001600160a01b0316906315f240539060640160206040518083038186803b15801561160e57600080fd5b505afa158015611622573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116469190615af9565b905065048c2739500081111561169e5760405162461bcd60e51b815260206004820152601c60248201527f626f72726f772072617465206973206162737572646c792068696768000000006044820152606401610987565b6000806116ab8989612fcc565b909250905060008260038111156116d257634e487b7160e01b600052602160045260246000fd5b1461171f5760405162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c7461006044820152606401610987565b60408051602081019091526000815260008060008061174c60405180602001604052808a81525087612fef565b9097509450600087600381111561177357634e487b7160e01b600052602160045260246000fd5b146117b7576117a46009600689600381111561179f57634e487b7160e01b600052602160045260246000fd5b613079565b9e50505050505050505050505050505090565b6117c1858c6129aa565b909750935060008760038111156117e857634e487b7160e01b600052602160045260246000fd5b14611814576117a46009600189600381111561179f57634e487b7160e01b600052602160045260246000fd5b61181e848c61311b565b9097509250600087600381111561184557634e487b7160e01b600052602160045260246000fd5b14611871576117a46009600489600381111561179f57634e487b7160e01b600052602160045260246000fd5b61188c6040518060200160405280600854815250858c613141565b909750915060008760038111156118b357634e487b7160e01b600052602160045260246000fd5b146118df576117a46009600589600381111561179f57634e487b7160e01b600052602160045260246000fd5b6118ea858a8b613141565b9097509050600087600381111561191157634e487b7160e01b600052602160045260246000fd5b1461193d576117a46009600389600381111561179f57634e487b7160e01b600052602160045260246000fd5b60098e9055600a819055600b839055600c829055604080518d815260208101869052908101829052606081018490527f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc049060800160405180910390a160006117a4565b6000805460ff166119e05760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff191681556119f633338686612677565b1490506000805460ff1916600117905592915050565b6000611a198334846131aa565b509050611a5b816040518060400160405280601681526020017f6c6971756964617465426f72726f77206661696c656400000000000000000000815250610a04565b505050565b6000805460ff16611aa05760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff19169055611ab63385858561330a565b90506000805460ff191660011790559392505050565b60035460009061010090046001600160a01b03163314611af057610d416045612a4a565b600480546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99101611137565b6000805460ff16611b8a5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff19168155611b9c611585565b14611be25760405162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b6044820152606401610987565b611bea610e3b565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600e6020526040812054819081908190818080611c2789612ef7565b935090506000816003811115611c4d57634e487b7160e01b600052602160045260246000fd5b14611c6b5760095b6000806000975097509750975050505050611cb2565b611c7361259f565b925090506000816003811115611c9957634e487b7160e01b600052602160045260246000fd5b14611ca5576009611c55565b5060009650919450925090505b9193509193565b6000610d4182613890565b6006546000906001600160a01b03166315f24053611ce0612a0a565b600b54600c546040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064015b60206040518083038186803b158015611d2b57600080fd5b505afa158015611d3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff19190615af9565b6006546000906001600160a01b031663b8168816611d7f612a0a565b600b54600c546008546040516001600160e01b031960e087901b1681526004810194909452602484019290925260448301526064820152608401611d13565b6000610d418261391e565b6000611dd582346139a7565b509050611e17816040518060400160405280601881526020017f7265706179426f72726f77426568616c66206661696c65640000000000000000815250610a04565b5050565b6004546000906001600160a01b031633141580611e36575033155b15611e4557610ff16000612a4a565b60038054600480546001600160a01b03808216610100818102610100600160a81b0319871617968790556001600160a01b031990931690935560408051948390048216808652929095041660208401529290917ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc910160405180910390a1600454604080516001600160a01b03808516825290921660208301527fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9910160405180910390a16000611598565b600080611f1c611585565b90508015611f4e57611142816010811115611f4757634e487b7160e01b600052602160045260246000fd5b6040611fef565b61114283613a60565b6000805460ff16611f975760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff19168155611fa9611585565b90508015611fdb576112cf816010811115611fd457634e487b7160e01b600052602160045260246000fd5b6046611fef565b6112e083613bc8565b6000610ff134613c5b565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083601081111561203257634e487b7160e01b600052602160045260246000fd5b83605381111561205257634e487b7160e01b600052602160045260246000fd5b60408051928352602083019190915260009082015260600160405180910390a182601081111561114257634e487b7160e01b600052602160045260246000fd5b600554604051634ef4c3e160e01b81523060048201526001600160a01b038481166024830152604482018490526000928392839290911690634ef4c3e190606401602060405180830381600087803b1580156120ed57600080fd5b505af1158015612101573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121259190615af9565b905080156121465761213a6003601f83613079565b60009250925050612598565b5042600954146121675761215c600a6022611fef565b600091509150612598565b6040805180820190915260008082526020820152600061218561259f565b836020018193508260038111156121ac57634e487b7160e01b600052602160045260246000fd5b60038111156121cb57634e487b7160e01b600052602160045260246000fd5b90525060009050826020015160038111156121f657634e487b7160e01b600052602160045260246000fd5b1461223357612226600960218460200151600381111561179f57634e487b7160e01b600052602160045260246000fd5b6000935093505050612598565b600061223f8787613cfe565b9050600061225b82604051806020016040528086815250613d90565b8560200181935082600381111561228257634e487b7160e01b600052602160045260246000fd5b60038111156122a157634e487b7160e01b600052602160045260246000fd5b90525060009050846020015160038111156122cc57634e487b7160e01b600052602160045260246000fd5b146123195760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c45446044820152606401610987565b6000612327600d548361311b565b8660200181935082600381111561234e57634e487b7160e01b600052602160045260246000fd5b600381111561236d57634e487b7160e01b600052602160045260246000fd5b905250600090508560200151600381111561239857634e487b7160e01b600052602160045260246000fd5b146123e55760405162461bcd60e51b815260206004820152601c60248201527f4d494e545f4e45575f544f54414c5f535550504c595f4641494c4544000000006044820152606401610987565b6001600160a01b0389166000908152600e6020526040812054612408908461311b565b8760200181935082600381111561242f57634e487b7160e01b600052602160045260246000fd5b600381111561244e57634e487b7160e01b600052602160045260246000fd5b905250600090508660200151600381111561247957634e487b7160e01b600052602160045260246000fd5b146124c65760405162461bcd60e51b815260206004820152601f60248201527f4d494e545f4e45575f4143434f554e545f42414c414e43455f4641494c4544006044820152606401610987565b6001600160a01b038a166000908152600e60205260409020546124eb908b9083613da0565b600d8290556001600160a01b038a166000818152600e60209081526040918290208490558151928352820186905281018490527f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f9060600160405180910390a16040518381526001600160a01b038b169030907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a36000975092955050505050505b9250929050565b600d546000908190806125b9575050600754600092909150565b60006125c3612a0a565b905060006125dd6040518060200160405280600081525090565b60006125ee84600b54600c54613f25565b93509050600081600381111561261457634e487b7160e01b600052602160045260246000fd5b14612626579660009650945050505050565b6126308386613f77565b92509050600081600381111561265657634e487b7160e01b600052602160045260246000fd5b14612668579660009650945050505050565b50516000969095509350505050565b6005546040516317b9b84b60e31b81523060048201526001600160a01b038581166024830152848116604483015260648201849052600092839291169063bdcdc25890608401602060405180830381600087803b1580156126d757600080fd5b505af11580156126eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061270f9190615af9565b9050801561272c576127246003604a83613079565b915050610fdf565b836001600160a01b0316856001600160a01b03161415612752576127246002604b611fef565b6000856001600160a01b0316876001600160a01b03161415612777575060001961279f565b506001600160a01b038086166000908152600f60209081526040808320938a16835292905220545b6000806000806127af8589612fcc565b909450925060008460038111156127d657634e487b7160e01b600052602160045260246000fd5b146127f4576127e76009604b611fef565b9650505050505050610fdf565b6001600160a01b038a166000908152600e60205260409020546128179089612fcc565b9094509150600084600381111561283e57634e487b7160e01b600052602160045260246000fd5b1461284f576127e76009604c611fef565b6001600160a01b0389166000908152600e6020526040902054612872908961311b565b9094509050600084600381111561289957634e487b7160e01b600052602160045260246000fd5b146128aa576127e76009604d611fef565b6001600160a01b038a166000908152600e60205260409020546128cf908b9084613da0565b6001600160a01b0389166000908152600e60205260409020546128f4908a9083613da0565b6001600160a01b03808b166000908152600e6020526040808220859055918b16815220819055600019851461294c576001600160a01b03808b166000908152600f60209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8a60405161299191815260200190565b60405180910390a35060009a9950505050505050505050565b6000806000806129ba8686612fef565b909250905060008260038111156129e157634e487b7160e01b600052602160045260246000fd5b146129f25750915060009050612598565b60006129fd8261405e565b9350935050509250929050565b6000806000612a194734612fcc565b90925090506000826003811115612a4057634e487b7160e01b600052602160045260246000fd5b14610d4157600080fd5b6000610d41600183611fef565b60008054819060ff16612a995760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff19168155612aab611585565b90508015612add576109d4816010811115612ad657634e487b7160e01b600052602160045260246000fd5b6036611fef565b6109ea333386614076565b60035461010090046001600160a01b03163314612b475760405162461bcd60e51b815260206004820152601960248201527f6f6e6c792061646d696e206d617920696e697469616c697a65000000000000006044820152606401610987565b600954158015612b575750600a54155b612ba35760405162461bcd60e51b815260206004820152601360248201527f616c726561647920696e697469616c697a6564000000000000000000000000006044820152606401610987565b600784905583612bf55760405162461bcd60e51b815260206004820152601e60248201527f696e69742065786368616e67652072617465206d757374206265203e203000006044820152606401610987565b6000612c0087610ff6565b14612c4d5760405162461bcd60e51b815260206004820152601660248201527f73657420636f6d7074726f6c6c6572206661696c6564000000000000000000006044820152606401610987565b42600955670de0b6b3a7640000600a556000612c6886613a60565b14612cb55760405162461bcd60e51b815260206004820152601e60248201527f73657420696e7465726573742072617465206d6f64656c206661696c656400006044820152606401610987565b8251612cc89060019060208601906157ec565b508151612cdc9060029060208501906157ec565b506003805460ff90921660ff199283161790556000805490911660011790555050505050565b600354600090819061010090046001600160a01b03163314612d28576111426031612a4a565b4260095414612d3d57611142600a6033611fef565b82612d46612a0a565b1015612d5857611142600e6032611fef565b600c54831115612d6e5761114260026034611fef565b82600c54612d7c9190615bde565b600c819055600354909150612d9f9061010090046001600160a01b03168461451d565b600354604080516101009092046001600160a01b031682526020820185905281018290527f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e90606001611137565b600354600090819061010090046001600160a01b03163314612e13576111426052612a4a565b4260095414612e2857611142600a6053611fef565b50601180549083905560408051828152602081018590527ff5815f353a60e815cce7553e4f60c533a59d26b1b5504ea4b6db8d60da3e4da29101611137565b6000805460ff16612ea75760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff19168155612eb9611585565b90508015612eeb576112cf816010811115612ee457634e487b7160e01b600052602160045260246000fd5b6027611fef565b6112e033600085614553565b6001600160a01b038116600090815260106020526040812080548291829182918291612f2c5750600096879650945050505050565b612f3c8160000154600a54614c9b565b90945092506000846003811115612f6357634e487b7160e01b600052602160045260246000fd5b14612f7657509195600095509350505050565b612f84838260010154614cee565b90945091506000846003811115612fab57634e487b7160e01b600052602160045260246000fd5b14612fbe57509195600095509350505050565b506000969095509350505050565b600080838311612fe3575060009050818303612598565b50600390506000612598565b60006130076040518060200160405280600081525090565b600080613018866000015186614c9b565b9092509050600082600381111561303f57634e487b7160e01b600052602160045260246000fd5b1461305e57506040805160208101909152600081529092509050612598565b60408051602081019091529081526000969095509350505050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa08460108111156130bc57634e487b7160e01b600052602160045260246000fd5b8460538111156130dc57634e487b7160e01b600052602160045260246000fd5b604080519283526020830191909152810184905260600160405180910390a1836010811115610fdf57634e487b7160e01b600052602160045260246000fd5b60008083830184811061313357600092509050612598565b600260009250925050612598565b6000806000806131518787612fef565b9092509050600082600381111561317857634e487b7160e01b600052602160045260246000fd5b1461318957509150600090506131a2565b61319b6131958261405e565b8661311b565b9350935050505b935093915050565b60008054819060ff166131ec5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff191681556131fe611585565b9050801561323c5761323081601081111561322957634e487b7160e01b600052602160045260246000fd5b600f611fef565b600092509250506132f3565b836001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561327757600080fd5b505af115801561328b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132af9190615af9565b905080156132e1576132308160108111156132da57634e487b7160e01b600052602160045260246000fd5b6010611fef565b6132ed33878787614d2d565b92509250505b6000805460ff191660011790559094909350915050565b60055460405163d02f735160e01b81523060048201526001600160a01b0386811660248301528581166044830152848116606483015260848201849052600092839291169063d02f73519060a401602060405180830381600087803b15801561337257600080fd5b505af1158015613386573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133aa9190615af9565b905080156133bf576127246003601b83613079565b846001600160a01b0316846001600160a01b031614156133e5576127246006601c611fef565b613435604080516101208101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0385166000908152600e60205260409020546134589085612fcc565b602083018190528282600381111561348057634e487b7160e01b600052602160045260246000fd5b600381111561349f57634e487b7160e01b600052602160045260246000fd5b90525060009050815160038111156134c757634e487b7160e01b600052602160045260246000fd5b14613500576134f76009601a8360000151600381111561179f57634e487b7160e01b600052602160045260246000fd5b92505050610fdf565b61351a846040518060200160405280601154815250615269565b6080820181905261352b9085615bde565b606082015261353861259f565b60c083018190528282600381111561356057634e487b7160e01b600052602160045260246000fd5b600381111561357f57634e487b7160e01b600052602160045260246000fd5b90525060009050815160038111156135a757634e487b7160e01b600052602160045260246000fd5b146135f45760405162461bcd60e51b815260206004820152601860248201527f65786368616e67652072617465206d617468206572726f7200000000000000006044820152606401610987565b61361460405180602001604052808360c00151815250826080015161528c565b60a08201819052600c546136289190615b87565b60e08201526080810151600d5461363f9190615bde565b6101008201526001600160a01b0386166000908152600e6020526040902054606082015161366d919061311b565b604083018190528282600381111561369557634e487b7160e01b600052602160045260246000fd5b60038111156136b457634e487b7160e01b600052602160045260246000fd5b90525060009050815160038111156136dc57634e487b7160e01b600052602160045260246000fd5b1461370c576134f7600960198360000151600381111561179f57634e487b7160e01b600052602160045260246000fd5b61374085600e6000886001600160a01b03166001600160a01b03168152602001908152602001600020548360200151613da0565b6001600160a01b0386166000908152600e602052604090819020549082015161376a918891613da0565b60e0810151600c55610100810151600d556020808201516001600160a01b038781166000818152600e855260408082209490945583860151928b16808252908490209290925560608501519251928352909290917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3306001600160a01b0316856001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836080015160405161383291815260200190565b60405180910390a360a081015160e08201516040805130815260208101939093528201527fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc59060600160405180910390a16000979650505050505050565b6000805460ff166138d05760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff191681556138e2611585565b90508015613914576112cf81601081111561390d57634e487b7160e01b600052602160045260246000fd5b6008611fef565b6112e033846152a0565b6000805460ff1661395e5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff19168155613970611585565b9050801561399b576112cf816010811115612ee457634e487b7160e01b600052602160045260246000fd5b6112e033846000614553565b60008054819060ff166139e95760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff191681556139fb611585565b90508015613a3957613a2d816010811115613a2657634e487b7160e01b600052602160045260246000fd5b6035611fef565b60009250925050613a4a565b613a44338686614076565b92509250505b6000805460ff1916600117905590939092509050565b600354600090819061010090046001600160a01b03163314613a86576111426042612a4a565b4260095414613a9b57611142600a6041611fef565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b815260040160206040518083038186803b158015613aec57600080fd5b505afa158015613b00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b249190615a09565b613b705760405162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c7365000000006044820152606401610987565b600680546001600160a01b0319166001600160a01b0385811691821790925560408051928416835260208301919091527fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f9269101611137565b60035460009061010090046001600160a01b03163314613bec57610d416047612a4a565b4260095414613c0157610d41600a6048611fef565b670de0b6b3a7640000821115613c1d57610d4160026049611fef565b600880549083905560408051828152602081018590527faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f8214609101611137565b6000805460ff16613c9b5760405162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b6044820152606401610987565b6000805460ff19168155613cad611585565b90508015613cdf576112cf816010811115613cd857634e487b7160e01b600052602160045260246000fd5b604e611fef565b613ce88361555a565b509150506000805460ff19166001179055919050565b6000336001600160a01b03841614613d4a5760405162461bcd60e51b815260206004820152600f60248201526e0e6cadcc8cae440dad2e6dac2e8c6d608b1b6044820152606401610987565b813414613d8a5760405162461bcd60e51b815260206004820152600e60248201526d0ecc2d8eaca40dad2e6dac2e8c6d60931b6044820152606401610987565b50919050565b6000806000806129ba86866155e8565b600554604080516312ab2eaf60e21b815290516000926001600160a01b031691634aacbabc916004808301926020929190829003018186803b158015613de557600080fd5b505afa158015613df9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e1d9190615938565b90506001600160a01b03811615801590613ea957506040516301fd3f7760e71b81523060048201526001600160a01b0382169063fe9fbb809060240160206040518083038186803b158015613e7157600080fd5b505afa158015613e85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ea99190615a09565b15613f1f57604051639eba1f6760e01b81523060048201526001600160a01b0385811660248301526044820185905260648201849052821690639eba1f67906084015b600060405180830381600087803b158015613f0657600080fd5b505af1158015613f1a573d6000803e3d6000fd5b505050505b50505050565b600080600080613f35878761311b565b90925090506000826003811115613f5c57634e487b7160e01b600052602160045260246000fd5b14613f6d57509150600090506131a2565b61319b8186612fcc565b6000613f8f6040518060200160405280600081525090565b600080613fa486670de0b6b3a7640000614c9b565b90925090506000826003811115613fcb57634e487b7160e01b600052602160045260246000fd5b14613fea57506040805160208101909152600081529092509050612598565b600080613ff78388614cee565b9092509050600082600381111561401e57634e487b7160e01b600052602160045260246000fd5b146140415781604051806020016040528060008152509550955050505050612598565b604080516020810190915290815260009890975095505050505050565b8051600090610d4190670de0b6b3a764000090615b9f565b600554604051631200453160e11b81523060048201526001600160a01b03858116602483015284811660448301526064820184905260009283928392909116906324008a6290608401602060405180830381600087803b1580156140d957600080fd5b505af11580156140ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141119190615af9565b90508015614132576141266003603883613079565b600092509250506131a2565b426009541461414757614126600a6039611fef565b6141906040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b600061419b87611503565b6001600160a01b038816600090815260106020526040902060010154606084015290506141c787612ef7565b60808401819052602084018260038111156141f257634e487b7160e01b600052602160045260246000fd5b600381111561421157634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561423c57634e487b7160e01b600052602160045260246000fd5b1461427a5761426c600960378460200151600381111561179f57634e487b7160e01b600052602160045260246000fd5b6000945094505050506131a2565b600019861415614293576080820151604083015261429b565b604082018690525b6142a9888360400151613cfe565b60e0830181905260808301516142be91612fcc565b60a08401819052602084018260038111156142e957634e487b7160e01b600052602160045260246000fd5b600381111561430857634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561433357634e487b7160e01b600052602160045260246000fd5b146143805760405162461bcd60e51b815260206004820181905260248201527f52455041595f4e45575f4143434f554e545f42414c414e43455f4641494c45446044820152606401610987565b614390600b548360e00151612fcc565b60c08401819052602084018260038111156143bb57634e487b7160e01b600052602160045260246000fd5b60038111156143da57634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561440557634e487b7160e01b600052602160045260246000fd5b146144525760405162461bcd60e51b815260206004820152601e60248201527f52455041595f4e45575f544f54414c5f42414c414e43455f4641494c454400006044820152606401610987565b60a0820180516001600160a01b03891660009081526010602052604090819020918255600a5460019092019190915560c0840151600b81905560e0850151925191517f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1936144ef938d938d936001600160a01b03958616815293909416602084015260408301919091526060820152608081019190915260a00190565b60405180910390a161450a87826145058a611503565b615669565b5060e00151600097909650945050505050565b6040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015611a5b573d6000803e3d6000fd5b6000821580614560575081155b6145ac5760405162461bcd60e51b815260206004820152601e60248201527f746f6b656e73496e206f7220616d6f756e74496e206d757374206265203000006044820152606401610987565b6145ed6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6145f561259f565b604083018190526020830182600381111561462057634e487b7160e01b600052602160045260246000fd5b600381111561463f57634e487b7160e01b600052602160045260246000fd5b905250600090508160200151600381111561466a57634e487b7160e01b600052602160045260246000fd5b146146a25761469a6009602b8360200151600381111561179f57634e487b7160e01b600052602160045260246000fd5b915050611142565b83156147a7576000198414156146d5576001600160a01b0385166000908152600e602052604090205460608201526146dd565b606081018490525b6146fd6040518060200160405280836040015181525082606001516129aa565b608083018190526020830182600381111561472857634e487b7160e01b600052602160045260246000fd5b600381111561474757634e487b7160e01b600052602160045260246000fd5b905250600090508160200151600381111561477257634e487b7160e01b600052602160045260246000fd5b146147a25761469a600960298360200151600381111561179f57634e487b7160e01b600052602160045260246000fd5b6148b5565b6000198314156147ee576001600160a01b0385166000908152600e602090815260409182902054606084019081528251918201835291830151815290516146fd91906129aa565b6080810183905260408051602081018252908201518152614810908490613d90565b606083018190526020830182600381111561483b57634e487b7160e01b600052602160045260246000fd5b600381111561485a57634e487b7160e01b600052602160045260246000fd5b905250600090508160200151600381111561488557634e487b7160e01b600052602160045260246000fd5b146148b55761469a6009602a8360200151600381111561179f57634e487b7160e01b600052602160045260246000fd5b600554606082015160405163eabe7d9160e01b81523060048201526001600160a01b0388811660248301526044820192909252600092919091169063eabe7d9190606401602060405180830381600087803b15801561491357600080fd5b505af1158015614927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061494b9190615af9565b90508015614969576149606003602883613079565b92505050611142565b426009541461497e57614960600a602c611fef565b61498e600d548360600151612fcc565b60a08401819052602084018260038111156149b957634e487b7160e01b600052602160045260246000fd5b60038111156149d857634e487b7160e01b600052602160045260246000fd5b9052506000905082602001516003811115614a0357634e487b7160e01b600052602160045260246000fd5b14614a33576149606009602e8460200151600381111561179f57634e487b7160e01b600052602160045260246000fd5b6001600160a01b0386166000908152600e60205260409020546060830151614a5b9190612fcc565b60c0840181905260208401826003811115614a8657634e487b7160e01b600052602160045260246000fd5b6003811115614aa557634e487b7160e01b600052602160045260246000fd5b9052506000905082602001516003811115614ad057634e487b7160e01b600052602160045260246000fd5b14614b00576149606009602d8460200151600381111561179f57634e487b7160e01b600052602160045260246000fd5b8160800151614b0d612a0a565b1015614b1f57614960600e602f611fef565b6001600160a01b0386166000908152600e602052604090205460c0830151614b48918891613da0565b60a0820151600d5560c08201516001600160a01b0387166000818152600e602052604090819020929092556060840151915130927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91614baa91815260200190565b60405180910390a36080820151606080840151604080516001600160a01b038b16815260208101949094528301527fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929910160405180910390a1600554608083015160608401516040516351dff98960e01b81523060048201526001600160a01b038a81166024830152604482019390935260648101919091529116906351dff98990608401600060405180830381600087803b158015614c6957600080fd5b505af1158015614c7d573d6000803e3d6000fd5b50505050614c8f86836080015161451d565b60009695505050505050565b60008083614cae57506000905080612598565b83830283858281614ccf57634e487b7160e01b600052601260045260246000fd5b0414614ce357600260009250925050612598565b600092509050612598565b60008082614d025750600190506000612598565b6000838581614d2157634e487b7160e01b600052601260045260246000fd5b04915091509250929050565b600554604051632fe3f38f60e11b81523060048201526001600160a01b03838116602483015286811660448301528581166064830152608482018590526000928392839290911690635fc7e71e9060a401602060405180830381600087803b158015614d9857600080fd5b505af1158015614dac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614dd09190615af9565b90508015614df157614de56003601283613079565b60009250925050615260565b4260095414614e0657614de5600a6016611fef565b42846001600160a01b031663cfa992016040518163ffffffff1660e01b8152600401602060405180830381600087803b158015614e4257600080fd5b505af1158015614e56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e7a9190615af9565b14614e8b57614de5600a6011611fef565b866001600160a01b0316866001600160a01b03161415614eb157614de560066017611fef565b84614ec257614de560076015611fef565b600019851415614ed857614de560076014611fef565b600080614ee6898989614076565b90925090508115614f2957614f1b826010811115614f1457634e487b7160e01b600052602160045260246000fd5b6018611fef565b600094509450505050615260565b60055460405163c488847b60e01b81523060048201526001600160a01b03888116602483015260448201849052600092839291169063c488847b90606401604080518083038186803b158015614f7e57600080fd5b505afa158015614f92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614fb69190615b11565b9092509050811561502f5760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f60448201527f414d4f554e545f5345495a455f4641494c4544000000000000000000000000006064820152608401610987565b6040516370a0823160e01b81526001600160a01b038b811660048301528291908a16906370a082319060240160206040518083038186803b15801561507357600080fd5b505afa158015615087573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906150ab9190615af9565b10156150f95760405162461bcd60e51b815260206004820152601860248201527f4c49515549444154455f5345495a455f544f4f5f4d55434800000000000000006044820152606401610987565b60006001600160a01b03891630141561511f57615118308d8d8561330a565b90506151ac565b60405163b2a02ff160e01b81526001600160a01b038d811660048301528c81166024830152604482018490528a169063b2a02ff190606401602060405180830381600087803b15801561517157600080fd5b505af1158015615185573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151a99190615af9565b90505b80156151fa5760405162461bcd60e51b815260206004820152601460248201527f746f6b656e207365697a757265206661696c65640000000000000000000000006044820152606401610987565b604080516001600160a01b038e811682528d811660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a16000975092955050505050505b94509492505050565b8051600090670de0b6b3a7640000906152829085615bbf565b6111429190615b9f565b600061114261529b84846157b9565b61405e565b60055460405163368f515360e21b81523060048201526001600160a01b03848116602483015260448201849052600092839291169063da3d454c90606401602060405180830381600087803b1580156152f857600080fd5b505af115801561530c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906153309190615af9565b9050801561534d576153456003600e83613079565b915050610d41565b50426009541461536957615362600a80611fef565b9050610d41565b81615372612a0a565b101561538457615362600e6009611fef565b60008061539085612ef7565b909250905060008260038111156153b757634e487b7160e01b600052602160045260246000fd5b146153ec576153e36009600784600381111561179f57634e487b7160e01b600052602160045260246000fd5b92505050610d41565b8060006153f9828761311b565b9094509050600084600381111561542057634e487b7160e01b600052602160045260246000fd5b146154575761544c6009600c86600381111561179f57634e487b7160e01b600052602160045260246000fd5b945050505050610d41565b6000615465600b548861311b565b9095509050600085600381111561548c57634e487b7160e01b600052602160045260246000fd5b146154c4576154b86009600b87600381111561179f57634e487b7160e01b600052602160045260246000fd5b95505050505050610d41565b6001600160a01b038816600081815260106020908152604091829020858155600a54600190910155600b849055815192835282018990528101839052606081018290527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a161554288846145058b611503565b61554c888861451d565b600098975050505050505050565b6000808080426009541461557e57615574600a604f611fef565b9590945092505050565b6155883386613cfe565b905080600c546155989190615b87565b600c81905560408051338152602081018490529081018290529092507fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc59060600160405180910390a16000615574565b60006156006040518060200160405280600081525090565b600080615615670de0b6b3a764000087614c9b565b9092509050600082600381111561563c57634e487b7160e01b600052602160045260246000fd5b1461565b57506040805160208101909152600081529092509050612598565b6129fd818660000151613f77565b600554604080516312ab2eaf60e21b815290516000926001600160a01b031691634aacbabc916004808301926020929190829003018186803b1580156156ae57600080fd5b505afa1580156156c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906156e69190615938565b90506001600160a01b0381161580159061577257506040516301fd3f7760e71b81523060048201526001600160a01b0382169063fe9fbb809060240160206040518083038186803b15801561573a57600080fd5b505afa15801561574e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906157729190615a09565b15613f1f57604051630578982360e01b81523060048201526001600160a01b0385811660248301526044820185905260648201849052821690630578982390608401613eec565b60408051602081019091526000815260405180602001604052808385600001516157e39190615bbf565b90529392505050565b8280546157f890615bf5565b90600052602060002090601f01602090048101928261581a5760008555615860565b82601f1061583357805160ff1916838001178555615860565b82800160010185558215615860579182015b82811115615860578251825591602001919060010190615845565b5061586c929150615870565b5090565b5b8082111561586c5760008155600101615871565b803561589081615c56565b919050565b600082601f8301126158a5578081fd5b813567ffffffffffffffff808211156158c0576158c0615c40565b604051601f8301601f19908116603f011681019082821181831017156158e8576158e8615c40565b81604052838152866020858801011115615900578485fd5b8360208701602083013792830160200193909352509392505050565b60006020828403121561592d578081fd5b813561114281615c56565b600060208284031215615949578081fd5b815161114281615c56565b60008060408385031215615966578081fd5b823561597181615c56565b9150602083013561598181615c56565b809150509250929050565b6000806000606084860312156159a0578081fd5b83356159ab81615c56565b925060208401356159bb81615c56565b929592945050506040919091013590565b60008060408385031215615966578182fd5b600080604083850312156159f0578182fd5b82356159fb81615c56565b946020939093013593505050565b600060208284031215615a1a578081fd5b81518015158114611142578182fd5b600080600080600080600060e0888a031215615a43578283fd5b8735615a4e81615c56565b96506020880135615a5e81615c56565b955060408801359450606088013567ffffffffffffffff80821115615a81578485fd5b615a8d8b838c01615895565b955060808a0135915080821115615aa2578485fd5b50615aaf8a828b01615895565b93505060a088013560ff81168114615ac5578283fd5b9150615ad360c08901615885565b905092959891949750929550565b600060208284031215615af2578081fd5b5035919050565b600060208284031215615b0a578081fd5b5051919050565b60008060408385031215615b23578182fd5b505080516020909101519092909150565b6000602080835283518082850152825b81811015615b6057858101830151858201604001528201615b44565b81811115615b715783604083870101525b50601f01601f1916929092016040019392505050565b60008219821115615b9a57615b9a615c2a565b500190565b600082615bba57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615615bd957615bd9615c2a565b500290565b600082821015615bf057615bf0615c2a565b500390565b600181811c90821680615c0957607f821691505b60208210811415613d8a57634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610d8257600080fdfea2646970667358221220ee36cda7dbe5e36cc8f260a666fd39ee43fbf0b43b190b08def292ab62d5521564736f6c63430008040033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.