Contract 0xd1233273793b113b653c049ac89ca370e3b85e47 1

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x5927051597054acccc415d430ce537fea63e37ba5569e848e48b956cb8f55e01Initialize45203752022-01-10 4:14:33322 days 20 hrs ago0x420220b72bbd307db8615e7aa0eadca399cf2fc0 IN  0xd1233273793b113b653c049ac89ca370e3b85e470 ETH0.001443189082 ETH
0xe2b7bd6e939fd60bb321e69969220f996ac3b7e96c57f316a0b8b047ad46a3560x60a0604024413002021-10-22 6:26:09402 days 18 hrs ago0x420220b72bbd307db8615e7aa0eadca399cf2fc0 IN  Create: Interest0 ETH0.050723069124 ETH
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x53a9c9618443a24286673502fb46eb5a3eb5e2ac81f8dada19ea61e740f1d087418724882022-11-28 12:12:0512 hrs 43 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x53a9c9618443a24286673502fb46eb5a3eb5e2ac81f8dada19ea61e740f1d087418724882022-11-28 12:12:0512 hrs 43 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x684d02b71cacde4285a2968ce90909f4fb09ae4792b7f8d0a6b519aa885ea35d418721792022-11-28 12:10:3512 hrs 45 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x684d02b71cacde4285a2968ce90909f4fb09ae4792b7f8d0a6b519aa885ea35d418721792022-11-28 12:10:3512 hrs 45 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x684d02b71cacde4285a2968ce90909f4fb09ae4792b7f8d0a6b519aa885ea35d418721792022-11-28 12:10:3512 hrs 45 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x684d02b71cacde4285a2968ce90909f4fb09ae4792b7f8d0a6b519aa885ea35d418721792022-11-28 12:10:3512 hrs 45 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x684d02b71cacde4285a2968ce90909f4fb09ae4792b7f8d0a6b519aa885ea35d418721792022-11-28 12:10:3512 hrs 45 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x684d02b71cacde4285a2968ce90909f4fb09ae4792b7f8d0a6b519aa885ea35d418721792022-11-28 12:10:3512 hrs 45 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x684d02b71cacde4285a2968ce90909f4fb09ae4792b7f8d0a6b519aa885ea35d418721792022-11-28 12:10:3512 hrs 45 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x684d02b71cacde4285a2968ce90909f4fb09ae4792b7f8d0a6b519aa885ea35d418721792022-11-28 12:10:3512 hrs 45 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x6abe31e3c8380abb94f4e3d5bbd6a8b4eb50ba38356d19cd7142f6a6aa174f7d418685872022-11-28 11:52:3313 hrs 3 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x6abe31e3c8380abb94f4e3d5bbd6a8b4eb50ba38356d19cd7142f6a6aa174f7d418685872022-11-28 11:52:3313 hrs 3 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x6abe31e3c8380abb94f4e3d5bbd6a8b4eb50ba38356d19cd7142f6a6aa174f7d418685872022-11-28 11:52:3313 hrs 3 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x6abe31e3c8380abb94f4e3d5bbd6a8b4eb50ba38356d19cd7142f6a6aa174f7d418685872022-11-28 11:52:3313 hrs 3 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x6abe31e3c8380abb94f4e3d5bbd6a8b4eb50ba38356d19cd7142f6a6aa174f7d418685872022-11-28 11:52:3313 hrs 3 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x6abe31e3c8380abb94f4e3d5bbd6a8b4eb50ba38356d19cd7142f6a6aa174f7d418685872022-11-28 11:52:3313 hrs 3 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x6abe31e3c8380abb94f4e3d5bbd6a8b4eb50ba38356d19cd7142f6a6aa174f7d418685872022-11-28 11:52:3313 hrs 3 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x6abe31e3c8380abb94f4e3d5bbd6a8b4eb50ba38356d19cd7142f6a6aa174f7d418685872022-11-28 11:52:3313 hrs 3 mins ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x2f383f34ca86fe2dbbc4e1b229ef121e694c0bebe3b0b562917a51b2860df139405111772022-11-23 10:03:395 days 14 hrs ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0x2f383f34ca86fe2dbbc4e1b229ef121e694c0bebe3b0b562917a51b2860df139405111772022-11-23 10:03:395 days 14 hrs ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0xf398d2cc2de03839d763e67743658a45534350d3feefb1216ef3b7b9f4444db8405111472022-11-23 10:03:295 days 14 hrs ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0xf398d2cc2de03839d763e67743658a45534350d3feefb1216ef3b7b9f4444db8405111472022-11-23 10:03:295 days 14 hrs ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0xf398d2cc2de03839d763e67743658a45534350d3feefb1216ef3b7b9f4444db8405111472022-11-23 10:03:295 days 14 hrs ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0xf398d2cc2de03839d763e67743658a45534350d3feefb1216ef3b7b9f4444db8405111472022-11-23 10:03:295 days 14 hrs ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
0xf398d2cc2de03839d763e67743658a45534350d3feefb1216ef3b7b9f4444db8405111472022-11-23 10:03:295 days 14 hrs ago 0xff84a807883c06e8b78c735c45d23dbcf66ce8c5 0xd1233273793b113b653c049ac89ca370e3b85e470 ETH
[ Download CSV Export 
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
Interest

Compiler Version
v0.8.3+commit.8d00100c

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 20 : Interest.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
pragma abicoder v2;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "../interfaces/Bank/IVaultLibrary.sol";
import "../interfaces/Bank/IfxToken.sol";
import "../interfaces/IValidator.sol";
import "../interfaces/Bank/IHandle.sol";
import "../interfaces/Bank/IInterest.sol";
import "../interfaces/external/IMakerJug.sol";
import "./HandlePausable.sol";

/**
 * @dev Keeps track of time passed and interest rates, storing relevant
        variables. Allows to track and update interest rates according to
        configured external protocols such as MakerDAO's.
 */
contract Interest is
    IInterest,
    Initializable,
    UUPSUpgradeable,
    OwnableUpgradeable,
    HandlePausable,
    ReentrancyGuardUpgradeable
{
    using SafeMath for uint256;

    /** @dev The Handle contract interface */
    IHandle private handle;
    /** @dev The VaultLibrary contract interface */
    IVaultLibrary private vaultLibrary;

    /** @dev mapping(collateral => cumulative interest rate) */
    mapping(address => uint256) public R;
    /** @dev Date when the interest rate was last globally charged
             i.e. the R value was updated. */
    uint256 public lastChargedDate;

    /** @dev Address from which to fetch external interest rates.
             This currently is the MakerDAO Multi-Collateral-Dai (MCD) Jug
             contract, but could be an IAggregatorInterface in the future if
             loading an average interest rate from different protocols other
             than just DAI. */
    address public interestRatesDataSource;
    /** @dev Time at which the interest rate was last automatically updated
             using the configured data source. */
    uint256 public interestRateLastUpdated;
    /** @dev Struct containing external protocol data needed to fetch info
             from such. Will not be needed if maintaining an aggregator
             interface contract in the future. */
    mapping(address => ExternalAssetData) externalAssetData;
    /** @dev Maximum interest ratio per 1,000 that can be set from an external
             source. */
    uint256 public maxInterestPerMille;

    /** @dev Proxy initialisation function */
    function initialize() public initializer {
        __UUPSUpgradeable_init();
        __Ownable_init();
        __ReentrancyGuard_init();
        lastChargedDate = block.timestamp;
    }

    /**
     * @dev Setter for Handle contract reference
     * @param _handle The Handle contract address
     */
    function setHandleContract(address _handle) public override onlyOwner {
        handle = IHandle(_handle);
        vaultLibrary = IVaultLibrary(handle.vaultLibrary());
    }

    /** @dev Getter for Handle contract address */
    function handleAddress() public view override returns (address) {
        return address(handle);
    }

    /**
     * @dev Setter for interestRatesDataSource.
     * @param source The address for the source contract.
     */
    function setDataSource(address source) external override onlyOwner {
        interestRatesDataSource = source;
    }

    /**
     * @dev Setter for externalAssetData
     * @param collateral The collateral token to set external asset data for.
     * @param makerDaoCollateralIlk The maker "ilk" value for the collateral.
     */
    function setCollateralExternalAssetData(
        address collateral,
        bytes32 makerDaoCollateralIlk
    ) external override onlyOwner {
        externalAssetData[collateral] = ExternalAssetData({
            makerDaoCollateralIlk: makerDaoCollateralIlk
        });
    }

    /**
     * @dev Unsets externalCollateralData for a collateral token.
     * @param collateral The collateral token to delete external asset data for.
     */
    function unsetCollateralExternalAssetData(address collateral)
        external
        override
        onlyOwner
    {
        delete externalAssetData[collateral];
    }

    /**
     * @dev Setter for maxInterestPerMille
     * @param interestPerMille The value to set maxInterestPerMille to
     */
    function setMaxExternalSourceInterest(uint256 interestPerMille)
        external
        override
        onlyOwner
    {
        maxInterestPerMille = interestPerMille;
    }

    /**
     * @dev Attempts to trigger an interest rate update according to the
            currently configured data source.
            It is important that this function does not revert as it is called
            from different parts of the protocol.
     */
    function tryUpdateRates() external override {
        // Abort update if the data source is not set.
        if (interestRatesDataSource == address(0)) return;
        // Abort update if the cache time of 1 day is still valid.
        if (block.timestamp < interestRateLastUpdated + 1 days) return;
        updateRates();
    }

    /**
     * @dev Updates the interest rate via the data source
     */
    function updateRates() public override notPaused {
        address[] memory collateralTokens = handle.getAllCollateralTypes();
        uint256 j = collateralTokens.length;
        IHandle.CollateralData memory data;
        uint256 interestRate;
        for (uint256 i = 0; i < j; i++) {
            interestRate = fetchRate(collateralTokens[i]);
            if (interestRate == 0) continue;
            data = handle.getCollateralDetails(collateralTokens[i]);
            // Update collateral with fetched interest.
            handle.setCollateralToken(
                collateralTokens[i],
                data.mintCR,
                data.liquidationFee,
                // New interest rate as a per mille ratio (1/1000th, 1 decimal).
                interestRate
            );
        }
        // Update the fetch time for caching purposes.
        interestRateLastUpdated = block.timestamp;
    }

    /**
     * @dev Fetches the interest rate for a token directly from the data source.
               This is not the current Handle protocol's interest rate but rather
               the current rate from the data source assigned to this contract,
               which may only be set to Handle after the cache time has expired.
            The current implementation simply reads the interest rate for
            the input token from the MCD Jug contract as a per mille ratio.
            In the future the data source could be changed to an intermediate
            contract that fetches the rates from multiple protocols and returns
            an averaged value.
            Returns the interest rate as a per mille (1/1000th, 1 decimal) ratio.
       @param token The token to find the interest rate for
     */
    function fetchRate(address token) public view override returns (uint256) {
        if (interestRatesDataSource == address(0)) return 0;
        ExternalAssetData storage data = externalAssetData[token];
        if (data.makerDaoCollateralIlk == "") return 0;
        IMakerJug jug = IMakerJug(interestRatesDataSource);
        uint256 unit = 10**27;
        // The maker stability fee is the base rate plus the collateral rate.
        uint256 stabilityPerSecond =
            jug.base().add(jug.ilks(data.makerDaoCollateralIlk).duty);
        // The rate is > 1 unit (10e27), the unit must be subtracted.
        if (stabilityPerSecond < unit) return 0;
        stabilityPerSecond = stabilityPerSecond.sub(unit);
        uint256 N = 365 * 24 * 60 * 60;
        // Maker compounds the interest, therefore the correct calculation
        // here would be (stabilityPerSecond ^ N), but this calculation is
        // too large and overflows. Therefore a linear approximation is used
        // which results in a similar value but not the same.
        uint256 rate = (stabilityPerSecond * N).mul(1000).div(unit);
        // Round rate down to the nearest half percent.
        rate = ((rate + 5 - 1) / 5) * 5 - 5;
        return
            maxInterestPerMille > 0 && rate > maxInterestPerMille
                ? maxInterestPerMille
                : rate;
    }

    /**
     * @dev Writes the current R value to storage. Only needed before
               updating the interest rate as this affects the rate over time
               and therefore the cumulative rate.
     */
    function charge() external override notPaused {
        // Abort if already called this block.
        if (lastChargedDate == block.timestamp) return;
        // Get the current R values and write to storage.
        (uint256[] memory currentR, address[] memory collateralTokens) =
            getCurrentR();
        uint256 l = currentR.length;
        assert(l == collateralTokens.length);
        for (uint256 i = 0; i < l; i++) {
            address token = collateralTokens[i];
            R[token] = currentR[i];
        }
        lastChargedDate = block.timestamp;
    }

    /**
     * @dev Returns the stored R value plus the delta cumulative rate
               applying the current interest rate for each collateral token
     */
    function getCurrentR()
        public
        view
        override
        returns (uint256[] memory currentR, address[] memory collateralTokens)
    {
        collateralTokens = handle.getAllCollateralTypes();
        uint256 l = collateralTokens.length;
        currentR = new uint256[](l);
        uint256 delta = block.timestamp.sub(lastChargedDate);
        uint256 interestRate;
        address token;
        for (uint256 i = 0; i < l; i++) {
            token = collateralTokens[i];
            interestRate = handle
                .getCollateralDetails(token)
                .interestRate
                .mul(1 ether)
                .div(1000);
            currentR[i] = R[token].add(interestRate.mul(delta).div(365 days));
        }
    }

    /** @dev Protected UUPS upgrade authorization function */
    function _authorizeUpgrade(address) internal override onlyOwner {}
}

File 2 of 20 : 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 3 of 20 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal initializer {
        __ERC1967Upgrade_init_unchained();
        __UUPSUpgradeable_init_unchained();
    }

    function __UUPSUpgradeable_init_unchained() internal initializer {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallSecure(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallSecure(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;
    uint256[50] private __gap;
}

File 4 of 20 : ReentrancyGuardUpgradeable.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 ReentrancyGuardUpgradeable 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 {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() 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;
    }
    uint256[49] private __gap;
}

File 5 of 20 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal initializer {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal initializer {
        _setOwner(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _setOwner(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
    uint256[49] private __gap;
}

File 6 of 20 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 7 of 20 : IVaultLibrary.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

interface IVaultLibrary {
    function doesMeetRatio(address account, address fxToken)
        external
        view
        returns (bool);

    function getFreeCollateralAsEth(address account, address fxToken)
        external
        view
        returns (uint256);

    function getFreeCollateralAsEthFromMinimumRatio(
        address account,
        address fxToken,
        uint256 minimumRatio
    ) external view returns (uint256);

    function getMinimumRatio(address account, address fxToken)
        external
        view
        returns (uint256 ratio);

    function getMinimumCollateral(
        uint256 tokenAmount,
        uint256 ratio,
        uint256 unitPrice
    ) external view returns (uint256 minimum);

    function getDebtAsEth(address account, address fxToken)
        external
        view
        returns (uint256 debt);

    function getTotalCollateralBalanceAsEth(address account, address fxToken)
        external
        view
        returns (uint256 balance);

    function getCurrentRatio(address account, address fxToken)
        external
        view
        returns (uint256 ratio);

    function getCollateralForAmount(
        address account,
        address fxToken,
        uint256 amountEth
    )
        external
        view
        returns (
            address[] memory collateralTypes,
            uint256[] memory collateralAmounts,
            bool metAmount
        );

    function getDecimalsAmount(
        uint256 amount,
        uint8 fromDecimals,
        uint8 toDecimals
    ) external pure returns (uint256);

    function calculateInterest(address account, address fxToken)
        external
        view
        returns (uint256 interest);

    function getInterestRate(address account, address fxToken)
        external
        view
        returns (uint256 rate);

    function getInterestDeltaR(address account, address fxToken)
        external
        view
        returns (uint256 dR);

    function getLiquidationFee(address account, address fxToken)
        external
        view
        returns (uint256 fee);

    function getCollateralShares(address account, address fxToken)
        external
        view
        returns (uint256[] memory shares);

    function getCollateralTypesSortedByLiquidationRank()
        external
        view
        returns (address[] memory sortedCollateralTypes);

    function getNewMinimumRatio(
        address account,
        address fxToken,
        address collateralToken,
        uint256 collateralAmount,
        uint256 collateralQuote,
        bool isDeposit
    ) external view returns (uint256 ratio, uint256 newCollateralAsEther);

    function canMint(
        address account,
        address fxToken,
        address collateralToken,
        uint256 collateralAmount,
        uint256 tokenAmount,
        uint256 fxQuote,
        uint256 collateralQuote
    ) external view returns (bool);

    function quickSort(
        uint256[] memory array,
        int256 left,
        int256 right
    ) external pure;

    function getTokenUnit(address token) external view returns (uint256);
}

File 8 of 20 : IfxToken.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IfxToken is IERC20 {
    function mint(address account, uint256 amount) external;

    function burn(address account, uint256 amount) external;
}

File 9 of 20 : IValidator.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

interface IValidator {
    modifier dueBy(uint256 date) {
        require(block.timestamp <= date, "Transaction has exceeded deadline");
        _;
    }

    modifier validAddress(address _address) {
        require(_address != address(0), "Invalid Address");
        _;
    }
}

File 10 of 20 : IHandle.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

pragma abicoder v2;

interface IHandle {
    struct Vault {
        // Collateral token address => balance
        mapping(address => uint256) collateralBalance;
        uint256 debt;
        // Collateral token address => R0
        mapping(address => uint256) R0;
    }

    struct CollateralData {
        uint256 mintCR;
        uint256 liquidationFee;
        uint256 interestRate;
    }

    event UpdateDebt(address indexed account, address indexed fxToken);

    event UpdateCollateral(
        address indexed account,
        address indexed fxToken,
        address indexed collateralToken
    );

    event ConfigureCollateralToken(address indexed collateralToken);

    event ConfigureFxToken(address indexed fxToken, bool removed);

    function setCollateralUpperBoundPCT(uint256 ratio) external;

    function setPaused(bool value) external;

    function setFxToken(address token) external;

    function removeFxToken(address token) external;

    function setCollateralToken(
        address token,
        uint256 mintCR,
        uint256 liquidationFee,
        uint256 interestRatePerMille
    ) external;

    function removeCollateralToken(address token) external;

    function getAllCollateralTypes()
        external
        view
        returns (address[] memory collateral);

    function getCollateralDetails(address collateral)
        external
        view
        returns (CollateralData memory);

    function WETH() external view returns (address);

    function treasury() external view returns (address payable);

    function comptroller() external view returns (address);

    function vaultLibrary() external view returns (address);

    function fxKeeperPool() external view returns (address);

    function pct() external view returns (address);

    function liquidator() external view returns (address);

    function interest() external view returns (address);

    function referral() external view returns (address);

    function forex() external view returns (address);

    function rewards() external view returns (address);

    function pctCollateralUpperBound() external view returns (uint256);

    function isFxTokenValid(address fxToken) external view returns (bool);

    function isCollateralValid(address collateral) external view returns (bool);

    function setComponents(address[] memory components) external;

    function updateDebtPosition(
        address account,
        uint256 amount,
        address fxToken,
        bool increase
    ) external;

    function updateCollateralBalance(
        address account,
        uint256 amount,
        address fxToken,
        address collateralToken,
        bool increase
    ) external;

    function setFeeRecipient(address feeRecipient) external;

    function setFees(
        uint256 withdrawFeePerMille,
        uint256 depositFeePerMille,
        uint256 mintFeePerMille,
        uint256 burnFeePerMille
    ) external;

    function getCollateralBalance(
        address account,
        address collateralType,
        address fxToken
    ) external view returns (uint256 balance);

    function getBalance(address account, address fxToken)
        external
        view
        returns (address[] memory collateral, uint256[] memory balances);

    function getDebt(address owner, address fxToken)
        external
        view
        returns (uint256 _debt);

    function getPrincipalDebt(address owner, address fxToken)
        external
        view
        returns (uint256 _debt);

    function getCollateralR0(
        address account,
        address fxToken,
        address collateral
    ) external view returns (uint256 R0);

    function getTokenPrice(address token) external view returns (uint256 quote);

    function setOracle(address fxToken, address oracle) external;

    function FeeRecipient() external view returns (address);

    function mintFeePerMille() external view returns (uint256);

    function burnFeePerMille() external view returns (uint256);

    function withdrawFeePerMille() external view returns (uint256);

    function depositFeePerMille() external view returns (uint256);

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

File 11 of 20 : IInterest.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
pragma abicoder v2;

interface IInterest {
    struct ExternalAssetData {
        bytes32 makerDaoCollateralIlk;
    }

    function setCollateralExternalAssetData(
        address collateral,
        bytes32 makerDaoCollateralIlk
    ) external;

    function unsetCollateralExternalAssetData(address collateral) external;

    function setMaxExternalSourceInterest(uint256 interestPerMille) external;

    function charge() external;

    function getCurrentR()
        external
        view
        returns (uint256[] memory R, address[] memory collateralTokens);

    function setDataSource(address source) external;

    function tryUpdateRates() external;

    function updateRates() external;

    function fetchRate(address token) external view returns (uint256);
}

File 12 of 20 : IMakerJug.sol
pragma solidity ^0.8.0;

// Minimal interface for fetching stability rates from Maker DAO's Jug contract.
// Source: https://github.com/makerdao/dss/blob/master/src/jug.sol#L46

interface IMakerJug {
    struct Ilk {
        // Collateral-specific, per-second stability fee contribution [ray]
        uint256 duty;
        // Time of last drip [unix epoch time]
        uint256 rho;
    }

    function ilks(bytes32 ilk) external view returns (Ilk memory);

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

File 13 of 20 : HandlePausable.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
pragma abicoder v2;

import "../interfaces/Bank/IHandle.sol";
import "../interfaces/Bank/IHandleComponent.sol";

abstract contract HandlePausable is IHandleComponent {
    function handleAddress() public view virtual override returns (address);

    modifier notPaused() {
        require(!IHandle(handleAddress()).isPaused(), "Paused");
        _;
    }
}

File 14 of 20 : ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal initializer {
        __ERC1967Upgrade_init_unchained();
    }

    function __ERC1967Upgrade_init_unchained() internal initializer {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallSecure(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        address oldImplementation = _getImplementation();

        // Initial upgrade and setup call
        _setImplementation(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }

        // Perform rollback test if not already in progress
        StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT);
        if (!rollbackTesting.value) {
            // Trigger rollback using upgradeTo from the new implementation
            rollbackTesting.value = true;
            _functionDelegateCall(
                newImplementation,
                abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
            );
            rollbackTesting.value = false;
            // Check rollback was effective
            require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
            // Finally reset to the new implementation and log the upgrade
            _upgradeTo(newImplementation);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @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) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }
    uint256[50] private __gap;
}

File 15 of 20 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

File 16 of 20 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @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 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 17 of 20 : StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        assembly {
            r.slot := slot
        }
    }
}

File 18 of 20 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal initializer {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal initializer {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 19 of 20 : 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 20 of 20 : IHandleComponent.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
pragma abicoder v2;

interface IHandleComponent {
    function setHandleContract(address hanlde) external;

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

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

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"R","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"charge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"fetchRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentR","outputs":[{"internalType":"uint256[]","name":"currentR","type":"uint256[]"},{"internalType":"address[]","name":"collateralTokens","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"handleAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"interestRateLastUpdated","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"interestRatesDataSource","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastChargedDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxInterestPerMille","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"bytes32","name":"makerDaoCollateralIlk","type":"bytes32"}],"name":"setCollateralExternalAssetData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"source","type":"address"}],"name":"setDataSource","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_handle","type":"address"}],"name":"setHandleContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"interestPerMille","type":"uint256"}],"name":"setMaxExternalSourceInterest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tryUpdateRates","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"}],"name":"unsetCollateralExternalAssetData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateRates","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]

60a06040523060601b60805234801561001757600080fd5b5060805160601c611ea861004b600039600081816103de015281816104270152818161087e01526108be0152611ea86000f3fe6080604052600436106101355760003560e01c806374bf578b116100ab5780639b1c414f1161006f5780639b1c414f14610303578063a2855f8214610323578063d56a5c7314610350578063d8e8ca1214610373578063f2fde38b14610393578063f83feadd146103b357610135565b806374bf578b1461027b578063755e67b1146102995780638129fc1c146102b95780638da5cb5b146102ce578063976802bf146102ec57610135565b80634f1ef286116100fd5780634f1ef286146101cf57806355161913146101e25780635f2566c1146101f75780637099df1d1461022f57806370fb072e14610246578063715018a61461026657610135565b80633659cfe61461013a5780633c3821f41461015c5780634342fef51461017157806343c4e6bf146101865780634cb7eb65146101af575b600080fd5b34801561014657600080fd5b5061015a6101553660046118ba565b6103d3565b005b34801561016857600080fd5b5061015a6104a5565b34801561017d57600080fd5b5061015a6107e1565b34801561019257600080fd5b5061019c60fe5481565b6040519081526020015b60405180910390f35b3480156101bb57600080fd5b5061015a6101ca3660046118f2565b61081d565b61015a6101dd36600461191d565b610873565b3480156101ee57600080fd5b5061015a61092d565b34801561020357600080fd5b5060ff54610217906001600160a01b031681565b6040516001600160a01b0390911681526020016101a6565b34801561023b57600080fd5b5061019c6101005481565b34801561025257600080fd5b5061015a610261366004611b03565b610aba565b34801561027257600080fd5b5061015a610aea565b34801561028757600080fd5b5060fb546001600160a01b0316610217565b3480156102a557600080fd5b5061015a6102b43660046118ba565b610b1e565b3480156102c557600080fd5b5061015a610b6a565b3480156102da57600080fd5b506097546001600160a01b0316610217565b3480156102f857600080fd5b5061019c6101025481565b34801561030f57600080fd5b5061015a61031e3660046118ba565b610bf1565b34801561032f57600080fd5b5061019c61033e3660046118ba565b60fd6020526000908152604090205481565b34801561035c57600080fd5b50610365610cca565b6040516101a6929190611b4f565b34801561037f57600080fd5b5061019c61038e3660046118ba565b610f22565b34801561039f57600080fd5b5061015a6103ae3660046118ba565b61112d565b3480156103bf57600080fd5b5061015a6103ce3660046118ba565b6111c5565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156104255760405162461bcd60e51b815260040161041c90611c05565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661045761120a565b6001600160a01b03161461047d5760405162461bcd60e51b815260040161041c90611c51565b61048681611238565b604080516000808252602082019092526104a291839190611262565b50565b60fb546001600160a01b03166001600160a01b031663b187bd266040518163ffffffff1660e01b815260040160206040518083038186803b1580156104e957600080fd5b505afa1580156104fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105219190611a73565b156105575760405162461bcd60e51b815260206004820152600660248201526514185d5cd95960d21b604482015260640161041c565b60fb54604080516314a6a4cf60e11b815290516000926001600160a01b03169163294d499e9160048083019286929190829003018186803b15801561059b57600080fd5b505afa1580156105af573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105d791908101906119bf565b905060008151905061060360405180606001604052806000815260200160008152602001600081525090565b6000805b838110156107d55761063f85828151811061063257634e487b7160e01b600052603260045260246000fd5b6020026020010151610f22565b91508161064b576107c3565b60fb5485516001600160a01b039091169063bd9e52009087908490811061068257634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b81526004016106b591906001600160a01b0391909116815260200190565b60606040518083038186803b1580156106cd57600080fd5b505afa1580156106e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107059190611a93565b60fb5486519194506001600160a01b03169063732409939087908490811061073d57634e487b7160e01b600052603260045260246000fd5b602002602001015185600001518660200151866040518563ffffffff1660e01b815260040161079094939291906001600160a01b0394909416845260208401929092526040830152606082015260800190565b600060405180830381600087803b1580156107aa57600080fd5b505af11580156107be573d6000803e3d6000fd5b505050505b806107cd81611def565b915050610607565b50504261010055505050565b60ff546001600160a01b03166107f65761081b565b610100546108079062015180611d51565b4210156108135761081b565b61081b6104a5565b565b6097546001600160a01b031633146108475760405162461bcd60e51b815260040161041c90611ceb565b60408051602080820183529281526001600160a01b039093166000908152610101909252902090519055565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156108bc5760405162461bcd60e51b815260040161041c90611c05565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166108ee61120a565b6001600160a01b0316146109145760405162461bcd60e51b815260040161041c90611c51565b61091d82611238565b61092982826001611262565b5050565b60fb546001600160a01b03166001600160a01b031663b187bd266040518163ffffffff1660e01b815260040160206040518083038186803b15801561097157600080fd5b505afa158015610985573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a99190611a73565b156109df5760405162461bcd60e51b815260206004820152600660248201526514185d5cd95960d21b604482015260640161041c565b4260fe5414156109ee5761081b565b6000806109f9610cca565b9150915060008251905081518114610a2157634e487b7160e01b600052600160045260246000fd5b60005b81811015610ab0576000838281518110610a4e57634e487b7160e01b600052603260045260246000fd5b60200260200101519050848281518110610a7857634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03909216600090815260fd909152604090205580610aa881611def565b915050610a24565b50504260fe555050565b6097546001600160a01b03163314610ae45760405162461bcd60e51b815260040161041c90611ceb565b61010255565b6097546001600160a01b03163314610b145760405162461bcd60e51b815260040161041c90611ceb565b61081b60006113ad565b6097546001600160a01b03163314610b485760405162461bcd60e51b815260040161041c90611ceb565b60ff80546001600160a01b0319166001600160a01b0392909216919091179055565b600054610100900460ff1680610b83575060005460ff16155b610b9f5760405162461bcd60e51b815260040161041c90611c9d565b600054610100900460ff16158015610bc1576000805461ffff19166101011790555b610bc96113ff565b610bd161147a565b610bd96114e1565b4260fe5580156104a2576000805461ff001916905550565b6097546001600160a01b03163314610c1b5760405162461bcd60e51b815260040161041c90611ceb565b60fb80546001600160a01b0319166001600160a01b0383169081179091556040805163eb0a8b9160e01b8152905163eb0a8b9191600480820192602092909190829003018186803b158015610c6f57600080fd5b505afa158015610c83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca791906118d6565b60fc80546001600160a01b0319166001600160a01b039290921691909117905550565b60608060fb60009054906101000a90046001600160a01b03166001600160a01b031663294d499e6040518163ffffffff1660e01b815260040160006040518083038186803b158015610d1b57600080fd5b505afa158015610d2f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d5791908101906119bf565b80519091508067ffffffffffffffff811115610d8357634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610dac578160200160208202803683370190505b5092506000610dc660fe544261154090919063ffffffff16565b905060008060005b84811015610f1957858181518110610df657634e487b7160e01b600052603260045260246000fd5b602090810291909101015160fb54604051625ecf2960e91b81526001600160a01b038084166004830152929450610ea6926103e892610ea092670de0b6b3a7640000929091169063bd9e52009060240160606040518083038186803b158015610e5e57600080fd5b505afa158015610e72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e969190611a93565b6040015190611553565b9061155f565b9250610edc610ebd6301e13380610ea08688611553565b6001600160a01b038416600090815260fd60205260409020549061156b565b878281518110610efc57634e487b7160e01b600052603260045260246000fd5b602090810291909101015280610f1181611def565b915050610dce565b50505050509091565b60ff546000906001600160a01b0316610f3d57506000611128565b6001600160a01b0382166000908152610101602052604090208054610f66576000915050611128565b60ff548154604051636cb1c69b60e11b81526001600160a01b03909216916b033b2e3c9fd0803ce80000009160009161107b91859163d9638d3691610fb19160040190815260200190565b604080518083038186803b158015610fc857600080fd5b505afa158015610fdc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110009190611ad0565b60000151846001600160a01b0316635001f3b56040518163ffffffff1660e01b815260040160206040518083038186803b15801561103d57600080fd5b505afa158015611051573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110759190611b1b565b9061156b565b905081811015611092576000945050505050611128565b61109c8183611540565b90506301e1338060006110bf84610ea06103e86110b98688611d89565b90611553565b905060058060016110d08483611d51565b6110da9190611da8565b6110e49190611d69565b6110ef906005611d89565b6110f99190611da8565b905060006101025411801561111057506101025481115b61111a578061111f565b610102545b96505050505050505b919050565b6097546001600160a01b031633146111575760405162461bcd60e51b815260040161041c90611ceb565b6001600160a01b0381166111bc5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161041c565b6104a2816113ad565b6097546001600160a01b031633146111ef5760405162461bcd60e51b815260040161041c90611ceb565b6001600160a01b031660009081526101016020526040812055565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6097546001600160a01b031633146104a25760405162461bcd60e51b815260040161041c90611ceb565b600061126c61120a565b905061127784611577565b6000835111806112845750815b1561129557611293848461161c565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff166113a657805460ff191660011781556040516001600160a01b038316602482015261131490869060440160408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b17905261161c565b50805460ff1916815561132561120a565b6001600160a01b0316826001600160a01b03161461139d5760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b606482015260840161041c565b6113a685611707565b5050505050565b609780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1680611418575060005460ff16155b6114345760405162461bcd60e51b815260040161041c90611c9d565b600054610100900460ff16158015611456576000805461ffff19166101011790555b61145e611747565b611466611747565b80156104a2576000805461ff001916905550565b600054610100900460ff1680611493575060005460ff16155b6114af5760405162461bcd60e51b815260040161041c90611c9d565b600054610100900460ff161580156114d1576000805461ffff19166101011790555b6114d9611747565b6114666117b1565b600054610100900460ff16806114fa575060005460ff16155b6115165760405162461bcd60e51b815260040161041c90611c9d565b600054610100900460ff16158015611538576000805461ffff19166101011790555b611466611811565b600061154c8284611da8565b9392505050565b600061154c8284611d89565b600061154c8284611d69565b600061154c8284611d51565b803b6115db5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161041c565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b61167b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161041c565b600080846001600160a01b0316846040516116969190611b33565b600060405180830381855af49150503d80600081146116d1576040519150601f19603f3d011682016040523d82523d6000602084013e6116d6565b606091505b50915091506116fe8282604051806060016040528060278152602001611e4c60279139611881565b95945050505050565b61171081611577565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b600054610100900460ff1680611760575060005460ff16155b61177c5760405162461bcd60e51b815260040161041c90611c9d565b600054610100900460ff16158015611466576000805461ffff191661010117905580156104a2576000805461ff001916905550565b600054610100900460ff16806117ca575060005460ff16155b6117e65760405162461bcd60e51b815260040161041c90611c9d565b600054610100900460ff16158015611808576000805461ffff19166101011790555b611466336113ad565b600054610100900460ff168061182a575060005460ff16155b6118465760405162461bcd60e51b815260040161041c90611c9d565b600054610100900460ff16158015611868576000805461ffff19166101011790555b600160c95580156104a2576000805461ff001916905550565b6060831561189057508161154c565b8251156118a05782518084602001fd5b8160405162461bcd60e51b815260040161041c9190611bd2565b6000602082840312156118cb578081fd5b813561154c81611e36565b6000602082840312156118e7578081fd5b815161154c81611e36565b60008060408385031215611904578081fd5b823561190f81611e36565b946020939093013593505050565b6000806040838503121561192f578182fd5b823561193a81611e36565b915060208381013567ffffffffffffffff80821115611957578384fd5b818601915086601f83011261196a578384fd5b81358181111561197c5761197c611e20565b61198e601f8201601f19168501611d20565b915080825287848285010111156119a3578485fd5b8084840185840137810190920192909252919491935090915050565b600060208083850312156119d1578182fd5b825167ffffffffffffffff808211156119e8578384fd5b818501915085601f8301126119fb578384fd5b815181811115611a0d57611a0d611e20565b8060051b9150611a1e848301611d20565b8181528481019084860184860187018a1015611a38578788fd5b8795505b83861015611a665780519450611a5185611e36565b84835260019590950194918601918601611a3c565b5098975050505050505050565b600060208284031215611a84578081fd5b8151801515811461154c578182fd5b600060608284031215611aa4578081fd5b611aae6060611d20565b8251815260208301516020820152604083015160408201528091505092915050565b600060408284031215611ae1578081fd5b611aeb6040611d20565b82518152602083015160208201528091505092915050565b600060208284031215611b14578081fd5b5035919050565b600060208284031215611b2c578081fd5b5051919050565b60008251611b45818460208701611dbf565b9190910192915050565b604080825283519082018190526000906020906060840190828701845b82811015611b8857815184529284019290840190600101611b6c565b50505083810382850152845180825285830191830190845b81811015611bc55783516001600160a01b031683529284019291840191600101611ba0565b5090979650505050505050565b6000602082528251806020840152611bf1816040850160208701611dbf565b601f01601f19169190910160400192915050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b604051601f8201601f1916810167ffffffffffffffff81118282101715611d4957611d49611e20565b604052919050565b60008219821115611d6457611d64611e0a565b500190565b600082611d8457634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611da357611da3611e0a565b500290565b600082821015611dba57611dba611e0a565b500390565b60005b83811015611dda578181015183820152602001611dc2565b83811115611de9576000848401525b50505050565b6000600019821415611e0357611e03611e0a565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146104a257600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212203515d169840b910f3c0856595aa89f0ed4957ae798dde280e040c957f95ec5cf64736f6c63430008030033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.