Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
KErc20
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 1 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "./abstract/KToken.sol"; import "./abstract/KErc20Storage.sol"; /** * @title KEOM's KErc20 Contract * @notice KTokens which wrap an EIP-20 underlying * @author KEOM */ contract KErc20 is KToken, KErc20Storage { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ ERC-20 name of this token * @param symbol_ ERC-20 symbol of this token * @param decimals_ ERC-20 decimal precision of this token * @param admin_ Address of the administrator of this token */ function initialize( address underlying_, IComptroller comptroller_, IInterestRateModel interestRateModel_, uint256 initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_, address payable admin_ ) external initializer { admin = payable(msg.sender); super.initialize( comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_ ); // Set underlying and sanity check it underlying = underlying_; IEIP20(underlying).totalSupply(); // Set the proper admin now that initialization is done admin = admin_; } /*** User Interface ***/ /** * @notice Sender supplies assets into the market and receives kTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @dev Reverts upon any failure */ function mint(uint256 mintAmount) external override { (uint256 err, ) = mintInternal(mintAmount); requireNoError(err, "mint failed"); } /** * @notice Sender redeems kTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of kTokens to redeem into underlying */ function redeem(uint256 redeemTokens) external override { redeemInternal(redeemTokens); } /** * @notice Sender redeems kTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to redeem */ function redeemUnderlying(uint256 redeemAmount) external override{ redeemUnderlyingInternal(redeemAmount); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow */ function borrow(uint256 borrowAmount) external override { borrowInternal(borrowAmount); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @dev Reverts upon any failure */ function repayBorrow(uint256 repayAmount) external override { (uint256 err, ) = repayBorrowInternal(repayAmount); requireNoError(err, "repayBorrow failed"); } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @dev Reverts upon any failure */ function repayBorrowBehalf(address borrower, uint256 repayAmount) external override { (uint256 err, ) = repayBorrowBehalfInternal(borrower, repayAmount); requireNoError(err, "repayBorrowBehalf failed"); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this kToken to be liquidated * @param repayAmount The amount of the underlying borrowed asset to repay * @param kTokenCollateral The market in which to seize collateral from the borrower * @dev Reverts upon any failure */ function liquidateBorrow( address borrower, uint256 repayAmount, IKToken kTokenCollateral ) external override { (uint256 err, ) = liquidateBorrowInternal( borrower, repayAmount, kTokenCollateral ); requireNoError(err, "liquidateBorrow failed"); } /** * @notice The sender liquidates the borrowers collateral and updates prices at Pyth's oracle. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this kToken to be liquidated * @param repayAmount The amount of the underlying borrowed asset to repay * @param kTokenCollateral The market in which to seize collateral from the borrower * @param priceUpdateData data for updating prices on Pyth smart contract * @dev Reverts upon any failure */ function liquidateBorrowWithPriceUpdate( address borrower, uint256 repayAmount, IKToken kTokenCollateral, bytes[] calldata priceUpdateData ) external { comptroller.updatePrices(priceUpdateData); (uint256 err, ) = liquidateBorrowInternal( borrower, repayAmount, kTokenCollateral ); requireNoError(err, "liquidateBorrow failed"); } /** * @notice The sender adds to reserves. * @param addAmount The amount fo underlying token to add as reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReserves(uint256 addAmount) external override returns (uint256) { return _addReservesInternal(addAmount); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying tokens owned by this contract */ function getCashPrior() internal override view returns (uint256) { IEIP20 token = IEIP20(underlying); return token.balanceOf(address(this)); } /** * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case. * This will revert due to insufficient balance or insufficient allowance. * This function returns the actual amount received, * which may be less than `amount` if there is a fee attached to the transfer. * * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ function doTransferIn(address from, uint256 amount) internal override returns (uint256) { IEIP20NonStandard token = IEIP20NonStandard(underlying); uint256 balanceBefore = IEIP20(underlying).balanceOf( address(this) ); token.transferFrom(from, address(this), amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) // set success to true } case 32 { // This is a compliant ERC-20 returndatacopy(0, 0, 32) success := mload(0) // Set `success = returndata` of external call } default { // This is an excessively non-compliant ERC-20, revert. revert(0, 0) } } require(success, "TOKEN_TRANSFER_IN_FAILED"); // Calculate the amount that was *actually* transferred uint256 balanceAfter = IEIP20(underlying).balanceOf( address(this) ); require(balanceAfter >= balanceBefore, "TOKEN_TRANSFER_IN_OVERFLOW"); return balanceAfter - balanceBefore; // underflow already checked above, just subtract } /** * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified * it is >= amount, this should not revert in normal conditions. * * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ function doTransferOut(address payable to, uint256 amount) internal override virtual { IEIP20NonStandard token = IEIP20NonStandard(underlying); token.transfer(to, amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) // set success to true } case 32 { // This is a complaint ERC-20 returndatacopy(0, 0, 32) success := mload(0) // Set `success = returndata` of external call } default { // This is an excessively non-compliant ERC-20, revert. revert(0, 0) } } require(success, "TOKEN_TRANSFER_OUT_FAILED"); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/Address.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !Address.isContract(address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; /** * @title KEOM's IInterestRateModel Interface * @author KEOM */ 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 "../ktokens/interfaces/IKToken.sol"; import "../oracles/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 kTokens) external returns (uint[] memory); function exitMarket(address kToken) external returns (uint); /*** Policy Hooks ***/ function mintAllowed(address kToken, address minter, uint mintAmount) external returns (uint); function redeemAllowed(address kToken, address redeemer, uint redeemTokens) external returns (uint); function redeemVerify(address kToken, address redeemer, uint redeemAmount, uint redeemTokens) external; function borrowAllowed(address kToken, address borrower, uint borrowAmount) external returns (uint); function repayBorrowAllowed( address kToken, address payer, address borrower, uint repayAmount) external returns (uint); function liquidateBorrowAllowed( address kTokenBorrowed, address kTokenCollateral, address liquidator, address borrower, uint repayAmount) external returns (uint, uint); function seizeAllowed( address kTokenCollateral, address kTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external returns (uint); function transferAllowed(address kToken, address src, address dst, uint transferTokens) external returns (uint); /*** Liquidity/Liquidation Calculations ***/ function liquidateCalculateSeizeTokens( address kTokenBorrowed, address kTokenCollateral, uint repayAmount, uint dynamicLiquidationIncentive) external view returns (uint, uint); function isMarket(address market) external view returns(bool); function getAllMarkets() external view returns(IKToken[] memory); function oracle() external view returns(PriceOracle); function updatePrices(bytes[] calldata priceUpdateData) external; }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "../interfaces/IKErc20.sol"; abstract contract KErc20Storage is IKErc20 { /** * @notice Underlying asset for this KToken */ address public override underlying; }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "./KTokenStorage.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 "@openzeppelin/contracts/proxy/utils/Initializable.sol"; /** * @title KEOM's KToken Contract * @notice Abstract base for KTokens * @author KEOM */ abstract contract KToken is KTokenStorage, Exponential, TokenErrorReporter, Initializable { /** * @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; } /** * @notice Transfer `tokens` tokens from `src` to `dst` by `spender` * @dev Called by both `transfer` and `transferFrom` internally * @param spender The address of the account performing the transfer * @param src The address of the source account * @param dst The address of the destination account * @param tokens The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferTokens( address spender, address src, address dst, uint256 tokens ) internal returns (uint256) { /* Fail if transfer not allowed */ uint256 allowed = comptroller.transferAllowed( address(this), src, dst, tokens ); require(allowed == 0, "ERC20: transfer not allowed"); /* Do not allow self-transfers */ require(src != dst, "ERC20: self-transfer not allowed"); /* Get the allowance, infinite for the account owner */ uint256 startingAllowance = 0; if (spender == src) { startingAllowance = type(uint256).max; } else { startingAllowance = transferAllowances[src][spender]; } /* Do the calculations, checking for {under,over}flow */ MathError mathErr; uint256 allowanceNew; uint256 srkTokensNew; uint256 dstTokensNew; (mathErr, allowanceNew) = subUInt(startingAllowance, tokens); require( mathErr == MathError.NO_ERROR, "ERC20: decreased allowance below zero" ); (mathErr, srkTokensNew) = subUInt(accountTokens[src], tokens); require( mathErr == MathError.NO_ERROR, "ERC20: transfer amount exceeds balance" ); (mathErr, dstTokensNew) = addUInt(accountTokens[dst], tokens); require( mathErr == MathError.NO_ERROR, "ERC20: maximum destination balance reached" ); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) accountTokens[src] = srkTokensNew; accountTokens[dst] = dstTokensNew; /* Eat some of the allowance (if necessary) */ if (startingAllowance != type(uint256).max) { transferAllowances[src][spender] = allowanceNew; } /* We emit a Transfer event */ emit Transfer(src, dst, tokens); // unused function // comptroller.transferVerify(address(this), src, dst, tokens); return uint256(Error.NO_ERROR); } /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external override nonReentrant returns (bool) { return transferTokens(msg.sender, msg.sender, dst, amount) == uint256(Error.NO_ERROR); } /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom( address src, address dst, uint256 amount ) external override nonReentrant returns (bool) { return transferTokens(msg.sender, src, dst, amount) == uint256(Error.NO_ERROR); } /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external override returns (bool) { address src = msg.sender; transferAllowances[src][spender] = amount; emit Approval(src, spender, amount); return true; } /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view override returns (uint256) { return transferAllowances[owner][spender]; } /** * @notice Get the token balance of the `owner` * @param owner The address of the account to query * @return The number of tokens owned by `owner` */ function balanceOf(address owner) external view override returns (uint256) { return accountTokens[owner]; } /** * @notice Get the underlying balance of the `owner` * @dev This also accrues interest in a transaction * @param owner The address of the account to query * @return The amount of underlying owned by `owner` */ function balanceOfUnderlying(address owner) external override returns (uint256) { Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()}); (MathError mErr, uint256 balance) = mulScalarTruncate( exchangeRate, accountTokens[owner] ); require(mErr == MathError.NO_ERROR, "balance could not be calculated"); return balance; } /** * @notice Get a snapshot of the account's balances, and the cached exchange rate * @dev This is used by comptroller to more efficiently perform liquidity checks. * @param account Address of the account to snapshot * @return (possible error, token balance, borrow balance, exchange rate mantissa) */ function getAccountSnapshot(address account) external view override returns ( uint256, uint256, uint256, uint256 ) { uint256 kTokenBalance = 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), kTokenBalance, 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 kToken * @return The borrow interest rate per timestmp, scaled by 1e18 */ function borrowRatePerTimestamp() external view override returns (uint256) { return interestRateModel.getBorrowRate( getCashPrior(), totalBorrows, totalReserves ); } /** * @notice Returns the current per-timestamp supply interest rate for this kToken * @return The supply interest rate per timestmp, scaled by 1e18 */ function supplyRatePerTimestamp() external view override returns (uint256) { return interestRateModel.getSupplyRate( getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa ); } /** * @notice Returns the current total borrows plus accrued interest * @return The total borrows with interest */ function totalBorrowsCurrent() external override nonReentrant returns (uint256) { require( accrueInterest() == uint256(Error.NO_ERROR), "accrue interest failed" ); return totalBorrows; } /** * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex * @param account The address whose balance should be calculated after updating borrowIndex * @return The calculated balance */ function borrowBalanceCurrent(address account) external override nonReentrant returns (uint256) { require( accrueInterest() == uint256(Error.NO_ERROR), "accrue interest failed" ); return borrowBalanceStored(account); } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return The calculated balance */ function borrowBalanceStored(address account) public view override returns (uint256) { (MathError err, uint256 result) = borrowBalanceStoredInternal(account); require(err == MathError.NO_ERROR, "borrowBalanceStored failed"); return result; } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return (error code, the calculated balance or 0 if error code is non-zero) */ function borrowBalanceStoredInternal(address account) internal view returns (MathError, uint256) { /* Note: we do not assert that the market is up to date */ MathError mathErr; uint256 principalTimesIndex; uint256 result; /* Get borrowBalance and borrowIndex */ BorrowSnapshot storage borrowSnapshot = accountBorrows[account]; /* If borrowBalance = 0 then borrowIndex is likely also 0. * Rather than failing the calculation with a division by 0, we immediately return 0 in this case. */ if (borrowSnapshot.principal == 0) { return (MathError.NO_ERROR, 0); } /* Calculate new borrow balance using the interest index: * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex */ (mathErr, principalTimesIndex) = mulUInt( borrowSnapshot.principal, borrowIndex ); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } (mathErr, result) = divUInt( principalTimesIndex, borrowSnapshot.interestIndex ); if (mathErr != MathError.NO_ERROR) { return (mathErr, 0); } return (MathError.NO_ERROR, result); } /** * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateCurrent() public override nonReentrant returns (uint256) { require( accrueInterest() == uint256(Error.NO_ERROR), "accrue interest failed" ); return exchangeRateStored(); } /** * @notice Calculates the exchange rate from the underlying to the KToken * @dev This function does not accrue interest before calculating the exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateStored() public view override returns (uint256) { (MathError err, uint256 result) = exchangeRateStoredInternal(); require(err == MathError.NO_ERROR, "exchangeRateStored failed"); return result; } /** * @notice Calculates the exchange rate from the underlying to the KToken * @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 kToken in the underlying asset * @return The quantity of underlying asset owned by this contract */ function getCash() external view override returns (uint256) { return getCashPrior(); } /** * @notice Applies accrued interest to total borrows and reserves * @dev This calculates interest accrued from the last checkpointed block * up to the current block and writes new checkpoint to storage. */ function accrueInterest() public override returns (uint256) { /* Remember the initial block timestamp */ uint256 currentBlockTimestamp = getBlockTimestamp(); uint256 accrualBlockTimestampPrior = accrualBlockTimestamp; /* Short-circuit accumulating 0 interest */ if (accrualBlockTimestampPrior == currentBlockTimestamp) { return uint256(Error.NO_ERROR); } /* Read the previous values out of storage */ uint256 cashPrior = getCashPrior(); uint256 borrowsPrior = totalBorrows; uint256 reservesPrior = totalReserves; uint256 borrowIndexPrior = borrowIndex; /* Calculate the current borrow interest rate */ uint256 borrowRateMantissa = interestRateModel.getBorrowRate( cashPrior, borrowsPrior, reservesPrior ); require( borrowRateMantissa <= borrowRateMaxMantissa, "borrow rate is absurdly high" ); /* Calculate the number of blocks elapsed since the last accrual */ (MathError mathErr, uint256 blockDelta) = subUInt( currentBlockTimestamp, accrualBlockTimestampPrior ); require( mathErr == MathError.NO_ERROR, "could not calculate block delta" ); /* * Calculate the interest accumulated into borrows and reserves and the new index: * simpleInterestFactor = borrowRate * blockDelta * interestAccumulated = simpleInterestFactor * totalBorrows * totalBorrowsNew = interestAccumulated + totalBorrows * totalReservesNew = interestAccumulated * reserveFactor + totalReserves * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex */ Exp memory simpleInterestFactor; uint256 interestAccumulated; uint256 totalBorrowsNew; uint256 totalReservesNew; uint256 borrowIndexNew; (mathErr, simpleInterestFactor) = mulScalar( Exp({mantissa: borrowRateMantissa}), blockDelta ); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED, uint256(mathErr) ); } (mathErr, interestAccumulated) = mulScalarTruncate( simpleInterestFactor, borrowsPrior ); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED, uint256(mathErr) ); } (mathErr, totalBorrowsNew) = addUInt(interestAccumulated, borrowsPrior); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED, uint256(mathErr) ); } (mathErr, totalReservesNew) = mulScalarTruncateAddUInt( Exp({mantissa: reserveFactorMantissa}), interestAccumulated, reservesPrior ); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED, uint256(mathErr) ); } (mathErr, borrowIndexNew) = mulScalarTruncateAddUInt( simpleInterestFactor, borrowIndexPrior, borrowIndexPrior ); if (mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED, uint256(mathErr) ); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accrualBlockTimestamp = currentBlockTimestamp; borrowIndex = borrowIndexNew; totalBorrows = totalBorrowsNew; totalReserves = totalReservesNew; /* We emit an AccrueInterest event */ emit AccrueInterest( cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew ); return uint256(Error.NO_ERROR); } /** * @notice Sender supplies assets into the market and receives kTokens 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 kTokens 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 kToken must handle variations between ERC-20 and NATIVE underlying. * `doTransferIn` reverts if anything goes wrong, since we can't be sure if * side-effects occurred. The function returns the amount actually transferred, * in case of a fee. On success, the kToken holds an additional `actualMintAmount` * of cash. */ uint256 actualMintAmount = doTransferIn(minter, mintAmount); /* * We get the current exchange rate and calculate the number of kTokens 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 kTokens 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" ); /* We write previously calculated values into storage */ totalSupply = totalSupplyNew; accountTokens[minter] = accountTokensNew; /* We emit a Mint event, and a Transfer event */ emit Mint(minter, actualMintAmount, mintTokens); emit Transfer(address(0), minter, mintTokens); return (uint256(Error.NO_ERROR), actualMintAmount); } /** * @notice Sender redeems kTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of kTokens 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 kTokens 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 kTokens * @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 kTokens 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 kTokens 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 kTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero) * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemFresh( address payable redeemer, uint256 redeemTokensIn, uint256 redeemAmountIn ) internal returns (uint256) { require( redeemTokensIn == 0 || redeemAmountIn == 0, "tokensIn or amountIn must be 0" ); RedeemLocalVars memory vars; /* exchangeRate = invoke Exchange Rate Stored() */ ( vars.mathErr, vars.exchangeRateMantissa ) = exchangeRateStoredInternal(); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_RATE_READ_FAILED, uint256(vars.mathErr) ); } /* If redeemTokensIn > 0: */ if (redeemTokensIn > 0) { /* * We calculate the exchange rate and the amount of underlying to be redeemed: * redeemTokens = redeemTokensIn * redeemAmount = redeemTokensIn x exchangeRateCurrent */ if (redeemTokensIn >= accountTokens[redeemer]) { vars.redeemTokens = accountTokens[redeemer]; } else { vars.redeemTokens = redeemTokensIn; } (vars.mathErr, vars.redeemAmount) = mulScalarTruncate( Exp({mantissa: vars.exchangeRateMantissa}), vars.redeemTokens ); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint256(vars.mathErr) ); } } else { /* * We get the current exchange rate and calculate the amount to be redeemed: * redeemTokens = redeemAmountIn / exchangeRate * redeemAmount = redeemAmountIn */ if (redeemAmountIn == type(uint256).max) { vars.redeemTokens = accountTokens[redeemer]; (vars.mathErr, vars.redeemAmount) = mulScalarTruncate( Exp({mantissa: vars.exchangeRateMantissa}), vars.redeemTokens ); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint256(vars.mathErr) ); } } else { vars.redeemAmount = redeemAmountIn; (vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate( redeemAmountIn, Exp({mantissa: vars.exchangeRateMantissa}) ); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo .REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, uint256(vars.mathErr) ); } } } /* Fail if redeem not allowed */ uint256 allowed = comptroller.redeemAllowed( address(this), redeemer, vars.redeemTokens ); if (allowed != 0) { return failOpaque( Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed ); } /* Verify market's block timestamp equals current block timestamp */ if (accrualBlockTimestamp != getBlockTimestamp()) { return fail( Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK ); } /* * We calculate the new total supply and redeemer balance, checking for underflow: * totalSupplyNew = totalSupply - redeemTokens * accountTokensNew = accountTokens[redeemer] - redeemTokens */ (vars.mathErr, vars.totalSupplyNew) = subUInt( totalSupply, vars.redeemTokens ); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint256(vars.mathErr) ); } if (vars.redeemTokens > accountTokens[redeemer]) vars.redeemTokens = accountTokens[redeemer]; (vars.mathErr, vars.accountTokensNew) = subUInt( accountTokens[redeemer], vars.redeemTokens ); if (vars.mathErr != MathError.NO_ERROR) { return failOpaque( Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr) ); } /* Fail gracefully if protocol has insufficient cash */ if (getCashPrior() < vars.redeemAmount) { return fail( Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE ); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* 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 kToken must handle variations between ERC-20 and NATIVE underlying. * On success, the kToken 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 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); /* We call the defense hook */ // unused function // comptroller.borrowVerify(address(this), borrower, borrowAmount); /* * We invoke doTransferOut for the borrower and the borrowAmount. * Note: The kToken must handle variations between ERC-20 and NATIVE underlying. * On success, the kToken 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; /* We remember the original borrowerIndex for verification purposes */ vars.borrowerIndex = accountBorrows[borrower].interestIndex; /* We fetch the amount the borrower owes, with accumulated interest */ (vars.mathErr, vars.accountBorrows) = borrowBalanceStoredInternal( borrower ); if (vars.mathErr != MathError.NO_ERROR) { return ( failOpaque( Error.MATH_ERROR, FailureInfo .REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, uint256(vars.mathErr) ), 0 ); } /* If repayAmount >= accountBorrows, repayAmount = accountBorrows */ if (repayAmount >= vars.accountBorrows) { vars.repayAmount = vars.accountBorrows; } else { vars.repayAmount = repayAmount; } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the payer and the repayAmount * Note: The kToken must handle variations between ERC-20 and NATIVE underlying. * On success, the kToken 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 ); /* 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 kToken to be liquidated * @param kTokenCollateral 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, IKToken kTokenCollateral ) 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 = kTokenCollateral.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, kTokenCollateral ); } /** * @notice The liquidator liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this kToken to be liquidated * @param liquidator The address repaying the borrow and seizing collateral * @param kTokenCollateral 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, IKToken kTokenCollateral ) internal returns (uint256, uint256) { /* Fail if liquidate not allowed */ (uint256 allowed, uint256 dynamicLiquidationIncentive) = comptroller.liquidateBorrowAllowed( address(this), address(kTokenCollateral), 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 kTokenCollateral market's block timestamp equals current block timestamp */ if (kTokenCollateral.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(kTokenCollateral), actualRepayAmount, dynamicLiquidationIncentive ); require( amountSeizeError == uint256(Error.NO_ERROR), "LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED" ); /* Revert if borrower collateral token balance < seizeTokens */ require( kTokenCollateral.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(kTokenCollateral) == address(this)) { seizeError = seizeInternal( address(this), liquidator, borrower, seizeTokens, dynamicLiquidationIncentive ); } else { seizeError = kTokenCollateral.seize( liquidator, borrower, seizeTokens, dynamicLiquidationIncentive ); } /* 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(kTokenCollateral), seizeTokens ); /* We call the defense hook */ // unused function // comptroller.liquidateBorrowVerify(address(this), address(kTokenCollateral), 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 kToken during the process of liquidation. * Its absolutely critical to use msg.sender as the borrowed kToken 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 * @param dynamicLiquidationIncentive The liquidation incentive that will be used to calculate protocol seize share * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seize( address liquidator, address borrower, uint256 seizeTokens, uint256 dynamicLiquidationIncentive ) external override nonReentrant returns (uint256) { return seizeInternal(msg.sender, liquidator, borrower, seizeTokens, dynamicLiquidationIncentive); } 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 KToken. * Its absolutely critical to use msg.sender as the seizer kToken and not a parameter. * @param seizerToken The contract seizing the collateral (i.e. borrowed kToken) * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of oTokens to seize * @param dynamicLiquidationIncentive The liquidation incentive that will be used to calculate protocol seize share * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seizeInternal( address seizerToken, address liquidator, address borrower, uint256 seizeTokens, uint256 dynamicLiquidationIncentive ) 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) ); } if (dynamicLiquidationIncentive > 1e18) { uint256 i; unchecked { i = dynamicLiquidationIncentive - 1e18; } uint256 protocolSeizeShare = mul_( i, Exp({mantissa: protocolSeizeShareMantissa}) ); vars.protocolSeizeTokens = mul_( seizeTokens, Exp({mantissa: protocolSeizeShare}) ); } 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 */ 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 ); return uint256(Error.NO_ERROR); } /*** Functions with price update ***/ /** * @notice Sender borrows assets from the protocol to their own address and updates prices at Pyth's oracle * @param borrowAmount The amount of the underlying asset to borrow * @param priceUpdateData data for updating prices on Pyth smart contract * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowWithPriceUpdate(uint256 borrowAmount, bytes[] calldata priceUpdateData) external returns (uint256) { comptroller.updatePrices(priceUpdateData); return borrowInternal(borrowAmount); } /** * @notice Sender redeems kTokens in exchange for the underlying asset and updates prices at Pyth's oracle * @param redeemTokens The number of kTokens to redeem into underlying * @param priceUpdateData data for updating prices on Pyth smart contract * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemWithPriceUpdate(uint256 redeemTokens, bytes[] calldata priceUpdateData) external returns (uint256) { comptroller.updatePrices(priceUpdateData); return redeemInternal(redeemTokens); } /** * @notice Sender redeems kTokens in exchange for a specified amount of underlying asset and updates prices at Pyth's oracle * @param redeemAmount The amount of underlying to receive from redeeming kTokens * @param priceUpdateData data for updating prices on Pyth smart contract * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlyingWithPriceUpdate(uint256 redeemAmount, bytes[] calldata priceUpdateData) external returns (uint256) { comptroller.updatePrices(priceUpdateData); return redeemUnderlyingInternal(redeemAmount); } /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` with updating prices at Pyth's oracle * @param dst The address of the destination account * @param amount The number of tokens to transfer * @param priceUpdateData data for updating prices on Pyth smart contract * @return Whether or not the transfer succeeded */ function transferWithPriceUpdate(address dst, uint256 amount, bytes[] calldata priceUpdateData) external nonReentrant returns (bool) { comptroller.updatePrices(priceUpdateData); return transferTokens(msg.sender, msg.sender, dst, amount) == uint256(Error.NO_ERROR); } /** * @notice Transfer `amount` tokens from `src` to `dst` with updating prices at Pyth's oracle * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @param priceUpdateData data for updating prices on Pyth smart contract * @return Whether or not the transfer succeeded */ function transferFromWithPriceUpdate( address src, address dst, uint256 amount, bytes[] calldata priceUpdateData ) external nonReentrant returns (bool) { comptroller.updatePrices(priceUpdateData); return transferTokens(msg.sender, src, dst, amount) == uint256(Error.NO_ERROR); } /*** Admin Functions ***/ function unauthorized(FailureInfo info) internal returns (uint) { return fail(Error.UNAUTHORIZED, info); } /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPendingAdmin(address payable newPendingAdmin) external override returns (uint256) { // Check caller = admin if (msg.sender != admin) { return unauthorized(FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(pendingAdmin, newPendingAdmin); // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; return uint256(Error.NO_ERROR); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() external override returns (uint256) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return unauthorized(FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = payable(address(0)); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint256(Error.NO_ERROR); } /** * @notice Sets a new comptroller for the market * @dev Admin function to set a new comptroller * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setComptroller(IComptroller newComptroller) public override returns (uint256) { // Check caller is admin if (msg.sender != admin) { return unauthorized(FailureInfo.SET_COMPTROLLER_OWNER_CHECK); } IComptroller oldComptroller = comptroller; // Ensure invoke comptroller.isComptroller() returns true require(newComptroller.isComptroller(), "marker method returned false"); // Set market's comptroller to newComptroller comptroller = newComptroller; // Emit NewComptroller(oldComptroller, newComptroller) emit NewComptroller(oldComptroller, newComptroller); return uint256(Error.NO_ERROR); } /** * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh * @dev Admin function to accrue interest and set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactor(uint256 newReserveFactorMantissa) external override nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed. return fail( Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED ); } // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to. return _setReserveFactorFresh(newReserveFactorMantissa); } /** * @notice Sets a new reserve factor for the protocol (*requires fresh interest accrual) * @dev Admin function to set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactorFresh(uint256 newReserveFactorMantissa) internal returns (uint256) { // Check caller is admin if (msg.sender != admin) { return unauthorized(FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK); } // Verify market's block timestamp equals current block timestamp if (accrualBlockTimestamp != getBlockTimestamp()) { return fail( Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK ); } // Check newReserveFactor ≤ maxReserveFactor if (newReserveFactorMantissa > reserveFactorMaxMantissa) { return fail( Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK ); } uint256 oldReserveFactorMantissa = reserveFactorMantissa; reserveFactorMantissa = newReserveFactorMantissa; emit NewReserveFactor( oldReserveFactorMantissa, newReserveFactorMantissa ); return uint256(Error.NO_ERROR); } /** * @notice Accrues interest and reduces reserves by transferring from msg.sender * @param addAmount Amount of addition to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReservesInternal(uint256 addAmount) internal nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail( Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED ); } // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to. (error, ) = _addReservesFresh(addAmount); return error; } /** * @notice Add reserves by transferring from caller * @dev Requires fresh interest accrual * @param addAmount Amount of addition to reserves * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees */ function _addReservesFresh(uint256 addAmount) internal returns (uint256, uint256) { // totalReserves + actualAddAmount uint256 totalReservesNew; uint256 actualAddAmount; // We fail gracefully unless market's block timestamp equals current block timestamp if (accrualBlockTimestamp != getBlockTimestamp()) { return ( fail( Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK ), actualAddAmount ); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the caller and the addAmount * Note: The kToken must handle variations between ERC-20 and NATIVE underlying. * On success, the kToken holds an additional addAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ actualAddAmount = doTransferIn(msg.sender, addAmount); /* Reverts on overflow */ totalReservesNew = totalReserves + actualAddAmount; // Store reserves[n+1] = reserves[n] + actualAddAmount totalReserves = totalReservesNew; /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */ emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew); /* Return (NO_ERROR, actualAddAmount) */ return (uint256(Error.NO_ERROR), actualAddAmount); } /** * @notice Accrues interest and reduces reserves by transferring to admin * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReserves(uint256 reduceAmount) external override nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail( Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED ); } // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to. return _reduceReservesFresh(reduceAmount); } /** * @notice Reduces reserves by transferring to admin * @dev Requires fresh interest accrual * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReservesFresh(uint256 reduceAmount) internal returns (uint256) { // totalReserves - reduceAmount uint256 totalReservesNew; // Check caller is admin if (msg.sender != admin) { return unauthorized(FailureInfo.REDUCE_RESERVES_ADMIN_CHECK); } // We fail gracefully unless market's block timestamp equals current block timestamp if (accrualBlockTimestamp != getBlockTimestamp()) { return fail( Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK ); } // Fail gracefully if protocol has insufficient underlying cash if (getCashPrior() < reduceAmount) { return fail( Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE ); } // Check reduceAmount ≤ reserves[n] (totalReserves) if (reduceAmount > totalReserves) { return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) // We checked reduceAmount <= totalReserves above, so this should never revert. totalReservesNew = totalReserves - reduceAmount; // Store reserves[n+1] = reserves[n] - reduceAmount totalReserves = totalReservesNew; // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. doTransferOut(admin, reduceAmount); emit ReservesReduced(admin, reduceAmount, totalReservesNew); return uint256(Error.NO_ERROR); } /** * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh * @dev Admin function to accrue interest and update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModel(IInterestRateModel newInterestRateModel) public override returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed return fail( Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED ); } // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to. return _setInterestRateModelFresh(newInterestRateModel); } /** * @notice updates the interest rate model (*requires fresh interest accrual) * @dev Admin function to update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModelFresh(IInterestRateModel newInterestRateModel) internal returns (uint256) { // Used to store old model for use in the event that is emitted on success IInterestRateModel oldInterestRateModel; // Check caller is admin if (msg.sender != admin) { return unauthorized(FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK); } // We fail gracefully unless market's block timestamp equals current block timestamp if (accrualBlockTimestamp != getBlockTimestamp()) { return fail( Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK ); } // Track the market's current interest rate model oldInterestRateModel = interestRateModel; // Ensure invoke newInterestRateModel.isInterestRateModel() returns true require( newInterestRateModel.isInterestRateModel(), "marker method returned false" ); // Set the interest rate model to newInterestRateModel interestRateModel = newInterestRateModel; // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel) emit NewMarketInterestRateModel( oldInterestRateModel, newInterestRateModel ); return uint256(Error.NO_ERROR); } /** * @notice accrues interest and updates the protocol seize share using _setProtocolSeizeShareFresh * @dev Admin function to accrue interest and update the protocol seize share * @param newProtocolSeizeShareMantissa the new protocol seize share to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setProtocolSeizeShare(uint256 newProtocolSeizeShareMantissa) external override nonReentrant returns (uint256) { uint256 error = accrueInterest(); if (error != uint256(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of protocol seize share failed return fail( Error(error), FailureInfo.SET_PROTOCOL_SEIZE_SHARE_ACCRUE_INTEREST_FAILED ); } // _setProtocolSeizeShareFresh emits protocol-seize-share-update-specific logs on errors, so we don't need to. return _setProtocolSeizeShareFresh(newProtocolSeizeShareMantissa); } /** * @notice updates the protocol seize share (*requires fresh interest accrual) * @dev Admin function to update the protocol seize share * @param newProtocolSeizeShareMantissa the new protocol seize share to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setProtocolSeizeShareFresh(uint256 newProtocolSeizeShareMantissa) internal returns (uint256) { // Check caller is admin if (msg.sender != admin) { return unauthorized(FailureInfo.SET_PROTOCOL_SEIZE_SHARE_OWNER_CHECK); } // We fail gracefully unless market's block timestamp equals current block timestamp if (accrualBlockTimestamp != getBlockTimestamp()) { return fail( Error.MARKET_NOT_FRESH, FailureInfo.SET_PROTOCOL_SEIZE_SHARE_FRESH_CHECK ); } // Emit NewProtocolSeizeShareMantissa(oldProtocolSeizeShareMantissa, newProtocolSeizeShareMantissa) emit NewProtocolSeizeShare( protocolSeizeShareMantissa, newProtocolSeizeShareMantissa ); // Set the protocol seize share to newProtocolSeizeShareMantissa protocolSeizeShareMantissa = newProtocolSeizeShareMantissa; return uint256(Error.NO_ERROR); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying owned by this contract */ function getCashPrior() internal view virtual returns (uint256); /** * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee. * This may revert due to insufficient balance or insufficient allowance. */ function doTransferIn(address from, uint256 amount) internal virtual returns (uint256); /** * @dev Performs a transfer out, ideally returning an explanatory error code upon failure tather than reverting. * If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract. * If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions. */ function doTransferOut(address payable to, uint256 amount) internal virtual; /*** Reentrancy Guard ***/ /** * @dev Prevents a contract from calling itself, directly or indirectly. */ modifier nonReentrant() { require(_notEntered, "re-entered"); _notEntered = false; _; _notEntered = true; // get a gas-refund post-Istanbul } function requireNoError(uint256 errCode, string memory message) internal pure { unchecked { if (errCode == uint256(Error.NO_ERROR)) { return; } bytes memory fullMessage = new bytes(bytes(message).length + 5); uint256 i; for (i = 0; i < bytes(message).length; i++) { fullMessage[i] = bytes(message)[i]; } fullMessage[i + 0] = bytes1(uint8(32)); fullMessage[i + 1] = bytes1(uint8(40)); fullMessage[i + 2] = bytes1(uint8(48 + (errCode / 10))); fullMessage[i + 3] = bytes1(uint8(48 + (errCode % 10))); fullMessage[i + 4] = bytes1(uint8(41)); require(errCode == uint256(Error.NO_ERROR), string(fullMessage)); } } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "../interfaces/IEIP20NonStandard.sol"; import "../interfaces/IKToken.sol"; import "../interfaces/IKErc20.sol"; import "../../interfaces/IComptroller.sol"; import "../../interest-rate-models/interfaces/IInterestRateModel.sol"; abstract contract KTokenStorage is IKToken { bool public constant override isKToken = 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-kToken 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 KTokens (used when totalSupply = 0) */ uint internal initialExchangeRateMantissa; /** * @notice Fraction of interest currently set aside for reserves */ uint public override reserveFactorMantissa; /** * @notice Block number that interest was last accrued at */ uint public override accrualBlockTimestamp; /** * @notice Accumulator of the total earned interest rate since the opening of the market */ uint public override borrowIndex; /** * @notice Total amount of outstanding borrows of the underlying in this market */ uint public override totalBorrows; /** * @notice Total amount of reserves of the underlying held in this market */ uint public totalReserves; /** * @notice Total number of tokens in circulation */ uint public override totalSupply; /** * @notice Official record of token balances for each account */ mapping (address => uint) internal accountTokens; /** * @notice Approved token transfer amounts on behalf of others */ mapping (address => mapping (address => uint)) internal transferAllowances; /** * @notice Container for borrow balance information * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action * @member interestIndex Global borrowIndex as of the most recent balance-changing action */ struct BorrowSnapshot { uint principal; uint interestIndex; } /** * @notice Mapping of account addresses to outstanding borrow balances */ mapping(address => BorrowSnapshot) internal accountBorrows; /** * @notice Share of seized collateral that is added to reserves */ uint public protocolSeizeShareMantissa; }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; /** * @title ERC 20 Token Standard Interface * https://eips.ethereum.org/EIPS/eip-20 */ interface IEIP20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return balance The balance */ function balanceOf(address owner) external view returns (uint256 balance); /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return success Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external returns (bool success); /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return success Whether or not the transfer succeeded */ function transferFrom(address src, address dst, uint256 amount) external returns (bool success); /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return success Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return remaining The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; /** * @title IEIP20NonStandard * @dev Version of ERC20 with no return values for `transfer` and `transferFrom` * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ interface IEIP20NonStandard { /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return balance The balance */ function balanceOf(address owner) external view returns (uint256 balance); /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transfer` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transfer(address dst, uint256 amount) external; /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transferFrom(address src, address dst, uint256 amount) external; /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved * @return success Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return remaining The number of tokens allowed to be spent */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "./IEIP20NonStandard.sol"; import "./IKToken.sol"; interface IKErc20 { /*** User Interface ***/ function mint(uint mintAmount) external; function redeem(uint redeemTokens) external; function redeemUnderlying(uint redeemAmount) external; function borrow(uint borrowAmount) external; function repayBorrow(uint repayAmount) external; function repayBorrowBehalf(address borrower, uint repayAmount) external; function liquidateBorrow(address borrower, uint repayAmount, IKToken kTokenCollateral) external; function underlying() external view returns(address); /*** Admin Functions ***/ function _addReserves(uint addAmount) external returns (uint); }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "../../interfaces/IComptroller.sol"; import "../../interest-rate-models/interfaces/IInterestRateModel.sol"; import "./IEIP20NonStandard.sol"; import "./IEIP20.sol"; interface IKToken is IEIP20{ /** * @notice Indicator that this is a KToken contract (for inspection) */ function isKToken() 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 kTokenCollateral, 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, uint dynamicLiquidationIncentive) 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; /** * @title Careful Math * @author KEOM * @notice Derived from OpenZeppelin's SafeMath library * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol */ contract CarefulMath { /** * @dev Possible error codes that we can return */ enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW } /** * @dev Multiplies two numbers, returns an error on overflow. */ function mulUInt(uint a, uint b) internal pure returns (MathError, uint) { unchecked { if (a == 0) { return (MathError.NO_ERROR, 0); } uint c = a * b; if (c / a != b) { return (MathError.INTEGER_OVERFLOW, 0); } else { return (MathError.NO_ERROR, c); } } } /** * @dev Integer division of two numbers, truncating the quotient. */ function divUInt(uint a, uint b) internal pure returns (MathError, uint) { unchecked { if (b == 0) { return (MathError.DIVISION_BY_ZERO, 0); } return (MathError.NO_ERROR, a / b); } } /** * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend). */ function subUInt(uint a, uint b) internal pure returns (MathError, uint) { unchecked { if (b <= a) { return (MathError.NO_ERROR, a - b); } else { return (MathError.INTEGER_UNDERFLOW, 0); } } } /** * @dev Adds two numbers, returns an error on overflow. */ function addUInt(uint a, uint b) internal pure returns (MathError, uint) { unchecked { uint c = a + b; if (c >= a) { return (MathError.NO_ERROR, c); } else { return (MathError.INTEGER_OVERFLOW, 0); } } } /** * @dev add a and b and then subtract c */ function addThenSubUInt(uint a, uint b, uint c) internal pure returns (MathError, uint) { (MathError err0, uint sum) = addUInt(a, b); if (err0 != MathError.NO_ERROR) { return (err0, 0); } return subUInt(sum, c); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; contract ComptrollerErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, COMPTROLLER_MISMATCH, INSUFFICIENT_SHORTFALL, INSUFFICIENT_LIQUIDITY, INVALID_CLOSE_FACTOR, INVALID_COLLATERAL_FACTOR, INVALID_LIQUIDATION_INCENTIVE, MARKET_NOT_ENTERED, // no longer possible MARKET_NOT_LISTED, MARKET_ALREADY_LISTED, MATH_ERROR, NONZERO_BORROW_BALANCE, PRICE_ERROR, REJECTION, SNAPSHOT_ERROR, TOO_MANY_ASSETS, TOO_MUCH_REPAY } enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK, EXIT_MARKET_BALANCE_OWED, EXIT_MARKET_REJECTION, SET_CLOSE_FACTOR_OWNER_CHECK, SET_CLOSE_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_NO_EXISTS, SET_COLLATERAL_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_WITHOUT_PRICE, SET_IMPLEMENTATION_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_VALIDATION, SET_MAX_ASSETS_OWNER_CHECK, SET_PENDING_ADMIN_OWNER_CHECK, SET_PENDING_IMPLEMENTATION_OWNER_CHECK, SET_PRICE_ORACLE_OWNER_CHECK, SUPPORT_MARKET_EXISTS, SUPPORT_MARKET_OWNER_CHECK, SET_PAUSE_GUARDIAN_OWNER_CHECK } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint error, uint info, uint detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(err); } } contract TokenErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, BAD_INPUT, COMPTROLLER_REJECTION, COMPTROLLER_CALCULATION_ERROR, INTEREST_RATE_MODEL_ERROR, INVALID_ACCOUNT_PAIR, INVALID_CLOSE_AMOUNT_REQUESTED, INVALID_COLLATERAL_FACTOR, MATH_ERROR, MARKET_NOT_FRESH, MARKET_NOT_LISTED, TOKEN_INSUFFICIENT_ALLOWANCE, TOKEN_INSUFFICIENT_BALANCE, TOKEN_INSUFFICIENT_CASH, TOKEN_TRANSFER_IN_FAILED, TOKEN_TRANSFER_OUT_FAILED } /* * Note: FailureInfo (but not Error) is kept in alphabetical order * This is because FailureInfo grows significantly faster, and * the order of Error has some meaning, while the order of FailureInfo * is entirely arbitrary. */ enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCRUE_INTEREST_ACCUMULATED_INTEREST_CALCULATION_FAILED, ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_BORROW_INDEX_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_TOTAL_BORROWS_CALCULATION_FAILED, ACCRUE_INTEREST_NEW_TOTAL_RESERVES_CALCULATION_FAILED, ACCRUE_INTEREST_SIMPLE_INTEREST_FACTOR_CALCULATION_FAILED, BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, BORROW_ACCRUE_INTEREST_FAILED, BORROW_CASH_NOT_AVAILABLE, BORROW_FRESHNESS_CHECK, BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, BORROW_MARKET_NOT_LISTED, BORROW_COMPTROLLER_REJECTION, LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED, LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED, LIQUIDATE_COLLATERAL_FRESHNESS_CHECK, LIQUIDATE_COMPTROLLER_REJECTION, LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED, LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX, LIQUIDATE_CLOSE_AMOUNT_IS_ZERO, LIQUIDATE_FRESHNESS_CHECK, LIQUIDATE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_REPAY_BORROW_FRESH_FAILED, LIQUIDATE_SEIZE_BALANCE_INCREMENT_FAILED, LIQUIDATE_SEIZE_BALANCE_DECREMENT_FAILED, LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_SEIZE_TOO_MUCH, MINT_ACCRUE_INTEREST_FAILED, MINT_COMPTROLLER_REJECTION, MINT_EXCHANGE_CALCULATION_FAILED, MINT_EXCHANGE_RATE_READ_FAILED, MINT_FRESHNESS_CHECK, MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, MINT_TRANSFER_IN_FAILED, MINT_TRANSFER_IN_NOT_POSSIBLE, REDEEM_ACCRUE_INTEREST_FAILED, REDEEM_COMPTROLLER_REJECTION, REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, REDEEM_EXCHANGE_RATE_READ_FAILED, REDEEM_FRESHNESS_CHECK, REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, REDEEM_TRANSFER_OUT_NOT_POSSIBLE, REDUCE_RESERVES_ACCRUE_INTEREST_FAILED, REDUCE_RESERVES_ADMIN_CHECK, REDUCE_RESERVES_CASH_NOT_AVAILABLE, REDUCE_RESERVES_FRESH_CHECK, REDUCE_RESERVES_VALIDATION, REPAY_BEHALF_ACCRUE_INTEREST_FAILED, REPAY_BORROW_ACCRUE_INTEREST_FAILED, REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, REPAY_BORROW_COMPTROLLER_REJECTION, REPAY_BORROW_FRESHNESS_CHECK, REPAY_BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, REPAY_BORROW_NEW_TOTAL_BALANCE_CALCULATION_FAILED, REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_VALIDATION, SET_COMPTROLLER_OWNER_CHECK, SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED, SET_INTEREST_RATE_MODEL_FRESH_CHECK, SET_INTEREST_RATE_MODEL_OWNER_CHECK, SET_MAX_ASSETS_OWNER_CHECK, SET_ORACLE_MARKET_NOT_LISTED, SET_PENDING_ADMIN_OWNER_CHECK, SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED, SET_RESERVE_FACTOR_ADMIN_CHECK, SET_RESERVE_FACTOR_FRESH_CHECK, SET_RESERVE_FACTOR_BOUNDS_CHECK, TRANSFER_COMPTROLLER_REJECTION, TRANSFER_NOT_ALLOWED, TRANSFER_NOT_ENOUGH, TRANSFER_TOO_MUCH, ADD_RESERVES_ACCRUE_INTEREST_FAILED, ADD_RESERVES_FRESH_CHECK, ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE, SET_PROTOCOL_SEIZE_SHARE_ACCRUE_INTEREST_FAILED, SET_PROTOCOL_SEIZE_SHARE_OWNER_CHECK, SET_PROTOCOL_SEIZE_SHARE_FRESH_CHECK } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint error, uint info, uint detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(err); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "./CarefulMath.sol"; import "./ExponentialNoError.sol"; /** * @title Exponential module for storing fixed-precision decimals * @author KEOM * @dev Legacy contract for compatibility reasons with existing contracts that still use MathError * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places. * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is: * `Exp({mantissa: 5100000000000000000})`. */ contract Exponential is CarefulMath, ExponentialNoError { /** * @dev Creates an exponential from numerator and denominator values. * Note: Returns an error if (`num` * 10e18) > MAX_INT, * or if `denom` is zero. */ function getExp(uint num, uint denom) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledNumerator) = mulUInt(num, expScale); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } (MathError err1, uint rational) = divUInt(scaledNumerator, denom); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: rational})); } /** * @dev Adds two exponentials, returning a new exponential. */ function addExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError error, uint result) = addUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Subtracts two exponentials, returning a new exponential. */ function subExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError error, uint result) = subUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Multiply an Exp by a scalar, returning a new Exp. */ function mulScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledMantissa) = mulUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: scaledMantissa})); } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mulScalarTruncate(Exp memory a, uint scalar) pure internal returns (MathError, uint) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(product)); } /** * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. */ function mulScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) pure internal returns (MathError, uint) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return addUInt(truncate(product), addend); } /** * @dev Divide an Exp by a scalar, returning a new Exp. */ function divScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint descaledMantissa) = divUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: descaledMantissa})); } /** * @dev Divide a scalar by an Exp, returning a new Exp. */ function divScalarByExp(uint scalar, Exp memory divisor) pure internal returns (MathError, Exp memory) { /* We are doing this as: getExp(mulUInt(expScale, scalar), divisor.mantissa) How it works: Exp = a / b; Scalar = s; `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale` */ (MathError err0, uint numerator) = mulUInt(expScale, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return getExp(numerator, divisor.mantissa); } /** * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer. */ function divScalarByExpTruncate(uint scalar, Exp memory divisor) pure internal returns (MathError, uint) { (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(fraction)); } /** * @dev Multiplies two exponentials, returning a new exponential. */ function mulExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError err0, uint doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } // We add half the scale before dividing so that we get rounding instead of truncation. // See "Listing 6" and text above it at https://accu.org/index.php/journals/1717 // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18. (MathError err1, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } (MathError err2, uint product) = divUInt(doubleScaledProductWithHalfScale, expScale); // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero. assert(err2 == MathError.NO_ERROR); return (MathError.NO_ERROR, Exp({mantissa: product})); } /** * @dev Multiplies two exponentials given their mantissas, returning a new exponential. */ function mulExp(uint a, uint b) pure internal returns (MathError, Exp memory) { return mulExp(Exp({mantissa: a}), Exp({mantissa: b})); } /** * @dev Multiplies three exponentials, returning a new exponential. */ function mulExp3(Exp memory a, Exp memory b, Exp memory c) pure internal returns (MathError, Exp memory) { (MathError err, Exp memory ab) = mulExp(a, b); if (err != MathError.NO_ERROR) { return (err, ab); } return mulExp(ab, c); } /** * @dev Divides two exponentials, returning a new exponential. * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b, * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa) */ function divExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { return getExp(a.mantissa, b.mantissa); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; /** * @title Exponential module for storing fixed-precision decimals * @author KEOM * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places. * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is: * `Exp({mantissa: 5100000000000000000})`. */ contract ExponentialNoError { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Truncates the given exp to a whole number value. * For example, truncate(Exp{mantissa: 15 * expScale}) = 15 */ function truncate(Exp memory exp) pure internal returns (uint) { // Note: We are not using careful math here as we're performing a division that cannot fail return exp.mantissa / expScale; } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mul_ScalarTruncate(Exp memory a, uint scalar) pure internal returns (uint) { return truncate(mul_(a, scalar)); } /** * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. */ function mul_ScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) pure internal returns (uint) { return truncate(mul_(a, scalar)) + addend; } /** * @dev Checks if first Exp is less than second Exp. */ function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa < right.mantissa; } /** * @dev Checks if left Exp <= right Exp. */ function lessThanOrEqualExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa <= right.mantissa; } /** * @dev Checks if left Exp > right Exp. */ function greaterThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa > right.mantissa; } /** * @dev returns true if Exp is exactly zero */ function isZeroExp(Exp memory value) pure internal returns (bool) { return value.mantissa == 0; } function safe224(uint n) pure internal returns (uint224) { require(n <= type(uint224).max, "safe224 overflow"); return uint224(n); } function safe32(uint n) pure internal returns (uint32) { require(n <= type(uint32).max, "safe32 overflow"); return uint32(n); } function add_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: a.mantissa + b.mantissa}); } function add_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: a.mantissa + b.mantissa}); } function add_(uint a, uint b, string memory errorMessage) pure internal returns (uint c) { unchecked { require((c = a + b ) >= a, errorMessage); } } function sub_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: a.mantissa - b.mantissa}); } function sub_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: a.mantissa - b.mantissa}); } function sub_(uint a, uint b, string memory errorMessage) pure internal returns (uint c) { unchecked { require((c = a - b) <= a, errorMessage); } } function mul_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: (a.mantissa * b.mantissa) / expScale}); } function mul_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: a.mantissa * b}); } function mul_(uint a, Exp memory b) pure internal returns (uint) { return (a * b.mantissa) / expScale; } function mul_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: (a.mantissa * b.mantissa) / doubleScale}); } function mul_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: a.mantissa * b}); } function mul_(uint a, Double memory b) pure internal returns (uint) { return (a * b.mantissa) / doubleScale; } function mul_(uint a, uint b, string memory errorMessage) pure internal returns (uint c) { unchecked { require(a == 0 || (c = a * b) / a == b, errorMessage); } } function div_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: (a.mantissa * expScale) / b.mantissa}); } function div_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: a.mantissa / b}); } function div_(uint a, Exp memory b) pure internal returns (uint) { return (a * expScale) / b.mantissa; } function div_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: (a.mantissa * doubleScale) / b.mantissa}); } function div_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: a.mantissa / b}); } function div_(uint a, Double memory b) pure internal returns (uint) { return (a * doubleScale) / b.mantissa; } function div_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { unchecked { require(b > 0, errorMessage); return a / b; } } function fraction(uint a, uint b) pure internal returns (Double memory) { return Double({mantissa: (a * doubleScale) / b}); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "../ktokens/interfaces/IKToken.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 kToken asset * @param kToken The kToken to get the underlying price of * @return The underlying asset price mantissa (scaled by 1e18). * Zero means the price is unavailable. */ function getUnderlyingPrice(IKToken kToken) external virtual view returns (uint); /** * @notice Updates multiple price feeds on Pyth oracle * @param priceUpdateData received from Pyth network and used to update the oracle */ function updateUnderlyingPrices(bytes[] calldata priceUpdateData) external virtual; }
{ "optimizer": { "enabled": true, "runs": 1 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/" ], "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"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":"kTokenCollateral","type":"address"},{"indexed":false,"internalType":"uint256","name":"seizeTokens","type":"uint256"}],"name":"LiquidateBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"mintAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mintTokens","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"NewAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IComptroller","name":"oldComptroller","type":"address"},{"indexed":false,"internalType":"contract IComptroller","name":"newComptroller","type":"address"}],"name":"NewComptroller","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IInterestRateModel","name":"oldInterestRateModel","type":"address"},{"indexed":false,"internalType":"contract IInterestRateModel","name":"newInterestRateModel","type":"address"}],"name":"NewMarketInterestRateModel","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingAdmin","type":"address"}],"name":"NewPendingAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldProtocolSeizeShareMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newProtocolSeizeShareMantissa","type":"uint256"}],"name":"NewProtocolSeizeShare","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldReserveFactorMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newReserveFactorMantissa","type":"uint256"}],"name":"NewReserveFactor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"redeemer","type":"address"},{"indexed":false,"internalType":"uint256","name":"redeemAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"payer","type":"address"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"repayAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accountBorrows","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"RepayBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"benefactor","type":"address"},{"indexed":false,"internalType":"uint256","name":"addAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalReserves","type":"uint256"}],"name":"ReservesAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"admin","type":"address"},{"indexed":false,"internalType":"uint256","name":"reduceAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalReserves","type":"uint256"}],"name":"ReservesReduced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"_acceptAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"addAmount","type":"uint256"}],"name":"_addReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reduceAmount","type":"uint256"}],"name":"_reduceReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IComptroller","name":"newComptroller","type":"address"}],"name":"_setComptroller","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IInterestRateModel","name":"newInterestRateModel","type":"address"}],"name":"_setInterestRateModel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newPendingAdmin","type":"address"}],"name":"_setPendingAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newProtocolSeizeShareMantissa","type":"uint256"}],"name":"_setProtocolSeizeShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newReserveFactorMantissa","type":"uint256"}],"name":"_setReserveFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accrualBlockTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accrueInterest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOfUnderlying","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"borrowBalanceCurrent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"borrowBalanceStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowRatePerTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"}],"name":"borrowWithPriceUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"comptroller","outputs":[{"internalType":"contract IComptroller","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exchangeRateCurrent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"exchangeRateStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getAccountSnapshot","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCash","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"underlying_","type":"address"},{"internalType":"contract IComptroller","name":"comptroller_","type":"address"},{"internalType":"contract IInterestRateModel","name":"interestRateModel_","type":"address"},{"internalType":"uint256","name":"initialExchangeRateMantissa_","type":"uint256"},{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address payable","name":"admin_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"interestRateModel","outputs":[{"internalType":"contract IInterestRateModel","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isKToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"repayAmount","type":"uint256"},{"internalType":"contract IKToken","name":"kTokenCollateral","type":"address"}],"name":"liquidateBorrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"repayAmount","type":"uint256"},{"internalType":"contract IKToken","name":"kTokenCollateral","type":"address"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"}],"name":"liquidateBorrowWithPriceUpdate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingAdmin","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolSeizeShareMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"}],"name":"redeemUnderlying","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemAmount","type":"uint256"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"}],"name":"redeemUnderlyingWithPriceUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"redeemTokens","type":"uint256"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"}],"name":"redeemWithPriceUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"repayAmount","type":"uint256"}],"name":"repayBorrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"repayAmount","type":"uint256"}],"name":"repayBorrowBehalf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reserveFactorMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"liquidator","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"uint256","name":"seizeTokens","type":"uint256"},{"internalType":"uint256","name":"dynamicLiquidationIncentive","type":"uint256"}],"name":"seize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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"},{"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"}],"name":"transferFromWithPriceUpdate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"}],"name":"transferWithPriceUpdate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50615e6f80620000216000396000f3fe608060405234801561001057600080fd5b506004361061027d5760003560e01c806306fdde0314610282578063095ea7b3146102a05780630e752702146102c3578063173b9904146102d857806317bfdfbc146102ef57806318160ddd14610302578063182df0f51461030b57806320bdc6571461031357806323b872dd1461032657806324e1afa1146103395780632608f8181461034c578063267822471461035f57806329d9109c1461037f5780632f8cf2d014610387578063313ce5671461039a5780633af9e669146103b95780633b1d21a2146103cc5780633e941010146103d45780634576b5db146103e757806347bd3718146103fa5780635d1ad088146104035780635fe3b56714610416578063601a0bf1146104295780636711cc4a1461043c5780636752e7021461044f5780636f307dc31461045857806370a082311461047157806373acee981461049a57806383030846146104a2578063852a12e3146104b55780638f840ddd146104c857806395d89b41146104d157806395dd9193146104d957806395e666c5146104ec578063a0712d68146104ff578063a6afed9514610512578063a9059cbb1461051a578063aa5af0fd1461052d578063b71d1a0c14610536578063bd6d894d14610549578063c37f68e214610551578063c5ebeaec14610574578063cd91801c14610587578063cfa992011461058f578063d2c6d0dc14610598578063d3bd2c72146105ab578063d4af8de2146105b3578063db006a75146105c6578063dd62ed3e146105d9578063e9c714f214610612578063f2b3abbd1461061a578063f3fdb15a1461062d578063f5e3c46214610640578063f851a44014610653578063fca7820b1461066b575b600080fd5b61028a61067e565b6040516102979190615bbe565b60405180910390f35b6102b36102ae366004615831565b61070c565b6040519015158152602001610297565b6102d66102d1366004615969565b61077c565b005b6102e160085481565b604051908152602001610297565b6102e16102fd36600461561e565b6107c2565b6102e1600d5481565b6102e161083b565b6102e1610321366004615999565b6108b8565b6102b3610334366004615672565b610930565b6102e1610347366004615999565b610980565b6102d661035a366004615831565b6109ee565b600454610372906001600160a01b031681565b6040516102979190615a2e565b6102b3600181565b6102e1610395366004615999565b610a3c565b6003546103a79060ff1681565b60405160ff9091168152602001610297565b6102e16103c736600461561e565b610aaa565b6102e1610b68565b6102e16103e2366004615969565b610b77565b6102e16103f536600461561e565b610b82565b6102e1600b5481565b6102b361041136600461585c565b610c9d565b600554610372906001600160a01b031681565b6102e1610437366004615969565b610d5b565b6102d661044a3660046158f6565b610de8565b6102e160115481565b601254610372906201000090046001600160a01b031681565b6102e161047f36600461561e565b6001600160a01b03166000908152600e602052604090205490565b6102e1610e9c565b6102e16104b0366004615969565b610f02565b6102d66104c3366004615969565b610f72565b6102e1600c5481565b61028a610f7b565b6102e16104e736600461561e565b610f88565b6102b36104fa3660046156b2565b611007565b6102d661050d366004615969565b6110c6565b6102e1611101565b6102b3610528366004615831565b611504565b6102e1600a5481565b6102e161054436600461561e565b611553565b6102e16115ce565b61056461055f36600461561e565b61163a565b6040516102979493929190615cb1565b6102d6610582366004615969565b6116f7565b6102e1611700565b6102e160095481565b6102e16105a6366004615722565b611790565b6102e16117e1565b6102d66105c1366004615767565b611825565b6102d66105d4366004615969565b6119d9565b6102e16105e736600461563a565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6102e16119e2565b6102e161062836600461561e565b611ac4565b600654610372906001600160a01b031681565b6102d661064e3660046158b5565b611b0a565b6003546103729061010090046001600160a01b031681565b6102e1610679366004615969565b611b58565b6001805461068b90615d3a565b80601f01602080910402602001604051908101604052809291908181526020018280546106b790615d3a565b80156107045780601f106106d957610100808354040283529160200191610704565b820191906000526020600020905b8154815290600101906020018083116106e757829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855292528083208590555191929182907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906107689087815260200190565b60405180910390a360019150505b92915050565b600061078782611bc8565b5090506107be81604051806040016040528060128152602001711c995c185e509bdc9c9bddc819985a5b195960721b815250611c62565b5050565b6000805460ff166107ee5760405162461bcd60e51b81526004016107e590615c77565b60405180910390fd5b6000805460ff19168155610800611101565b1461081d5760405162461bcd60e51b81526004016107e590615c11565b61082682610f88565b90505b6000805460ff19166001179055919050565b6000806000610848611ea6565b9092509050600082600381111561086f57634e487b7160e01b600052602160045260246000fd5b146107765760405162461bcd60e51b8152602060048201526019602482015278195e18da185b99d954985d1954dd1bdc99590819985a5b1959603a1b60448201526064016107e5565b600554604051630a4ccbeb60e01b81526000916001600160a01b031690630a4ccbeb906108eb9086908690600401615b27565b600060405180830381600087803b15801561090557600080fd5b505af1158015610919573d6000803e3d6000fd5b5050505061092684611f70565b90505b9392505050565b6000805460ff166109535760405162461bcd60e51b81526004016107e590615c77565b6000805460ff1916815561096933868686611fe3565b1490506000805460ff191660011790559392505050565b600554604051630a4ccbeb60e01b81526000916001600160a01b031690630a4ccbeb906109b39086908690600401615b27565b600060405180830381600087803b1580156109cd57600080fd5b505af11580156109e1573d6000803e3d6000fd5b50505050610926846123f3565b60006109fa8383612464565b509050610a3781604051806040016040528060188152602001771c995c185e509bdc9c9bddd0995a185b198819985a5b195960421b815250611c62565b505050565b600554604051630a4ccbeb60e01b81526000916001600160a01b031690630a4ccbeb90610a6f9086908690600401615b27565b600060405180830381600087803b158015610a8957600080fd5b505af1158015610a9d573d6000803e3d6000fd5b5050505061092684612500565b6000806040518060200160405280610ac06115ce565b90526001600160a01b0384166000908152600e6020526040812054919250908190610aec90849061256c565b90925090506000826003811115610b1357634e487b7160e01b600052602160045260246000fd5b14610b605760405162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c617465640060448201526064016107e5565b949350505050565b6000610b726125cd565b905090565b60006107768261265c565b60035460009061010090046001600160a01b03163314610ba657610776603f6126e2565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b158015610beb57600080fd5b505afa158015610bff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c239190615949565b610c3f5760405162461bcd60e51b81526004016107e590615c41565b600580546001600160a01b0319166001600160a01b0385161790556040517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d90610c8c9083908690615a42565b60405180910390a160009392505050565b6000805460ff16610cc05760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19169055600554604051630a4ccbeb60e01b81526001600160a01b0390911690630a4ccbeb90610cfc9086908690600401615b27565b600060405180830381600087803b158015610d1657600080fd5b505af1158015610d2a573d6000803e3d6000fd5b5060009250610d37915050565b610d4333338888611fe3565b1490506000805460ff19166001179055949350505050565b6000805460ff16610d7e5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155610d90611101565b90508015610dca57610dc2816010811115610dbb57634e487b7160e01b600052602160045260246000fd5b60306126eb565b915050610829565b610dd383612775565b9150506000805460ff19166001179055919050565b600554604051630a4ccbeb60e01b81526001600160a01b0390911690630a4ccbeb90610e1a9085908590600401615b27565b600060405180830381600087803b158015610e3457600080fd5b505af1158015610e48573d6000803e3d6000fd5b505050506000610e5986868661285a565b509050610e9481604051806040016040528060168152602001751b1a5c5d5a59185d19509bdc9c9bddc819985a5b195960521b815250611c62565b505050505050565b6000805460ff16610ebf5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155610ed1611101565b14610eee5760405162461bcd60e51b81526004016107e590615c11565b50600b546000805460ff1916600117905590565b6000805460ff16610f255760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155610f37611101565b90508015610f6957610dc2816010811115610f6257634e487b7160e01b600052602160045260246000fd5b60516126eb565b610dd38361299d565b6107be81611f70565b6002805461068b90615d3a565b6000806000610f9684612a1e565b90925090506000826003811115610fbd57634e487b7160e01b600052602160045260246000fd5b146109295760405162461bcd60e51b815260206004820152601a602482015279189bdc9c9bddd0985b185b98d954dd1bdc99590819985a5b195960321b60448201526064016107e5565b6000805460ff1661102a5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19169055600554604051630a4ccbeb60e01b81526001600160a01b0390911690630a4ccbeb906110669086908690600401615b27565b600060405180830381600087803b15801561108057600080fd5b505af1158015611094573d6000803e3d6000fd5b50600092506110a1915050565b6110ad33888888611fe3565b1490506000805460ff1916600117905595945050505050565b60006110d182612af3565b5090506107be816040518060400160405280600b81526020016a1b5a5b9d0819985a5b195960aa1b815250611c62565b60095460009042908082141561111b5760005b9250505090565b60006111256125cd565b600b54600c54600a546006546040516315f2405360e01b81529495509293919290916000916001600160a01b0316906315f240539061116c90889088908890600401615c9b565b60206040518083038186803b15801561118457600080fd5b505afa158015611198573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111bc9190615981565b905065048c273950008111156112135760405162461bcd60e51b815260206004820152601c60248201527b0c4dee4e4deee40e4c2e8ca40d2e640c2c4e6eae4c8d8f240d0d2ced60231b60448201526064016107e5565b6000806112208989612b66565b9092509050600082600381111561124757634e487b7160e01b600052602160045260246000fd5b146112945760405162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c74610060448201526064016107e5565b61129c61549a565b6000806000806112ba60405180602001604052808a81525087612b89565b909750945060008760038111156112e157634e487b7160e01b600052602160045260246000fd5b14611325576113126009600689600381111561130d57634e487b7160e01b600052602160045260246000fd5b612c05565b9e50505050505050505050505050505090565b61132f858c61256c565b9097509350600087600381111561135657634e487b7160e01b600052602160045260246000fd5b14611382576113126009600189600381111561130d57634e487b7160e01b600052602160045260246000fd5b61138c848c612c8e565b909750925060008760038111156113b357634e487b7160e01b600052602160045260246000fd5b146113df576113126009600489600381111561130d57634e487b7160e01b600052602160045260246000fd5b6113fa6040518060200160405280600854815250858c612cb4565b9097509150600087600381111561142157634e487b7160e01b600052602160045260246000fd5b1461144d576113126009600589600381111561130d57634e487b7160e01b600052602160045260246000fd5b611458858a8b612cb4565b9097509050600087600381111561147f57634e487b7160e01b600052602160045260246000fd5b146114ab576113126009600389600381111561130d57634e487b7160e01b600052602160045260246000fd5b60098e9055600a819055600b839055600c8290556040517f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc04906114f5908e90879085908890615cb1565b60405180910390a16000611312565b6000805460ff166115275760405162461bcd60e51b81526004016107e590615c77565b6000805460ff1916815561153d33338686611fe3565b1490506000805460ff1916600117905592915050565b60035460009061010090046001600160a01b031633146115775761077660456126e2565b600454604051600080516020615dfa833981519152916115a4916001600160a01b03909116908590615a42565b60405180910390a1600480546001600160a01b0319166001600160a01b0384161790556000610776565b6000805460ff166115f15760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155611603611101565b146116205760405162461bcd60e51b81526004016107e590615c11565b61162861083b565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600e602052604081205481908190819081808061166589612a1e565b93509050600081600381111561168b57634e487b7160e01b600052602160045260246000fd5b146116a95760095b60008060009750975097509750505050506116f0565b6116b1611ea6565b9250905060008160038111156116d757634e487b7160e01b600052602160045260246000fd5b146116e3576009611693565b5060009650919450925090505b9193509193565b6107be816123f3565b6006546000906001600160a01b03166315f2405361171c6125cd565b600b54600c546040518463ffffffff1660e01b815260040161174093929190615c9b565b60206040518083038186803b15801561175857600080fd5b505afa15801561176c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b729190615981565b6000805460ff166117b35760405162461bcd60e51b81526004016107e590615c77565b6000805460ff191690556117ca3386868686612d1d565b90506000805460ff19166001179055949350505050565b6006546000906001600160a01b031663b81688166117fd6125cd565b600b54600c546008546040518563ffffffff1660e01b81526004016117409493929190615cb1565b601254610100900460ff166118405760125460ff1615611844565b303b155b6118a75760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016107e5565b601254610100900460ff161580156118c9576012805461ffff19166101011790555b60038054610100600160a81b03191633610100021790556118ee88888888888861323e565b88601260026101000a8154816001600160a01b0302191690836001600160a01b03160217905550601260029054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561196357600080fd5b505afa158015611977573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199b9190615981565b5060038054610100600160a81b0319166101006001600160a01b0385160217905580156119ce576012805461ff00191690555b505050505050505050565b6107be81612500565b6004546000906001600160a01b0316331415806119fd575033155b15611a0c57610b7260006126e2565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b03199093169093556040519382900481169492937ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc93611a8293879391041690615a42565b60405180910390a1600454604051600080516020615dfa83398151915291611ab59184916001600160a01b031690615a42565b60405180910390a16000611114565b600080611acf611101565b90508015611b0157610929816010811115611afa57634e487b7160e01b600052602160045260246000fd5b60406126eb565b61092983613443565b6000611b1784848461285a565b509050611b5281604051806040016040528060168152602001751b1a5c5d5a59185d19509bdc9c9bddc819985a5b195960521b815250611c62565b50505050565b6000805460ff16611b7b5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155611b8d611101565b90508015611bbf57610dc2816010811115611bb857634e487b7160e01b600052602160045260246000fd5b60466126eb565b610dd383613570565b60008054819060ff16611bed5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155611bff611101565b90508015611c3d57611c31816010811115611c2a57634e487b7160e01b600052602160045260246000fd5b60366126eb565b60009250925050611c4e565b611c48333386613603565b92509250505b6000805460ff191660011790559092909150565b81611c6b575050565b600081516005016001600160401b03811115611c9757634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611cc1576020820181803683370190505b50905060005b8251811015611d3a57828181518110611cf057634e487b7160e01b600052603260045260246000fd5b602001015160f81c60f81b828281518110611d1b57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600101611cc7565b8151600160fd1b90839083908110611d6257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602860f81b828260010181518110611da157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840460300160f81b828260020181518110611de557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840660300160f81b828260030181518110611e2957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602960f81b828260040181518110611e6857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350818415611e9f5760405162461bcd60e51b81526004016107e59190615bbe565b5050505050565b600d54600090819080611ec0575050600754600092909150565b6000611eca6125cd565b90506000611ed661549a565b6000611ee784600b54600c54613a69565b935090506000816003811115611f0d57634e487b7160e01b600052602160045260246000fd5b14611f1f579660009650945050505050565b611f298386613abb565b925090506000816003811115611f4f57634e487b7160e01b600052602160045260246000fd5b14611f61579660009650945050505050565b50516000969095509350505050565b6000805460ff16611f935760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155611fa5611101565b90508015611fd757610dc2816010811115611fd057634e487b7160e01b600052602160045260246000fd5b60276126eb565b610dd333600085613b94565b6005546040516317b9b84b60e31b815260009182916001600160a01b039091169063bdcdc2589061201e903090899089908990600401615afd565b602060405180830381600087803b15801561203857600080fd5b505af115801561204c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120709190615981565b905080156120be5760405162461bcd60e51b815260206004820152601b60248201527a115490cc8c0e881d1c985b9cd9995c881b9bdd08185b1b1bddd959602a1b60448201526064016107e5565b836001600160a01b0316856001600160a01b031614156121205760405162461bcd60e51b815260206004820181905260248201527f45524332303a2073656c662d7472616e73666572206e6f7420616c6c6f77656460448201526064016107e5565b6000856001600160a01b0316876001600160a01b03161415612145575060001961216d565b506001600160a01b038086166000908152600f60209081526040808320938a16835292905220545b60008060008061217d8589612b66565b909450925060008460038111156121a457634e487b7160e01b600052602160045260246000fd5b146121ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016107e5565b6001600160a01b038a166000908152600e60205260409020546122229089612b66565b9094509150600084600381111561224957634e487b7160e01b600052602160045260246000fd5b146122a55760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016107e5565b6001600160a01b0389166000908152600e60205260409020546122c89089612c8e565b909450905060008460038111156122ef57634e487b7160e01b600052602160045260246000fd5b1461234f5760405162461bcd60e51b815260206004820152602a60248201527f45524332303a206d6178696d756d2064657374696e6174696f6e2062616c616e60448201526918d9481c995858da195960b21b60648201526084016107e5565b6001600160a01b03808b166000908152600e6020526040808220859055918b1681522081905560001985146123a7576001600160a01b03808b166000908152600f60209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b0316600080516020615e1a8339815191528a6040516123da91815260200190565b60405180910390a360009b9a5050505050505050505050565b6000805460ff166124165760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155612428611101565b9050801561245a57610dc281601081111561245357634e487b7160e01b600052602160045260246000fd5b60086126eb565b610dd333846142d1565b60008054819060ff166124895760405162461bcd60e51b81526004016107e590615c77565b6000805460ff1916815561249b611101565b905080156124d9576124cd8160108111156124c657634e487b7160e01b600052602160045260246000fd5b60356126eb565b600092509250506124ea565b6124e4338686613603565b92509250505b6000805460ff1916600117905590939092509050565b6000805460ff166125235760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155612535611101565b9050801561256057610dc2816010811115611fd057634e487b7160e01b600052602160045260246000fd5b610dd333846000613b94565b60008060008061257c8686612b89565b909250905060008260038111156125a357634e487b7160e01b600052602160045260246000fd5b146125b457509150600090506125c6565b60006125bf82614575565b9350935050505b9250929050565b6012546040516370a0823160e01b81526000916201000090046001600160a01b03169081906370a0823190612606903090600401615a2e565b60206040518083038186803b15801561261e57600080fd5b505afa158015612632573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126569190615981565b91505090565b6000805460ff1661267f5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155612691611101565b905080156126c357610dc28160108111156126bc57634e487b7160e01b600052602160045260246000fd5b604e6126eb565b6126cc8361458d565b509150506000805460ff19166001179055919050565b60006107766001835b6000600080516020615dda83398151915283601081111561271c57634e487b7160e01b600052602160045260246000fd5b83605381111561273c57634e487b7160e01b600052602160045260246000fd5b600060405161274d93929190615c9b565b60405180910390a182601081111561092957634e487b7160e01b600052602160045260246000fd5b600354600090819061010090046001600160a01b0316331461279b5761092960316126e2565b42600954146127b057610929600a60336126eb565b826127b96125cd565b10156127cb57610929600e60326126eb565b600c548311156127e157610929600260346126eb565b82600c546127ef9190615d23565b600c8190556003549091506128129061010090046001600160a01b031684614604565b7f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e600360019054906101000a90046001600160a01b03168483604051610c8c93929190615a5c565b60008054819060ff1661287f5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155612891611101565b905080156128cf576128c38160108111156128bc57634e487b7160e01b600052602160045260246000fd5b600f6126eb565b60009250925050612986565b836001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561290a57600080fd5b505af115801561291e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129429190615981565b90508015612974576128c381601081111561296d57634e487b7160e01b600052602160045260246000fd5b60106126eb565b612980338787876146eb565b92509250505b6000805460ff191660011790559094909350915050565b60035460009061010090046001600160a01b031633146129c15761077660526126e2565b42600954146129d657610776600a60536126eb565b60115460408051918252602082018490527ff5815f353a60e815cce7553e4f60c533a59d26b1b5504ea4b6db8d60da3e4da2910160405180910390a160118290556000610776565b6001600160a01b038116600090815260106020526040812080548291829182918291612a535750600096879650945050505050565b612a638160000154600a54614c13565b90945092506000846003811115612a8a57634e487b7160e01b600052602160045260246000fd5b14612a9d57509195600095509350505050565b612aab838260010154614c66565b90945091506000846003811115612ad257634e487b7160e01b600052602160045260246000fd5b14612ae557509195600095509350505050565b506000969095509350505050565b60008054819060ff16612b185760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155612b2a611101565b90508015612b5c57611c31816010811115612b5557634e487b7160e01b600052602160045260246000fd5b601e6126eb565b611c483385614ca5565b600080838311612b7d5750600090508183036125c6565b506003905060006125c6565b6000612b9361549a565b600080612ba4866000015186614c13565b90925090506000826003811115612bcb57634e487b7160e01b600052602160045260246000fd5b14612bea575060408051602081019091526000815290925090506125c6565b60408051602081019091529081526000969095509350505050565b6000600080516020615dda833981519152846010811115612c3657634e487b7160e01b600052602160045260246000fd5b846053811115612c5657634e487b7160e01b600052602160045260246000fd5b84604051612c6693929190615c9b565b60405180910390a183601081111561092657634e487b7160e01b600052602160045260246000fd5b600080838301848110612ca6576000925090506125c6565b6002600092509250506125c6565b600080600080612cc48787612b89565b90925090506000826003811115612ceb57634e487b7160e01b600052602160045260246000fd5b14612cfc5750915060009050612d15565b612d0e612d0882614575565b86612c8e565b9350935050505b935093915050565b60055460405163d02f735160e01b815260009182916001600160a01b039091169063d02f735190612d5a9030908b908b908b908b90600401615aca565b602060405180830381600087803b158015612d7457600080fd5b505af1158015612d88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dac9190615981565b90508015612dc957612dc16003601b83612c05565b915050613235565b856001600160a01b0316856001600160a01b03161415612def57612dc16006601c6126eb565b612e3f604080516101208101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0386166000908152600e6020526040902054612e629086612b66565b6020830181905282826003811115612e8a57634e487b7160e01b600052602160045260246000fd5b6003811115612ea957634e487b7160e01b600052602160045260246000fd5b9052506000905081516003811115612ed157634e487b7160e01b600052602160045260246000fd5b14612f0a57612f016009601a8360000151600381111561130d57634e487b7160e01b600052602160045260246000fd5b92505050613235565b670de0b6b3a7640000841115612f67576000670de0b6b3a7640000850390506000612f4582604051806020016040528060115481525061516d565b9050612f5f8760405180602001604052808481525061516d565b608084015250505b6080810151612f769086615d23565b6060820152612f83611ea6565b60c0830181905282826003811115612fab57634e487b7160e01b600052602160045260246000fd5b6003811115612fca57634e487b7160e01b600052602160045260246000fd5b9052506000905081516003811115612ff257634e487b7160e01b600052602160045260246000fd5b1461303a5760405162461bcd60e51b815260206004820152601860248201527732bc31b430b733b2903930ba329036b0ba341032b93937b960411b60448201526064016107e5565b61305a60405180602001604052808360c001518152508260800151615190565b60a08201819052600c5461306e9190615ccc565b60e08201526080810151600d546130859190615d23565b6101008201526001600160a01b0387166000908152600e602052604090205460608201516130b39190612c8e565b60408301819052828260038111156130db57634e487b7160e01b600052602160045260246000fd5b60038111156130fa57634e487b7160e01b600052602160045260246000fd5b905250600090508151600381111561312257634e487b7160e01b600052602160045260246000fd5b1461315257612f01600960198360000151600381111561130d57634e487b7160e01b600052602160045260246000fd5b60e0810151600c55610100810151600d556020808201516001600160a01b038881166000818152600e855260408082209490945583860151928c1680825290849020929092556060850151925192835290929091600080516020615e1a833981519152910160405180910390a3306001600160a01b0316866001600160a01b0316600080516020615e1a83398151915283608001516040516131f691815260200190565b60405180910390a360a081015160e0820151604051600080516020615dba83398151915292613226923092615a5c565b60405180910390a16000925050505b95945050505050565b60035461010090046001600160a01b031633146132995760405162461bcd60e51b81526020600482015260196024820152786f6e6c792061646d696e206d617920696e697469616c697a6560381b60448201526064016107e5565b6009541580156132a95750600a54155b6132eb5760405162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b60448201526064016107e5565b60078490558361333d5760405162461bcd60e51b815260206004820152601e60248201527f696e69742065786368616e67652072617465206d757374206265203e2030000060448201526064016107e5565b600061334887610b82565b1461338e5760405162461bcd60e51b81526020600482015260166024820152751cd95d0818dbdb5c1d1c9bdb1b195c8819985a5b195960521b60448201526064016107e5565b42600955670de0b6b3a7640000600a5560006133a986613443565b146133f65760405162461bcd60e51b815260206004820152601e60248201527f73657420696e7465726573742072617465206d6f64656c206661696c6564000060448201526064016107e5565b82516134099060019060208601906154ad565b50815161341d9060029060208501906154ad565b506003805460ff90921660ff199283161790556000805490911660011790555050505050565b600354600090819061010090046001600160a01b031633146134695761092960426126e2565b426009541461347e57610929600a60416126eb565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156134cf57600080fd5b505afa1580156134e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135079190615949565b6135235760405162461bcd60e51b81526004016107e590615c41565b600680546001600160a01b0319166001600160a01b0385161790556040517fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f92690610c8c9083908690615a42565b60035460009061010090046001600160a01b031633146135945761077660476126e2565b42600954146135a957610776600a60486126eb565b670de0b6b3a76400008211156135c557610776600260496126eb565b600880549083905560408051828152602081018590527faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f8214609101610c8c565b600554604051631200453160e11b8152600091829182916001600160a01b0316906324008a629061363e9030908a908a908a90600401615afd565b602060405180830381600087803b15801561365857600080fd5b505af115801561366c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136909190615981565b905080156136b1576136a56003603883612c05565b60009250925050612d15565b42600954146136c6576136a5600a60396126eb565b61370f6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b038616600090815260106020526040902060010154606082015261373986612a1e565b608083018190526020830182600381111561376457634e487b7160e01b600052602160045260246000fd5b600381111561378357634e487b7160e01b600052602160045260246000fd5b90525060009050816020015160038111156137ae57634e487b7160e01b600052602160045260246000fd5b146137eb576137de600960378360200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b6000935093505050612d15565b80608001518510613805576080810151604082015261380d565b604081018590525b61381b8782604001516151a4565b60e08201819052608082015161383091612b66565b60a083018190526020830182600381111561385b57634e487b7160e01b600052602160045260246000fd5b600381111561387a57634e487b7160e01b600052602160045260246000fd5b90525060009050816020015160038111156138a557634e487b7160e01b600052602160045260246000fd5b146138f25760405162461bcd60e51b815260206004820181905260248201527f52455041595f4e45575f4143434f554e545f42414c414e43455f4641494c454460448201526064016107e5565b613902600b548260e00151612b66565b60c083018190526020830182600381111561392d57634e487b7160e01b600052602160045260246000fd5b600381111561394c57634e487b7160e01b600052602160045260246000fd5b905250600090508160200151600381111561397757634e487b7160e01b600052602160045260246000fd5b146139c45760405162461bcd60e51b815260206004820152601e60248201527f52455041595f4e45575f544f54414c5f42414c414e43455f4641494c4544000060448201526064016107e5565b60a081810180516001600160a01b03898116600081815260106020908152604091829020948555600a5460019095019490945560c0870151600b81905560e088015195518251948f16855294840192909252820193909352606081019190915260808101919091527f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1910160405180910390a160e00151600097909650945050505050565b600080600080613a798787612c8e565b90925090506000826003811115613aa057634e487b7160e01b600052602160045260246000fd5b14613ab15750915060009050612d15565b612d0e8186612b66565b6000613ac561549a565b600080613ada86670de0b6b3a7640000614c13565b90925090506000826003811115613b0157634e487b7160e01b600052602160045260246000fd5b14613b20575060408051602081019091526000815290925090506125c6565b600080613b2d8388614c66565b90925090506000826003811115613b5457634e487b7160e01b600052602160045260246000fd5b14613b7757816040518060200160405280600081525095509550505050506125c6565b604080516020810190915290815260009890975095505050505050565b6000821580613ba1575081155b613bed5760405162461bcd60e51b815260206004820152601e60248201527f746f6b656e73496e206f7220616d6f756e74496e206d7573742062652030000060448201526064016107e5565b613c2e6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b613c36611ea6565b6040830181905260208301826003811115613c6157634e487b7160e01b600052602160045260246000fd5b6003811115613c8057634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613cab57634e487b7160e01b600052602160045260246000fd5b14613ce357613cdb6009602b8360200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b915050610929565b8315613dfd576001600160a01b0385166000908152600e60205260409020548410613d2b576001600160a01b0385166000908152600e60205260409020546060820152613d33565b606081018490525b613d5360405180602001604052808360400151815250826060015161256c565b6080830181905260208301826003811115613d7e57634e487b7160e01b600052602160045260246000fd5b6003811115613d9d57634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613dc857634e487b7160e01b600052602160045260246000fd5b14613df857613cdb600960298360200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b613f0b565b600019831415613e44576001600160a01b0385166000908152600e60209081526040918290205460608401908152825191820183529183015181529051613d53919061256c565b6080810183905260408051602081018252908201518152613e669084906153eb565b6060830181905260208301826003811115613e9157634e487b7160e01b600052602160045260246000fd5b6003811115613eb057634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613edb57634e487b7160e01b600052602160045260246000fd5b14613f0b57613cdb6009602a8360200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b600554606082015160405163eabe7d9160e01b81526000926001600160a01b03169163eabe7d9191613f449130918b9190600401615a7d565b602060405180830381600087803b158015613f5e57600080fd5b505af1158015613f72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f969190615981565b90508015613fb457613fab6003602883612c05565b92505050610929565b4260095414613fc957613fab600a602c6126eb565b613fd9600d548360600151612b66565b60a084018190526020840182600381111561400457634e487b7160e01b600052602160045260246000fd5b600381111561402357634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561404e57634e487b7160e01b600052602160045260246000fd5b1461407e57613fab6009602e8460200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b6001600160a01b0386166000908152600e6020526040902054606083015111156140c1576001600160a01b0386166000908152600e602052604090205460608301525b6001600160a01b0386166000908152600e602052604090205460608301516140e99190612b66565b60c084018190526020840182600381111561411457634e487b7160e01b600052602160045260246000fd5b600381111561413357634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561415e57634e487b7160e01b600052602160045260246000fd5b1461418e57613fab6009602d8460200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b816080015161419b6125cd565b10156141ad57613fab600e602f6126eb565b60a0820151600d5560c08201516001600160a01b0387166000818152600e60205260409081902092909255606084015191513092600080516020615e1a833981519152916141fd91815260200190565b60405180910390a3608082015160608301516040517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a9299261423f928a92615a5c565b60405180910390a1600554608083015160608401516040516351dff98960e01b81526001600160a01b03909316926351dff989926142859230928c929190600401615aa1565b600060405180830381600087803b15801561429f57600080fd5b505af11580156142b3573d6000803e3d6000fd5b505050506142c5868360800151614604565b60009695505050505050565b60055460405163368f515360e21b815260009182916001600160a01b039091169063da3d454c9061430a90309088908890600401615a7d565b602060405180830381600087803b15801561432457600080fd5b505af1158015614338573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061435c9190615981565b90508015614379576143716003600e83612c05565b915050610776565b5042600954146143955761438e600a806126eb565b9050610776565b8161439e6125cd565b10156143b05761438e600e60096126eb565b6000806143bc85612a1e565b909250905060008260038111156143e357634e487b7160e01b600052602160045260246000fd5b146144185761440f6009600784600381111561130d57634e487b7160e01b600052602160045260246000fd5b92505050610776565b60006144248286612c8e565b9093509050600083600381111561444b57634e487b7160e01b600052602160045260246000fd5b14614481576144776009600c85600381111561130d57634e487b7160e01b600052602160045260246000fd5b9350505050610776565b600061448f600b5487612c8e565b909450905060008460038111156144b657634e487b7160e01b600052602160045260246000fd5b146144ed576144e26009600b86600381111561130d57634e487b7160e01b600052602160045260246000fd5b945050505050610776565b6001600160a01b038716600081815260106020908152604091829020858155600a54600190910155600b849055815192835282018890528101839052606081018290527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a16145678787614604565b60005b979650505050505050565b805160009061077690670de0b6b3a764000090615ce4565b600080808042600954146145b1576145a7600a604f6126eb565b9590945092505050565b6145bb33866151a4565b905080600c546145cb9190615ccc565b915081600c81905550600080516020615dba8339815191523382846040516145f593929190615a5c565b60405180910390a160006145a7565b60125460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490526201000090920490911690819063a9059cbb90604401600060405180830381600087803b15801561465b57600080fd5b505af115801561466f573d6000803e3d6000fd5b5050505060003d6000811461468b576020811461469557600080fd5b60001991506146a1565b60206000803e60005191505b5080611b525760405162461bcd60e51b81526020600482015260196024820152781513d2d15397d514905394d1915497d3d55517d19052531151603a1b60448201526064016107e5565b600554604051632fe3f38f60e11b81526000918291829182916001600160a01b0390911690635fc7e71e9061472c90309089908d908d908d90600401615aca565b6040805180830381600087803b15801561474557600080fd5b505af1158015614759573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061477d91906159e2565b91509150816000146147a3576147966003601284612c05565b6000935093505050614c0a565b42600954146147b857614796600a60166126eb565b42856001600160a01b031663cfa992016040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156147f457600080fd5b505af1158015614808573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061482c9190615981565b1461483d57614796600a60116126eb565b876001600160a01b0316876001600160a01b0316141561486357614796600660176126eb565b8561487457614796600760156126eb565b60001986141561488a57614796600760146126eb565b6000806148988a8a8a613603565b909250905081156148dc576148cd8260108111156148c657634e487b7160e01b600052602160045260246000fd5b60186126eb565b60009550955050505050614c0a565b600554604051639e9b187760e01b815260009182916001600160a01b0390911690639e9b1877906149179030908d9088908b90600401615aa1565b604080518083038186803b15801561492e57600080fd5b505afa158015614942573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061496691906159e2565b909250905081156149d55760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f604482015272105353d5539517d4d152569157d19052531151606a1b60648201526084016107e5565b6040516370a0823160e01b815281906001600160a01b038b16906370a0823190614a03908f90600401615a2e565b60206040518083038186803b158015614a1b57600080fd5b505afa158015614a2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a539190615981565b1015614a9c5760405162461bcd60e51b815260206004820152601860248201527709892a2aa928882a88abea68a92b48abea89e9ebe9aaa86960431b60448201526064016107e5565b60006001600160a01b038a16301415614ac357614abc308e8e858a612d1d565b9050614b4a565b896001600160a01b031663d2c6d0dc8e8e858a6040518563ffffffff1660e01b8152600401614af59493929190615aa1565b602060405180830381600087803b158015614b0f57600080fd5b505af1158015614b23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b479190615981565b90505b8015614b8f5760405162461bcd60e51b81526020600482015260146024820152731d1bdad95b881cd95a5e9d5c994819985a5b195960621b60448201526064016107e5565b7f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb528d8d868d86604051614bf49594939291906001600160a01b039586168152938516602085015260408401929092529092166060820152608081019190915260a00190565b60405180910390a1600098509296505050505050505b94509492505050565b60008083614c26575060009050806125c6565b83830283858281614c4757634e487b7160e01b600052601260045260246000fd5b0414614c5b576002600092509250506125c6565b6000925090506125c6565b60008082614c7a57506001905060006125c6565b6000838581614c9957634e487b7160e01b600052601260045260246000fd5b04915091509250929050565b600554604051634ef4c3e160e01b8152600091829182916001600160a01b031690634ef4c3e190614cde90309089908990600401615a7d565b602060405180830381600087803b158015614cf857600080fd5b505af1158015614d0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d309190615981565b90508015614d5157614d456003601f83612c05565b600092509250506125c6565b504260095414614d7257614d67600a60226126eb565b6000915091506125c6565b60408051808201909152600080825260208201526000614d90611ea6565b83602001819350826003811115614db757634e487b7160e01b600052602160045260246000fd5b6003811115614dd657634e487b7160e01b600052602160045260246000fd5b9052506000905082602001516003811115614e0157634e487b7160e01b600052602160045260246000fd5b14614e3e57614e31600960218460200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b60009350935050506125c6565b6000614e4a87876151a4565b90506000614e66826040518060200160405280868152506153eb565b85602001819350826003811115614e8d57634e487b7160e01b600052602160045260246000fd5b6003811115614eac57634e487b7160e01b600052602160045260246000fd5b9052506000905084602001516003811115614ed757634e487b7160e01b600052602160045260246000fd5b14614f245760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c454460448201526064016107e5565b6000614f32600d5483612c8e565b86602001819350826003811115614f5957634e487b7160e01b600052602160045260246000fd5b6003811115614f7857634e487b7160e01b600052602160045260246000fd5b9052506000905085602001516003811115614fa357634e487b7160e01b600052602160045260246000fd5b14614fef5760405162461bcd60e51b815260206004820152601c60248201527b1352539517d39155d7d513d5105317d4d55414131657d1905253115160221b60448201526064016107e5565b6001600160a01b0389166000908152600e60205260408120546150129084612c8e565b8760200181935082600381111561503957634e487b7160e01b600052602160045260246000fd5b600381111561505857634e487b7160e01b600052602160045260246000fd5b905250600090508660200151600381111561508357634e487b7160e01b600052602160045260246000fd5b146150d05760405162461bcd60e51b815260206004820152601f60248201527f4d494e545f4e45575f4143434f554e545f42414c414e43455f4641494c45440060448201526064016107e5565b600d8290556001600160a01b038a166000908152600e602052604090819020829055517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f90615124908c9087908790615a5c565b60405180910390a16040518381526001600160a01b038b1690600090600080516020615e1a8339815191529060200160405180910390a360009a93995092975050505050505050565b8051600090670de0b6b3a7640000906151869085615d04565b6109299190615ce4565b600061092961519f84846153fb565b614575565b6012546040516370a0823160e01b81526000916201000090046001600160a01b031690829082906370a08231906151df903090600401615a2e565b60206040518083038186803b1580156151f757600080fd5b505afa15801561520b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061522f9190615981565b6040516323b872dd60e01b81529091506001600160a01b038316906323b872dd9061526290889030908990600401615a7d565b600060405180830381600087803b15801561527c57600080fd5b505af1158015615290573d6000803e3d6000fd5b5050505060003d600081146152ac57602081146152b657600080fd5b60001991506152c2565b60206000803e60005191505b508061530b5760405162461bcd60e51b81526020600482015260186024820152771513d2d15397d514905394d1915497d25397d1905253115160421b60448201526064016107e5565b6012546040516370a0823160e01b81526000916201000090046001600160a01b0316906370a0823190615342903090600401615a2e565b60206040518083038186803b15801561535a57600080fd5b505afa15801561536e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906153929190615981565b9050828110156153e15760405162461bcd60e51b815260206004820152601a602482015279544f4b454e5f5452414e534645525f494e5f4f564552464c4f5760301b60448201526064016107e5565b61456a8382615d23565b60008060008061257c8686615427565b61540361549a565b604051806020016040528083856000015161541e9190615d04565b90529392505050565b600061543161549a565b600080615446670de0b6b3a764000087614c13565b9092509050600082600381111561546d57634e487b7160e01b600052602160045260246000fd5b1461548c575060408051602081019091526000815290925090506125c6565b6125bf818660000151613abb565b6040518060200160405280600081525090565b8280546154b990615d3a565b90600052602060002090601f0160209004810192826154db5760008555615521565b82601f106154f457805160ff1916838001178555615521565b82800160010185558215615521579182015b82811115615521578251825591602001919060010190615506565b5061552d929150615531565b5090565b5b8082111561552d5760008155600101615532565b803561555181615da1565b919050565b60008083601f840112615567578081fd5b5081356001600160401b0381111561557d578182fd5b6020830191508360208260051b85010111156125c657600080fd5b600082601f8301126155a8578081fd5b81356001600160401b03808211156155c2576155c2615d8b565b604051601f8301601f19908116603f011681019082821181831017156155ea576155ea615d8b565b81604052838152866020858801011115615602578485fd5b8360208701602083013792830160200193909352509392505050565b60006020828403121561562f578081fd5b813561092981615da1565b6000806040838503121561564c578081fd5b823561565781615da1565b9150602083013561566781615da1565b809150509250929050565b600080600060608486031215615686578081fd5b833561569181615da1565b925060208401356156a181615da1565b929592945050506040919091013590565b6000806000806000608086880312156156c9578081fd5b85356156d481615da1565b945060208601356156e481615da1565b93506040860135925060608601356001600160401b03811115615705578182fd5b61571188828901615556565b969995985093965092949392505050565b60008060008060808587031215615737578384fd5b843561574281615da1565b9350602085013561575281615da1565b93969395505050506040820135916060013590565b600080600080600080600080610100898b031215615783578283fd5b883561578e81615da1565b9750602089013561579e81615da1565b965060408901356157ae81615da1565b95506060890135945060808901356001600160401b03808211156157d0578485fd5b6157dc8c838d01615598565b955060a08b01359150808211156157f1578485fd5b506157fe8b828c01615598565b93505060c089013560ff81168114615814578283fd5b915061582260e08a01615546565b90509295985092959890939650565b60008060408385031215615843578182fd5b823561584e81615da1565b946020939093013593505050565b60008060008060608587031215615871578384fd5b843561587c81615da1565b93506020850135925060408501356001600160401b0381111561589d578283fd5b6158a987828801615556565b95989497509550505050565b6000806000606084860312156158c9578081fd5b83356158d481615da1565b92506020840135915060408401356158eb81615da1565b809150509250925092565b60008060008060006080868803121561590d578283fd5b853561591881615da1565b945060208601359350604086013561592f81615da1565b925060608601356001600160401b03811115615705578182fd5b60006020828403121561595a578081fd5b81518015158114610929578182fd5b60006020828403121561597a578081fd5b5035919050565b600060208284031215615992578081fd5b5051919050565b6000806000604084860312156159ad578081fd5b8335925060208401356001600160401b038111156159c9578182fd5b6159d586828701615556565b9497909650939450505050565b600080604083850312156159f4578182fd5b505080516020909101519092909150565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b6001600160a01b039586168152938516602085015291841660408401529092166060820152608081019190915260a00190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b60208082528181018390526000906040600585901b8401810190840186845b87811015615bb157868403603f190183528135368a9003601e19018112615b6b578687fd5b890180356001600160401b03811115615b82578788fd5b8036038b1315615b90578788fd5b615b9d8682898501615a05565b955050509184019190840190600101615b46565b5091979650505050505050565b6000602080835283518082850152825b81811015615bea57858101830151858201604001528201615bce565b81811115615bfb5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252601690820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604082015260600190565b6020808252601c908201527b6d61726b6572206d6574686f642072657475726e65642066616c736560201b604082015260600190565b6020808252600a90820152691c994b595b9d195c995960b21b604082015260600190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60008219821115615cdf57615cdf615d75565b500190565b600082615cff57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615615d1e57615d1e615d75565b500290565b600082821015615d3557615d35615d75565b500390565b600181811c90821680615d4e57607f821691505b60208210811415615d6f57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114615db657600080fd5b5056fea91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc545b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0ca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa264697066735822122033ddbfeb5634ccdc906195953977f2b388e3fe6278e1418c64300ad4f0c9bab664736f6c63430008040033
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061027d5760003560e01c806306fdde0314610282578063095ea7b3146102a05780630e752702146102c3578063173b9904146102d857806317bfdfbc146102ef57806318160ddd14610302578063182df0f51461030b57806320bdc6571461031357806323b872dd1461032657806324e1afa1146103395780632608f8181461034c578063267822471461035f57806329d9109c1461037f5780632f8cf2d014610387578063313ce5671461039a5780633af9e669146103b95780633b1d21a2146103cc5780633e941010146103d45780634576b5db146103e757806347bd3718146103fa5780635d1ad088146104035780635fe3b56714610416578063601a0bf1146104295780636711cc4a1461043c5780636752e7021461044f5780636f307dc31461045857806370a082311461047157806373acee981461049a57806383030846146104a2578063852a12e3146104b55780638f840ddd146104c857806395d89b41146104d157806395dd9193146104d957806395e666c5146104ec578063a0712d68146104ff578063a6afed9514610512578063a9059cbb1461051a578063aa5af0fd1461052d578063b71d1a0c14610536578063bd6d894d14610549578063c37f68e214610551578063c5ebeaec14610574578063cd91801c14610587578063cfa992011461058f578063d2c6d0dc14610598578063d3bd2c72146105ab578063d4af8de2146105b3578063db006a75146105c6578063dd62ed3e146105d9578063e9c714f214610612578063f2b3abbd1461061a578063f3fdb15a1461062d578063f5e3c46214610640578063f851a44014610653578063fca7820b1461066b575b600080fd5b61028a61067e565b6040516102979190615bbe565b60405180910390f35b6102b36102ae366004615831565b61070c565b6040519015158152602001610297565b6102d66102d1366004615969565b61077c565b005b6102e160085481565b604051908152602001610297565b6102e16102fd36600461561e565b6107c2565b6102e1600d5481565b6102e161083b565b6102e1610321366004615999565b6108b8565b6102b3610334366004615672565b610930565b6102e1610347366004615999565b610980565b6102d661035a366004615831565b6109ee565b600454610372906001600160a01b031681565b6040516102979190615a2e565b6102b3600181565b6102e1610395366004615999565b610a3c565b6003546103a79060ff1681565b60405160ff9091168152602001610297565b6102e16103c736600461561e565b610aaa565b6102e1610b68565b6102e16103e2366004615969565b610b77565b6102e16103f536600461561e565b610b82565b6102e1600b5481565b6102b361041136600461585c565b610c9d565b600554610372906001600160a01b031681565b6102e1610437366004615969565b610d5b565b6102d661044a3660046158f6565b610de8565b6102e160115481565b601254610372906201000090046001600160a01b031681565b6102e161047f36600461561e565b6001600160a01b03166000908152600e602052604090205490565b6102e1610e9c565b6102e16104b0366004615969565b610f02565b6102d66104c3366004615969565b610f72565b6102e1600c5481565b61028a610f7b565b6102e16104e736600461561e565b610f88565b6102b36104fa3660046156b2565b611007565b6102d661050d366004615969565b6110c6565b6102e1611101565b6102b3610528366004615831565b611504565b6102e1600a5481565b6102e161054436600461561e565b611553565b6102e16115ce565b61056461055f36600461561e565b61163a565b6040516102979493929190615cb1565b6102d6610582366004615969565b6116f7565b6102e1611700565b6102e160095481565b6102e16105a6366004615722565b611790565b6102e16117e1565b6102d66105c1366004615767565b611825565b6102d66105d4366004615969565b6119d9565b6102e16105e736600461563a565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b6102e16119e2565b6102e161062836600461561e565b611ac4565b600654610372906001600160a01b031681565b6102d661064e3660046158b5565b611b0a565b6003546103729061010090046001600160a01b031681565b6102e1610679366004615969565b611b58565b6001805461068b90615d3a565b80601f01602080910402602001604051908101604052809291908181526020018280546106b790615d3a565b80156107045780601f106106d957610100808354040283529160200191610704565b820191906000526020600020905b8154815290600101906020018083116106e757829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855292528083208590555191929182907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906107689087815260200190565b60405180910390a360019150505b92915050565b600061078782611bc8565b5090506107be81604051806040016040528060128152602001711c995c185e509bdc9c9bddc819985a5b195960721b815250611c62565b5050565b6000805460ff166107ee5760405162461bcd60e51b81526004016107e590615c77565b60405180910390fd5b6000805460ff19168155610800611101565b1461081d5760405162461bcd60e51b81526004016107e590615c11565b61082682610f88565b90505b6000805460ff19166001179055919050565b6000806000610848611ea6565b9092509050600082600381111561086f57634e487b7160e01b600052602160045260246000fd5b146107765760405162461bcd60e51b8152602060048201526019602482015278195e18da185b99d954985d1954dd1bdc99590819985a5b1959603a1b60448201526064016107e5565b600554604051630a4ccbeb60e01b81526000916001600160a01b031690630a4ccbeb906108eb9086908690600401615b27565b600060405180830381600087803b15801561090557600080fd5b505af1158015610919573d6000803e3d6000fd5b5050505061092684611f70565b90505b9392505050565b6000805460ff166109535760405162461bcd60e51b81526004016107e590615c77565b6000805460ff1916815561096933868686611fe3565b1490506000805460ff191660011790559392505050565b600554604051630a4ccbeb60e01b81526000916001600160a01b031690630a4ccbeb906109b39086908690600401615b27565b600060405180830381600087803b1580156109cd57600080fd5b505af11580156109e1573d6000803e3d6000fd5b50505050610926846123f3565b60006109fa8383612464565b509050610a3781604051806040016040528060188152602001771c995c185e509bdc9c9bddd0995a185b198819985a5b195960421b815250611c62565b505050565b600554604051630a4ccbeb60e01b81526000916001600160a01b031690630a4ccbeb90610a6f9086908690600401615b27565b600060405180830381600087803b158015610a8957600080fd5b505af1158015610a9d573d6000803e3d6000fd5b5050505061092684612500565b6000806040518060200160405280610ac06115ce565b90526001600160a01b0384166000908152600e6020526040812054919250908190610aec90849061256c565b90925090506000826003811115610b1357634e487b7160e01b600052602160045260246000fd5b14610b605760405162461bcd60e51b815260206004820152601f60248201527f62616c616e636520636f756c64206e6f742062652063616c63756c617465640060448201526064016107e5565b949350505050565b6000610b726125cd565b905090565b60006107768261265c565b60035460009061010090046001600160a01b03163314610ba657610776603f6126e2565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b158015610beb57600080fd5b505afa158015610bff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c239190615949565b610c3f5760405162461bcd60e51b81526004016107e590615c41565b600580546001600160a01b0319166001600160a01b0385161790556040517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d90610c8c9083908690615a42565b60405180910390a160009392505050565b6000805460ff16610cc05760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19169055600554604051630a4ccbeb60e01b81526001600160a01b0390911690630a4ccbeb90610cfc9086908690600401615b27565b600060405180830381600087803b158015610d1657600080fd5b505af1158015610d2a573d6000803e3d6000fd5b5060009250610d37915050565b610d4333338888611fe3565b1490506000805460ff19166001179055949350505050565b6000805460ff16610d7e5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155610d90611101565b90508015610dca57610dc2816010811115610dbb57634e487b7160e01b600052602160045260246000fd5b60306126eb565b915050610829565b610dd383612775565b9150506000805460ff19166001179055919050565b600554604051630a4ccbeb60e01b81526001600160a01b0390911690630a4ccbeb90610e1a9085908590600401615b27565b600060405180830381600087803b158015610e3457600080fd5b505af1158015610e48573d6000803e3d6000fd5b505050506000610e5986868661285a565b509050610e9481604051806040016040528060168152602001751b1a5c5d5a59185d19509bdc9c9bddc819985a5b195960521b815250611c62565b505050505050565b6000805460ff16610ebf5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155610ed1611101565b14610eee5760405162461bcd60e51b81526004016107e590615c11565b50600b546000805460ff1916600117905590565b6000805460ff16610f255760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155610f37611101565b90508015610f6957610dc2816010811115610f6257634e487b7160e01b600052602160045260246000fd5b60516126eb565b610dd38361299d565b6107be81611f70565b6002805461068b90615d3a565b6000806000610f9684612a1e565b90925090506000826003811115610fbd57634e487b7160e01b600052602160045260246000fd5b146109295760405162461bcd60e51b815260206004820152601a602482015279189bdc9c9bddd0985b185b98d954dd1bdc99590819985a5b195960321b60448201526064016107e5565b6000805460ff1661102a5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19169055600554604051630a4ccbeb60e01b81526001600160a01b0390911690630a4ccbeb906110669086908690600401615b27565b600060405180830381600087803b15801561108057600080fd5b505af1158015611094573d6000803e3d6000fd5b50600092506110a1915050565b6110ad33888888611fe3565b1490506000805460ff1916600117905595945050505050565b60006110d182612af3565b5090506107be816040518060400160405280600b81526020016a1b5a5b9d0819985a5b195960aa1b815250611c62565b60095460009042908082141561111b5760005b9250505090565b60006111256125cd565b600b54600c54600a546006546040516315f2405360e01b81529495509293919290916000916001600160a01b0316906315f240539061116c90889088908890600401615c9b565b60206040518083038186803b15801561118457600080fd5b505afa158015611198573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111bc9190615981565b905065048c273950008111156112135760405162461bcd60e51b815260206004820152601c60248201527b0c4dee4e4deee40e4c2e8ca40d2e640c2c4e6eae4c8d8f240d0d2ced60231b60448201526064016107e5565b6000806112208989612b66565b9092509050600082600381111561124757634e487b7160e01b600052602160045260246000fd5b146112945760405162461bcd60e51b815260206004820152601f60248201527f636f756c64206e6f742063616c63756c61746520626c6f636b2064656c74610060448201526064016107e5565b61129c61549a565b6000806000806112ba60405180602001604052808a81525087612b89565b909750945060008760038111156112e157634e487b7160e01b600052602160045260246000fd5b14611325576113126009600689600381111561130d57634e487b7160e01b600052602160045260246000fd5b612c05565b9e50505050505050505050505050505090565b61132f858c61256c565b9097509350600087600381111561135657634e487b7160e01b600052602160045260246000fd5b14611382576113126009600189600381111561130d57634e487b7160e01b600052602160045260246000fd5b61138c848c612c8e565b909750925060008760038111156113b357634e487b7160e01b600052602160045260246000fd5b146113df576113126009600489600381111561130d57634e487b7160e01b600052602160045260246000fd5b6113fa6040518060200160405280600854815250858c612cb4565b9097509150600087600381111561142157634e487b7160e01b600052602160045260246000fd5b1461144d576113126009600589600381111561130d57634e487b7160e01b600052602160045260246000fd5b611458858a8b612cb4565b9097509050600087600381111561147f57634e487b7160e01b600052602160045260246000fd5b146114ab576113126009600389600381111561130d57634e487b7160e01b600052602160045260246000fd5b60098e9055600a819055600b839055600c8290556040517f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc04906114f5908e90879085908890615cb1565b60405180910390a16000611312565b6000805460ff166115275760405162461bcd60e51b81526004016107e590615c77565b6000805460ff1916815561153d33338686611fe3565b1490506000805460ff1916600117905592915050565b60035460009061010090046001600160a01b031633146115775761077660456126e2565b600454604051600080516020615dfa833981519152916115a4916001600160a01b03909116908590615a42565b60405180910390a1600480546001600160a01b0319166001600160a01b0384161790556000610776565b6000805460ff166115f15760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155611603611101565b146116205760405162461bcd60e51b81526004016107e590615c11565b61162861083b565b90506000805460ff1916600117905590565b6001600160a01b0381166000908152600e602052604081205481908190819081808061166589612a1e565b93509050600081600381111561168b57634e487b7160e01b600052602160045260246000fd5b146116a95760095b60008060009750975097509750505050506116f0565b6116b1611ea6565b9250905060008160038111156116d757634e487b7160e01b600052602160045260246000fd5b146116e3576009611693565b5060009650919450925090505b9193509193565b6107be816123f3565b6006546000906001600160a01b03166315f2405361171c6125cd565b600b54600c546040518463ffffffff1660e01b815260040161174093929190615c9b565b60206040518083038186803b15801561175857600080fd5b505afa15801561176c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b729190615981565b6000805460ff166117b35760405162461bcd60e51b81526004016107e590615c77565b6000805460ff191690556117ca3386868686612d1d565b90506000805460ff19166001179055949350505050565b6006546000906001600160a01b031663b81688166117fd6125cd565b600b54600c546008546040518563ffffffff1660e01b81526004016117409493929190615cb1565b601254610100900460ff166118405760125460ff1615611844565b303b155b6118a75760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016107e5565b601254610100900460ff161580156118c9576012805461ffff19166101011790555b60038054610100600160a81b03191633610100021790556118ee88888888888861323e565b88601260026101000a8154816001600160a01b0302191690836001600160a01b03160217905550601260029054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561196357600080fd5b505afa158015611977573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199b9190615981565b5060038054610100600160a81b0319166101006001600160a01b0385160217905580156119ce576012805461ff00191690555b505050505050505050565b6107be81612500565b6004546000906001600160a01b0316331415806119fd575033155b15611a0c57610b7260006126e2565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b03199093169093556040519382900481169492937ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc93611a8293879391041690615a42565b60405180910390a1600454604051600080516020615dfa83398151915291611ab59184916001600160a01b031690615a42565b60405180910390a16000611114565b600080611acf611101565b90508015611b0157610929816010811115611afa57634e487b7160e01b600052602160045260246000fd5b60406126eb565b61092983613443565b6000611b1784848461285a565b509050611b5281604051806040016040528060168152602001751b1a5c5d5a59185d19509bdc9c9bddc819985a5b195960521b815250611c62565b50505050565b6000805460ff16611b7b5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155611b8d611101565b90508015611bbf57610dc2816010811115611bb857634e487b7160e01b600052602160045260246000fd5b60466126eb565b610dd383613570565b60008054819060ff16611bed5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155611bff611101565b90508015611c3d57611c31816010811115611c2a57634e487b7160e01b600052602160045260246000fd5b60366126eb565b60009250925050611c4e565b611c48333386613603565b92509250505b6000805460ff191660011790559092909150565b81611c6b575050565b600081516005016001600160401b03811115611c9757634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611cc1576020820181803683370190505b50905060005b8251811015611d3a57828181518110611cf057634e487b7160e01b600052603260045260246000fd5b602001015160f81c60f81b828281518110611d1b57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600101611cc7565b8151600160fd1b90839083908110611d6257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602860f81b828260010181518110611da157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840460300160f81b828260020181518110611de557634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600a840660300160f81b828260030181518110611e2957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350602960f81b828260040181518110611e6857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350818415611e9f5760405162461bcd60e51b81526004016107e59190615bbe565b5050505050565b600d54600090819080611ec0575050600754600092909150565b6000611eca6125cd565b90506000611ed661549a565b6000611ee784600b54600c54613a69565b935090506000816003811115611f0d57634e487b7160e01b600052602160045260246000fd5b14611f1f579660009650945050505050565b611f298386613abb565b925090506000816003811115611f4f57634e487b7160e01b600052602160045260246000fd5b14611f61579660009650945050505050565b50516000969095509350505050565b6000805460ff16611f935760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155611fa5611101565b90508015611fd757610dc2816010811115611fd057634e487b7160e01b600052602160045260246000fd5b60276126eb565b610dd333600085613b94565b6005546040516317b9b84b60e31b815260009182916001600160a01b039091169063bdcdc2589061201e903090899089908990600401615afd565b602060405180830381600087803b15801561203857600080fd5b505af115801561204c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120709190615981565b905080156120be5760405162461bcd60e51b815260206004820152601b60248201527a115490cc8c0e881d1c985b9cd9995c881b9bdd08185b1b1bddd959602a1b60448201526064016107e5565b836001600160a01b0316856001600160a01b031614156121205760405162461bcd60e51b815260206004820181905260248201527f45524332303a2073656c662d7472616e73666572206e6f7420616c6c6f77656460448201526064016107e5565b6000856001600160a01b0316876001600160a01b03161415612145575060001961216d565b506001600160a01b038086166000908152600f60209081526040808320938a16835292905220545b60008060008061217d8589612b66565b909450925060008460038111156121a457634e487b7160e01b600052602160045260246000fd5b146121ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016107e5565b6001600160a01b038a166000908152600e60205260409020546122229089612b66565b9094509150600084600381111561224957634e487b7160e01b600052602160045260246000fd5b146122a55760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016107e5565b6001600160a01b0389166000908152600e60205260409020546122c89089612c8e565b909450905060008460038111156122ef57634e487b7160e01b600052602160045260246000fd5b1461234f5760405162461bcd60e51b815260206004820152602a60248201527f45524332303a206d6178696d756d2064657374696e6174696f6e2062616c616e60448201526918d9481c995858da195960b21b60648201526084016107e5565b6001600160a01b03808b166000908152600e6020526040808220859055918b1681522081905560001985146123a7576001600160a01b03808b166000908152600f60209081526040808320938f168352929052208390555b886001600160a01b03168a6001600160a01b0316600080516020615e1a8339815191528a6040516123da91815260200190565b60405180910390a360009b9a5050505050505050505050565b6000805460ff166124165760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155612428611101565b9050801561245a57610dc281601081111561245357634e487b7160e01b600052602160045260246000fd5b60086126eb565b610dd333846142d1565b60008054819060ff166124895760405162461bcd60e51b81526004016107e590615c77565b6000805460ff1916815561249b611101565b905080156124d9576124cd8160108111156124c657634e487b7160e01b600052602160045260246000fd5b60356126eb565b600092509250506124ea565b6124e4338686613603565b92509250505b6000805460ff1916600117905590939092509050565b6000805460ff166125235760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155612535611101565b9050801561256057610dc2816010811115611fd057634e487b7160e01b600052602160045260246000fd5b610dd333846000613b94565b60008060008061257c8686612b89565b909250905060008260038111156125a357634e487b7160e01b600052602160045260246000fd5b146125b457509150600090506125c6565b60006125bf82614575565b9350935050505b9250929050565b6012546040516370a0823160e01b81526000916201000090046001600160a01b03169081906370a0823190612606903090600401615a2e565b60206040518083038186803b15801561261e57600080fd5b505afa158015612632573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126569190615981565b91505090565b6000805460ff1661267f5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155612691611101565b905080156126c357610dc28160108111156126bc57634e487b7160e01b600052602160045260246000fd5b604e6126eb565b6126cc8361458d565b509150506000805460ff19166001179055919050565b60006107766001835b6000600080516020615dda83398151915283601081111561271c57634e487b7160e01b600052602160045260246000fd5b83605381111561273c57634e487b7160e01b600052602160045260246000fd5b600060405161274d93929190615c9b565b60405180910390a182601081111561092957634e487b7160e01b600052602160045260246000fd5b600354600090819061010090046001600160a01b0316331461279b5761092960316126e2565b42600954146127b057610929600a60336126eb565b826127b96125cd565b10156127cb57610929600e60326126eb565b600c548311156127e157610929600260346126eb565b82600c546127ef9190615d23565b600c8190556003549091506128129061010090046001600160a01b031684614604565b7f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e600360019054906101000a90046001600160a01b03168483604051610c8c93929190615a5c565b60008054819060ff1661287f5760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155612891611101565b905080156128cf576128c38160108111156128bc57634e487b7160e01b600052602160045260246000fd5b600f6126eb565b60009250925050612986565b836001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561290a57600080fd5b505af115801561291e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129429190615981565b90508015612974576128c381601081111561296d57634e487b7160e01b600052602160045260246000fd5b60106126eb565b612980338787876146eb565b92509250505b6000805460ff191660011790559094909350915050565b60035460009061010090046001600160a01b031633146129c15761077660526126e2565b42600954146129d657610776600a60536126eb565b60115460408051918252602082018490527ff5815f353a60e815cce7553e4f60c533a59d26b1b5504ea4b6db8d60da3e4da2910160405180910390a160118290556000610776565b6001600160a01b038116600090815260106020526040812080548291829182918291612a535750600096879650945050505050565b612a638160000154600a54614c13565b90945092506000846003811115612a8a57634e487b7160e01b600052602160045260246000fd5b14612a9d57509195600095509350505050565b612aab838260010154614c66565b90945091506000846003811115612ad257634e487b7160e01b600052602160045260246000fd5b14612ae557509195600095509350505050565b506000969095509350505050565b60008054819060ff16612b185760405162461bcd60e51b81526004016107e590615c77565b6000805460ff19168155612b2a611101565b90508015612b5c57611c31816010811115612b5557634e487b7160e01b600052602160045260246000fd5b601e6126eb565b611c483385614ca5565b600080838311612b7d5750600090508183036125c6565b506003905060006125c6565b6000612b9361549a565b600080612ba4866000015186614c13565b90925090506000826003811115612bcb57634e487b7160e01b600052602160045260246000fd5b14612bea575060408051602081019091526000815290925090506125c6565b60408051602081019091529081526000969095509350505050565b6000600080516020615dda833981519152846010811115612c3657634e487b7160e01b600052602160045260246000fd5b846053811115612c5657634e487b7160e01b600052602160045260246000fd5b84604051612c6693929190615c9b565b60405180910390a183601081111561092657634e487b7160e01b600052602160045260246000fd5b600080838301848110612ca6576000925090506125c6565b6002600092509250506125c6565b600080600080612cc48787612b89565b90925090506000826003811115612ceb57634e487b7160e01b600052602160045260246000fd5b14612cfc5750915060009050612d15565b612d0e612d0882614575565b86612c8e565b9350935050505b935093915050565b60055460405163d02f735160e01b815260009182916001600160a01b039091169063d02f735190612d5a9030908b908b908b908b90600401615aca565b602060405180830381600087803b158015612d7457600080fd5b505af1158015612d88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dac9190615981565b90508015612dc957612dc16003601b83612c05565b915050613235565b856001600160a01b0316856001600160a01b03161415612def57612dc16006601c6126eb565b612e3f604080516101208101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0386166000908152600e6020526040902054612e629086612b66565b6020830181905282826003811115612e8a57634e487b7160e01b600052602160045260246000fd5b6003811115612ea957634e487b7160e01b600052602160045260246000fd5b9052506000905081516003811115612ed157634e487b7160e01b600052602160045260246000fd5b14612f0a57612f016009601a8360000151600381111561130d57634e487b7160e01b600052602160045260246000fd5b92505050613235565b670de0b6b3a7640000841115612f67576000670de0b6b3a7640000850390506000612f4582604051806020016040528060115481525061516d565b9050612f5f8760405180602001604052808481525061516d565b608084015250505b6080810151612f769086615d23565b6060820152612f83611ea6565b60c0830181905282826003811115612fab57634e487b7160e01b600052602160045260246000fd5b6003811115612fca57634e487b7160e01b600052602160045260246000fd5b9052506000905081516003811115612ff257634e487b7160e01b600052602160045260246000fd5b1461303a5760405162461bcd60e51b815260206004820152601860248201527732bc31b430b733b2903930ba329036b0ba341032b93937b960411b60448201526064016107e5565b61305a60405180602001604052808360c001518152508260800151615190565b60a08201819052600c5461306e9190615ccc565b60e08201526080810151600d546130859190615d23565b6101008201526001600160a01b0387166000908152600e602052604090205460608201516130b39190612c8e565b60408301819052828260038111156130db57634e487b7160e01b600052602160045260246000fd5b60038111156130fa57634e487b7160e01b600052602160045260246000fd5b905250600090508151600381111561312257634e487b7160e01b600052602160045260246000fd5b1461315257612f01600960198360000151600381111561130d57634e487b7160e01b600052602160045260246000fd5b60e0810151600c55610100810151600d556020808201516001600160a01b038881166000818152600e855260408082209490945583860151928c1680825290849020929092556060850151925192835290929091600080516020615e1a833981519152910160405180910390a3306001600160a01b0316866001600160a01b0316600080516020615e1a83398151915283608001516040516131f691815260200190565b60405180910390a360a081015160e0820151604051600080516020615dba83398151915292613226923092615a5c565b60405180910390a16000925050505b95945050505050565b60035461010090046001600160a01b031633146132995760405162461bcd60e51b81526020600482015260196024820152786f6e6c792061646d696e206d617920696e697469616c697a6560381b60448201526064016107e5565b6009541580156132a95750600a54155b6132eb5760405162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b60448201526064016107e5565b60078490558361333d5760405162461bcd60e51b815260206004820152601e60248201527f696e69742065786368616e67652072617465206d757374206265203e2030000060448201526064016107e5565b600061334887610b82565b1461338e5760405162461bcd60e51b81526020600482015260166024820152751cd95d0818dbdb5c1d1c9bdb1b195c8819985a5b195960521b60448201526064016107e5565b42600955670de0b6b3a7640000600a5560006133a986613443565b146133f65760405162461bcd60e51b815260206004820152601e60248201527f73657420696e7465726573742072617465206d6f64656c206661696c6564000060448201526064016107e5565b82516134099060019060208601906154ad565b50815161341d9060029060208501906154ad565b506003805460ff90921660ff199283161790556000805490911660011790555050505050565b600354600090819061010090046001600160a01b031633146134695761092960426126e2565b426009541461347e57610929600a60416126eb565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156134cf57600080fd5b505afa1580156134e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135079190615949565b6135235760405162461bcd60e51b81526004016107e590615c41565b600680546001600160a01b0319166001600160a01b0385161790556040517fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f92690610c8c9083908690615a42565b60035460009061010090046001600160a01b031633146135945761077660476126e2565b42600954146135a957610776600a60486126eb565b670de0b6b3a76400008211156135c557610776600260496126eb565b600880549083905560408051828152602081018590527faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f8214609101610c8c565b600554604051631200453160e11b8152600091829182916001600160a01b0316906324008a629061363e9030908a908a908a90600401615afd565b602060405180830381600087803b15801561365857600080fd5b505af115801561366c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136909190615981565b905080156136b1576136a56003603883612c05565b60009250925050612d15565b42600954146136c6576136a5600a60396126eb565b61370f6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b038616600090815260106020526040902060010154606082015261373986612a1e565b608083018190526020830182600381111561376457634e487b7160e01b600052602160045260246000fd5b600381111561378357634e487b7160e01b600052602160045260246000fd5b90525060009050816020015160038111156137ae57634e487b7160e01b600052602160045260246000fd5b146137eb576137de600960378360200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b6000935093505050612d15565b80608001518510613805576080810151604082015261380d565b604081018590525b61381b8782604001516151a4565b60e08201819052608082015161383091612b66565b60a083018190526020830182600381111561385b57634e487b7160e01b600052602160045260246000fd5b600381111561387a57634e487b7160e01b600052602160045260246000fd5b90525060009050816020015160038111156138a557634e487b7160e01b600052602160045260246000fd5b146138f25760405162461bcd60e51b815260206004820181905260248201527f52455041595f4e45575f4143434f554e545f42414c414e43455f4641494c454460448201526064016107e5565b613902600b548260e00151612b66565b60c083018190526020830182600381111561392d57634e487b7160e01b600052602160045260246000fd5b600381111561394c57634e487b7160e01b600052602160045260246000fd5b905250600090508160200151600381111561397757634e487b7160e01b600052602160045260246000fd5b146139c45760405162461bcd60e51b815260206004820152601e60248201527f52455041595f4e45575f544f54414c5f42414c414e43455f4641494c4544000060448201526064016107e5565b60a081810180516001600160a01b03898116600081815260106020908152604091829020948555600a5460019095019490945560c0870151600b81905560e088015195518251948f16855294840192909252820193909352606081019190915260808101919091527f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1910160405180910390a160e00151600097909650945050505050565b600080600080613a798787612c8e565b90925090506000826003811115613aa057634e487b7160e01b600052602160045260246000fd5b14613ab15750915060009050612d15565b612d0e8186612b66565b6000613ac561549a565b600080613ada86670de0b6b3a7640000614c13565b90925090506000826003811115613b0157634e487b7160e01b600052602160045260246000fd5b14613b20575060408051602081019091526000815290925090506125c6565b600080613b2d8388614c66565b90925090506000826003811115613b5457634e487b7160e01b600052602160045260246000fd5b14613b7757816040518060200160405280600081525095509550505050506125c6565b604080516020810190915290815260009890975095505050505050565b6000821580613ba1575081155b613bed5760405162461bcd60e51b815260206004820152601e60248201527f746f6b656e73496e206f7220616d6f756e74496e206d7573742062652030000060448201526064016107e5565b613c2e6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b613c36611ea6565b6040830181905260208301826003811115613c6157634e487b7160e01b600052602160045260246000fd5b6003811115613c8057634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613cab57634e487b7160e01b600052602160045260246000fd5b14613ce357613cdb6009602b8360200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b915050610929565b8315613dfd576001600160a01b0385166000908152600e60205260409020548410613d2b576001600160a01b0385166000908152600e60205260409020546060820152613d33565b606081018490525b613d5360405180602001604052808360400151815250826060015161256c565b6080830181905260208301826003811115613d7e57634e487b7160e01b600052602160045260246000fd5b6003811115613d9d57634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613dc857634e487b7160e01b600052602160045260246000fd5b14613df857613cdb600960298360200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b613f0b565b600019831415613e44576001600160a01b0385166000908152600e60209081526040918290205460608401908152825191820183529183015181529051613d53919061256c565b6080810183905260408051602081018252908201518152613e669084906153eb565b6060830181905260208301826003811115613e9157634e487b7160e01b600052602160045260246000fd5b6003811115613eb057634e487b7160e01b600052602160045260246000fd5b9052506000905081602001516003811115613edb57634e487b7160e01b600052602160045260246000fd5b14613f0b57613cdb6009602a8360200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b600554606082015160405163eabe7d9160e01b81526000926001600160a01b03169163eabe7d9191613f449130918b9190600401615a7d565b602060405180830381600087803b158015613f5e57600080fd5b505af1158015613f72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f969190615981565b90508015613fb457613fab6003602883612c05565b92505050610929565b4260095414613fc957613fab600a602c6126eb565b613fd9600d548360600151612b66565b60a084018190526020840182600381111561400457634e487b7160e01b600052602160045260246000fd5b600381111561402357634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561404e57634e487b7160e01b600052602160045260246000fd5b1461407e57613fab6009602e8460200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b6001600160a01b0386166000908152600e6020526040902054606083015111156140c1576001600160a01b0386166000908152600e602052604090205460608301525b6001600160a01b0386166000908152600e602052604090205460608301516140e99190612b66565b60c084018190526020840182600381111561411457634e487b7160e01b600052602160045260246000fd5b600381111561413357634e487b7160e01b600052602160045260246000fd5b905250600090508260200151600381111561415e57634e487b7160e01b600052602160045260246000fd5b1461418e57613fab6009602d8460200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b816080015161419b6125cd565b10156141ad57613fab600e602f6126eb565b60a0820151600d5560c08201516001600160a01b0387166000818152600e60205260409081902092909255606084015191513092600080516020615e1a833981519152916141fd91815260200190565b60405180910390a3608082015160608301516040517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a9299261423f928a92615a5c565b60405180910390a1600554608083015160608401516040516351dff98960e01b81526001600160a01b03909316926351dff989926142859230928c929190600401615aa1565b600060405180830381600087803b15801561429f57600080fd5b505af11580156142b3573d6000803e3d6000fd5b505050506142c5868360800151614604565b60009695505050505050565b60055460405163368f515360e21b815260009182916001600160a01b039091169063da3d454c9061430a90309088908890600401615a7d565b602060405180830381600087803b15801561432457600080fd5b505af1158015614338573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061435c9190615981565b90508015614379576143716003600e83612c05565b915050610776565b5042600954146143955761438e600a806126eb565b9050610776565b8161439e6125cd565b10156143b05761438e600e60096126eb565b6000806143bc85612a1e565b909250905060008260038111156143e357634e487b7160e01b600052602160045260246000fd5b146144185761440f6009600784600381111561130d57634e487b7160e01b600052602160045260246000fd5b92505050610776565b60006144248286612c8e565b9093509050600083600381111561444b57634e487b7160e01b600052602160045260246000fd5b14614481576144776009600c85600381111561130d57634e487b7160e01b600052602160045260246000fd5b9350505050610776565b600061448f600b5487612c8e565b909450905060008460038111156144b657634e487b7160e01b600052602160045260246000fd5b146144ed576144e26009600b86600381111561130d57634e487b7160e01b600052602160045260246000fd5b945050505050610776565b6001600160a01b038716600081815260106020908152604091829020858155600a54600190910155600b849055815192835282018890528101839052606081018290527f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809060800160405180910390a16145678787614604565b60005b979650505050505050565b805160009061077690670de0b6b3a764000090615ce4565b600080808042600954146145b1576145a7600a604f6126eb565b9590945092505050565b6145bb33866151a4565b905080600c546145cb9190615ccc565b915081600c81905550600080516020615dba8339815191523382846040516145f593929190615a5c565b60405180910390a160006145a7565b60125460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490526201000090920490911690819063a9059cbb90604401600060405180830381600087803b15801561465b57600080fd5b505af115801561466f573d6000803e3d6000fd5b5050505060003d6000811461468b576020811461469557600080fd5b60001991506146a1565b60206000803e60005191505b5080611b525760405162461bcd60e51b81526020600482015260196024820152781513d2d15397d514905394d1915497d3d55517d19052531151603a1b60448201526064016107e5565b600554604051632fe3f38f60e11b81526000918291829182916001600160a01b0390911690635fc7e71e9061472c90309089908d908d908d90600401615aca565b6040805180830381600087803b15801561474557600080fd5b505af1158015614759573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061477d91906159e2565b91509150816000146147a3576147966003601284612c05565b6000935093505050614c0a565b42600954146147b857614796600a60166126eb565b42856001600160a01b031663cfa992016040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156147f457600080fd5b505af1158015614808573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061482c9190615981565b1461483d57614796600a60116126eb565b876001600160a01b0316876001600160a01b0316141561486357614796600660176126eb565b8561487457614796600760156126eb565b60001986141561488a57614796600760146126eb565b6000806148988a8a8a613603565b909250905081156148dc576148cd8260108111156148c657634e487b7160e01b600052602160045260246000fd5b60186126eb565b60009550955050505050614c0a565b600554604051639e9b187760e01b815260009182916001600160a01b0390911690639e9b1877906149179030908d9088908b90600401615aa1565b604080518083038186803b15801561492e57600080fd5b505afa158015614942573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061496691906159e2565b909250905081156149d55760405162461bcd60e51b815260206004820152603360248201527f4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f604482015272105353d5539517d4d152569157d19052531151606a1b60648201526084016107e5565b6040516370a0823160e01b815281906001600160a01b038b16906370a0823190614a03908f90600401615a2e565b60206040518083038186803b158015614a1b57600080fd5b505afa158015614a2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a539190615981565b1015614a9c5760405162461bcd60e51b815260206004820152601860248201527709892a2aa928882a88abea68a92b48abea89e9ebe9aaa86960431b60448201526064016107e5565b60006001600160a01b038a16301415614ac357614abc308e8e858a612d1d565b9050614b4a565b896001600160a01b031663d2c6d0dc8e8e858a6040518563ffffffff1660e01b8152600401614af59493929190615aa1565b602060405180830381600087803b158015614b0f57600080fd5b505af1158015614b23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b479190615981565b90505b8015614b8f5760405162461bcd60e51b81526020600482015260146024820152731d1bdad95b881cd95a5e9d5c994819985a5b195960621b60448201526064016107e5565b7f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb528d8d868d86604051614bf49594939291906001600160a01b039586168152938516602085015260408401929092529092166060820152608081019190915260a00190565b60405180910390a1600098509296505050505050505b94509492505050565b60008083614c26575060009050806125c6565b83830283858281614c4757634e487b7160e01b600052601260045260246000fd5b0414614c5b576002600092509250506125c6565b6000925090506125c6565b60008082614c7a57506001905060006125c6565b6000838581614c9957634e487b7160e01b600052601260045260246000fd5b04915091509250929050565b600554604051634ef4c3e160e01b8152600091829182916001600160a01b031690634ef4c3e190614cde90309089908990600401615a7d565b602060405180830381600087803b158015614cf857600080fd5b505af1158015614d0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d309190615981565b90508015614d5157614d456003601f83612c05565b600092509250506125c6565b504260095414614d7257614d67600a60226126eb565b6000915091506125c6565b60408051808201909152600080825260208201526000614d90611ea6565b83602001819350826003811115614db757634e487b7160e01b600052602160045260246000fd5b6003811115614dd657634e487b7160e01b600052602160045260246000fd5b9052506000905082602001516003811115614e0157634e487b7160e01b600052602160045260246000fd5b14614e3e57614e31600960218460200151600381111561130d57634e487b7160e01b600052602160045260246000fd5b60009350935050506125c6565b6000614e4a87876151a4565b90506000614e66826040518060200160405280868152506153eb565b85602001819350826003811115614e8d57634e487b7160e01b600052602160045260246000fd5b6003811115614eac57634e487b7160e01b600052602160045260246000fd5b9052506000905084602001516003811115614ed757634e487b7160e01b600052602160045260246000fd5b14614f245760405162461bcd60e51b815260206004820181905260248201527f4d494e545f45584348414e47455f43414c43554c4154494f4e5f4641494c454460448201526064016107e5565b6000614f32600d5483612c8e565b86602001819350826003811115614f5957634e487b7160e01b600052602160045260246000fd5b6003811115614f7857634e487b7160e01b600052602160045260246000fd5b9052506000905085602001516003811115614fa357634e487b7160e01b600052602160045260246000fd5b14614fef5760405162461bcd60e51b815260206004820152601c60248201527b1352539517d39155d7d513d5105317d4d55414131657d1905253115160221b60448201526064016107e5565b6001600160a01b0389166000908152600e60205260408120546150129084612c8e565b8760200181935082600381111561503957634e487b7160e01b600052602160045260246000fd5b600381111561505857634e487b7160e01b600052602160045260246000fd5b905250600090508660200151600381111561508357634e487b7160e01b600052602160045260246000fd5b146150d05760405162461bcd60e51b815260206004820152601f60248201527f4d494e545f4e45575f4143434f554e545f42414c414e43455f4641494c45440060448201526064016107e5565b600d8290556001600160a01b038a166000908152600e602052604090819020829055517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f90615124908c9087908790615a5c565b60405180910390a16040518381526001600160a01b038b1690600090600080516020615e1a8339815191529060200160405180910390a360009a93995092975050505050505050565b8051600090670de0b6b3a7640000906151869085615d04565b6109299190615ce4565b600061092961519f84846153fb565b614575565b6012546040516370a0823160e01b81526000916201000090046001600160a01b031690829082906370a08231906151df903090600401615a2e565b60206040518083038186803b1580156151f757600080fd5b505afa15801561520b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061522f9190615981565b6040516323b872dd60e01b81529091506001600160a01b038316906323b872dd9061526290889030908990600401615a7d565b600060405180830381600087803b15801561527c57600080fd5b505af1158015615290573d6000803e3d6000fd5b5050505060003d600081146152ac57602081146152b657600080fd5b60001991506152c2565b60206000803e60005191505b508061530b5760405162461bcd60e51b81526020600482015260186024820152771513d2d15397d514905394d1915497d25397d1905253115160421b60448201526064016107e5565b6012546040516370a0823160e01b81526000916201000090046001600160a01b0316906370a0823190615342903090600401615a2e565b60206040518083038186803b15801561535a57600080fd5b505afa15801561536e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906153929190615981565b9050828110156153e15760405162461bcd60e51b815260206004820152601a602482015279544f4b454e5f5452414e534645525f494e5f4f564552464c4f5760301b60448201526064016107e5565b61456a8382615d23565b60008060008061257c8686615427565b61540361549a565b604051806020016040528083856000015161541e9190615d04565b90529392505050565b600061543161549a565b600080615446670de0b6b3a764000087614c13565b9092509050600082600381111561546d57634e487b7160e01b600052602160045260246000fd5b1461548c575060408051602081019091526000815290925090506125c6565b6125bf818660000151613abb565b6040518060200160405280600081525090565b8280546154b990615d3a565b90600052602060002090601f0160209004810192826154db5760008555615521565b82601f106154f457805160ff1916838001178555615521565b82800160010185558215615521579182015b82811115615521578251825591602001919060010190615506565b5061552d929150615531565b5090565b5b8082111561552d5760008155600101615532565b803561555181615da1565b919050565b60008083601f840112615567578081fd5b5081356001600160401b0381111561557d578182fd5b6020830191508360208260051b85010111156125c657600080fd5b600082601f8301126155a8578081fd5b81356001600160401b03808211156155c2576155c2615d8b565b604051601f8301601f19908116603f011681019082821181831017156155ea576155ea615d8b565b81604052838152866020858801011115615602578485fd5b8360208701602083013792830160200193909352509392505050565b60006020828403121561562f578081fd5b813561092981615da1565b6000806040838503121561564c578081fd5b823561565781615da1565b9150602083013561566781615da1565b809150509250929050565b600080600060608486031215615686578081fd5b833561569181615da1565b925060208401356156a181615da1565b929592945050506040919091013590565b6000806000806000608086880312156156c9578081fd5b85356156d481615da1565b945060208601356156e481615da1565b93506040860135925060608601356001600160401b03811115615705578182fd5b61571188828901615556565b969995985093965092949392505050565b60008060008060808587031215615737578384fd5b843561574281615da1565b9350602085013561575281615da1565b93969395505050506040820135916060013590565b600080600080600080600080610100898b031215615783578283fd5b883561578e81615da1565b9750602089013561579e81615da1565b965060408901356157ae81615da1565b95506060890135945060808901356001600160401b03808211156157d0578485fd5b6157dc8c838d01615598565b955060a08b01359150808211156157f1578485fd5b506157fe8b828c01615598565b93505060c089013560ff81168114615814578283fd5b915061582260e08a01615546565b90509295985092959890939650565b60008060408385031215615843578182fd5b823561584e81615da1565b946020939093013593505050565b60008060008060608587031215615871578384fd5b843561587c81615da1565b93506020850135925060408501356001600160401b0381111561589d578283fd5b6158a987828801615556565b95989497509550505050565b6000806000606084860312156158c9578081fd5b83356158d481615da1565b92506020840135915060408401356158eb81615da1565b809150509250925092565b60008060008060006080868803121561590d578283fd5b853561591881615da1565b945060208601359350604086013561592f81615da1565b925060608601356001600160401b03811115615705578182fd5b60006020828403121561595a578081fd5b81518015158114610929578182fd5b60006020828403121561597a578081fd5b5035919050565b600060208284031215615992578081fd5b5051919050565b6000806000604084860312156159ad578081fd5b8335925060208401356001600160401b038111156159c9578182fd5b6159d586828701615556565b9497909650939450505050565b600080604083850312156159f4578182fd5b505080516020909101519092909150565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b6001600160a01b039586168152938516602085015291841660408401529092166060820152608081019190915260a00190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b60208082528181018390526000906040600585901b8401810190840186845b87811015615bb157868403603f190183528135368a9003601e19018112615b6b578687fd5b890180356001600160401b03811115615b82578788fd5b8036038b1315615b90578788fd5b615b9d8682898501615a05565b955050509184019190840190600101615b46565b5091979650505050505050565b6000602080835283518082850152825b81811015615bea57858101830151858201604001528201615bce565b81811115615bfb5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252601690820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604082015260600190565b6020808252601c908201527b6d61726b6572206d6574686f642072657475726e65642066616c736560201b604082015260600190565b6020808252600a90820152691c994b595b9d195c995960b21b604082015260600190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b60008219821115615cdf57615cdf615d75565b500190565b600082615cff57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615615d1e57615d1e615d75565b500290565b600082821015615d3557615d35615d75565b500390565b600181811c90821680615d4e57607f821691505b60208210811415615d6f57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114615db657600080fd5b5056fea91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc545b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0ca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa264697066735822122033ddbfeb5634ccdc906195953977f2b388e3fe6278e1418c64300ad4f0c9bab664736f6c63430008040033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 35 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.