ETH Price: $3,035.07 (-6.79%)

Contract

0x62316768ef954734445AAB3273Fd6077005FfABf
 

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
0x608060401055241362023-06-13 9:04:09305 days ago1686647049IN
 Create: RewardsDistributor
0 ETH0.000000130.00006867

Latest 25 internal transactions (View All)

Advanced mode:
Parent Txn Hash Block From To Value
1075578842023-07-30 10:55:45258 days ago1690714545
0x62316768...7005FfABf
0 ETH
1075578572023-07-30 10:54:51258 days ago1690714491
0x62316768...7005FfABf
0 ETH
1075578572023-07-30 10:54:51258 days ago1690714491
0x62316768...7005FfABf
0 ETH
1075578152023-07-30 10:53:27258 days ago1690714407
0x62316768...7005FfABf
0 ETH
1075577942023-07-30 10:52:45258 days ago1690714365
0x62316768...7005FfABf
0 ETH
1075574512023-07-30 10:41:19258 days ago1690713679
0x62316768...7005FfABf
0 ETH
1075555112023-07-30 9:36:39258 days ago1690709799
0x62316768...7005FfABf
0 ETH
1075531582023-07-30 8:18:13258 days ago1690705093
0x62316768...7005FfABf
0 ETH
1075528332023-07-30 8:07:23258 days ago1690704443
0x62316768...7005FfABf
0 ETH
1075519602023-07-30 7:38:17258 days ago1690702697
0x62316768...7005FfABf
0 ETH
1075510662023-07-30 7:08:29258 days ago1690700909
0x62316768...7005FfABf
0 ETH
1075449812023-07-30 3:45:39259 days ago1690688739
0x62316768...7005FfABf
0 ETH
1075449442023-07-30 3:44:25259 days ago1690688665
0x62316768...7005FfABf
0 ETH
1075432262023-07-30 2:47:09259 days ago1690685229
0x62316768...7005FfABf
0 ETH
1075432082023-07-30 2:46:33259 days ago1690685193
0x62316768...7005FfABf
0 ETH
1075431862023-07-30 2:45:49259 days ago1690685149
0x62316768...7005FfABf
0 ETH
1075431302023-07-30 2:43:57259 days ago1690685037
0x62316768...7005FfABf
0 ETH
1075360262023-07-29 22:47:09259 days ago1690670829
0x62316768...7005FfABf
0 ETH
1075297832023-07-29 19:19:03259 days ago1690658343
0x62316768...7005FfABf
0 ETH
1075297522023-07-29 19:18:01259 days ago1690658281
0x62316768...7005FfABf
0 ETH
1075296832023-07-29 19:15:43259 days ago1690658143
0x62316768...7005FfABf
0 ETH
1075296832023-07-29 19:15:43259 days ago1690658143
0x62316768...7005FfABf
0 ETH
1075296652023-07-29 19:15:07259 days ago1690658107
0x62316768...7005FfABf
0 ETH
1075296102023-07-29 19:13:17259 days ago1690657997
0x62316768...7005FfABf
0 ETH
1075292442023-07-29 19:01:05259 days ago1690657265
0x62316768...7005FfABf
0 ETH
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RewardsDistributor

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 26 : RewardsDistributor.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./dependencies/openzeppelin/utils/math/SafeCast.sol";
import "./dependencies/openzeppelin/token/ERC20/utils/SafeERC20.sol";
import "./dependencies/openzeppelin/security/ReentrancyGuard.sol";
import "./interfaces/IDebtToken.sol";
import "./interfaces/IDepositToken.sol";
import "./access/Manageable.sol";
import "./storage/RewardsDistributorStorage.sol";
import "./lib/WadRayMath.sol";
import "./interfaces/external/IVPool.sol";
import "./interfaces/external/IPoolRewards.sol";

/// @notice Updated to IPoolRewards will trigger treasury upgrade and we want to avoid it.
/// Hence defining new interface here.
interface IPoolRewardsExt is IPoolRewards {
    function rewardRates(address rewardToken_) external returns (uint256);
}

error AddressIsNull();
error NotTokenSpeedKeeper();

error DistributorDoesNotExist();
error InvalidToken();
error RewardTokenIsNull();
error ReachedMaxRewardTokens();
error ArraysLengthDoNotMatch();

/**
 * @title RewardsDistributor contract
 */
contract RewardsDistributor is ReentrancyGuard, Manageable, RewardsDistributorStorageV2 {
    using SafeERC20 for IERC20;
    using SafeCast for uint256;
    using WadRayMath for uint256;

    string public constant VERSION = "1.2.0";

    /// @notice The initial index
    uint224 public constant INITIAL_INDEX = 1e18;

    /// @notice Max reward tokens to avoid DoS scenario
    uint224 public constant MAX_REWARD_TOKENS = 20;

    /// @notice Emitted when reward is claimed
    event RewardClaimed(address indexed account, uint256 amount);

    /// @notice Emitted when updating accrued token
    event TokensAccruedUpdated(IERC20 indexed token, address indexed account, uint256 tokensDelta, uint256 supplyIndex);

    /// @notice Emitted when updating token speed
    event TokenSpeedUpdated(IERC20 indexed token, uint256 oldSpeed, uint256 newSpeed);

    /// @notice Emitted when updating token index
    event TokenIndexUpdated(uint224 newIndex, uint32 newTimestamp);

    /**
     * @dev Throws if this contract isn't registered on pool
     */
    modifier onlyIfDistributorExists() {
        bool _distributorAdded = false;
        address[] memory _rewardsDistributors = pool.getRewardsDistributors();
        uint256 _length = _rewardsDistributors.length;
        for (uint256 i; i < _length; ++i) {
            if (_rewardsDistributors[i] == address(this)) {
                _distributorAdded = true;
                break;
            }
        }
        if (!_distributorAdded) revert DistributorDoesNotExist();
        _;
    }

    /**
     * @dev Throws if token doesn't exist
     * @dev Should be a DepositToken (suppliers) or DebtToken (borrowers)
     */
    modifier onlyIfTokenExists(address token_) {
        IPool _pool = pool;
        if (!_pool.doesDebtTokenExist(IDebtToken(token_)) && !_pool.doesDepositTokenExist(IDepositToken(token_))) {
            revert InvalidToken();
        }
        _;
    }

    function initialize(IPool pool_, IERC20 rewardToken_) external initializer {
        if (address(rewardToken_) == address(0)) revert RewardTokenIsNull();

        __ReentrancyGuard_init();
        __Manageable_init(pool_);

        rewardToken = rewardToken_;
    }

    /**
     * @notice Returns claimable amount consider all tokens
     */
    function claimable(address account_) external view override returns (uint256 _claimable) {
        _claimable = tokensAccruedOf[account_];
        for (uint256 i; i < tokens.length; ++i) {
            _claimable += _claimableRewards(account_, tokens[i]);
        }
    }

    /**
     * @notice Returns updated claimable amount for given token
     * @dev Removing this function will change interface and will result
     * updating other contracts using interface.
     */
    function claimable(address, IERC20) public view override returns (uint256) {
        revert("Unsupported");
    }

    /**
     * @notice Claim tokens accrued by account in all tokens
     */
    function claimRewards(address account_) external override {
        claimRewards(account_, tokens);
    }

    /**
     * @notice Claim tokens accrued by account in the specified tokens
     */
    function claimRewards(address account_, IERC20[] memory tokens_) public override {
        address[] memory _accounts = new address[](1);
        _accounts[0] = account_;
        claimRewards(_accounts, tokens_);
    }

    /**
     * @notice Claim tokens accrued by the accounts in the specified tokens
     */
    function claimRewards(address[] memory accounts_, IERC20[] memory tokens_) public override nonReentrant {
        uint256 _accountsLength = accounts_.length;
        uint256 _tokensLength = tokens_.length;
        for (uint256 i; i < _tokensLength; ++i) {
            IERC20 _token = tokens_[i];

            if (tokenStates[_token].index > 0) {
                _updateTokenIndex(_token);
                for (uint256 j; j < _accountsLength; j++) {
                    _updateTokensAccruedOf(_token, accounts_[j]);
                }
            }
        }

        for (uint256 j; j < _accountsLength; j++) {
            address _account = accounts_[j];
            _transferRewardIfEnoughTokens(_account, tokensAccruedOf[_account]);
        }
    }

    /**
     * @notice Update indexes on pre-mint and pre-burn
     * @dev Called by DepositToken and DebtToken contracts
     * This function also may be called by anyone to update stored indexes
     */
    function updateBeforeMintOrBurn(IERC20 token_, address account_) external override {
        if (tokenStates[token_].index > 0) {
            _updateTokenIndex(token_);
            _updateTokensAccruedOf(token_, account_);
        }
    }

    /**
     * @notice Update indexes on pre-transfer
     * @dev Called by DepositToken and DebtToken contracts
     */
    function updateBeforeTransfer(IERC20 token_, address from_, address to_) external override {
        if (tokenStates[token_].index > 0) {
            _updateTokenIndex(token_);
            _updateTokensAccruedOf(token_, from_);
            _updateTokensAccruedOf(token_, to_);
        }
    }

    /**
     * @notice Calculate updated token index values
     */
    function _calculateTokenIndex(
        TokenState memory _supplyState,
        IERC20 token_
    ) private view returns (uint224 _newIndex, uint32 _newTimestamp) {
        uint256 _speed = tokenSpeeds[token_];
        uint256 _deltaTimestamps = block.timestamp - uint256(_supplyState.timestamp);
        if (_deltaTimestamps > 0 && _speed > 0) {
            uint256 _totalSupply = token_.totalSupply();
            uint256 _tokensAccrued = _deltaTimestamps * _speed;
            uint256 _ratio = _totalSupply > 0 ? _tokensAccrued.wadDiv(_totalSupply) : 0;
            _newIndex = (_supplyState.index + _ratio).toUint224();
            _newTimestamp = block.timestamp.toUint32();
        } else if (_deltaTimestamps > 0 && _supplyState.index > 0) {
            _newTimestamp = block.timestamp.toUint32();
        }
    }

    /**
     * @notice Calculate updated account index and claimable values
     */
    function _calculateTokenDelta(
        TokenState memory _tokenState,
        IERC20 token_,
        address account_
    ) private view returns (uint256 _tokenIndex, uint256 _tokensDelta) {
        _tokenIndex = _tokenState.index;
        uint256 _accountIndex = accountIndexOf[token_][account_];

        if (_accountIndex == 0 && _tokenIndex > INITIAL_INDEX) {
            _accountIndex = INITIAL_INDEX;
        }

        uint256 _deltaIndex = _tokenIndex - _accountIndex;
        _tokensDelta = token_.balanceOf(account_).wadMul(_deltaIndex);
    }

    function _claimableRewards(address account_, IERC20 token_) internal view returns (uint256 _claimableDelta) {
        TokenState memory _tokenState = tokenStates[token_];
        (uint224 _newIndex, uint32 _newTimestamp) = _calculateTokenIndex(_tokenState, token_);
        if (_newIndex > 0 && _newTimestamp > 0) {
            _tokenState = TokenState({index: _newIndex, timestamp: _newTimestamp});
        } else if (_newTimestamp > 0) {
            _tokenState.timestamp = _newTimestamp;
        }
        (, _claimableDelta) = _calculateTokenDelta(_tokenState, token_, account_);
    }

    /**
     * @notice Transfer tokens to the user
     * @dev If there is not enough tokens, we do not perform the transfer
     */
    function _transferRewardIfEnoughTokens(address account_, uint256 amount_) private {
        IERC20 _rewardToken = rewardToken;
        uint256 _balance = _rewardToken.balanceOf(address(this));
        if (amount_ > 0 && amount_ <= _balance) {
            tokensAccruedOf[account_] = 0;
            _rewardToken.safeTransfer(account_, amount_);
            emit RewardClaimed(account_, amount_);
        }
    }

    /**
     * @notice Calculate tokens accrued by an account
     */
    function _updateTokensAccruedOf(IERC20 token_, address account_) private {
        (uint256 _tokenIndex, uint256 _tokensDelta) = _calculateTokenDelta(tokenStates[token_], token_, account_);
        accountIndexOf[token_][account_] = _tokenIndex;
        tokensAccruedOf[account_] = tokensAccruedOf[account_] + _tokensDelta;
        emit TokensAccruedUpdated(token_, account_, _tokensDelta, _tokenIndex);
    }

    /**
     * @notice Accrue reward token by updating the index
     */
    function _updateTokenIndex(IERC20 token_) private {
        TokenState storage _supplyState = tokenStates[token_];
        (uint224 _newIndex, uint32 _newTimestamp) = _calculateTokenIndex(_supplyState, token_);
        if (_newIndex > 0 && _newTimestamp > 0) {
            _supplyState.index = _newIndex;
            _supplyState.timestamp = _newTimestamp;
            emit TokenIndexUpdated(_newIndex, _newTimestamp);
        } else if (_newTimestamp > 0) {
            _supplyState.timestamp = _newTimestamp;
            emit TokenIndexUpdated(_supplyState.index, _newTimestamp);
        }
    }

    /**
     * @notice Update the speed for token
     */
    function _updateTokenSpeed(
        IERC20 token_,
        uint256 newSpeed_
    ) private onlyIfDistributorExists onlyIfTokenExists(address(token_)) {
        uint256 _currentSpeed = tokenSpeeds[token_];
        if (_currentSpeed > 0) {
            _updateTokenIndex(token_);
        } else if (newSpeed_ > 0) {
            // Add token to the list
            if (tokenStates[token_].index == 0) {
                if (tokens.length == MAX_REWARD_TOKENS) revert ReachedMaxRewardTokens();
                tokenStates[token_] = TokenState({index: INITIAL_INDEX, timestamp: block.timestamp.toUint32()});
                tokens.push(token_);
            } else {
                // Update timestamp to ensure extra interest is not accrued during the prior period
                tokenStates[token_].timestamp = block.timestamp.toUint32();
            }
        }

        if (_currentSpeed != newSpeed_) {
            tokenSpeeds[token_] = newSpeed_;
            emit TokenSpeedUpdated(token_, _currentSpeed, newSpeed_);
        }
    }

    /**
     * @notice Update speed for a single deposit token
     */
    function updateTokenSpeed(IERC20 token_, uint256 newSpeed_) external override onlyGovernor {
        _updateTokenSpeed(token_, newSpeed_);
    }

    /**
     * @notice Update token speeds
     */
    function updateTokenSpeeds(IERC20[] calldata tokens_, uint256[] calldata speeds_) external override onlyGovernor {
        uint256 _tokensLength = tokens_.length;
        if (_tokensLength != speeds_.length) revert ArraysLengthDoNotMatch();

        for (uint256 i; i < _tokensLength; ++i) {
            _updateTokenSpeed(tokens_[i], speeds_[i]);
        }
    }

    //********************************  TokenSpeed and RewardRate sync fix ***********************************/
    /// @notice This is temporary fix to keep tokenSpeed and rewardRate from Vesper in sync.
    function syncTokenSpeed(IDepositToken depositToken_) external {
        if (msg.sender != tokenSpeedKeeper) revert NotTokenSpeedKeeper();

        IVPool _vPool = IVPool(address(depositToken_.underlying()));
        IPoolRewardsExt _rewards = IPoolRewardsExt(_vPool.poolRewards());
        uint256 _speed = (_rewards.rewardRates(address(rewardToken)) * _vPool.balanceOf(address(pool.treasury()))) /
            _vPool.totalSupply();
        _updateTokenSpeed(IERC20(address(depositToken_)), _speed);
    }

    /// @notice This function is part of temporary fix to keep tokenSpeed and rewardRate in sync.
    function updateTokenSpeedKeeper(address keeper_) external onlyGovernor {
        if (keeper_ == address(0)) revert AddressIsNull();
        tokenSpeedKeeper = keeper_;
    }
}

File 2 of 26 : Manageable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/openzeppelin/proxy/utils/Initializable.sol";
import "../interfaces/IGovernable.sol";
import "../interfaces/IManageable.sol";

error SenderIsNotPool();
error SenderIsNotGovernor();
error IsPaused();
error IsShutdown();
error PoolAddressIsNull();

/**
 * @title Reusable contract that handles accesses
 */
abstract contract Manageable is IManageable, Initializable {
    /**
     * @notice Pool contract
     */
    IPool public pool;

    /**
     * @dev Throws if `msg.sender` isn't the pool
     */
    modifier onlyPool() {
        if (msg.sender != address(pool)) revert SenderIsNotPool();
        _;
    }

    /**
     * @dev Throws if `msg.sender` isn't the governor
     */
    modifier onlyGovernor() {
        if (msg.sender != governor()) revert SenderIsNotGovernor();
        _;
    }

    /**
     * @dev Throws if contract is paused
     */
    modifier whenNotPaused() {
        if (pool.paused()) revert IsPaused();
        _;
    }

    /**
     * @dev Throws if contract is shutdown
     */
    modifier whenNotShutdown() {
        if (pool.everythingStopped()) revert IsShutdown();
        _;
    }

    // solhint-disable-next-line func-name-mixedcase
    function __Manageable_init(IPool pool_) internal initializer {
        if (address(pool_) == address(0)) revert PoolAddressIsNull();
        pool = pool_;
    }

    /**
     * @notice Get the governor
     * @return _governor The governor
     */
    function governor() public view returns (address _governor) {
        _governor = IGovernable(address(pool)).governor();
    }

    uint256[49] private __gap;
}

File 3 of 26 : Initializable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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 a proxied contract can't have 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.
 */
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() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 4 of 26 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    function __ReentrancyGuard_init() internal initializer {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 5 of 26 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 6 of 26 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 7 of 26 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 8 of 26 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (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);
            }
        }
    }
}

File 9 of 26 : SafeCast.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {
    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128) {
        require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits");
        return int128(value);
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64) {
        require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits");
        return int64(value);
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32) {
        require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits");
        return int32(value);
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16) {
        require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits");
        return int16(value);
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8) {
        require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits");
        return int8(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

File 10 of 26 : IDebtToken.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/openzeppelin/token/ERC20/extensions/IERC20Metadata.sol";
import "./ISyntheticToken.sol";

interface IDebtToken is IERC20Metadata {
    function lastTimestampAccrued() external view returns (uint256);

    function isActive() external view returns (bool);

    function syntheticToken() external view returns (ISyntheticToken);

    function accrueInterest() external;

    function debtIndex() external returns (uint256 debtIndex_);

    function burn(address from_, uint256 amount_) external;

    function issue(uint256 amount_, address to_) external returns (uint256 _issued, uint256 _fee);

    function flashIssue(address borrower_, uint256 amount_) external returns (uint256 _issued, uint256 _fee);

    function repay(address onBehalfOf_, uint256 amount_) external returns (uint256 _repaid, uint256 _fee);

    function repayAll(address onBehalfOf_) external returns (uint256 _repaid, uint256 _fee);

    function quoteIssueIn(uint256 amountToIssue_) external view returns (uint256 _amount, uint256 _fee);

    function quoteIssueOut(uint256 amount_) external view returns (uint256 _amountToIssue, uint256 _fee);

    function quoteRepayIn(uint256 amountToRepay_) external view returns (uint256 _amount, uint256 _fee);

    function quoteRepayOut(uint256 amount_) external view returns (uint256 _amountToRepay, uint256 _fee);

    function updateMaxTotalSupply(uint256 newMaxTotalSupply_) external;

    function updateInterestRate(uint256 newInterestRate_) external;

    function maxTotalSupply() external view returns (uint256);

    function interestRate() external view returns (uint256);

    function interestRatePerSecond() external view returns (uint256);

    function toggleIsActive() external;
}

File 11 of 26 : IDepositToken.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/openzeppelin/token/ERC20/extensions/IERC20Metadata.sol";

interface IDepositToken is IERC20Metadata {
    function underlying() external view returns (IERC20);

    function collateralFactor() external view returns (uint256);

    function unlockedBalanceOf(address account_) external view returns (uint256);

    function lockedBalanceOf(address account_) external view returns (uint256);

    function flashWithdraw(address account_, uint256 amount_) external returns (uint256 _withdrawn, uint256 _fee);

    function deposit(uint256 amount_, address onBehalfOf_) external returns (uint256 _deposited, uint256 _fee);

    function quoteDepositIn(uint256 amountToDeposit_) external view returns (uint256 _amount, uint256 _fee);

    function quoteDepositOut(uint256 amount_) external view returns (uint256 _amountToDeposit, uint256 _fee);

    function quoteWithdrawIn(uint256 amountToWithdraw_) external view returns (uint256 _amount, uint256 _fee);

    function quoteWithdrawOut(uint256 amount_) external view returns (uint256 _amountToWithdraw, uint256 _fee);

    function withdraw(uint256 amount_, address to_) external returns (uint256 _withdrawn, uint256 _fee);

    function seize(address from_, address to_, uint256 amount_) external;

    function updateCollateralFactor(uint128 newCollateralFactor_) external;

    function isActive() external view returns (bool);

    function toggleIsActive() external;

    function maxTotalSupply() external view returns (uint256);

    function updateMaxTotalSupply(uint256 newMaxTotalSupply_) external;
}

File 12 of 26 : IFeeProvider.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @notice FeeProvider interface
 */
interface IFeeProvider {
    struct LiquidationFees {
        uint128 liquidatorIncentive;
        uint128 protocolFee;
    }

    function defaultSwapFee() external view returns (uint256);

    function depositFee() external view returns (uint256);

    function issueFee() external view returns (uint256);

    function liquidationFees() external view returns (uint128 liquidatorIncentive, uint128 protocolFee);

    function repayFee() external view returns (uint256);

    function swapFeeFor(address account_) external view returns (uint256);

    function withdrawFee() external view returns (uint256);
}

File 13 of 26 : IGovernable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @notice Governable interface
 */
interface IGovernable {
    function governor() external view returns (address _governor);

    function transferGovernorship(address _proposedGovernor) external;
}

File 14 of 26 : IManageable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./IPool.sol";

/**
 * @notice Manageable interface
 */
interface IManageable {
    function pool() external view returns (IPool _pool);
}

File 15 of 26 : IPauseable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

interface IPauseable {
    function paused() external view returns (bool);

    function everythingStopped() external view returns (bool);
}

File 16 of 26 : IPool.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./IDepositToken.sol";
import "./IDebtToken.sol";
import "./ITreasury.sol";
import "./IRewardsDistributor.sol";
import "./IPoolRegistry.sol";
import "./IFeeProvider.sol";
import "./external/ISwapper.sol";
import "../interfaces/IFeeProvider.sol";

/**
 * @notice Pool interface
 */
interface IPool is IPauseable, IGovernable {
    function debtFloorInUsd() external view returns (uint256);

    function feeCollector() external view returns (address);

    function swapper() external view returns (ISwapper);

    function feeProvider() external view returns (IFeeProvider);

    function maxLiquidable() external view returns (uint256);

    function flashRepay(
        ISyntheticToken syntheticToken_,
        IDepositToken depositToken_,
        uint256 withdrawAmount_,
        uint256 repayAmountMin_
    ) external returns (uint256 _withdrawn, uint256 _repaid);

    function doesSyntheticTokenExist(ISyntheticToken syntheticToken_) external view returns (bool);

    function doesDebtTokenExist(IDebtToken debtToken_) external view returns (bool);

    function doesDepositTokenExist(IDepositToken depositToken_) external view returns (bool);

    function depositTokenOf(IERC20 underlying_) external view returns (IDepositToken);

    function debtTokenOf(ISyntheticToken syntheticToken_) external view returns (IDebtToken);

    function getDepositTokens() external view returns (address[] memory);

    function getDebtTokens() external view returns (address[] memory);

    function getRewardsDistributors() external view returns (address[] memory);

    function debtOf(address account_) external view returns (uint256 _debtInUsd);

    function depositOf(address account_) external view returns (uint256 _depositInUsd, uint256 _issuableLimitInUsd);

    function debtPositionOf(
        address account_
    )
        external
        view
        returns (
            bool _isHealthy,
            uint256 _depositInUsd,
            uint256 _debtInUsd,
            uint256 _issuableLimitInUsd,
            uint256 _issuableInUsd
        );

    function leverage(
        IERC20 tokenIn_,
        IDepositToken depositToken_,
        ISyntheticToken syntheticToken_,
        uint256 amountIn_,
        uint256 leverage_,
        uint256 depositAmountMin_
    ) external returns (uint256 _deposited, uint256 _issued);

    function liquidate(
        ISyntheticToken syntheticToken_,
        address account_,
        uint256 amountToRepay_,
        IDepositToken depositToken_
    ) external returns (uint256 _totalSeized, uint256 _toLiquidator, uint256 _fee);

    function quoteLiquidateIn(
        ISyntheticToken syntheticToken_,
        uint256 totalToSeized_,
        IDepositToken depositToken_
    ) external view returns (uint256 _amountToRepay, uint256 _toLiquidator, uint256 _fee);

    function quoteLiquidateMax(
        ISyntheticToken syntheticToken_,
        address account_,
        IDepositToken depositToken_
    ) external view returns (uint256 _maxAmountToRepay);

    function quoteLiquidateOut(
        ISyntheticToken syntheticToken_,
        uint256 amountToRepay_,
        IDepositToken depositToken_
    ) external view returns (uint256 _totalSeized, uint256 _toLiquidator, uint256 _fee);

    function quoteSwapIn(
        ISyntheticToken syntheticTokenIn_,
        ISyntheticToken syntheticTokenOut_,
        uint256 amountOut_
    ) external view returns (uint256 _amountIn, uint256 _fee);

    function quoteSwapOut(
        ISyntheticToken syntheticTokenIn_,
        ISyntheticToken syntheticTokenOut_,
        uint256 amountIn_
    ) external view returns (uint256 _amountOut, uint256 _fee);

    function swap(
        ISyntheticToken syntheticTokenIn_,
        ISyntheticToken syntheticTokenOut_,
        uint256 amountIn_
    ) external returns (uint256 _amountOut, uint256 _fee);

    function treasury() external view returns (ITreasury);

    function masterOracle() external view returns (IMasterOracle);

    function poolRegistry() external view returns (IPoolRegistry);

    function addToDepositTokensOfAccount(address account_) external;

    function removeFromDepositTokensOfAccount(address account_) external;

    function addToDebtTokensOfAccount(address account_) external;

    function removeFromDebtTokensOfAccount(address account_) external;

    function getDepositTokensOfAccount(address account_) external view returns (address[] memory);

    function getDebtTokensOfAccount(address account_) external view returns (address[] memory);

    function isSwapActive() external view returns (bool);
}

File 17 of 26 : IPoolRegistry.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./external/IMasterOracle.sol";
import "./IPauseable.sol";
import "./IGovernable.sol";
import "./ISyntheticToken.sol";

interface IPoolRegistry is IPauseable, IGovernable {
    function isPoolRegistered(address pool_) external view returns (bool);

    function feeCollector() external view returns (address);

    function nativeTokenGateway() external view returns (address);

    function getPools() external view returns (address[] memory);

    function registerPool(address pool_) external;

    function unregisterPool(address pool_) external;

    function masterOracle() external view returns (IMasterOracle);

    function updateMasterOracle(IMasterOracle newOracle_) external;

    function updateFeeCollector(address newFeeCollector_) external;

    function updateNativeTokenGateway(address newGateway_) external;

    function idOfPool(address pool_) external view returns (uint256);

    function nextPoolId() external view returns (uint256);
}

File 18 of 26 : IRewardsDistributor.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/openzeppelin/token/ERC20/IERC20.sol";

/**
 * @notice Reward Distributor interface
 */
interface IRewardsDistributor {
    function rewardToken() external view returns (IERC20);

    function tokenSpeeds(IERC20 token_) external view returns (uint256);

    function tokensAccruedOf(address account_) external view returns (uint256);

    function updateBeforeMintOrBurn(IERC20 token_, address account_) external;

    function updateBeforeTransfer(IERC20 token_, address from_, address to_) external;

    function claimable(address account_) external view returns (uint256 _claimable);

    function claimable(address account_, IERC20 token_) external view returns (uint256 _claimable);

    function claimRewards(address account_) external;

    function claimRewards(address account_, IERC20[] memory tokens_) external;

    function claimRewards(address[] memory accounts_, IERC20[] memory tokens_) external;

    function updateTokenSpeed(IERC20 token_, uint256 newSpeed_) external;

    function updateTokenSpeeds(IERC20[] calldata tokens_, uint256[] calldata speeds_) external;

    function tokens(uint256) external view returns (IERC20);

    function tokenStates(IERC20) external view returns (uint224 index, uint32 timestamp);

    function accountIndexOf(IERC20, address) external view returns (uint256);
}

File 19 of 26 : ISyntheticToken.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../dependencies/openzeppelin/token/ERC20/extensions/IERC20Metadata.sol";
import "./IDebtToken.sol";
import "./IPoolRegistry.sol";

interface ISyntheticToken is IERC20Metadata {
    function isActive() external view returns (bool);

    function mint(address to_, uint256 amount_) external;

    function burn(address from_, uint256 amount) external;

    function poolRegistry() external returns (IPoolRegistry);

    function toggleIsActive() external;

    function seize(address from_, address to_, uint256 amount_) external;

    function updateMaxTotalSupply(uint256 newMaxTotalSupply_) external;

    function maxTotalSupply() external view returns (uint256);
}

File 20 of 26 : ITreasury.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

interface ITreasury {
    function pull(address to_, uint256 amount_) external;

    function migrateTo(address newTreasury_) external;
}

File 21 of 26 : IMasterOracle.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

interface IMasterOracle {
    function quoteTokenToUsd(address _asset, uint256 _amount) external view returns (uint256 _amountInUsd);

    function quoteUsdToToken(address _asset, uint256 _amountInUsd) external view returns (uint256 _amount);

    function quote(address _assetIn, address _assetOut, uint256 _amountIn) external view returns (uint256 _amountOut);
}

File 22 of 26 : IPoolRewards.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

interface IPoolRewards {
    function claimReward(address) external;

    function updateReward(address) external;

    function getRewardTokens() external view returns (address[] memory);
}

File 23 of 26 : ISwapper.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

interface ISwapper {
    function swapExactInput(
        address tokenIn_,
        address tokenOut_,
        uint256 amountIn_,
        uint256 amountOutMin_,
        address receiver_
    ) external returns (uint256 _amountOut);
}

File 24 of 26 : IVPool.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../../dependencies/openzeppelin/token/ERC20/IERC20.sol";

interface IVPool is IERC20 {
    function token() external view returns (address _token);

    function deposit(uint256 _amount) external;

    function withdraw(uint256 _shares) external;

    function poolRewards() external view returns (address);
}

File 25 of 26 : WadRayMath.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @title Math library
 * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)
 * @dev Based on https://github.com/dapphub/ds-math/blob/master/src/math.sol
 */
library WadRayMath {
    uint256 internal constant WAD = 1e18;
    uint256 internal constant HALF_WAD = WAD / 2;

    uint256 internal constant RAY = 1e27;
    uint256 internal constant HALF_RAY = RAY / 2;

    uint256 internal constant WAD_RAY_RATIO = 1e9;

    /**
     * @dev Multiplies two wad, rounding half up to the nearest wad
     * @param a Wad
     * @param b Wad
     * @return The result of a*b, in wad
     */
    function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0 || b == 0) {
            return 0;
        }

        return (a * b + HALF_WAD) / WAD;
    }

    /**
     * @dev Divides two wad, rounding half up to the nearest wad
     * @param a Wad
     * @param b Wad
     * @return The result of a/b, in wad
     */
    function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        return (a * WAD + b / 2) / b;
    }
}

File 26 of 26 : RewardsDistributorStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../interfaces/IRewardsDistributor.sol";

abstract contract RewardsDistributorStorageV1 is IRewardsDistributor {
    struct TokenState {
        uint224 index; // The last updated index
        uint32 timestamp; // The timestamp of the latest index update
    }

    /**
     * @notice The token to reward
     */
    IERC20 public override rewardToken;

    /**
     * @notice Track tokens for reward
     */
    IERC20[] public override tokens;

    /**
     * @notice The amount of token distributed for each token per second
     */
    mapping(IERC20 => uint256) public override tokenSpeeds;

    /**
     * @notice The reward state for each token
     */
    mapping(IERC20 => TokenState) public override tokenStates;

    /**
     * @notice The supply index for each token for each account as of the last time they accrued token
     */
    mapping(IERC20 => mapping(address => uint256)) public override accountIndexOf;

    /**
     * @notice The token accrued but not yet transferred to each user
     */
    mapping(address => uint256) public override tokensAccruedOf;
}

abstract contract RewardsDistributorStorageV2 is RewardsDistributorStorageV1 {
    address public tokenSpeedKeeper;
}

Settings
{
  "evmVersion": "london",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"AddressIsNull","type":"error"},{"inputs":[],"name":"ArraysLengthDoNotMatch","type":"error"},{"inputs":[],"name":"DistributorDoesNotExist","type":"error"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[],"name":"NotTokenSpeedKeeper","type":"error"},{"inputs":[],"name":"PoolAddressIsNull","type":"error"},{"inputs":[],"name":"ReachedMaxRewardTokens","type":"error"},{"inputs":[],"name":"RewardTokenIsNull","type":"error"},{"inputs":[],"name":"SenderIsNotGovernor","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint224","name":"newIndex","type":"uint224"},{"indexed":false,"internalType":"uint32","name":"newTimestamp","type":"uint32"}],"name":"TokenIndexUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldSpeed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newSpeed","type":"uint256"}],"name":"TokenSpeedUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokensDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"supplyIndex","type":"uint256"}],"name":"TokensAccruedUpdated","type":"event"},{"inputs":[],"name":"INITIAL_INDEX","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_REWARD_TOKENS","outputs":[{"internalType":"uint224","name":"","type":"uint224"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"accountIndexOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"contract IERC20[]","name":"tokens_","type":"address[]"}],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts_","type":"address[]"},{"internalType":"contract IERC20[]","name":"tokens_","type":"address[]"}],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"}],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"}],"name":"claimable","outputs":[{"internalType":"uint256","name":"_claimable","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"contract IERC20","name":"","type":"address"}],"name":"claimable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governor","outputs":[{"internalType":"address","name":"_governor","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IPool","name":"pool_","type":"address"},{"internalType":"contract IERC20","name":"rewardToken_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"contract IPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IDepositToken","name":"depositToken_","type":"address"}],"name":"syncTokenSpeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tokenSpeedKeeper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"name":"tokenSpeeds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"name":"tokenStates","outputs":[{"internalType":"uint224","name":"index","type":"uint224"},{"internalType":"uint32","name":"timestamp","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokens","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokensAccruedOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token_","type":"address"},{"internalType":"address","name":"account_","type":"address"}],"name":"updateBeforeMintOrBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token_","type":"address"},{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"}],"name":"updateBeforeTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token_","type":"address"},{"internalType":"uint256","name":"newSpeed_","type":"uint256"}],"name":"updateTokenSpeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"keeper_","type":"address"}],"name":"updateTokenSpeedKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20[]","name":"tokens_","type":"address[]"},{"internalType":"uint256[]","name":"speeds_","type":"uint256[]"}],"name":"updateTokenSpeeds","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b5061233e806100206000396000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c80634f64b2be116100c3578063b17b23a01161007c578063b17b23a014610343578063b9afda2d14610356578063d4570c1c14610369578063ef5cfb8c1461037c578063f7c618c11461038f578063ffa1ad74146103a257600080fd5b80634f64b2be1461028f5780635d0cde97146102a257806389cb096a146102aa578063a0cfa0dd146102f0578063a428d9c814610310578063aa6299751461032357600080fd5b80631b30f0c0116101155780631b30f0c01461021d5780632026ffa3146102305780633ddc9ce314610243578063402914f514610256578063485cc955146102695780634b38585a1461027c57600080fd5b8063013bc51c1461015d57806301bc3acb1461019b57806306b997ea146101b05780630c340a24146101db578063160c3a03146101e357806316f0115b1461020a575b600080fd5b61018861016b366004611cfd565b603860209081526000928352604080842090915290825290205481565b6040519081526020015b60405180910390f35b6101ae6101a9366004611d82565b6103d3565b005b603a546101c3906001600160a01b031681565b6040516001600160a01b039091168152602001610192565b6101c3610498565b6101f2670de0b6b3a764000081565b6040516001600160e01b039091168152602001610192565b6002546101c3906001600160a01b031681565b6101ae61022b366004611cfd565b61051a565b6101ae61023e366004611ecd565b610558565b6101ae610251366004611f1d565b6105bd565b610188610264366004611f1d565b6108f6565b6101ae610277366004611cfd565b61096e565b6101ae61028a366004611f1d565b610a37565b6101c361029d366004611f3a565b610ab9565b6101f2601481565b6102e26102b8366004611f1d565b6037602052600090815260409020546001600160e01b03811690600160e01b900463ffffffff1682565b604051610192929190611f53565b6101886102fe366004611f1d565b60366020526000908152604090205481565b6101ae61031e366004611f72565b610ae3565b610188610331366004611f1d565b60396020526000908152604090205481565b6101ae61035136600461202a565b610c68565b6101ae610364366004612075565b610cac565b610188610377366004611cfd565b610cef565b6101ae61038a366004611f1d565b610d28565b6034546101c3906001600160a01b031681565b6103c6604051806040016040528060058152602001640312e322e360dc1b81525081565b60405161019291906120cd565b6103db610498565b6001600160a01b0316336001600160a01b03161461040c57604051634b98449160e11b815260040160405180910390fd5b8281811461042d57604051631dc1520760e31b815260040160405180910390fd5b60005b818110156104905761048086868381811061044d5761044d612100565b90506020020160208101906104629190611f1d565b85858481811061047457610474612100565b90506020020135610d8f565b6104898161212c565b9050610430565b505050505050565b6002546040805163030d028960e21b815290516000926001600160a01b031691630c340a24916004808301926020929190829003018186803b1580156104dd57600080fd5b505afa1580156104f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105159190612147565b905090565b6001600160a01b0382166000908152603760205260409020546001600160e01b0316156105545761054a82611197565b61055482826112da565b5050565b60408051600180825281830190925260009160208083019080368337019050509050828160008151811061058e5761058e612100565b60200260200101906001600160a01b031690816001600160a01b0316815250506105b88183610ae3565b505050565b603a546001600160a01b031633146105e8576040516355bbb60960e11b815260040160405180910390fd5b6000816001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561062357600080fd5b505afa158015610637573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065b9190612147565b90506000816001600160a01b0316638bc6beb26040518163ffffffff1660e01b815260040160206040518083038186803b15801561069857600080fd5b505afa1580156106ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d09190612147565b90506000826001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561070d57600080fd5b505afa158015610721573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107459190612164565b836001600160a01b03166370a08231600260009054906101000a90046001600160a01b03166001600160a01b03166361d027b36040518163ffffffff1660e01b815260040160206040518083038186803b1580156107a257600080fd5b505afa1580156107b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107da9190612147565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b15801561081957600080fd5b505afa15801561082d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108519190612164565b603454604051633d3b260360e01b81526001600160a01b03918216600482015290851690633d3b260390602401602060405180830381600087803b15801561089857600080fd5b505af11580156108ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d09190612164565b6108da919061217d565b6108e4919061219c565b90506108f08482610d8f565b50505050565b6001600160a01b038116600090815260396020526040812054905b6035548110156109685761094c836035838154811061093257610932612100565b6000918252602090912001546001600160a01b03166113ce565b61095690836121be565b91506109618161212c565b9050610911565b50919050565b600054610100900460ff1680610987575060005460ff16155b6109ac5760405162461bcd60e51b81526004016109a3906121d6565b60405180910390fd5b600054610100900460ff161580156109ce576000805461ffff19166101011790555b6001600160a01b0382166109f557604051636d4b163760e11b815260040160405180910390fd5b6109fd6114a0565b610a068361150f565b603480546001600160a01b0319166001600160a01b03841617905580156105b8576000805461ff0019169055505050565b610a3f610498565b6001600160a01b0316336001600160a01b031614610a7057604051634b98449160e11b815260040160405180910390fd5b6001600160a01b038116610a975760405163fb7566d760e01b815260040160405180910390fd5b603a80546001600160a01b0319166001600160a01b0392909216919091179055565b60358181548110610ac957600080fd5b6000918252602090912001546001600160a01b0316905081565b60026001541415610b365760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109a3565b60026001558151815160005b81811015610bf1576000848281518110610b5e57610b5e612100565b6020908102919091018101516001600160a01b038116600090815260379092526040909120549091506001600160e01b031615610be057610b9e81611197565b60005b84811015610bde57610bcc82888381518110610bbf57610bbf612100565b60200260200101516112da565b80610bd68161212c565b915050610ba1565b505b50610bea8161212c565b9050610b42565b5060005b82811015610c5d576000858281518110610c1157610c11612100565b60200260200101519050610c4a8160396000846001600160a01b03166001600160a01b03168152602001908152602001600020546115bd565b5080610c558161212c565b915050610bf5565b505060018055505050565b6001600160a01b0383166000908152603760205260409020546001600160e01b0316156105b857610c9883611197565b610ca283836112da565b6105b883826112da565b610cb4610498565b6001600160a01b0316336001600160a01b031614610ce557604051634b98449160e11b815260040160405180910390fd5b6105548282610d8f565b60405162461bcd60e51b815260206004820152600b60248201526a155b9cdd5c1c1bdc9d195960aa1b60448201526000906064016109a3565b610d8c816035805480602002602001604051908101604052809291908181526020018280548015610d8257602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610d64575b5050505050610558565b50565b600080600260009054906101000a90046001600160a01b03166001600160a01b0316633605b51b6040518163ffffffff1660e01b815260040160006040518083038186803b158015610de057600080fd5b505afa158015610df4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e1c9190810190612224565b805190915060005b81811015610e7857306001600160a01b0316838281518110610e4857610e48612100565b60200260200101516001600160a01b03161415610e685760019350610e78565b610e718161212c565b9050610e24565b5082610e9757604051634757a01f60e01b815260040160405180910390fd5b6002546040516308a00b1f60e31b81526001600160a01b03808816600483015287921690819063450058f89060240160206040518083038186803b158015610ede57600080fd5b505afa158015610ef2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1691906122b3565b158015610f995750604051633e25dee160e21b81526001600160a01b03838116600483015282169063f8977b849060240160206040518083038186803b158015610f5f57600080fd5b505afa158015610f73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9791906122b3565b155b15610fb75760405163c1ab6dc160e01b815260040160405180910390fd5b6001600160a01b0387166000908152603660205260409020548015610fe457610fdf88611197565b611130565b8615611130576001600160a01b0388166000908152603760205260409020546001600160e01b03166110ec576035546014141561103457604051639e8b4a2160e01b815260040160405180910390fd5b6040518060400160405280670de0b6b3a76400006001600160e01b0316815260200161105f426116c4565b63ffffffff9081169091526001600160a01b038a166000818152603760209081526040822085519590910151909316600160e01b026001600160e01b03909416939093179091556035805460018101825592527fcfa4bec1d3298408bb5afcfcd9c430549c5b31f8aa5c5848151c0a55f473c34d90910180546001600160a01b0319169091179055611130565b6110f5426116c4565b6001600160a01b0389166000908152603760205260409020805463ffffffff92909216600160e01b026001600160e01b039092169190911790555b86811461118d576001600160a01b0388166000818152603660209081526040918290208a905581518481529081018a90527f07295410ddc875d5ff9b778ece2c279c9b91abeefd296803662b28cf6ad33c08910160405180910390a25b5050505050505050565b6001600160a01b0381166000908152603760209081526040808320815180830190925280546001600160e01b0381168352600160e01b900463ffffffff169282019290925290919081906111eb908561172d565b915091506000826001600160e01b031611801561120e575060008163ffffffff16115b1561126c5763ffffffff8116600160e01b026001600160e01b0383161783556040517f883d8b44a1f0e651bb0d11a8e962de03c77a351328bbeb12b702e5632288ee6f9061125f9084908490611f53565b60405180910390a16108f0565b63ffffffff8116156108f057825463ffffffff8216600160e01b026001600160e01b0391821681811786556040517f883d8b44a1f0e651bb0d11a8e962de03c77a351328bbeb12b702e5632288ee6f936112cc9316909117908490611f53565b60405180910390a150505050565b6001600160a01b03821660009081526037602090815260408083208151808301909252546001600160e01b0381168252600160e01b900463ffffffff1691810191909152819061132b908585611880565b6001600160a01b0380871660009081526038602090815260408083209389168352928152828220859055603990522054919350915061136b9082906121be565b6001600160a01b038481166000818152603960209081526040918290209490945580518581529384018690529092918716917f49abdf3748a8d465b0d3d5d126dab076f5109ea80b761c4c1c45b2710165087b910160405180910390a350505050565b6001600160a01b03811660009081526037602090815260408083208151808301909252546001600160e01b0381168252600160e01b900463ffffffff1691810191909152818061141e838661172d565b915091506000826001600160e01b0316118015611441575060008163ffffffff16115b15611471576040518060400160405280836001600160e01b031681526020018263ffffffff16815250925061148a565b63ffffffff81161561148a5763ffffffff811660208401525b611495838688611880565b979650505050505050565b600054610100900460ff16806114b9575060005460ff16155b6114d55760405162461bcd60e51b81526004016109a3906121d6565b600054610100900460ff161580156114f7576000805461ffff19166101011790555b600180558015610d8c576000805461ff001916905550565b600054610100900460ff1680611528575060005460ff16155b6115445760405162461bcd60e51b81526004016109a3906121d6565b600054610100900460ff16158015611566576000805461ffff19166101011790555b6001600160a01b03821661158d5760405163724f500960e01b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0384161790558015610554576000805461ff00191690555050565b6034546040516370a0823160e01b81523060048201526001600160a01b039091169060009082906370a082319060240160206040518083038186803b15801561160557600080fd5b505afa158015611619573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061163d9190612164565b905060008311801561164f5750808311155b156108f0576001600160a01b0380851660009081526039602052604081205561167b908316858561197c565b836001600160a01b03167f106f923f993c2149d49b4255ff723acafa1f2d94393f561d3eda32ae348f7241846040516116b691815260200190565b60405180910390a250505050565b600063ffffffff8211156117295760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203360448201526532206269747360d01b60648201526084016109a3565b5090565b6001600160a01b03811660009081526036602090815260408220549084015182919082906117619063ffffffff16426122d5565b90506000811180156117735750600082115b1561184d576000856001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156117b357600080fd5b505afa1580156117c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117eb9190612164565b905060006117f9848461217d565b9050600080831161180b576000611815565b61181582846119ce565b9050611838818a600001516001600160e01b031661183391906121be565b611a0b565b9650611843426116c4565b9550505050611877565b600081118015611866575085516001600160e01b031615155b1561187757611874426116c4565b92505b50509250929050565b82516001600160a01b0380841660009081526038602090815260408083209386168352929052908120546001600160e01b0390921691801580156118cb5750670de0b6b3a764000083115b156118db5750670de0b6b3a76400005b60006118e782856122d5565b6040516370a0823160e01b81526001600160a01b038781166004830152919250611970918391908916906370a082319060240160206040518083038186803b15801561193257600080fd5b505afa158015611946573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196a9190612164565b90611a74565b92505050935093915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526105b8908490611aac565b6000816119dc60028261219c565b6119ee670de0b6b3a76400008661217d565b6119f891906121be565b611a02919061219c565b90505b92915050565b60006001600160e01b038211156117295760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20326044820152663234206269747360c81b60648201526084016109a3565b6000821580611a81575081155b15611a8e57506000611a05565b670de0b6b3a7640000611aa260028261219c565b6119ee848661217d565b6000611b01826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611b7e9092919063ffffffff16565b8051909150156105b85780806020019051810190611b1f91906122b3565b6105b85760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109a3565b6060611b8d8484600085611b97565b90505b9392505050565b606082471015611bf85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109a3565b843b611c465760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109a3565b600080866001600160a01b03168587604051611c6291906122ec565b60006040518083038185875af1925050503d8060008114611c9f576040519150601f19603f3d011682016040523d82523d6000602084013e611ca4565b606091505b509150915061149582828660608315611cbe575081611b90565b825115611cce5782518084602001fd5b8160405162461bcd60e51b81526004016109a391906120cd565b6001600160a01b0381168114610d8c57600080fd5b60008060408385031215611d1057600080fd5b8235611d1b81611ce8565b91506020830135611d2b81611ce8565b809150509250929050565b60008083601f840112611d4857600080fd5b50813567ffffffffffffffff811115611d6057600080fd5b6020830191508360208260051b8501011115611d7b57600080fd5b9250929050565b60008060008060408587031215611d9857600080fd5b843567ffffffffffffffff80821115611db057600080fd5b611dbc88838901611d36565b90965094506020870135915080821115611dd557600080fd5b50611de287828801611d36565b95989497509550505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611e2d57611e2d611dee565b604052919050565b600067ffffffffffffffff821115611e4f57611e4f611dee565b5060051b60200190565b600082601f830112611e6a57600080fd5b81356020611e7f611e7a83611e35565b611e04565b82815260059290921b84018101918181019086841115611e9e57600080fd5b8286015b84811015611ec2578035611eb581611ce8565b8352918301918301611ea2565b509695505050505050565b60008060408385031215611ee057600080fd5b8235611eeb81611ce8565b9150602083013567ffffffffffffffff811115611f0757600080fd5b611f1385828601611e59565b9150509250929050565b600060208284031215611f2f57600080fd5b8135611b9081611ce8565b600060208284031215611f4c57600080fd5b5035919050565b6001600160e01b0392909216825263ffffffff16602082015260400190565b60008060408385031215611f8557600080fd5b823567ffffffffffffffff80821115611f9d57600080fd5b818501915085601f830112611fb157600080fd5b81356020611fc1611e7a83611e35565b82815260059290921b84018101918181019089841115611fe057600080fd5b948201945b83861015612007578535611ff881611ce8565b82529482019490820190611fe5565b9650508601359250508082111561201d57600080fd5b50611f1385828601611e59565b60008060006060848603121561203f57600080fd5b833561204a81611ce8565b9250602084013561205a81611ce8565b9150604084013561206a81611ce8565b809150509250925092565b6000806040838503121561208857600080fd5b823561209381611ce8565b946020939093013593505050565b60005b838110156120bc5781810151838201526020016120a4565b838111156108f05750506000910152565b60208152600082518060208401526120ec8160408501602087016120a1565b601f01601f19169190910160400192915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561214057612140612116565b5060010190565b60006020828403121561215957600080fd5b8151611b9081611ce8565b60006020828403121561217657600080fd5b5051919050565b600081600019048311821515161561219757612197612116565b500290565b6000826121b957634e487b7160e01b600052601260045260246000fd5b500490565b600082198211156121d1576121d1612116565b500190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000602080838503121561223757600080fd5b825167ffffffffffffffff81111561224e57600080fd5b8301601f8101851361225f57600080fd5b805161226d611e7a82611e35565b81815260059190911b8201830190838101908783111561228c57600080fd5b928401925b828410156114955783516122a481611ce8565b82529284019290840190612291565b6000602082840312156122c557600080fd5b81518015158114611b9057600080fd5b6000828210156122e7576122e7612116565b500390565b600082516122fe8184602087016120a1565b919091019291505056fea264697066735822122083a3d4732533164966aa60cb19134856a5c9bb3d4fbe1ea54e4703ead438bf8864736f6c63430008090033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101585760003560e01c80634f64b2be116100c3578063b17b23a01161007c578063b17b23a014610343578063b9afda2d14610356578063d4570c1c14610369578063ef5cfb8c1461037c578063f7c618c11461038f578063ffa1ad74146103a257600080fd5b80634f64b2be1461028f5780635d0cde97146102a257806389cb096a146102aa578063a0cfa0dd146102f0578063a428d9c814610310578063aa6299751461032357600080fd5b80631b30f0c0116101155780631b30f0c01461021d5780632026ffa3146102305780633ddc9ce314610243578063402914f514610256578063485cc955146102695780634b38585a1461027c57600080fd5b8063013bc51c1461015d57806301bc3acb1461019b57806306b997ea146101b05780630c340a24146101db578063160c3a03146101e357806316f0115b1461020a575b600080fd5b61018861016b366004611cfd565b603860209081526000928352604080842090915290825290205481565b6040519081526020015b60405180910390f35b6101ae6101a9366004611d82565b6103d3565b005b603a546101c3906001600160a01b031681565b6040516001600160a01b039091168152602001610192565b6101c3610498565b6101f2670de0b6b3a764000081565b6040516001600160e01b039091168152602001610192565b6002546101c3906001600160a01b031681565b6101ae61022b366004611cfd565b61051a565b6101ae61023e366004611ecd565b610558565b6101ae610251366004611f1d565b6105bd565b610188610264366004611f1d565b6108f6565b6101ae610277366004611cfd565b61096e565b6101ae61028a366004611f1d565b610a37565b6101c361029d366004611f3a565b610ab9565b6101f2601481565b6102e26102b8366004611f1d565b6037602052600090815260409020546001600160e01b03811690600160e01b900463ffffffff1682565b604051610192929190611f53565b6101886102fe366004611f1d565b60366020526000908152604090205481565b6101ae61031e366004611f72565b610ae3565b610188610331366004611f1d565b60396020526000908152604090205481565b6101ae61035136600461202a565b610c68565b6101ae610364366004612075565b610cac565b610188610377366004611cfd565b610cef565b6101ae61038a366004611f1d565b610d28565b6034546101c3906001600160a01b031681565b6103c6604051806040016040528060058152602001640312e322e360dc1b81525081565b60405161019291906120cd565b6103db610498565b6001600160a01b0316336001600160a01b03161461040c57604051634b98449160e11b815260040160405180910390fd5b8281811461042d57604051631dc1520760e31b815260040160405180910390fd5b60005b818110156104905761048086868381811061044d5761044d612100565b90506020020160208101906104629190611f1d565b85858481811061047457610474612100565b90506020020135610d8f565b6104898161212c565b9050610430565b505050505050565b6002546040805163030d028960e21b815290516000926001600160a01b031691630c340a24916004808301926020929190829003018186803b1580156104dd57600080fd5b505afa1580156104f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105159190612147565b905090565b6001600160a01b0382166000908152603760205260409020546001600160e01b0316156105545761054a82611197565b61055482826112da565b5050565b60408051600180825281830190925260009160208083019080368337019050509050828160008151811061058e5761058e612100565b60200260200101906001600160a01b031690816001600160a01b0316815250506105b88183610ae3565b505050565b603a546001600160a01b031633146105e8576040516355bbb60960e11b815260040160405180910390fd5b6000816001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561062357600080fd5b505afa158015610637573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065b9190612147565b90506000816001600160a01b0316638bc6beb26040518163ffffffff1660e01b815260040160206040518083038186803b15801561069857600080fd5b505afa1580156106ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d09190612147565b90506000826001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561070d57600080fd5b505afa158015610721573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107459190612164565b836001600160a01b03166370a08231600260009054906101000a90046001600160a01b03166001600160a01b03166361d027b36040518163ffffffff1660e01b815260040160206040518083038186803b1580156107a257600080fd5b505afa1580156107b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107da9190612147565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b15801561081957600080fd5b505afa15801561082d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108519190612164565b603454604051633d3b260360e01b81526001600160a01b03918216600482015290851690633d3b260390602401602060405180830381600087803b15801561089857600080fd5b505af11580156108ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d09190612164565b6108da919061217d565b6108e4919061219c565b90506108f08482610d8f565b50505050565b6001600160a01b038116600090815260396020526040812054905b6035548110156109685761094c836035838154811061093257610932612100565b6000918252602090912001546001600160a01b03166113ce565b61095690836121be565b91506109618161212c565b9050610911565b50919050565b600054610100900460ff1680610987575060005460ff16155b6109ac5760405162461bcd60e51b81526004016109a3906121d6565b60405180910390fd5b600054610100900460ff161580156109ce576000805461ffff19166101011790555b6001600160a01b0382166109f557604051636d4b163760e11b815260040160405180910390fd5b6109fd6114a0565b610a068361150f565b603480546001600160a01b0319166001600160a01b03841617905580156105b8576000805461ff0019169055505050565b610a3f610498565b6001600160a01b0316336001600160a01b031614610a7057604051634b98449160e11b815260040160405180910390fd5b6001600160a01b038116610a975760405163fb7566d760e01b815260040160405180910390fd5b603a80546001600160a01b0319166001600160a01b0392909216919091179055565b60358181548110610ac957600080fd5b6000918252602090912001546001600160a01b0316905081565b60026001541415610b365760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109a3565b60026001558151815160005b81811015610bf1576000848281518110610b5e57610b5e612100565b6020908102919091018101516001600160a01b038116600090815260379092526040909120549091506001600160e01b031615610be057610b9e81611197565b60005b84811015610bde57610bcc82888381518110610bbf57610bbf612100565b60200260200101516112da565b80610bd68161212c565b915050610ba1565b505b50610bea8161212c565b9050610b42565b5060005b82811015610c5d576000858281518110610c1157610c11612100565b60200260200101519050610c4a8160396000846001600160a01b03166001600160a01b03168152602001908152602001600020546115bd565b5080610c558161212c565b915050610bf5565b505060018055505050565b6001600160a01b0383166000908152603760205260409020546001600160e01b0316156105b857610c9883611197565b610ca283836112da565b6105b883826112da565b610cb4610498565b6001600160a01b0316336001600160a01b031614610ce557604051634b98449160e11b815260040160405180910390fd5b6105548282610d8f565b60405162461bcd60e51b815260206004820152600b60248201526a155b9cdd5c1c1bdc9d195960aa1b60448201526000906064016109a3565b610d8c816035805480602002602001604051908101604052809291908181526020018280548015610d8257602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610d64575b5050505050610558565b50565b600080600260009054906101000a90046001600160a01b03166001600160a01b0316633605b51b6040518163ffffffff1660e01b815260040160006040518083038186803b158015610de057600080fd5b505afa158015610df4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e1c9190810190612224565b805190915060005b81811015610e7857306001600160a01b0316838281518110610e4857610e48612100565b60200260200101516001600160a01b03161415610e685760019350610e78565b610e718161212c565b9050610e24565b5082610e9757604051634757a01f60e01b815260040160405180910390fd5b6002546040516308a00b1f60e31b81526001600160a01b03808816600483015287921690819063450058f89060240160206040518083038186803b158015610ede57600080fd5b505afa158015610ef2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1691906122b3565b158015610f995750604051633e25dee160e21b81526001600160a01b03838116600483015282169063f8977b849060240160206040518083038186803b158015610f5f57600080fd5b505afa158015610f73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9791906122b3565b155b15610fb75760405163c1ab6dc160e01b815260040160405180910390fd5b6001600160a01b0387166000908152603660205260409020548015610fe457610fdf88611197565b611130565b8615611130576001600160a01b0388166000908152603760205260409020546001600160e01b03166110ec576035546014141561103457604051639e8b4a2160e01b815260040160405180910390fd5b6040518060400160405280670de0b6b3a76400006001600160e01b0316815260200161105f426116c4565b63ffffffff9081169091526001600160a01b038a166000818152603760209081526040822085519590910151909316600160e01b026001600160e01b03909416939093179091556035805460018101825592527fcfa4bec1d3298408bb5afcfcd9c430549c5b31f8aa5c5848151c0a55f473c34d90910180546001600160a01b0319169091179055611130565b6110f5426116c4565b6001600160a01b0389166000908152603760205260409020805463ffffffff92909216600160e01b026001600160e01b039092169190911790555b86811461118d576001600160a01b0388166000818152603660209081526040918290208a905581518481529081018a90527f07295410ddc875d5ff9b778ece2c279c9b91abeefd296803662b28cf6ad33c08910160405180910390a25b5050505050505050565b6001600160a01b0381166000908152603760209081526040808320815180830190925280546001600160e01b0381168352600160e01b900463ffffffff169282019290925290919081906111eb908561172d565b915091506000826001600160e01b031611801561120e575060008163ffffffff16115b1561126c5763ffffffff8116600160e01b026001600160e01b0383161783556040517f883d8b44a1f0e651bb0d11a8e962de03c77a351328bbeb12b702e5632288ee6f9061125f9084908490611f53565b60405180910390a16108f0565b63ffffffff8116156108f057825463ffffffff8216600160e01b026001600160e01b0391821681811786556040517f883d8b44a1f0e651bb0d11a8e962de03c77a351328bbeb12b702e5632288ee6f936112cc9316909117908490611f53565b60405180910390a150505050565b6001600160a01b03821660009081526037602090815260408083208151808301909252546001600160e01b0381168252600160e01b900463ffffffff1691810191909152819061132b908585611880565b6001600160a01b0380871660009081526038602090815260408083209389168352928152828220859055603990522054919350915061136b9082906121be565b6001600160a01b038481166000818152603960209081526040918290209490945580518581529384018690529092918716917f49abdf3748a8d465b0d3d5d126dab076f5109ea80b761c4c1c45b2710165087b910160405180910390a350505050565b6001600160a01b03811660009081526037602090815260408083208151808301909252546001600160e01b0381168252600160e01b900463ffffffff1691810191909152818061141e838661172d565b915091506000826001600160e01b0316118015611441575060008163ffffffff16115b15611471576040518060400160405280836001600160e01b031681526020018263ffffffff16815250925061148a565b63ffffffff81161561148a5763ffffffff811660208401525b611495838688611880565b979650505050505050565b600054610100900460ff16806114b9575060005460ff16155b6114d55760405162461bcd60e51b81526004016109a3906121d6565b600054610100900460ff161580156114f7576000805461ffff19166101011790555b600180558015610d8c576000805461ff001916905550565b600054610100900460ff1680611528575060005460ff16155b6115445760405162461bcd60e51b81526004016109a3906121d6565b600054610100900460ff16158015611566576000805461ffff19166101011790555b6001600160a01b03821661158d5760405163724f500960e01b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0384161790558015610554576000805461ff00191690555050565b6034546040516370a0823160e01b81523060048201526001600160a01b039091169060009082906370a082319060240160206040518083038186803b15801561160557600080fd5b505afa158015611619573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061163d9190612164565b905060008311801561164f5750808311155b156108f0576001600160a01b0380851660009081526039602052604081205561167b908316858561197c565b836001600160a01b03167f106f923f993c2149d49b4255ff723acafa1f2d94393f561d3eda32ae348f7241846040516116b691815260200190565b60405180910390a250505050565b600063ffffffff8211156117295760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203360448201526532206269747360d01b60648201526084016109a3565b5090565b6001600160a01b03811660009081526036602090815260408220549084015182919082906117619063ffffffff16426122d5565b90506000811180156117735750600082115b1561184d576000856001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156117b357600080fd5b505afa1580156117c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117eb9190612164565b905060006117f9848461217d565b9050600080831161180b576000611815565b61181582846119ce565b9050611838818a600001516001600160e01b031661183391906121be565b611a0b565b9650611843426116c4565b9550505050611877565b600081118015611866575085516001600160e01b031615155b1561187757611874426116c4565b92505b50509250929050565b82516001600160a01b0380841660009081526038602090815260408083209386168352929052908120546001600160e01b0390921691801580156118cb5750670de0b6b3a764000083115b156118db5750670de0b6b3a76400005b60006118e782856122d5565b6040516370a0823160e01b81526001600160a01b038781166004830152919250611970918391908916906370a082319060240160206040518083038186803b15801561193257600080fd5b505afa158015611946573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196a9190612164565b90611a74565b92505050935093915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526105b8908490611aac565b6000816119dc60028261219c565b6119ee670de0b6b3a76400008661217d565b6119f891906121be565b611a02919061219c565b90505b92915050565b60006001600160e01b038211156117295760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20326044820152663234206269747360c81b60648201526084016109a3565b6000821580611a81575081155b15611a8e57506000611a05565b670de0b6b3a7640000611aa260028261219c565b6119ee848661217d565b6000611b01826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611b7e9092919063ffffffff16565b8051909150156105b85780806020019051810190611b1f91906122b3565b6105b85760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109a3565b6060611b8d8484600085611b97565b90505b9392505050565b606082471015611bf85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109a3565b843b611c465760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109a3565b600080866001600160a01b03168587604051611c6291906122ec565b60006040518083038185875af1925050503d8060008114611c9f576040519150601f19603f3d011682016040523d82523d6000602084013e611ca4565b606091505b509150915061149582828660608315611cbe575081611b90565b825115611cce5782518084602001fd5b8160405162461bcd60e51b81526004016109a391906120cd565b6001600160a01b0381168114610d8c57600080fd5b60008060408385031215611d1057600080fd5b8235611d1b81611ce8565b91506020830135611d2b81611ce8565b809150509250929050565b60008083601f840112611d4857600080fd5b50813567ffffffffffffffff811115611d6057600080fd5b6020830191508360208260051b8501011115611d7b57600080fd5b9250929050565b60008060008060408587031215611d9857600080fd5b843567ffffffffffffffff80821115611db057600080fd5b611dbc88838901611d36565b90965094506020870135915080821115611dd557600080fd5b50611de287828801611d36565b95989497509550505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611e2d57611e2d611dee565b604052919050565b600067ffffffffffffffff821115611e4f57611e4f611dee565b5060051b60200190565b600082601f830112611e6a57600080fd5b81356020611e7f611e7a83611e35565b611e04565b82815260059290921b84018101918181019086841115611e9e57600080fd5b8286015b84811015611ec2578035611eb581611ce8565b8352918301918301611ea2565b509695505050505050565b60008060408385031215611ee057600080fd5b8235611eeb81611ce8565b9150602083013567ffffffffffffffff811115611f0757600080fd5b611f1385828601611e59565b9150509250929050565b600060208284031215611f2f57600080fd5b8135611b9081611ce8565b600060208284031215611f4c57600080fd5b5035919050565b6001600160e01b0392909216825263ffffffff16602082015260400190565b60008060408385031215611f8557600080fd5b823567ffffffffffffffff80821115611f9d57600080fd5b818501915085601f830112611fb157600080fd5b81356020611fc1611e7a83611e35565b82815260059290921b84018101918181019089841115611fe057600080fd5b948201945b83861015612007578535611ff881611ce8565b82529482019490820190611fe5565b9650508601359250508082111561201d57600080fd5b50611f1385828601611e59565b60008060006060848603121561203f57600080fd5b833561204a81611ce8565b9250602084013561205a81611ce8565b9150604084013561206a81611ce8565b809150509250925092565b6000806040838503121561208857600080fd5b823561209381611ce8565b946020939093013593505050565b60005b838110156120bc5781810151838201526020016120a4565b838111156108f05750506000910152565b60208152600082518060208401526120ec8160408501602087016120a1565b601f01601f19169190910160400192915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561214057612140612116565b5060010190565b60006020828403121561215957600080fd5b8151611b9081611ce8565b60006020828403121561217657600080fd5b5051919050565b600081600019048311821515161561219757612197612116565b500290565b6000826121b957634e487b7160e01b600052601260045260246000fd5b500490565b600082198211156121d1576121d1612116565b500190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000602080838503121561223757600080fd5b825167ffffffffffffffff81111561224e57600080fd5b8301601f8101851361225f57600080fd5b805161226d611e7a82611e35565b81815260059190911b8201830190838101908783111561228c57600080fd5b928401925b828410156114955783516122a481611ce8565b82529284019290840190612291565b6000602082840312156122c557600080fd5b81518015158114611b9057600080fd5b6000828210156122e7576122e7612116565b500390565b600082516122fe8184602087016120a1565b919091019291505056fea264697066735822122083a3d4732533164966aa60cb19134856a5c9bb3d4fbe1ea54e4703ead438bf8864736f6c63430008090033

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.